documentation.d.ts 3.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970889718897288973889748897588976889778897888979889808898188982889838898488985889868898788988889898899088991889928899388994889958899688997889988899989000890018900289003890048900589006890078900889009890108901189012890138901489015890168901789018890198902089021890228902389024890258902689027890288902989030890318903289033890348903589036890378903889039890408904189042890438904489045890468904789048890498905089051890528905389054890558905689057890588905989060890618906289063890648906589066890678906889069890708907189072890738907489075890768907789078890798908089081
  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. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13070. visibleOnFrame: boolean;
  13071. /**
  13072. * Creates a new NodeMaterialBlock
  13073. * @param name defines the block name
  13074. * @param target defines the target of that block (Vertex by default)
  13075. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13076. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13077. */
  13078. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13079. /**
  13080. * Initialize the block and prepare the context for build
  13081. * @param state defines the state that will be used for the build
  13082. */
  13083. initialize(state: NodeMaterialBuildState): void;
  13084. /**
  13085. * Bind data to effect. Will only be called for blocks with isBindable === true
  13086. * @param effect defines the effect to bind data to
  13087. * @param nodeMaterial defines the hosting NodeMaterial
  13088. * @param mesh defines the mesh that will be rendered
  13089. * @param subMesh defines the submesh that will be rendered
  13090. */
  13091. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13092. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13093. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13094. protected _writeFloat(value: number): string;
  13095. /**
  13096. * Gets the current class name e.g. "NodeMaterialBlock"
  13097. * @returns the class name
  13098. */
  13099. getClassName(): string;
  13100. /**
  13101. * Register a new input. Must be called inside a block constructor
  13102. * @param name defines the connection point name
  13103. * @param type defines the connection point type
  13104. * @param isOptional defines a boolean indicating that this input can be omitted
  13105. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13106. * @param point an already created connection point. If not provided, create a new one
  13107. * @returns the current block
  13108. */
  13109. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13110. /**
  13111. * Register a new output. Must be called inside a block constructor
  13112. * @param name defines the connection point name
  13113. * @param type defines the connection point type
  13114. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13115. * @param point an already created connection point. If not provided, create a new one
  13116. * @returns the current block
  13117. */
  13118. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13119. /**
  13120. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13121. * @param forOutput defines an optional connection point to check compatibility with
  13122. * @returns the first available input or null
  13123. */
  13124. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13125. /**
  13126. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13127. * @param forBlock defines an optional block to check compatibility with
  13128. * @returns the first available input or null
  13129. */
  13130. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13131. /**
  13132. * Gets the sibling of the given output
  13133. * @param current defines the current output
  13134. * @returns the next output in the list or null
  13135. */
  13136. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13137. /**
  13138. * Connect current block with another block
  13139. * @param other defines the block to connect with
  13140. * @param options define the various options to help pick the right connections
  13141. * @returns the current block
  13142. */
  13143. connectTo(other: NodeMaterialBlock, options?: {
  13144. input?: string;
  13145. output?: string;
  13146. outputSwizzle?: string;
  13147. }): this | undefined;
  13148. protected _buildBlock(state: NodeMaterialBuildState): void;
  13149. /**
  13150. * Add uniforms, samplers and uniform buffers at compilation time
  13151. * @param state defines the state to update
  13152. * @param nodeMaterial defines the node material requesting the update
  13153. * @param defines defines the material defines to update
  13154. * @param uniformBuffers defines the list of uniform buffer names
  13155. */
  13156. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13157. /**
  13158. * Add potential fallbacks if shader compilation fails
  13159. * @param mesh defines the mesh to be rendered
  13160. * @param fallbacks defines the current prioritized list of fallbacks
  13161. */
  13162. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13163. /**
  13164. * Initialize defines for shader compilation
  13165. * @param mesh defines the mesh to be rendered
  13166. * @param nodeMaterial defines the node material requesting the update
  13167. * @param defines defines the material defines to update
  13168. * @param useInstances specifies that instances should be used
  13169. */
  13170. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13171. /**
  13172. * Update defines for shader compilation
  13173. * @param mesh defines the mesh to be rendered
  13174. * @param nodeMaterial defines the node material requesting the update
  13175. * @param defines defines the material defines to update
  13176. * @param useInstances specifies that instances should be used
  13177. * @param subMesh defines which submesh to render
  13178. */
  13179. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13180. /**
  13181. * Lets the block try to connect some inputs automatically
  13182. * @param material defines the hosting NodeMaterial
  13183. */
  13184. autoConfigure(material: NodeMaterial): void;
  13185. /**
  13186. * Function called when a block is declared as repeatable content generator
  13187. * @param vertexShaderState defines the current compilation state for the vertex shader
  13188. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13189. * @param mesh defines the mesh to be rendered
  13190. * @param defines defines the material defines to update
  13191. */
  13192. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13193. /**
  13194. * Checks if the block is ready
  13195. * @param mesh defines the mesh to be rendered
  13196. * @param nodeMaterial defines the node material requesting the update
  13197. * @param defines defines the material defines to update
  13198. * @param useInstances specifies that instances should be used
  13199. * @returns true if the block is ready
  13200. */
  13201. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13202. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13203. private _processBuild;
  13204. /**
  13205. * Validates the new name for the block node.
  13206. * @param newName the new name to be given to the node.
  13207. * @returns false if the name is a reserve word, else true.
  13208. */
  13209. validateBlockName(newName: string): boolean;
  13210. /**
  13211. * Compile the current node and generate the shader code
  13212. * @param state defines the current compilation state (uniforms, samplers, current string)
  13213. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13214. * @returns true if already built
  13215. */
  13216. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13217. protected _inputRename(name: string): string;
  13218. protected _outputRename(name: string): string;
  13219. protected _dumpPropertiesCode(): string;
  13220. /** @hidden */
  13221. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13222. /** @hidden */
  13223. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13224. /**
  13225. * Clone the current block to a new identical block
  13226. * @param scene defines the hosting scene
  13227. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13228. * @returns a copy of the current block
  13229. */
  13230. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13231. /**
  13232. * Serializes this block in a JSON representation
  13233. * @returns the serialized block object
  13234. */
  13235. serialize(): any;
  13236. /** @hidden */
  13237. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13238. private _deserializePortDisplayNamesAndExposedOnFrame;
  13239. /**
  13240. * Release resources
  13241. */
  13242. dispose(): void;
  13243. }
  13244. }
  13245. declare module BABYLON {
  13246. /**
  13247. * Base class of materials working in push mode in babylon JS
  13248. * @hidden
  13249. */
  13250. export class PushMaterial extends Material {
  13251. protected _activeEffect: Effect;
  13252. protected _normalMatrix: Matrix;
  13253. constructor(name: string, scene: Scene);
  13254. getEffect(): Effect;
  13255. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13256. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13257. /**
  13258. * Binds the given world matrix to the active effect
  13259. *
  13260. * @param world the matrix to bind
  13261. */
  13262. bindOnlyWorldMatrix(world: Matrix): void;
  13263. /**
  13264. * Binds the given normal matrix to the active effect
  13265. *
  13266. * @param normalMatrix the matrix to bind
  13267. */
  13268. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13269. bind(world: Matrix, mesh?: Mesh): void;
  13270. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13271. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13272. }
  13273. }
  13274. declare module BABYLON {
  13275. /**
  13276. * Root class for all node material optimizers
  13277. */
  13278. export class NodeMaterialOptimizer {
  13279. /**
  13280. * Function used to optimize a NodeMaterial graph
  13281. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13282. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13283. */
  13284. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13285. }
  13286. }
  13287. declare module BABYLON {
  13288. /**
  13289. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13290. */
  13291. export class TransformBlock extends NodeMaterialBlock {
  13292. /**
  13293. * Defines the value to use to complement W value to transform it to a Vector4
  13294. */
  13295. complementW: number;
  13296. /**
  13297. * Defines the value to use to complement z value to transform it to a Vector4
  13298. */
  13299. complementZ: number;
  13300. /**
  13301. * Creates a new TransformBlock
  13302. * @param name defines the block name
  13303. */
  13304. constructor(name: string);
  13305. /**
  13306. * Gets the current class name
  13307. * @returns the class name
  13308. */
  13309. getClassName(): string;
  13310. /**
  13311. * Gets the vector input
  13312. */
  13313. get vector(): NodeMaterialConnectionPoint;
  13314. /**
  13315. * Gets the output component
  13316. */
  13317. get output(): NodeMaterialConnectionPoint;
  13318. /**
  13319. * Gets the xyz output component
  13320. */
  13321. get xyz(): NodeMaterialConnectionPoint;
  13322. /**
  13323. * Gets the matrix transform input
  13324. */
  13325. get transform(): NodeMaterialConnectionPoint;
  13326. protected _buildBlock(state: NodeMaterialBuildState): this;
  13327. /**
  13328. * Update defines for shader compilation
  13329. * @param mesh defines the mesh to be rendered
  13330. * @param nodeMaterial defines the node material requesting the update
  13331. * @param defines defines the material defines to update
  13332. * @param useInstances specifies that instances should be used
  13333. * @param subMesh defines which submesh to render
  13334. */
  13335. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13336. serialize(): any;
  13337. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13338. protected _dumpPropertiesCode(): string;
  13339. }
  13340. }
  13341. declare module BABYLON {
  13342. /**
  13343. * Block used to output the vertex position
  13344. */
  13345. export class VertexOutputBlock extends NodeMaterialBlock {
  13346. /**
  13347. * Creates a new VertexOutputBlock
  13348. * @param name defines the block name
  13349. */
  13350. constructor(name: string);
  13351. /**
  13352. * Gets the current class name
  13353. * @returns the class name
  13354. */
  13355. getClassName(): string;
  13356. /**
  13357. * Gets the vector input component
  13358. */
  13359. get vector(): NodeMaterialConnectionPoint;
  13360. protected _buildBlock(state: NodeMaterialBuildState): this;
  13361. }
  13362. }
  13363. declare module BABYLON {
  13364. /**
  13365. * Block used to output the final color
  13366. */
  13367. export class FragmentOutputBlock extends NodeMaterialBlock {
  13368. /**
  13369. * Create a new FragmentOutputBlock
  13370. * @param name defines the block name
  13371. */
  13372. constructor(name: string);
  13373. /**
  13374. * Gets the current class name
  13375. * @returns the class name
  13376. */
  13377. getClassName(): string;
  13378. /**
  13379. * Gets the rgba input component
  13380. */
  13381. get rgba(): NodeMaterialConnectionPoint;
  13382. /**
  13383. * Gets the rgb input component
  13384. */
  13385. get rgb(): NodeMaterialConnectionPoint;
  13386. /**
  13387. * Gets the a input component
  13388. */
  13389. get a(): NodeMaterialConnectionPoint;
  13390. protected _buildBlock(state: NodeMaterialBuildState): this;
  13391. }
  13392. }
  13393. declare module BABYLON {
  13394. /**
  13395. * Block used for the particle ramp gradient section
  13396. */
  13397. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13398. /**
  13399. * Create a new ParticleRampGradientBlock
  13400. * @param name defines the block name
  13401. */
  13402. constructor(name: string);
  13403. /**
  13404. * Gets the current class name
  13405. * @returns the class name
  13406. */
  13407. getClassName(): string;
  13408. /**
  13409. * Gets the color input component
  13410. */
  13411. get color(): NodeMaterialConnectionPoint;
  13412. /**
  13413. * Gets the rampColor output component
  13414. */
  13415. get rampColor(): NodeMaterialConnectionPoint;
  13416. /**
  13417. * Initialize the block and prepare the context for build
  13418. * @param state defines the state that will be used for the build
  13419. */
  13420. initialize(state: NodeMaterialBuildState): void;
  13421. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13422. }
  13423. }
  13424. declare module BABYLON {
  13425. /**
  13426. * Block used for the particle blend multiply section
  13427. */
  13428. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13429. /**
  13430. * Create a new ParticleBlendMultiplyBlock
  13431. * @param name defines the block name
  13432. */
  13433. constructor(name: string);
  13434. /**
  13435. * Gets the current class name
  13436. * @returns the class name
  13437. */
  13438. getClassName(): string;
  13439. /**
  13440. * Gets the color input component
  13441. */
  13442. get color(): NodeMaterialConnectionPoint;
  13443. /**
  13444. * Gets the alphaTexture input component
  13445. */
  13446. get alphaTexture(): NodeMaterialConnectionPoint;
  13447. /**
  13448. * Gets the alphaColor input component
  13449. */
  13450. get alphaColor(): NodeMaterialConnectionPoint;
  13451. /**
  13452. * Gets the blendColor output component
  13453. */
  13454. get blendColor(): NodeMaterialConnectionPoint;
  13455. /**
  13456. * Initialize the block and prepare the context for build
  13457. * @param state defines the state that will be used for the build
  13458. */
  13459. initialize(state: NodeMaterialBuildState): void;
  13460. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13461. }
  13462. }
  13463. declare module BABYLON {
  13464. /**
  13465. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  13466. */
  13467. export class VectorMergerBlock extends NodeMaterialBlock {
  13468. /**
  13469. * Create a new VectorMergerBlock
  13470. * @param name defines the block name
  13471. */
  13472. constructor(name: string);
  13473. /**
  13474. * Gets the current class name
  13475. * @returns the class name
  13476. */
  13477. getClassName(): string;
  13478. /**
  13479. * Gets the xyz component (input)
  13480. */
  13481. get xyzIn(): NodeMaterialConnectionPoint;
  13482. /**
  13483. * Gets the xy component (input)
  13484. */
  13485. get xyIn(): NodeMaterialConnectionPoint;
  13486. /**
  13487. * Gets the x component (input)
  13488. */
  13489. get x(): NodeMaterialConnectionPoint;
  13490. /**
  13491. * Gets the y component (input)
  13492. */
  13493. get y(): NodeMaterialConnectionPoint;
  13494. /**
  13495. * Gets the z component (input)
  13496. */
  13497. get z(): NodeMaterialConnectionPoint;
  13498. /**
  13499. * Gets the w component (input)
  13500. */
  13501. get w(): NodeMaterialConnectionPoint;
  13502. /**
  13503. * Gets the xyzw component (output)
  13504. */
  13505. get xyzw(): NodeMaterialConnectionPoint;
  13506. /**
  13507. * Gets the xyz component (output)
  13508. */
  13509. get xyzOut(): NodeMaterialConnectionPoint;
  13510. /**
  13511. * Gets the xy component (output)
  13512. */
  13513. get xyOut(): NodeMaterialConnectionPoint;
  13514. /**
  13515. * Gets the xy component (output)
  13516. * @deprecated Please use xyOut instead.
  13517. */
  13518. get xy(): NodeMaterialConnectionPoint;
  13519. /**
  13520. * Gets the xyz component (output)
  13521. * @deprecated Please use xyzOut instead.
  13522. */
  13523. get xyz(): NodeMaterialConnectionPoint;
  13524. protected _buildBlock(state: NodeMaterialBuildState): this;
  13525. }
  13526. }
  13527. declare module BABYLON {
  13528. /**
  13529. * Block used to remap a float from a range to a new one
  13530. */
  13531. export class RemapBlock extends NodeMaterialBlock {
  13532. /**
  13533. * Gets or sets the source range
  13534. */
  13535. sourceRange: Vector2;
  13536. /**
  13537. * Gets or sets the target range
  13538. */
  13539. targetRange: Vector2;
  13540. /**
  13541. * Creates a new RemapBlock
  13542. * @param name defines the block name
  13543. */
  13544. constructor(name: string);
  13545. /**
  13546. * Gets the current class name
  13547. * @returns the class name
  13548. */
  13549. getClassName(): string;
  13550. /**
  13551. * Gets the input component
  13552. */
  13553. get input(): NodeMaterialConnectionPoint;
  13554. /**
  13555. * Gets the source min input component
  13556. */
  13557. get sourceMin(): NodeMaterialConnectionPoint;
  13558. /**
  13559. * Gets the source max input component
  13560. */
  13561. get sourceMax(): NodeMaterialConnectionPoint;
  13562. /**
  13563. * Gets the target min input component
  13564. */
  13565. get targetMin(): NodeMaterialConnectionPoint;
  13566. /**
  13567. * Gets the target max input component
  13568. */
  13569. get targetMax(): NodeMaterialConnectionPoint;
  13570. /**
  13571. * Gets the output component
  13572. */
  13573. get output(): NodeMaterialConnectionPoint;
  13574. protected _buildBlock(state: NodeMaterialBuildState): this;
  13575. protected _dumpPropertiesCode(): string;
  13576. serialize(): any;
  13577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13578. }
  13579. }
  13580. declare module BABYLON {
  13581. /**
  13582. * Block used to multiply 2 values
  13583. */
  13584. export class MultiplyBlock extends NodeMaterialBlock {
  13585. /**
  13586. * Creates a new MultiplyBlock
  13587. * @param name defines the block name
  13588. */
  13589. constructor(name: string);
  13590. /**
  13591. * Gets the current class name
  13592. * @returns the class name
  13593. */
  13594. getClassName(): string;
  13595. /**
  13596. * Gets the left operand input component
  13597. */
  13598. get left(): NodeMaterialConnectionPoint;
  13599. /**
  13600. * Gets the right operand input component
  13601. */
  13602. get right(): NodeMaterialConnectionPoint;
  13603. /**
  13604. * Gets the output component
  13605. */
  13606. get output(): NodeMaterialConnectionPoint;
  13607. protected _buildBlock(state: NodeMaterialBuildState): this;
  13608. }
  13609. }
  13610. declare module BABYLON {
  13611. /** Interface used by value gradients (color, factor, ...) */
  13612. export interface IValueGradient {
  13613. /**
  13614. * Gets or sets the gradient value (between 0 and 1)
  13615. */
  13616. gradient: number;
  13617. }
  13618. /** Class used to store color4 gradient */
  13619. export class ColorGradient implements IValueGradient {
  13620. /**
  13621. * Gets or sets the gradient value (between 0 and 1)
  13622. */
  13623. gradient: number;
  13624. /**
  13625. * Gets or sets first associated color
  13626. */
  13627. color1: Color4;
  13628. /**
  13629. * Gets or sets second associated color
  13630. */
  13631. color2?: Color4 | undefined;
  13632. /**
  13633. * Creates a new color4 gradient
  13634. * @param gradient gets or sets the gradient value (between 0 and 1)
  13635. * @param color1 gets or sets first associated color
  13636. * @param color2 gets or sets first second color
  13637. */
  13638. constructor(
  13639. /**
  13640. * Gets or sets the gradient value (between 0 and 1)
  13641. */
  13642. gradient: number,
  13643. /**
  13644. * Gets or sets first associated color
  13645. */
  13646. color1: Color4,
  13647. /**
  13648. * Gets or sets second associated color
  13649. */
  13650. color2?: Color4 | undefined);
  13651. /**
  13652. * Will get a color picked randomly between color1 and color2.
  13653. * If color2 is undefined then color1 will be used
  13654. * @param result defines the target Color4 to store the result in
  13655. */
  13656. getColorToRef(result: Color4): void;
  13657. }
  13658. /** Class used to store color 3 gradient */
  13659. export class Color3Gradient implements IValueGradient {
  13660. /**
  13661. * Gets or sets the gradient value (between 0 and 1)
  13662. */
  13663. gradient: number;
  13664. /**
  13665. * Gets or sets the associated color
  13666. */
  13667. color: Color3;
  13668. /**
  13669. * Creates a new color3 gradient
  13670. * @param gradient gets or sets the gradient value (between 0 and 1)
  13671. * @param color gets or sets associated color
  13672. */
  13673. constructor(
  13674. /**
  13675. * Gets or sets the gradient value (between 0 and 1)
  13676. */
  13677. gradient: number,
  13678. /**
  13679. * Gets or sets the associated color
  13680. */
  13681. color: Color3);
  13682. }
  13683. /** Class used to store factor gradient */
  13684. export class FactorGradient implements IValueGradient {
  13685. /**
  13686. * Gets or sets the gradient value (between 0 and 1)
  13687. */
  13688. gradient: number;
  13689. /**
  13690. * Gets or sets first associated factor
  13691. */
  13692. factor1: number;
  13693. /**
  13694. * Gets or sets second associated factor
  13695. */
  13696. factor2?: number | undefined;
  13697. /**
  13698. * Creates a new factor gradient
  13699. * @param gradient gets or sets the gradient value (between 0 and 1)
  13700. * @param factor1 gets or sets first associated factor
  13701. * @param factor2 gets or sets second associated factor
  13702. */
  13703. constructor(
  13704. /**
  13705. * Gets or sets the gradient value (between 0 and 1)
  13706. */
  13707. gradient: number,
  13708. /**
  13709. * Gets or sets first associated factor
  13710. */
  13711. factor1: number,
  13712. /**
  13713. * Gets or sets second associated factor
  13714. */
  13715. factor2?: number | undefined);
  13716. /**
  13717. * Will get a number picked randomly between factor1 and factor2.
  13718. * If factor2 is undefined then factor1 will be used
  13719. * @returns the picked number
  13720. */
  13721. getFactor(): number;
  13722. }
  13723. /**
  13724. * Helper used to simplify some generic gradient tasks
  13725. */
  13726. export class GradientHelper {
  13727. /**
  13728. * Gets the current gradient from an array of IValueGradient
  13729. * @param ratio defines the current ratio to get
  13730. * @param gradients defines the array of IValueGradient
  13731. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  13732. */
  13733. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  13734. }
  13735. }
  13736. declare module BABYLON {
  13737. interface ThinEngine {
  13738. /**
  13739. * Creates a raw texture
  13740. * @param data defines the data to store in the texture
  13741. * @param width defines the width of the texture
  13742. * @param height defines the height of the texture
  13743. * @param format defines the format of the data
  13744. * @param generateMipMaps defines if the engine should generate the mip levels
  13745. * @param invertY defines if data must be stored with Y axis inverted
  13746. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  13747. * @param compression defines the compression used (null by default)
  13748. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13749. * @returns the raw texture inside an InternalTexture
  13750. */
  13751. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  13752. /**
  13753. * Update a raw texture
  13754. * @param texture defines the texture to update
  13755. * @param data defines the data to store in the texture
  13756. * @param format defines the format of the data
  13757. * @param invertY defines if data must be stored with Y axis inverted
  13758. */
  13759. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13760. /**
  13761. * Update a raw texture
  13762. * @param texture defines the texture to update
  13763. * @param data defines the data to store in the texture
  13764. * @param format defines the format of the data
  13765. * @param invertY defines if data must be stored with Y axis inverted
  13766. * @param compression defines the compression used (null by default)
  13767. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13768. */
  13769. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  13770. /**
  13771. * Creates a new raw cube texture
  13772. * @param data defines the array of data to use to create each face
  13773. * @param size defines the size of the textures
  13774. * @param format defines the format of the data
  13775. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13776. * @param generateMipMaps defines if the engine should generate the mip levels
  13777. * @param invertY defines if data must be stored with Y axis inverted
  13778. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13779. * @param compression defines the compression used (null by default)
  13780. * @returns the cube texture as an InternalTexture
  13781. */
  13782. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  13783. /**
  13784. * Update a raw cube texture
  13785. * @param texture defines the texture to udpdate
  13786. * @param data defines the data to store
  13787. * @param format defines the data format
  13788. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13789. * @param invertY defines if data must be stored with Y axis inverted
  13790. */
  13791. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  13792. /**
  13793. * Update a raw cube texture
  13794. * @param texture defines the texture to udpdate
  13795. * @param data defines the data to store
  13796. * @param format defines the data format
  13797. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13798. * @param invertY defines if data must be stored with Y axis inverted
  13799. * @param compression defines the compression used (null by default)
  13800. */
  13801. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  13802. /**
  13803. * Update a raw cube texture
  13804. * @param texture defines the texture to udpdate
  13805. * @param data defines the data to store
  13806. * @param format defines the data format
  13807. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  13808. * @param invertY defines if data must be stored with Y axis inverted
  13809. * @param compression defines the compression used (null by default)
  13810. * @param level defines which level of the texture to update
  13811. */
  13812. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  13813. /**
  13814. * Creates a new raw cube texture from a specified url
  13815. * @param url defines the url where the data is located
  13816. * @param scene defines the current scene
  13817. * @param size defines the size of the textures
  13818. * @param format defines the format of the data
  13819. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13820. * @param noMipmap defines if the engine should avoid generating the mip levels
  13821. * @param callback defines a callback used to extract texture data from loaded data
  13822. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13823. * @param onLoad defines a callback called when texture is loaded
  13824. * @param onError defines a callback called if there is an error
  13825. * @returns the cube texture as an InternalTexture
  13826. */
  13827. 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;
  13828. /**
  13829. * Creates a new raw cube texture from a specified url
  13830. * @param url defines the url where the data is located
  13831. * @param scene defines the current scene
  13832. * @param size defines the size of the textures
  13833. * @param format defines the format of the data
  13834. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  13835. * @param noMipmap defines if the engine should avoid generating the mip levels
  13836. * @param callback defines a callback used to extract texture data from loaded data
  13837. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  13838. * @param onLoad defines a callback called when texture is loaded
  13839. * @param onError defines a callback called if there is an error
  13840. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13841. * @param invertY defines if data must be stored with Y axis inverted
  13842. * @returns the cube texture as an InternalTexture
  13843. */
  13844. 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;
  13845. /**
  13846. * Creates a new raw 3D texture
  13847. * @param data defines the data used to create the texture
  13848. * @param width defines the width of the texture
  13849. * @param height defines the height of the texture
  13850. * @param depth defines the depth of the texture
  13851. * @param format defines the format of the texture
  13852. * @param generateMipMaps defines if the engine must generate mip levels
  13853. * @param invertY defines if data must be stored with Y axis inverted
  13854. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13855. * @param compression defines the compressed used (can be null)
  13856. * @param textureType defines the compressed used (can be null)
  13857. * @returns a new raw 3D texture (stored in an InternalTexture)
  13858. */
  13859. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13860. /**
  13861. * Update a raw 3D texture
  13862. * @param texture defines the texture to update
  13863. * @param data defines the data to store
  13864. * @param format defines the data format
  13865. * @param invertY defines if data must be stored with Y axis inverted
  13866. */
  13867. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13868. /**
  13869. * Update a raw 3D texture
  13870. * @param texture defines the texture to update
  13871. * @param data defines the data to store
  13872. * @param format defines the data format
  13873. * @param invertY defines if data must be stored with Y axis inverted
  13874. * @param compression defines the used compression (can be null)
  13875. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13876. */
  13877. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13878. /**
  13879. * Creates a new raw 2D array texture
  13880. * @param data defines the data used to create the texture
  13881. * @param width defines the width of the texture
  13882. * @param height defines the height of the texture
  13883. * @param depth defines the number of layers of the texture
  13884. * @param format defines the format of the texture
  13885. * @param generateMipMaps defines if the engine must generate mip levels
  13886. * @param invertY defines if data must be stored with Y axis inverted
  13887. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  13888. * @param compression defines the compressed used (can be null)
  13889. * @param textureType defines the compressed used (can be null)
  13890. * @returns a new raw 2D array texture (stored in an InternalTexture)
  13891. */
  13892. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  13893. /**
  13894. * Update a raw 2D array texture
  13895. * @param texture defines the texture to update
  13896. * @param data defines the data to store
  13897. * @param format defines the data format
  13898. * @param invertY defines if data must be stored with Y axis inverted
  13899. */
  13900. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  13901. /**
  13902. * Update a raw 2D array texture
  13903. * @param texture defines the texture to update
  13904. * @param data defines the data to store
  13905. * @param format defines the data format
  13906. * @param invertY defines if data must be stored with Y axis inverted
  13907. * @param compression defines the used compression (can be null)
  13908. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13909. */
  13910. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13911. }
  13912. }
  13913. declare module BABYLON {
  13914. /**
  13915. * Raw texture can help creating a texture directly from an array of data.
  13916. * This can be super useful if you either get the data from an uncompressed source or
  13917. * if you wish to create your texture pixel by pixel.
  13918. */
  13919. export class RawTexture extends Texture {
  13920. /**
  13921. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13922. */
  13923. format: number;
  13924. /**
  13925. * Instantiates a new RawTexture.
  13926. * Raw texture can help creating a texture directly from an array of data.
  13927. * This can be super useful if you either get the data from an uncompressed source or
  13928. * if you wish to create your texture pixel by pixel.
  13929. * @param data define the array of data to use to create the texture
  13930. * @param width define the width of the texture
  13931. * @param height define the height of the texture
  13932. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13933. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13934. * @param generateMipMaps define whether mip maps should be generated or not
  13935. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13936. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13937. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13938. */
  13939. constructor(data: ArrayBufferView, width: number, height: number,
  13940. /**
  13941. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13942. */
  13943. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13944. /**
  13945. * Updates the texture underlying data.
  13946. * @param data Define the new data of the texture
  13947. */
  13948. update(data: ArrayBufferView): void;
  13949. /**
  13950. * Creates a luminance texture from some data.
  13951. * @param data Define the texture data
  13952. * @param width Define the width of the texture
  13953. * @param height Define the height of the texture
  13954. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13955. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13956. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13957. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13958. * @returns the luminance texture
  13959. */
  13960. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13961. /**
  13962. * Creates a luminance alpha texture from some data.
  13963. * @param data Define the texture data
  13964. * @param width Define the width of the texture
  13965. * @param height Define the height of the texture
  13966. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13967. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13968. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13969. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13970. * @returns the luminance alpha texture
  13971. */
  13972. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13973. /**
  13974. * Creates an alpha texture from some data.
  13975. * @param data Define the texture data
  13976. * @param width Define the width of the texture
  13977. * @param height Define the height of the texture
  13978. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13979. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13980. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13981. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13982. * @returns the alpha texture
  13983. */
  13984. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13985. /**
  13986. * Creates a RGB texture from some data.
  13987. * @param data Define the texture data
  13988. * @param width Define the width of the texture
  13989. * @param height Define the height of the texture
  13990. * @param sceneOrEngine defines the scene or engine the texture will belong to
  13991. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13992. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13993. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13994. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13995. * @returns the RGB alpha texture
  13996. */
  13997. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13998. /**
  13999. * Creates a RGBA texture from some data.
  14000. * @param data Define the texture data
  14001. * @param width Define the width of the texture
  14002. * @param height Define the height of the texture
  14003. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14004. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14005. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14006. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14007. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14008. * @returns the RGBA texture
  14009. */
  14010. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14011. /**
  14012. * Creates a R texture from some data.
  14013. * @param data Define the texture data
  14014. * @param width Define the width of the texture
  14015. * @param height Define the height of the texture
  14016. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14017. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14018. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14019. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14020. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14021. * @returns the R texture
  14022. */
  14023. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14024. }
  14025. }
  14026. declare module BABYLON {
  14027. interface ThinEngine {
  14028. /**
  14029. * Update a dynamic index buffer
  14030. * @param indexBuffer defines the target index buffer
  14031. * @param indices defines the data to update
  14032. * @param offset defines the offset in the target index buffer where update should start
  14033. */
  14034. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14035. /**
  14036. * Updates a dynamic vertex buffer.
  14037. * @param vertexBuffer the vertex buffer to update
  14038. * @param data the data used to update the vertex buffer
  14039. * @param byteOffset the byte offset of the data
  14040. * @param byteLength the byte length of the data
  14041. */
  14042. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14043. }
  14044. }
  14045. declare module BABYLON {
  14046. interface AbstractScene {
  14047. /**
  14048. * The list of procedural textures added to the scene
  14049. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14050. */
  14051. proceduralTextures: Array<ProceduralTexture>;
  14052. }
  14053. /**
  14054. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14055. * in a given scene.
  14056. */
  14057. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14058. /**
  14059. * The component name helpfull to identify the component in the list of scene components.
  14060. */
  14061. readonly name: string;
  14062. /**
  14063. * The scene the component belongs to.
  14064. */
  14065. scene: Scene;
  14066. /**
  14067. * Creates a new instance of the component for the given scene
  14068. * @param scene Defines the scene to register the component in
  14069. */
  14070. constructor(scene: Scene);
  14071. /**
  14072. * Registers the component in a given scene
  14073. */
  14074. register(): void;
  14075. /**
  14076. * Rebuilds the elements related to this component in case of
  14077. * context lost for instance.
  14078. */
  14079. rebuild(): void;
  14080. /**
  14081. * Disposes the component and the associated ressources.
  14082. */
  14083. dispose(): void;
  14084. private _beforeClear;
  14085. }
  14086. }
  14087. declare module BABYLON {
  14088. interface ThinEngine {
  14089. /**
  14090. * Creates a new render target cube texture
  14091. * @param size defines the size of the texture
  14092. * @param options defines the options used to create the texture
  14093. * @returns a new render target cube texture stored in an InternalTexture
  14094. */
  14095. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14096. }
  14097. }
  14098. declare module BABYLON {
  14099. /** @hidden */
  14100. export var proceduralVertexShader: {
  14101. name: string;
  14102. shader: string;
  14103. };
  14104. }
  14105. declare module BABYLON {
  14106. /**
  14107. * 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.
  14108. * This is the base class of any Procedural texture and contains most of the shareable code.
  14109. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14110. */
  14111. export class ProceduralTexture extends Texture {
  14112. /**
  14113. * Define if the texture is enabled or not (disabled texture will not render)
  14114. */
  14115. isEnabled: boolean;
  14116. /**
  14117. * Define if the texture must be cleared before rendering (default is true)
  14118. */
  14119. autoClear: boolean;
  14120. /**
  14121. * Callback called when the texture is generated
  14122. */
  14123. onGenerated: () => void;
  14124. /**
  14125. * Event raised when the texture is generated
  14126. */
  14127. onGeneratedObservable: Observable<ProceduralTexture>;
  14128. /**
  14129. * Event raised before the texture is generated
  14130. */
  14131. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14132. /**
  14133. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14134. */
  14135. nodeMaterialSource: Nullable<NodeMaterial>;
  14136. /** @hidden */
  14137. _generateMipMaps: boolean;
  14138. /** @hidden **/
  14139. _effect: Effect;
  14140. /** @hidden */
  14141. _textures: {
  14142. [key: string]: Texture;
  14143. };
  14144. /** @hidden */
  14145. protected _fallbackTexture: Nullable<Texture>;
  14146. private _size;
  14147. private _currentRefreshId;
  14148. private _frameId;
  14149. private _refreshRate;
  14150. private _vertexBuffers;
  14151. private _indexBuffer;
  14152. private _uniforms;
  14153. private _samplers;
  14154. private _fragment;
  14155. private _floats;
  14156. private _ints;
  14157. private _floatsArrays;
  14158. private _colors3;
  14159. private _colors4;
  14160. private _vectors2;
  14161. private _vectors3;
  14162. private _matrices;
  14163. private _fallbackTextureUsed;
  14164. private _fullEngine;
  14165. private _cachedDefines;
  14166. private _contentUpdateId;
  14167. private _contentData;
  14168. /**
  14169. * Instantiates a new procedural texture.
  14170. * 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.
  14171. * This is the base class of any Procedural texture and contains most of the shareable code.
  14172. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14173. * @param name Define the name of the texture
  14174. * @param size Define the size of the texture to create
  14175. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14176. * @param scene Define the scene the texture belongs to
  14177. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14178. * @param generateMipMaps Define if the texture should creates mip maps or not
  14179. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14180. * @param textureType The FBO internal texture type
  14181. */
  14182. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14183. /**
  14184. * The effect that is created when initializing the post process.
  14185. * @returns The created effect corresponding the the postprocess.
  14186. */
  14187. getEffect(): Effect;
  14188. /**
  14189. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14190. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14191. */
  14192. getContent(): Nullable<ArrayBufferView>;
  14193. private _createIndexBuffer;
  14194. /** @hidden */
  14195. _rebuild(): void;
  14196. /**
  14197. * Resets the texture in order to recreate its associated resources.
  14198. * This can be called in case of context loss
  14199. */
  14200. reset(): void;
  14201. protected _getDefines(): string;
  14202. /**
  14203. * Is the texture ready to be used ? (rendered at least once)
  14204. * @returns true if ready, otherwise, false.
  14205. */
  14206. isReady(): boolean;
  14207. /**
  14208. * Resets the refresh counter of the texture and start bak from scratch.
  14209. * Could be useful to regenerate the texture if it is setup to render only once.
  14210. */
  14211. resetRefreshCounter(): void;
  14212. /**
  14213. * Set the fragment shader to use in order to render the texture.
  14214. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14215. */
  14216. setFragment(fragment: any): void;
  14217. /**
  14218. * Define the refresh rate of the texture or the rendering frequency.
  14219. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14220. */
  14221. get refreshRate(): number;
  14222. set refreshRate(value: number);
  14223. /** @hidden */
  14224. _shouldRender(): boolean;
  14225. /**
  14226. * Get the size the texture is rendering at.
  14227. * @returns the size (on cube texture it is always squared)
  14228. */
  14229. getRenderSize(): RenderTargetTextureSize;
  14230. /**
  14231. * Resize the texture to new value.
  14232. * @param size Define the new size the texture should have
  14233. * @param generateMipMaps Define whether the new texture should create mip maps
  14234. */
  14235. resize(size: number, generateMipMaps: boolean): void;
  14236. private _checkUniform;
  14237. /**
  14238. * Set a texture in the shader program used to render.
  14239. * @param name Define the name of the uniform samplers as defined in the shader
  14240. * @param texture Define the texture to bind to this sampler
  14241. * @return the texture itself allowing "fluent" like uniform updates
  14242. */
  14243. setTexture(name: string, texture: Texture): ProceduralTexture;
  14244. /**
  14245. * Set a float in the shader.
  14246. * @param name Define the name of the uniform as defined in the shader
  14247. * @param value Define the value to give to the uniform
  14248. * @return the texture itself allowing "fluent" like uniform updates
  14249. */
  14250. setFloat(name: string, value: number): ProceduralTexture;
  14251. /**
  14252. * Set a int in the shader.
  14253. * @param name Define the name of the uniform as defined in the shader
  14254. * @param value Define the value to give to the uniform
  14255. * @return the texture itself allowing "fluent" like uniform updates
  14256. */
  14257. setInt(name: string, value: number): ProceduralTexture;
  14258. /**
  14259. * Set an array of floats in the shader.
  14260. * @param name Define the name of the uniform as defined in the shader
  14261. * @param value Define the value to give to the uniform
  14262. * @return the texture itself allowing "fluent" like uniform updates
  14263. */
  14264. setFloats(name: string, value: number[]): ProceduralTexture;
  14265. /**
  14266. * Set a vec3 in the shader from a Color3.
  14267. * @param name Define the name of the uniform as defined in the shader
  14268. * @param value Define the value to give to the uniform
  14269. * @return the texture itself allowing "fluent" like uniform updates
  14270. */
  14271. setColor3(name: string, value: Color3): ProceduralTexture;
  14272. /**
  14273. * Set a vec4 in the shader from a Color4.
  14274. * @param name Define the name of the uniform as defined in the shader
  14275. * @param value Define the value to give to the uniform
  14276. * @return the texture itself allowing "fluent" like uniform updates
  14277. */
  14278. setColor4(name: string, value: Color4): ProceduralTexture;
  14279. /**
  14280. * Set a vec2 in the shader from a Vector2.
  14281. * @param name Define the name of the uniform as defined in the shader
  14282. * @param value Define the value to give to the uniform
  14283. * @return the texture itself allowing "fluent" like uniform updates
  14284. */
  14285. setVector2(name: string, value: Vector2): ProceduralTexture;
  14286. /**
  14287. * Set a vec3 in the shader from a Vector3.
  14288. * @param name Define the name of the uniform as defined in the shader
  14289. * @param value Define the value to give to the uniform
  14290. * @return the texture itself allowing "fluent" like uniform updates
  14291. */
  14292. setVector3(name: string, value: Vector3): ProceduralTexture;
  14293. /**
  14294. * Set a mat4 in the shader from a MAtrix.
  14295. * @param name Define the name of the uniform as defined in the shader
  14296. * @param value Define the value to give to the uniform
  14297. * @return the texture itself allowing "fluent" like uniform updates
  14298. */
  14299. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14300. /**
  14301. * Render the texture to its associated render target.
  14302. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14303. */
  14304. render(useCameraPostProcess?: boolean): void;
  14305. /**
  14306. * Clone the texture.
  14307. * @returns the cloned texture
  14308. */
  14309. clone(): ProceduralTexture;
  14310. /**
  14311. * Dispose the texture and release its asoociated resources.
  14312. */
  14313. dispose(): void;
  14314. }
  14315. }
  14316. declare module BABYLON {
  14317. /**
  14318. * This represents the base class for particle system in Babylon.
  14319. * 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.
  14320. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14321. * @example https://doc.babylonjs.com/babylon101/particles
  14322. */
  14323. export class BaseParticleSystem {
  14324. /**
  14325. * Source color is added to the destination color without alpha affecting the result
  14326. */
  14327. static BLENDMODE_ONEONE: number;
  14328. /**
  14329. * Blend current color and particle color using particle’s alpha
  14330. */
  14331. static BLENDMODE_STANDARD: number;
  14332. /**
  14333. * Add current color and particle color multiplied by particle’s alpha
  14334. */
  14335. static BLENDMODE_ADD: number;
  14336. /**
  14337. * Multiply current color with particle color
  14338. */
  14339. static BLENDMODE_MULTIPLY: number;
  14340. /**
  14341. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14342. */
  14343. static BLENDMODE_MULTIPLYADD: number;
  14344. /**
  14345. * List of animations used by the particle system.
  14346. */
  14347. animations: Animation[];
  14348. /**
  14349. * Gets or sets the unique id of the particle system
  14350. */
  14351. uniqueId: number;
  14352. /**
  14353. * The id of the Particle system.
  14354. */
  14355. id: string;
  14356. /**
  14357. * The friendly name of the Particle system.
  14358. */
  14359. name: string;
  14360. /**
  14361. * Snippet ID if the particle system was created from the snippet server
  14362. */
  14363. snippetId: string;
  14364. /**
  14365. * The rendering group used by the Particle system to chose when to render.
  14366. */
  14367. renderingGroupId: number;
  14368. /**
  14369. * The emitter represents the Mesh or position we are attaching the particle system to.
  14370. */
  14371. emitter: Nullable<AbstractMesh | Vector3>;
  14372. /**
  14373. * The maximum number of particles to emit per frame
  14374. */
  14375. emitRate: number;
  14376. /**
  14377. * If you want to launch only a few particles at once, that can be done, as well.
  14378. */
  14379. manualEmitCount: number;
  14380. /**
  14381. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14382. */
  14383. updateSpeed: number;
  14384. /**
  14385. * The amount of time the particle system is running (depends of the overall update speed).
  14386. */
  14387. targetStopDuration: number;
  14388. /**
  14389. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14390. */
  14391. disposeOnStop: boolean;
  14392. /**
  14393. * Minimum power of emitting particles.
  14394. */
  14395. minEmitPower: number;
  14396. /**
  14397. * Maximum power of emitting particles.
  14398. */
  14399. maxEmitPower: number;
  14400. /**
  14401. * Minimum life time of emitting particles.
  14402. */
  14403. minLifeTime: number;
  14404. /**
  14405. * Maximum life time of emitting particles.
  14406. */
  14407. maxLifeTime: number;
  14408. /**
  14409. * Minimum Size of emitting particles.
  14410. */
  14411. minSize: number;
  14412. /**
  14413. * Maximum Size of emitting particles.
  14414. */
  14415. maxSize: number;
  14416. /**
  14417. * Minimum scale of emitting particles on X axis.
  14418. */
  14419. minScaleX: number;
  14420. /**
  14421. * Maximum scale of emitting particles on X axis.
  14422. */
  14423. maxScaleX: number;
  14424. /**
  14425. * Minimum scale of emitting particles on Y axis.
  14426. */
  14427. minScaleY: number;
  14428. /**
  14429. * Maximum scale of emitting particles on Y axis.
  14430. */
  14431. maxScaleY: number;
  14432. /**
  14433. * Gets or sets the minimal initial rotation in radians.
  14434. */
  14435. minInitialRotation: number;
  14436. /**
  14437. * Gets or sets the maximal initial rotation in radians.
  14438. */
  14439. maxInitialRotation: number;
  14440. /**
  14441. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14442. */
  14443. minAngularSpeed: number;
  14444. /**
  14445. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14446. */
  14447. maxAngularSpeed: number;
  14448. /**
  14449. * The texture used to render each particle. (this can be a spritesheet)
  14450. */
  14451. particleTexture: Nullable<BaseTexture>;
  14452. /**
  14453. * The layer mask we are rendering the particles through.
  14454. */
  14455. layerMask: number;
  14456. /**
  14457. * This can help using your own shader to render the particle system.
  14458. * The according effect will be created
  14459. */
  14460. customShader: any;
  14461. /**
  14462. * By default particle system starts as soon as they are created. This prevents the
  14463. * automatic start to happen and let you decide when to start emitting particles.
  14464. */
  14465. preventAutoStart: boolean;
  14466. private _noiseTexture;
  14467. /**
  14468. * Gets or sets a texture used to add random noise to particle positions
  14469. */
  14470. get noiseTexture(): Nullable<ProceduralTexture>;
  14471. set noiseTexture(value: Nullable<ProceduralTexture>);
  14472. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14473. noiseStrength: Vector3;
  14474. /**
  14475. * Callback triggered when the particle animation is ending.
  14476. */
  14477. onAnimationEnd: Nullable<() => void>;
  14478. /**
  14479. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14480. */
  14481. blendMode: number;
  14482. /**
  14483. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14484. * to override the particles.
  14485. */
  14486. forceDepthWrite: boolean;
  14487. /** 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 */
  14488. preWarmCycles: number;
  14489. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14490. preWarmStepOffset: number;
  14491. /**
  14492. * 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)
  14493. */
  14494. spriteCellChangeSpeed: number;
  14495. /**
  14496. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14497. */
  14498. startSpriteCellID: number;
  14499. /**
  14500. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14501. */
  14502. endSpriteCellID: number;
  14503. /**
  14504. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14505. */
  14506. spriteCellWidth: number;
  14507. /**
  14508. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14509. */
  14510. spriteCellHeight: number;
  14511. /**
  14512. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14513. */
  14514. spriteRandomStartCell: boolean;
  14515. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14516. translationPivot: Vector2;
  14517. /** @hidden */
  14518. protected _isAnimationSheetEnabled: boolean;
  14519. /**
  14520. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14521. */
  14522. beginAnimationOnStart: boolean;
  14523. /**
  14524. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14525. */
  14526. beginAnimationFrom: number;
  14527. /**
  14528. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14529. */
  14530. beginAnimationTo: number;
  14531. /**
  14532. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14533. */
  14534. beginAnimationLoop: boolean;
  14535. /**
  14536. * Gets or sets a world offset applied to all particles
  14537. */
  14538. worldOffset: Vector3;
  14539. /**
  14540. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14541. */
  14542. get isAnimationSheetEnabled(): boolean;
  14543. set isAnimationSheetEnabled(value: boolean);
  14544. /**
  14545. * Get hosting scene
  14546. * @returns the scene
  14547. */
  14548. getScene(): Nullable<Scene>;
  14549. /**
  14550. * You can use gravity if you want to give an orientation to your particles.
  14551. */
  14552. gravity: Vector3;
  14553. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14554. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14555. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14556. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14557. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14558. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14559. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14560. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14561. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14562. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14563. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14564. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14565. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14566. /**
  14567. * Defines the delay in milliseconds before starting the system (0 by default)
  14568. */
  14569. startDelay: number;
  14570. /**
  14571. * Gets the current list of drag gradients.
  14572. * You must use addDragGradient and removeDragGradient to udpate this list
  14573. * @returns the list of drag gradients
  14574. */
  14575. getDragGradients(): Nullable<Array<FactorGradient>>;
  14576. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14577. limitVelocityDamping: number;
  14578. /**
  14579. * Gets the current list of limit velocity gradients.
  14580. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14581. * @returns the list of limit velocity gradients
  14582. */
  14583. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14584. /**
  14585. * Gets the current list of color gradients.
  14586. * You must use addColorGradient and removeColorGradient to udpate this list
  14587. * @returns the list of color gradients
  14588. */
  14589. getColorGradients(): Nullable<Array<ColorGradient>>;
  14590. /**
  14591. * Gets the current list of size gradients.
  14592. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14593. * @returns the list of size gradients
  14594. */
  14595. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14596. /**
  14597. * Gets the current list of color remap gradients.
  14598. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14599. * @returns the list of color remap gradients
  14600. */
  14601. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14602. /**
  14603. * Gets the current list of alpha remap gradients.
  14604. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14605. * @returns the list of alpha remap gradients
  14606. */
  14607. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14608. /**
  14609. * Gets the current list of life time gradients.
  14610. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14611. * @returns the list of life time gradients
  14612. */
  14613. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14614. /**
  14615. * Gets the current list of angular speed gradients.
  14616. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14617. * @returns the list of angular speed gradients
  14618. */
  14619. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14620. /**
  14621. * Gets the current list of velocity gradients.
  14622. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14623. * @returns the list of velocity gradients
  14624. */
  14625. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14626. /**
  14627. * Gets the current list of start size gradients.
  14628. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14629. * @returns the list of start size gradients
  14630. */
  14631. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14632. /**
  14633. * Gets the current list of emit rate gradients.
  14634. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14635. * @returns the list of emit rate gradients
  14636. */
  14637. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14638. /**
  14639. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14640. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14641. */
  14642. get direction1(): Vector3;
  14643. set direction1(value: Vector3);
  14644. /**
  14645. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14646. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14647. */
  14648. get direction2(): Vector3;
  14649. set direction2(value: Vector3);
  14650. /**
  14651. * 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.
  14652. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14653. */
  14654. get minEmitBox(): Vector3;
  14655. set minEmitBox(value: Vector3);
  14656. /**
  14657. * 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.
  14658. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14659. */
  14660. get maxEmitBox(): Vector3;
  14661. set maxEmitBox(value: Vector3);
  14662. /**
  14663. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14664. */
  14665. color1: Color4;
  14666. /**
  14667. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14668. */
  14669. color2: Color4;
  14670. /**
  14671. * Color the particle will have at the end of its lifetime
  14672. */
  14673. colorDead: Color4;
  14674. /**
  14675. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14676. */
  14677. textureMask: Color4;
  14678. /**
  14679. * The particle emitter type defines the emitter used by the particle system.
  14680. * It can be for example box, sphere, or cone...
  14681. */
  14682. particleEmitterType: IParticleEmitterType;
  14683. /** @hidden */
  14684. _isSubEmitter: boolean;
  14685. /**
  14686. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14687. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14688. */
  14689. billboardMode: number;
  14690. protected _isBillboardBased: boolean;
  14691. /**
  14692. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14693. */
  14694. get isBillboardBased(): boolean;
  14695. set isBillboardBased(value: boolean);
  14696. /**
  14697. * The scene the particle system belongs to.
  14698. */
  14699. protected _scene: Nullable<Scene>;
  14700. /**
  14701. * The engine the particle system belongs to.
  14702. */
  14703. protected _engine: ThinEngine;
  14704. /**
  14705. * Local cache of defines for image processing.
  14706. */
  14707. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14708. /**
  14709. * Default configuration related to image processing available in the standard Material.
  14710. */
  14711. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  14712. /**
  14713. * Gets the image processing configuration used either in this material.
  14714. */
  14715. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  14716. /**
  14717. * Sets the Default image processing configuration used either in the this material.
  14718. *
  14719. * If sets to null, the scene one is in use.
  14720. */
  14721. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  14722. /**
  14723. * Attaches a new image processing configuration to the Standard Material.
  14724. * @param configuration
  14725. */
  14726. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14727. /** @hidden */
  14728. protected _reset(): void;
  14729. /** @hidden */
  14730. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14731. /**
  14732. * Instantiates a particle system.
  14733. * 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.
  14734. * @param name The name of the particle system
  14735. */
  14736. constructor(name: string);
  14737. /**
  14738. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14739. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14740. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14741. * @returns the emitter
  14742. */
  14743. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14744. /**
  14745. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14746. * @param radius The radius of the hemisphere to emit from
  14747. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14748. * @returns the emitter
  14749. */
  14750. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14751. /**
  14752. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14753. * @param radius The radius of the sphere to emit from
  14754. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14755. * @returns the emitter
  14756. */
  14757. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14758. /**
  14759. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14760. * @param radius The radius of the sphere to emit from
  14761. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14762. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14763. * @returns the emitter
  14764. */
  14765. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14766. /**
  14767. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14768. * @param radius The radius of the emission cylinder
  14769. * @param height The height of the emission cylinder
  14770. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14771. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14772. * @returns the emitter
  14773. */
  14774. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14775. /**
  14776. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14777. * @param radius The radius of the cylinder to emit from
  14778. * @param height The height of the emission cylinder
  14779. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14780. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14781. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14782. * @returns the emitter
  14783. */
  14784. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14785. /**
  14786. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14787. * @param radius The radius of the cone to emit from
  14788. * @param angle The base angle of the cone
  14789. * @returns the emitter
  14790. */
  14791. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14792. /**
  14793. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14794. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14795. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14796. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14797. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14798. * @returns the emitter
  14799. */
  14800. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14801. }
  14802. }
  14803. declare module BABYLON {
  14804. /**
  14805. * Type of sub emitter
  14806. */
  14807. export enum SubEmitterType {
  14808. /**
  14809. * Attached to the particle over it's lifetime
  14810. */
  14811. ATTACHED = 0,
  14812. /**
  14813. * Created when the particle dies
  14814. */
  14815. END = 1
  14816. }
  14817. /**
  14818. * Sub emitter class used to emit particles from an existing particle
  14819. */
  14820. export class SubEmitter {
  14821. /**
  14822. * the particle system to be used by the sub emitter
  14823. */
  14824. particleSystem: ParticleSystem;
  14825. /**
  14826. * Type of the submitter (Default: END)
  14827. */
  14828. type: SubEmitterType;
  14829. /**
  14830. * 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)
  14831. * Note: This only is supported when using an emitter of type Mesh
  14832. */
  14833. inheritDirection: boolean;
  14834. /**
  14835. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14836. */
  14837. inheritedVelocityAmount: number;
  14838. /**
  14839. * Creates a sub emitter
  14840. * @param particleSystem the particle system to be used by the sub emitter
  14841. */
  14842. constructor(
  14843. /**
  14844. * the particle system to be used by the sub emitter
  14845. */
  14846. particleSystem: ParticleSystem);
  14847. /**
  14848. * Clones the sub emitter
  14849. * @returns the cloned sub emitter
  14850. */
  14851. clone(): SubEmitter;
  14852. /**
  14853. * Serialize current object to a JSON object
  14854. * @returns the serialized object
  14855. */
  14856. serialize(): any;
  14857. /** @hidden */
  14858. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  14859. /**
  14860. * Creates a new SubEmitter from a serialized JSON version
  14861. * @param serializationObject defines the JSON object to read from
  14862. * @param sceneOrEngine defines the hosting scene or the hosting engine
  14863. * @param rootUrl defines the rootUrl for data loading
  14864. * @returns a new SubEmitter
  14865. */
  14866. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  14867. /** Release associated resources */
  14868. dispose(): void;
  14869. }
  14870. }
  14871. declare module BABYLON {
  14872. /** @hidden */
  14873. export var clipPlaneFragmentDeclaration: {
  14874. name: string;
  14875. shader: string;
  14876. };
  14877. }
  14878. declare module BABYLON {
  14879. /** @hidden */
  14880. export var imageProcessingDeclaration: {
  14881. name: string;
  14882. shader: string;
  14883. };
  14884. }
  14885. declare module BABYLON {
  14886. /** @hidden */
  14887. export var imageProcessingFunctions: {
  14888. name: string;
  14889. shader: string;
  14890. };
  14891. }
  14892. declare module BABYLON {
  14893. /** @hidden */
  14894. export var clipPlaneFragment: {
  14895. name: string;
  14896. shader: string;
  14897. };
  14898. }
  14899. declare module BABYLON {
  14900. /** @hidden */
  14901. export var particlesPixelShader: {
  14902. name: string;
  14903. shader: string;
  14904. };
  14905. }
  14906. declare module BABYLON {
  14907. /** @hidden */
  14908. export var clipPlaneVertexDeclaration: {
  14909. name: string;
  14910. shader: string;
  14911. };
  14912. }
  14913. declare module BABYLON {
  14914. /** @hidden */
  14915. export var clipPlaneVertex: {
  14916. name: string;
  14917. shader: string;
  14918. };
  14919. }
  14920. declare module BABYLON {
  14921. /** @hidden */
  14922. export var particlesVertexShader: {
  14923. name: string;
  14924. shader: string;
  14925. };
  14926. }
  14927. declare module BABYLON {
  14928. /**
  14929. * Interface used to define entities containing multiple clip planes
  14930. */
  14931. export interface IClipPlanesHolder {
  14932. /**
  14933. * Gets or sets the active clipplane 1
  14934. */
  14935. clipPlane: Nullable<Plane>;
  14936. /**
  14937. * Gets or sets the active clipplane 2
  14938. */
  14939. clipPlane2: Nullable<Plane>;
  14940. /**
  14941. * Gets or sets the active clipplane 3
  14942. */
  14943. clipPlane3: Nullable<Plane>;
  14944. /**
  14945. * Gets or sets the active clipplane 4
  14946. */
  14947. clipPlane4: Nullable<Plane>;
  14948. /**
  14949. * Gets or sets the active clipplane 5
  14950. */
  14951. clipPlane5: Nullable<Plane>;
  14952. /**
  14953. * Gets or sets the active clipplane 6
  14954. */
  14955. clipPlane6: Nullable<Plane>;
  14956. }
  14957. }
  14958. declare module BABYLON {
  14959. /**
  14960. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  14961. *
  14962. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  14963. *
  14964. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  14965. */
  14966. export class ThinMaterialHelper {
  14967. /**
  14968. * Binds the clip plane information from the holder to the effect.
  14969. * @param effect The effect we are binding the data to
  14970. * @param holder The entity containing the clip plane information
  14971. */
  14972. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  14973. }
  14974. }
  14975. declare module BABYLON {
  14976. interface ThinEngine {
  14977. /**
  14978. * Sets alpha constants used by some alpha blending modes
  14979. * @param r defines the red component
  14980. * @param g defines the green component
  14981. * @param b defines the blue component
  14982. * @param a defines the alpha component
  14983. */
  14984. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  14985. /**
  14986. * Sets the current alpha mode
  14987. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  14988. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  14989. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14990. */
  14991. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  14992. /**
  14993. * Gets the current alpha mode
  14994. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  14995. * @returns the current alpha mode
  14996. */
  14997. getAlphaMode(): number;
  14998. /**
  14999. * Sets the current alpha equation
  15000. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15001. */
  15002. setAlphaEquation(equation: number): void;
  15003. /**
  15004. * Gets the current alpha equation.
  15005. * @returns the current alpha equation
  15006. */
  15007. getAlphaEquation(): number;
  15008. }
  15009. }
  15010. declare module BABYLON {
  15011. /**
  15012. * This represents a particle system in Babylon.
  15013. * 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.
  15014. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15015. * @example https://doc.babylonjs.com/babylon101/particles
  15016. */
  15017. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15018. /**
  15019. * Billboard mode will only apply to Y axis
  15020. */
  15021. static readonly BILLBOARDMODE_Y: number;
  15022. /**
  15023. * Billboard mode will apply to all axes
  15024. */
  15025. static readonly BILLBOARDMODE_ALL: number;
  15026. /**
  15027. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15028. */
  15029. static readonly BILLBOARDMODE_STRETCHED: number;
  15030. /**
  15031. * This function can be defined to provide custom update for active particles.
  15032. * This function will be called instead of regular update (age, position, color, etc.).
  15033. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15034. */
  15035. updateFunction: (particles: Particle[]) => void;
  15036. private _emitterWorldMatrix;
  15037. /**
  15038. * This function can be defined to specify initial direction for every new particle.
  15039. * It by default use the emitterType defined function
  15040. */
  15041. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15042. /**
  15043. * This function can be defined to specify initial position for every new particle.
  15044. * It by default use the emitterType defined function
  15045. */
  15046. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15047. /**
  15048. * @hidden
  15049. */
  15050. _inheritedVelocityOffset: Vector3;
  15051. /**
  15052. * An event triggered when the system is disposed
  15053. */
  15054. onDisposeObservable: Observable<IParticleSystem>;
  15055. /**
  15056. * An event triggered when the system is stopped
  15057. */
  15058. onStoppedObservable: Observable<IParticleSystem>;
  15059. private _onDisposeObserver;
  15060. /**
  15061. * Sets a callback that will be triggered when the system is disposed
  15062. */
  15063. set onDispose(callback: () => void);
  15064. private _particles;
  15065. private _epsilon;
  15066. private _capacity;
  15067. private _stockParticles;
  15068. private _newPartsExcess;
  15069. private _vertexData;
  15070. private _vertexBuffer;
  15071. private _vertexBuffers;
  15072. private _spriteBuffer;
  15073. private _indexBuffer;
  15074. private _effect;
  15075. private _customEffect;
  15076. private _cachedDefines;
  15077. private _scaledColorStep;
  15078. private _colorDiff;
  15079. private _scaledDirection;
  15080. private _scaledGravity;
  15081. private _currentRenderId;
  15082. private _alive;
  15083. private _useInstancing;
  15084. private _vertexArrayObject;
  15085. private _started;
  15086. private _stopped;
  15087. private _actualFrame;
  15088. private _scaledUpdateSpeed;
  15089. private _vertexBufferSize;
  15090. /** @hidden */
  15091. _currentEmitRateGradient: Nullable<FactorGradient>;
  15092. /** @hidden */
  15093. _currentEmitRate1: number;
  15094. /** @hidden */
  15095. _currentEmitRate2: number;
  15096. /** @hidden */
  15097. _currentStartSizeGradient: Nullable<FactorGradient>;
  15098. /** @hidden */
  15099. _currentStartSize1: number;
  15100. /** @hidden */
  15101. _currentStartSize2: number;
  15102. private readonly _rawTextureWidth;
  15103. private _rampGradientsTexture;
  15104. private _useRampGradients;
  15105. /** Gets or sets a matrix to use to compute projection */
  15106. defaultProjectionMatrix: Matrix;
  15107. /** Gets or sets a matrix to use to compute view */
  15108. defaultViewMatrix: Matrix;
  15109. /** Gets or sets a boolean indicating that ramp gradients must be used
  15110. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15111. */
  15112. get useRampGradients(): boolean;
  15113. set useRampGradients(value: boolean);
  15114. /**
  15115. * 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.
  15116. * 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: [])
  15117. */
  15118. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15119. private _subEmitters;
  15120. /**
  15121. * @hidden
  15122. * If the particle systems emitter should be disposed when the particle system is disposed
  15123. */
  15124. _disposeEmitterOnDispose: boolean;
  15125. /**
  15126. * The current active Sub-systems, this property is used by the root particle system only.
  15127. */
  15128. activeSubSystems: Array<ParticleSystem>;
  15129. /**
  15130. * Specifies if the particles are updated in emitter local space or world space
  15131. */
  15132. isLocal: boolean;
  15133. private _rootParticleSystem;
  15134. /**
  15135. * Gets the current list of active particles
  15136. */
  15137. get particles(): Particle[];
  15138. /**
  15139. * Gets the number of particles active at the same time.
  15140. * @returns The number of active particles.
  15141. */
  15142. getActiveCount(): number;
  15143. /**
  15144. * Returns the string "ParticleSystem"
  15145. * @returns a string containing the class name
  15146. */
  15147. getClassName(): string;
  15148. /**
  15149. * Gets a boolean indicating that the system is stopping
  15150. * @returns true if the system is currently stopping
  15151. */
  15152. isStopping(): boolean;
  15153. /**
  15154. * Gets the custom effect used to render the particles
  15155. * @param blendMode Blend mode for which the effect should be retrieved
  15156. * @returns The effect
  15157. */
  15158. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15159. /**
  15160. * Sets the custom effect used to render the particles
  15161. * @param effect The effect to set
  15162. * @param blendMode Blend mode for which the effect should be set
  15163. */
  15164. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15165. /** @hidden */
  15166. private _onBeforeDrawParticlesObservable;
  15167. /**
  15168. * Observable that will be called just before the particles are drawn
  15169. */
  15170. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15171. /**
  15172. * Gets the name of the particle vertex shader
  15173. */
  15174. get vertexShaderName(): string;
  15175. /**
  15176. * Instantiates a particle system.
  15177. * 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.
  15178. * @param name The name of the particle system
  15179. * @param capacity The max number of particles alive at the same time
  15180. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15181. * @param customEffect a custom effect used to change the way particles are rendered by default
  15182. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15183. * @param epsilon Offset used to render the particles
  15184. */
  15185. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15186. private _addFactorGradient;
  15187. private _removeFactorGradient;
  15188. /**
  15189. * Adds a new life time gradient
  15190. * @param gradient defines the gradient to use (between 0 and 1)
  15191. * @param factor defines the life time factor to affect to the specified gradient
  15192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15193. * @returns the current particle system
  15194. */
  15195. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15196. /**
  15197. * Remove a specific life time gradient
  15198. * @param gradient defines the gradient to remove
  15199. * @returns the current particle system
  15200. */
  15201. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15202. /**
  15203. * Adds a new size gradient
  15204. * @param gradient defines the gradient to use (between 0 and 1)
  15205. * @param factor defines the size factor to affect to the specified gradient
  15206. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15207. * @returns the current particle system
  15208. */
  15209. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15210. /**
  15211. * Remove a specific size gradient
  15212. * @param gradient defines the gradient to remove
  15213. * @returns the current particle system
  15214. */
  15215. removeSizeGradient(gradient: number): IParticleSystem;
  15216. /**
  15217. * Adds a new color remap gradient
  15218. * @param gradient defines the gradient to use (between 0 and 1)
  15219. * @param min defines the color remap minimal range
  15220. * @param max defines the color remap maximal range
  15221. * @returns the current particle system
  15222. */
  15223. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15224. /**
  15225. * Remove a specific color remap gradient
  15226. * @param gradient defines the gradient to remove
  15227. * @returns the current particle system
  15228. */
  15229. removeColorRemapGradient(gradient: number): IParticleSystem;
  15230. /**
  15231. * Adds a new alpha remap gradient
  15232. * @param gradient defines the gradient to use (between 0 and 1)
  15233. * @param min defines the alpha remap minimal range
  15234. * @param max defines the alpha remap maximal range
  15235. * @returns the current particle system
  15236. */
  15237. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15238. /**
  15239. * Remove a specific alpha remap gradient
  15240. * @param gradient defines the gradient to remove
  15241. * @returns the current particle system
  15242. */
  15243. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15244. /**
  15245. * Adds a new angular speed gradient
  15246. * @param gradient defines the gradient to use (between 0 and 1)
  15247. * @param factor defines the angular speed to affect to the specified gradient
  15248. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15249. * @returns the current particle system
  15250. */
  15251. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15252. /**
  15253. * Remove a specific angular speed gradient
  15254. * @param gradient defines the gradient to remove
  15255. * @returns the current particle system
  15256. */
  15257. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15258. /**
  15259. * Adds a new velocity gradient
  15260. * @param gradient defines the gradient to use (between 0 and 1)
  15261. * @param factor defines the velocity to affect to the specified gradient
  15262. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15263. * @returns the current particle system
  15264. */
  15265. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15266. /**
  15267. * Remove a specific velocity gradient
  15268. * @param gradient defines the gradient to remove
  15269. * @returns the current particle system
  15270. */
  15271. removeVelocityGradient(gradient: number): IParticleSystem;
  15272. /**
  15273. * Adds a new limit velocity gradient
  15274. * @param gradient defines the gradient to use (between 0 and 1)
  15275. * @param factor defines the limit velocity value to affect to the specified gradient
  15276. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15277. * @returns the current particle system
  15278. */
  15279. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15280. /**
  15281. * Remove a specific limit velocity gradient
  15282. * @param gradient defines the gradient to remove
  15283. * @returns the current particle system
  15284. */
  15285. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15286. /**
  15287. * Adds a new drag gradient
  15288. * @param gradient defines the gradient to use (between 0 and 1)
  15289. * @param factor defines the drag value to affect to the specified gradient
  15290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15291. * @returns the current particle system
  15292. */
  15293. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15294. /**
  15295. * Remove a specific drag gradient
  15296. * @param gradient defines the gradient to remove
  15297. * @returns the current particle system
  15298. */
  15299. removeDragGradient(gradient: number): IParticleSystem;
  15300. /**
  15301. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15302. * @param gradient defines the gradient to use (between 0 and 1)
  15303. * @param factor defines the emit rate value to affect to the specified gradient
  15304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15305. * @returns the current particle system
  15306. */
  15307. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15308. /**
  15309. * Remove a specific emit rate gradient
  15310. * @param gradient defines the gradient to remove
  15311. * @returns the current particle system
  15312. */
  15313. removeEmitRateGradient(gradient: number): IParticleSystem;
  15314. /**
  15315. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15316. * @param gradient defines the gradient to use (between 0 and 1)
  15317. * @param factor defines the start size value to affect to the specified gradient
  15318. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15319. * @returns the current particle system
  15320. */
  15321. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15322. /**
  15323. * Remove a specific start size gradient
  15324. * @param gradient defines the gradient to remove
  15325. * @returns the current particle system
  15326. */
  15327. removeStartSizeGradient(gradient: number): IParticleSystem;
  15328. private _createRampGradientTexture;
  15329. /**
  15330. * Gets the current list of ramp gradients.
  15331. * You must use addRampGradient and removeRampGradient to udpate this list
  15332. * @returns the list of ramp gradients
  15333. */
  15334. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15335. /** Force the system to rebuild all gradients that need to be resync */
  15336. forceRefreshGradients(): void;
  15337. private _syncRampGradientTexture;
  15338. /**
  15339. * Adds a new ramp gradient used to remap particle colors
  15340. * @param gradient defines the gradient to use (between 0 and 1)
  15341. * @param color defines the color to affect to the specified gradient
  15342. * @returns the current particle system
  15343. */
  15344. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15345. /**
  15346. * Remove a specific ramp gradient
  15347. * @param gradient defines the gradient to remove
  15348. * @returns the current particle system
  15349. */
  15350. removeRampGradient(gradient: number): ParticleSystem;
  15351. /**
  15352. * Adds a new color gradient
  15353. * @param gradient defines the gradient to use (between 0 and 1)
  15354. * @param color1 defines the color to affect to the specified gradient
  15355. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15356. * @returns this particle system
  15357. */
  15358. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15359. /**
  15360. * Remove a specific color gradient
  15361. * @param gradient defines the gradient to remove
  15362. * @returns this particle system
  15363. */
  15364. removeColorGradient(gradient: number): IParticleSystem;
  15365. private _fetchR;
  15366. protected _reset(): void;
  15367. private _resetEffect;
  15368. private _createVertexBuffers;
  15369. private _createIndexBuffer;
  15370. /**
  15371. * Gets the maximum number of particles active at the same time.
  15372. * @returns The max number of active particles.
  15373. */
  15374. getCapacity(): number;
  15375. /**
  15376. * Gets whether there are still active particles in the system.
  15377. * @returns True if it is alive, otherwise false.
  15378. */
  15379. isAlive(): boolean;
  15380. /**
  15381. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15382. * @returns True if it has been started, otherwise false.
  15383. */
  15384. isStarted(): boolean;
  15385. private _prepareSubEmitterInternalArray;
  15386. /**
  15387. * Starts the particle system and begins to emit
  15388. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15389. */
  15390. start(delay?: number): void;
  15391. /**
  15392. * Stops the particle system.
  15393. * @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.
  15394. */
  15395. stop(stopSubEmitters?: boolean): void;
  15396. /**
  15397. * Remove all active particles
  15398. */
  15399. reset(): void;
  15400. /**
  15401. * @hidden (for internal use only)
  15402. */
  15403. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15404. /**
  15405. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15406. * Its lifetime will start back at 0.
  15407. */
  15408. recycleParticle: (particle: Particle) => void;
  15409. private _stopSubEmitters;
  15410. private _createParticle;
  15411. private _removeFromRoot;
  15412. private _emitFromParticle;
  15413. private _update;
  15414. /** @hidden */
  15415. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15416. /** @hidden */
  15417. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15418. /**
  15419. * Fill the defines array according to the current settings of the particle system
  15420. * @param defines Array to be updated
  15421. * @param blendMode blend mode to take into account when updating the array
  15422. */
  15423. fillDefines(defines: Array<string>, blendMode: number): void;
  15424. /**
  15425. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15426. * @param uniforms Uniforms array to fill
  15427. * @param attributes Attributes array to fill
  15428. * @param samplers Samplers array to fill
  15429. */
  15430. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15431. /** @hidden */
  15432. private _getEffect;
  15433. /**
  15434. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15435. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15436. */
  15437. animate(preWarmOnly?: boolean): void;
  15438. private _appendParticleVertices;
  15439. /**
  15440. * Rebuilds the particle system.
  15441. */
  15442. rebuild(): void;
  15443. /**
  15444. * Is this system ready to be used/rendered
  15445. * @return true if the system is ready
  15446. */
  15447. isReady(): boolean;
  15448. private _render;
  15449. /**
  15450. * Renders the particle system in its current state.
  15451. * @returns the current number of particles
  15452. */
  15453. render(): number;
  15454. /**
  15455. * Disposes the particle system and free the associated resources
  15456. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15457. */
  15458. dispose(disposeTexture?: boolean): void;
  15459. /**
  15460. * Clones the particle system.
  15461. * @param name The name of the cloned object
  15462. * @param newEmitter The new emitter to use
  15463. * @returns the cloned particle system
  15464. */
  15465. clone(name: string, newEmitter: any): ParticleSystem;
  15466. /**
  15467. * Serializes the particle system to a JSON object
  15468. * @param serializeTexture defines if the texture must be serialized as well
  15469. * @returns the JSON object
  15470. */
  15471. serialize(serializeTexture?: boolean): any;
  15472. /** @hidden */
  15473. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  15474. /** @hidden */
  15475. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  15476. /**
  15477. * Parses a JSON object to create a particle system.
  15478. * @param parsedParticleSystem The JSON object to parse
  15479. * @param sceneOrEngine The scene or the engine to create the particle system in
  15480. * @param rootUrl The root url to use to load external dependencies like texture
  15481. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15482. * @returns the Parsed particle system
  15483. */
  15484. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15485. }
  15486. }
  15487. declare module BABYLON {
  15488. /**
  15489. * A particle represents one of the element emitted by a particle system.
  15490. * This is mainly define by its coordinates, direction, velocity and age.
  15491. */
  15492. export class Particle {
  15493. /**
  15494. * The particle system the particle belongs to.
  15495. */
  15496. particleSystem: ParticleSystem;
  15497. private static _Count;
  15498. /**
  15499. * Unique ID of the particle
  15500. */
  15501. id: number;
  15502. /**
  15503. * The world position of the particle in the scene.
  15504. */
  15505. position: Vector3;
  15506. /**
  15507. * The world direction of the particle in the scene.
  15508. */
  15509. direction: Vector3;
  15510. /**
  15511. * The color of the particle.
  15512. */
  15513. color: Color4;
  15514. /**
  15515. * The color change of the particle per step.
  15516. */
  15517. colorStep: Color4;
  15518. /**
  15519. * Defines how long will the life of the particle be.
  15520. */
  15521. lifeTime: number;
  15522. /**
  15523. * The current age of the particle.
  15524. */
  15525. age: number;
  15526. /**
  15527. * The current size of the particle.
  15528. */
  15529. size: number;
  15530. /**
  15531. * The current scale of the particle.
  15532. */
  15533. scale: Vector2;
  15534. /**
  15535. * The current angle of the particle.
  15536. */
  15537. angle: number;
  15538. /**
  15539. * Defines how fast is the angle changing.
  15540. */
  15541. angularSpeed: number;
  15542. /**
  15543. * Defines the cell index used by the particle to be rendered from a sprite.
  15544. */
  15545. cellIndex: number;
  15546. /**
  15547. * The information required to support color remapping
  15548. */
  15549. remapData: Vector4;
  15550. /** @hidden */
  15551. _randomCellOffset?: number;
  15552. /** @hidden */
  15553. _initialDirection: Nullable<Vector3>;
  15554. /** @hidden */
  15555. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15556. /** @hidden */
  15557. _initialStartSpriteCellID: number;
  15558. /** @hidden */
  15559. _initialEndSpriteCellID: number;
  15560. /** @hidden */
  15561. _currentColorGradient: Nullable<ColorGradient>;
  15562. /** @hidden */
  15563. _currentColor1: Color4;
  15564. /** @hidden */
  15565. _currentColor2: Color4;
  15566. /** @hidden */
  15567. _currentSizeGradient: Nullable<FactorGradient>;
  15568. /** @hidden */
  15569. _currentSize1: number;
  15570. /** @hidden */
  15571. _currentSize2: number;
  15572. /** @hidden */
  15573. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15574. /** @hidden */
  15575. _currentAngularSpeed1: number;
  15576. /** @hidden */
  15577. _currentAngularSpeed2: number;
  15578. /** @hidden */
  15579. _currentVelocityGradient: Nullable<FactorGradient>;
  15580. /** @hidden */
  15581. _currentVelocity1: number;
  15582. /** @hidden */
  15583. _currentVelocity2: number;
  15584. /** @hidden */
  15585. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15586. /** @hidden */
  15587. _currentLimitVelocity1: number;
  15588. /** @hidden */
  15589. _currentLimitVelocity2: number;
  15590. /** @hidden */
  15591. _currentDragGradient: Nullable<FactorGradient>;
  15592. /** @hidden */
  15593. _currentDrag1: number;
  15594. /** @hidden */
  15595. _currentDrag2: number;
  15596. /** @hidden */
  15597. _randomNoiseCoordinates1: Vector3;
  15598. /** @hidden */
  15599. _randomNoiseCoordinates2: Vector3;
  15600. /** @hidden */
  15601. _localPosition?: Vector3;
  15602. /**
  15603. * Creates a new instance Particle
  15604. * @param particleSystem the particle system the particle belongs to
  15605. */
  15606. constructor(
  15607. /**
  15608. * The particle system the particle belongs to.
  15609. */
  15610. particleSystem: ParticleSystem);
  15611. private updateCellInfoFromSystem;
  15612. /**
  15613. * Defines how the sprite cell index is updated for the particle
  15614. */
  15615. updateCellIndex(): void;
  15616. /** @hidden */
  15617. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15618. /** @hidden */
  15619. _inheritParticleInfoToSubEmitters(): void;
  15620. /** @hidden */
  15621. _reset(): void;
  15622. /**
  15623. * Copy the properties of particle to another one.
  15624. * @param other the particle to copy the information to.
  15625. */
  15626. copyTo(other: Particle): void;
  15627. }
  15628. }
  15629. declare module BABYLON {
  15630. /**
  15631. * Particle emitter represents a volume emitting particles.
  15632. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15633. */
  15634. export interface IParticleEmitterType {
  15635. /**
  15636. * Called by the particle System when the direction is computed for the created particle.
  15637. * @param worldMatrix is the world matrix of the particle system
  15638. * @param directionToUpdate is the direction vector to update with the result
  15639. * @param particle is the particle we are computed the direction for
  15640. * @param isLocal defines if the direction should be set in local space
  15641. */
  15642. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15643. /**
  15644. * Called by the particle System when the position is computed for the created particle.
  15645. * @param worldMatrix is the world matrix of the particle system
  15646. * @param positionToUpdate is the position vector to update with the result
  15647. * @param particle is the particle we are computed the position for
  15648. * @param isLocal defines if the position should be set in local space
  15649. */
  15650. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15651. /**
  15652. * Clones the current emitter and returns a copy of it
  15653. * @returns the new emitter
  15654. */
  15655. clone(): IParticleEmitterType;
  15656. /**
  15657. * Called by the GPUParticleSystem to setup the update shader
  15658. * @param effect defines the update shader
  15659. */
  15660. applyToShader(effect: Effect): void;
  15661. /**
  15662. * Returns a string to use to update the GPU particles update shader
  15663. * @returns the effect defines string
  15664. */
  15665. getEffectDefines(): string;
  15666. /**
  15667. * Returns a string representing the class name
  15668. * @returns a string containing the class name
  15669. */
  15670. getClassName(): string;
  15671. /**
  15672. * Serializes the particle system to a JSON object.
  15673. * @returns the JSON object
  15674. */
  15675. serialize(): any;
  15676. /**
  15677. * Parse properties from a JSON object
  15678. * @param serializationObject defines the JSON object
  15679. * @param scene defines the hosting scene
  15680. */
  15681. parse(serializationObject: any, scene: Nullable<Scene>): void;
  15682. }
  15683. }
  15684. declare module BABYLON {
  15685. /**
  15686. * Particle emitter emitting particles from the inside of a box.
  15687. * It emits the particles randomly between 2 given directions.
  15688. */
  15689. export class BoxParticleEmitter implements IParticleEmitterType {
  15690. /**
  15691. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15692. */
  15693. direction1: Vector3;
  15694. /**
  15695. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15696. */
  15697. direction2: Vector3;
  15698. /**
  15699. * 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.
  15700. */
  15701. minEmitBox: Vector3;
  15702. /**
  15703. * 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.
  15704. */
  15705. maxEmitBox: Vector3;
  15706. /**
  15707. * Creates a new instance BoxParticleEmitter
  15708. */
  15709. constructor();
  15710. /**
  15711. * Called by the particle System when the direction is computed for the created particle.
  15712. * @param worldMatrix is the world matrix of the particle system
  15713. * @param directionToUpdate is the direction vector to update with the result
  15714. * @param particle is the particle we are computed the direction for
  15715. * @param isLocal defines if the direction should be set in local space
  15716. */
  15717. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15718. /**
  15719. * Called by the particle System when the position is computed for the created particle.
  15720. * @param worldMatrix is the world matrix of the particle system
  15721. * @param positionToUpdate is the position vector to update with the result
  15722. * @param particle is the particle we are computed the position for
  15723. * @param isLocal defines if the position should be set in local space
  15724. */
  15725. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15726. /**
  15727. * Clones the current emitter and returns a copy of it
  15728. * @returns the new emitter
  15729. */
  15730. clone(): BoxParticleEmitter;
  15731. /**
  15732. * Called by the GPUParticleSystem to setup the update shader
  15733. * @param effect defines the update shader
  15734. */
  15735. applyToShader(effect: Effect): void;
  15736. /**
  15737. * Returns a string to use to update the GPU particles update shader
  15738. * @returns a string containng the defines string
  15739. */
  15740. getEffectDefines(): string;
  15741. /**
  15742. * Returns the string "BoxParticleEmitter"
  15743. * @returns a string containing the class name
  15744. */
  15745. getClassName(): string;
  15746. /**
  15747. * Serializes the particle system to a JSON object.
  15748. * @returns the JSON object
  15749. */
  15750. serialize(): any;
  15751. /**
  15752. * Parse properties from a JSON object
  15753. * @param serializationObject defines the JSON object
  15754. */
  15755. parse(serializationObject: any): void;
  15756. }
  15757. }
  15758. declare module BABYLON {
  15759. /**
  15760. * Particle emitter emitting particles from the inside of a cone.
  15761. * It emits the particles alongside the cone volume from the base to the particle.
  15762. * The emission direction might be randomized.
  15763. */
  15764. export class ConeParticleEmitter implements IParticleEmitterType {
  15765. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15766. directionRandomizer: number;
  15767. private _radius;
  15768. private _angle;
  15769. private _height;
  15770. /**
  15771. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15772. */
  15773. radiusRange: number;
  15774. /**
  15775. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15776. */
  15777. heightRange: number;
  15778. /**
  15779. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15780. */
  15781. emitFromSpawnPointOnly: boolean;
  15782. /**
  15783. * Gets or sets the radius of the emission cone
  15784. */
  15785. get radius(): number;
  15786. set radius(value: number);
  15787. /**
  15788. * Gets or sets the angle of the emission cone
  15789. */
  15790. get angle(): number;
  15791. set angle(value: number);
  15792. private _buildHeight;
  15793. /**
  15794. * Creates a new instance ConeParticleEmitter
  15795. * @param radius the radius of the emission cone (1 by default)
  15796. * @param angle the cone base angle (PI by default)
  15797. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15798. */
  15799. constructor(radius?: number, angle?: number,
  15800. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15801. directionRandomizer?: number);
  15802. /**
  15803. * Called by the particle System when the direction is computed for the created particle.
  15804. * @param worldMatrix is the world matrix of the particle system
  15805. * @param directionToUpdate is the direction vector to update with the result
  15806. * @param particle is the particle we are computed the direction for
  15807. * @param isLocal defines if the direction should be set in local space
  15808. */
  15809. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15810. /**
  15811. * Called by the particle System when the position is computed for the created particle.
  15812. * @param worldMatrix is the world matrix of the particle system
  15813. * @param positionToUpdate is the position vector to update with the result
  15814. * @param particle is the particle we are computed the position for
  15815. * @param isLocal defines if the position should be set in local space
  15816. */
  15817. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15818. /**
  15819. * Clones the current emitter and returns a copy of it
  15820. * @returns the new emitter
  15821. */
  15822. clone(): ConeParticleEmitter;
  15823. /**
  15824. * Called by the GPUParticleSystem to setup the update shader
  15825. * @param effect defines the update shader
  15826. */
  15827. applyToShader(effect: Effect): void;
  15828. /**
  15829. * Returns a string to use to update the GPU particles update shader
  15830. * @returns a string containng the defines string
  15831. */
  15832. getEffectDefines(): string;
  15833. /**
  15834. * Returns the string "ConeParticleEmitter"
  15835. * @returns a string containing the class name
  15836. */
  15837. getClassName(): string;
  15838. /**
  15839. * Serializes the particle system to a JSON object.
  15840. * @returns the JSON object
  15841. */
  15842. serialize(): any;
  15843. /**
  15844. * Parse properties from a JSON object
  15845. * @param serializationObject defines the JSON object
  15846. */
  15847. parse(serializationObject: any): void;
  15848. }
  15849. }
  15850. declare module BABYLON {
  15851. /**
  15852. * Particle emitter emitting particles from the inside of a cylinder.
  15853. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15854. */
  15855. export class CylinderParticleEmitter implements IParticleEmitterType {
  15856. /**
  15857. * The radius of the emission cylinder.
  15858. */
  15859. radius: number;
  15860. /**
  15861. * The height of the emission cylinder.
  15862. */
  15863. height: number;
  15864. /**
  15865. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15866. */
  15867. radiusRange: number;
  15868. /**
  15869. * How much to randomize the particle direction [0-1].
  15870. */
  15871. directionRandomizer: number;
  15872. /**
  15873. * Creates a new instance CylinderParticleEmitter
  15874. * @param radius the radius of the emission cylinder (1 by default)
  15875. * @param height the height of the emission cylinder (1 by default)
  15876. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15877. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15878. */
  15879. constructor(
  15880. /**
  15881. * The radius of the emission cylinder.
  15882. */
  15883. radius?: number,
  15884. /**
  15885. * The height of the emission cylinder.
  15886. */
  15887. height?: number,
  15888. /**
  15889. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15890. */
  15891. radiusRange?: number,
  15892. /**
  15893. * How much to randomize the particle direction [0-1].
  15894. */
  15895. directionRandomizer?: number);
  15896. /**
  15897. * Called by the particle System when the direction is computed for the created particle.
  15898. * @param worldMatrix is the world matrix of the particle system
  15899. * @param directionToUpdate is the direction vector to update with the result
  15900. * @param particle is the particle we are computed the direction for
  15901. * @param isLocal defines if the direction should be set in local space
  15902. */
  15903. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15904. /**
  15905. * Called by the particle System when the position is computed for the created particle.
  15906. * @param worldMatrix is the world matrix of the particle system
  15907. * @param positionToUpdate is the position vector to update with the result
  15908. * @param particle is the particle we are computed the position for
  15909. * @param isLocal defines if the position should be set in local space
  15910. */
  15911. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  15912. /**
  15913. * Clones the current emitter and returns a copy of it
  15914. * @returns the new emitter
  15915. */
  15916. clone(): CylinderParticleEmitter;
  15917. /**
  15918. * Called by the GPUParticleSystem to setup the update shader
  15919. * @param effect defines the update shader
  15920. */
  15921. applyToShader(effect: Effect): void;
  15922. /**
  15923. * Returns a string to use to update the GPU particles update shader
  15924. * @returns a string containng the defines string
  15925. */
  15926. getEffectDefines(): string;
  15927. /**
  15928. * Returns the string "CylinderParticleEmitter"
  15929. * @returns a string containing the class name
  15930. */
  15931. getClassName(): string;
  15932. /**
  15933. * Serializes the particle system to a JSON object.
  15934. * @returns the JSON object
  15935. */
  15936. serialize(): any;
  15937. /**
  15938. * Parse properties from a JSON object
  15939. * @param serializationObject defines the JSON object
  15940. */
  15941. parse(serializationObject: any): void;
  15942. }
  15943. /**
  15944. * Particle emitter emitting particles from the inside of a cylinder.
  15945. * It emits the particles randomly between two vectors.
  15946. */
  15947. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15948. /**
  15949. * The min limit of the emission direction.
  15950. */
  15951. direction1: Vector3;
  15952. /**
  15953. * The max limit of the emission direction.
  15954. */
  15955. direction2: Vector3;
  15956. /**
  15957. * Creates a new instance CylinderDirectedParticleEmitter
  15958. * @param radius the radius of the emission cylinder (1 by default)
  15959. * @param height the height of the emission cylinder (1 by default)
  15960. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15961. * @param direction1 the min limit of the emission direction (up vector by default)
  15962. * @param direction2 the max limit of the emission direction (up vector by default)
  15963. */
  15964. constructor(radius?: number, height?: number, radiusRange?: number,
  15965. /**
  15966. * The min limit of the emission direction.
  15967. */
  15968. direction1?: Vector3,
  15969. /**
  15970. * The max limit of the emission direction.
  15971. */
  15972. direction2?: Vector3);
  15973. /**
  15974. * Called by the particle System when the direction is computed for the created particle.
  15975. * @param worldMatrix is the world matrix of the particle system
  15976. * @param directionToUpdate is the direction vector to update with the result
  15977. * @param particle is the particle we are computed the direction for
  15978. */
  15979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15980. /**
  15981. * Clones the current emitter and returns a copy of it
  15982. * @returns the new emitter
  15983. */
  15984. clone(): CylinderDirectedParticleEmitter;
  15985. /**
  15986. * Called by the GPUParticleSystem to setup the update shader
  15987. * @param effect defines the update shader
  15988. */
  15989. applyToShader(effect: Effect): void;
  15990. /**
  15991. * Returns a string to use to update the GPU particles update shader
  15992. * @returns a string containng the defines string
  15993. */
  15994. getEffectDefines(): string;
  15995. /**
  15996. * Returns the string "CylinderDirectedParticleEmitter"
  15997. * @returns a string containing the class name
  15998. */
  15999. getClassName(): string;
  16000. /**
  16001. * Serializes the particle system to a JSON object.
  16002. * @returns the JSON object
  16003. */
  16004. serialize(): any;
  16005. /**
  16006. * Parse properties from a JSON object
  16007. * @param serializationObject defines the JSON object
  16008. */
  16009. parse(serializationObject: any): void;
  16010. }
  16011. }
  16012. declare module BABYLON {
  16013. /**
  16014. * Particle emitter emitting particles from the inside of a hemisphere.
  16015. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16016. */
  16017. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16018. /**
  16019. * The radius of the emission hemisphere.
  16020. */
  16021. radius: number;
  16022. /**
  16023. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16024. */
  16025. radiusRange: number;
  16026. /**
  16027. * How much to randomize the particle direction [0-1].
  16028. */
  16029. directionRandomizer: number;
  16030. /**
  16031. * Creates a new instance HemisphericParticleEmitter
  16032. * @param radius the radius of the emission hemisphere (1 by default)
  16033. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16034. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16035. */
  16036. constructor(
  16037. /**
  16038. * The radius of the emission hemisphere.
  16039. */
  16040. radius?: number,
  16041. /**
  16042. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16043. */
  16044. radiusRange?: number,
  16045. /**
  16046. * How much to randomize the particle direction [0-1].
  16047. */
  16048. directionRandomizer?: number);
  16049. /**
  16050. * Called by the particle System when the direction is computed for the created particle.
  16051. * @param worldMatrix is the world matrix of the particle system
  16052. * @param directionToUpdate is the direction vector to update with the result
  16053. * @param particle is the particle we are computed the direction for
  16054. * @param isLocal defines if the direction should be set in local space
  16055. */
  16056. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16057. /**
  16058. * Called by the particle System when the position is computed for the created particle.
  16059. * @param worldMatrix is the world matrix of the particle system
  16060. * @param positionToUpdate is the position vector to update with the result
  16061. * @param particle is the particle we are computed the position for
  16062. * @param isLocal defines if the position should be set in local space
  16063. */
  16064. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16065. /**
  16066. * Clones the current emitter and returns a copy of it
  16067. * @returns the new emitter
  16068. */
  16069. clone(): HemisphericParticleEmitter;
  16070. /**
  16071. * Called by the GPUParticleSystem to setup the update shader
  16072. * @param effect defines the update shader
  16073. */
  16074. applyToShader(effect: Effect): void;
  16075. /**
  16076. * Returns a string to use to update the GPU particles update shader
  16077. * @returns a string containng the defines string
  16078. */
  16079. getEffectDefines(): string;
  16080. /**
  16081. * Returns the string "HemisphericParticleEmitter"
  16082. * @returns a string containing the class name
  16083. */
  16084. getClassName(): string;
  16085. /**
  16086. * Serializes the particle system to a JSON object.
  16087. * @returns the JSON object
  16088. */
  16089. serialize(): any;
  16090. /**
  16091. * Parse properties from a JSON object
  16092. * @param serializationObject defines the JSON object
  16093. */
  16094. parse(serializationObject: any): void;
  16095. }
  16096. }
  16097. declare module BABYLON {
  16098. /**
  16099. * Particle emitter emitting particles from a point.
  16100. * It emits the particles randomly between 2 given directions.
  16101. */
  16102. export class PointParticleEmitter implements IParticleEmitterType {
  16103. /**
  16104. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16105. */
  16106. direction1: Vector3;
  16107. /**
  16108. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16109. */
  16110. direction2: Vector3;
  16111. /**
  16112. * Creates a new instance PointParticleEmitter
  16113. */
  16114. constructor();
  16115. /**
  16116. * Called by the particle System when the direction is computed for the created particle.
  16117. * @param worldMatrix is the world matrix of the particle system
  16118. * @param directionToUpdate is the direction vector to update with the result
  16119. * @param particle is the particle we are computed the direction for
  16120. * @param isLocal defines if the direction should be set in local space
  16121. */
  16122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16123. /**
  16124. * Called by the particle System when the position is computed for the created particle.
  16125. * @param worldMatrix is the world matrix of the particle system
  16126. * @param positionToUpdate is the position vector to update with the result
  16127. * @param particle is the particle we are computed the position for
  16128. * @param isLocal defines if the position should be set in local space
  16129. */
  16130. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16131. /**
  16132. * Clones the current emitter and returns a copy of it
  16133. * @returns the new emitter
  16134. */
  16135. clone(): PointParticleEmitter;
  16136. /**
  16137. * Called by the GPUParticleSystem to setup the update shader
  16138. * @param effect defines the update shader
  16139. */
  16140. applyToShader(effect: Effect): void;
  16141. /**
  16142. * Returns a string to use to update the GPU particles update shader
  16143. * @returns a string containng the defines string
  16144. */
  16145. getEffectDefines(): string;
  16146. /**
  16147. * Returns the string "PointParticleEmitter"
  16148. * @returns a string containing the class name
  16149. */
  16150. getClassName(): string;
  16151. /**
  16152. * Serializes the particle system to a JSON object.
  16153. * @returns the JSON object
  16154. */
  16155. serialize(): any;
  16156. /**
  16157. * Parse properties from a JSON object
  16158. * @param serializationObject defines the JSON object
  16159. */
  16160. parse(serializationObject: any): void;
  16161. }
  16162. }
  16163. declare module BABYLON {
  16164. /**
  16165. * Particle emitter emitting particles from the inside of a sphere.
  16166. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16167. */
  16168. export class SphereParticleEmitter implements IParticleEmitterType {
  16169. /**
  16170. * The radius of the emission sphere.
  16171. */
  16172. radius: number;
  16173. /**
  16174. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16175. */
  16176. radiusRange: number;
  16177. /**
  16178. * How much to randomize the particle direction [0-1].
  16179. */
  16180. directionRandomizer: number;
  16181. /**
  16182. * Creates a new instance SphereParticleEmitter
  16183. * @param radius the radius of the emission sphere (1 by default)
  16184. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16185. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16186. */
  16187. constructor(
  16188. /**
  16189. * The radius of the emission sphere.
  16190. */
  16191. radius?: number,
  16192. /**
  16193. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16194. */
  16195. radiusRange?: number,
  16196. /**
  16197. * How much to randomize the particle direction [0-1].
  16198. */
  16199. directionRandomizer?: number);
  16200. /**
  16201. * Called by the particle System when the direction is computed for the created particle.
  16202. * @param worldMatrix is the world matrix of the particle system
  16203. * @param directionToUpdate is the direction vector to update with the result
  16204. * @param particle is the particle we are computed the direction for
  16205. * @param isLocal defines if the direction should be set in local space
  16206. */
  16207. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16208. /**
  16209. * Called by the particle System when the position is computed for the created particle.
  16210. * @param worldMatrix is the world matrix of the particle system
  16211. * @param positionToUpdate is the position vector to update with the result
  16212. * @param particle is the particle we are computed the position for
  16213. * @param isLocal defines if the position should be set in local space
  16214. */
  16215. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16216. /**
  16217. * Clones the current emitter and returns a copy of it
  16218. * @returns the new emitter
  16219. */
  16220. clone(): SphereParticleEmitter;
  16221. /**
  16222. * Called by the GPUParticleSystem to setup the update shader
  16223. * @param effect defines the update shader
  16224. */
  16225. applyToShader(effect: Effect): void;
  16226. /**
  16227. * Returns a string to use to update the GPU particles update shader
  16228. * @returns a string containng the defines string
  16229. */
  16230. getEffectDefines(): string;
  16231. /**
  16232. * Returns the string "SphereParticleEmitter"
  16233. * @returns a string containing the class name
  16234. */
  16235. getClassName(): string;
  16236. /**
  16237. * Serializes the particle system to a JSON object.
  16238. * @returns the JSON object
  16239. */
  16240. serialize(): any;
  16241. /**
  16242. * Parse properties from a JSON object
  16243. * @param serializationObject defines the JSON object
  16244. */
  16245. parse(serializationObject: any): void;
  16246. }
  16247. /**
  16248. * Particle emitter emitting particles from the inside of a sphere.
  16249. * It emits the particles randomly between two vectors.
  16250. */
  16251. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16252. /**
  16253. * The min limit of the emission direction.
  16254. */
  16255. direction1: Vector3;
  16256. /**
  16257. * The max limit of the emission direction.
  16258. */
  16259. direction2: Vector3;
  16260. /**
  16261. * Creates a new instance SphereDirectedParticleEmitter
  16262. * @param radius the radius of the emission sphere (1 by default)
  16263. * @param direction1 the min limit of the emission direction (up vector by default)
  16264. * @param direction2 the max limit of the emission direction (up vector by default)
  16265. */
  16266. constructor(radius?: number,
  16267. /**
  16268. * The min limit of the emission direction.
  16269. */
  16270. direction1?: Vector3,
  16271. /**
  16272. * The max limit of the emission direction.
  16273. */
  16274. direction2?: Vector3);
  16275. /**
  16276. * Called by the particle System when the direction is computed for the created particle.
  16277. * @param worldMatrix is the world matrix of the particle system
  16278. * @param directionToUpdate is the direction vector to update with the result
  16279. * @param particle is the particle we are computed the direction for
  16280. */
  16281. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16282. /**
  16283. * Clones the current emitter and returns a copy of it
  16284. * @returns the new emitter
  16285. */
  16286. clone(): SphereDirectedParticleEmitter;
  16287. /**
  16288. * Called by the GPUParticleSystem to setup the update shader
  16289. * @param effect defines the update shader
  16290. */
  16291. applyToShader(effect: Effect): void;
  16292. /**
  16293. * Returns a string to use to update the GPU particles update shader
  16294. * @returns a string containng the defines string
  16295. */
  16296. getEffectDefines(): string;
  16297. /**
  16298. * Returns the string "SphereDirectedParticleEmitter"
  16299. * @returns a string containing the class name
  16300. */
  16301. getClassName(): string;
  16302. /**
  16303. * Serializes the particle system to a JSON object.
  16304. * @returns the JSON object
  16305. */
  16306. serialize(): any;
  16307. /**
  16308. * Parse properties from a JSON object
  16309. * @param serializationObject defines the JSON object
  16310. */
  16311. parse(serializationObject: any): void;
  16312. }
  16313. }
  16314. declare module BABYLON {
  16315. /**
  16316. * Particle emitter emitting particles from a custom list of positions.
  16317. */
  16318. export class CustomParticleEmitter implements IParticleEmitterType {
  16319. /**
  16320. * Gets or sets the position generator that will create the inital position of each particle.
  16321. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16322. */
  16323. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16324. /**
  16325. * Gets or sets the destination generator that will create the final destination of each particle.
  16326. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16327. */
  16328. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16329. /**
  16330. * Creates a new instance CustomParticleEmitter
  16331. */
  16332. constructor();
  16333. /**
  16334. * Called by the particle System when the direction is computed for the created particle.
  16335. * @param worldMatrix is the world matrix of the particle system
  16336. * @param directionToUpdate is the direction vector to update with the result
  16337. * @param particle is the particle we are computed the direction for
  16338. * @param isLocal defines if the direction should be set in local space
  16339. */
  16340. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16341. /**
  16342. * Called by the particle System when the position is computed for the created particle.
  16343. * @param worldMatrix is the world matrix of the particle system
  16344. * @param positionToUpdate is the position vector to update with the result
  16345. * @param particle is the particle we are computed the position for
  16346. * @param isLocal defines if the position should be set in local space
  16347. */
  16348. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16349. /**
  16350. * Clones the current emitter and returns a copy of it
  16351. * @returns the new emitter
  16352. */
  16353. clone(): CustomParticleEmitter;
  16354. /**
  16355. * Called by the GPUParticleSystem to setup the update shader
  16356. * @param effect defines the update shader
  16357. */
  16358. applyToShader(effect: Effect): void;
  16359. /**
  16360. * Returns a string to use to update the GPU particles update shader
  16361. * @returns a string containng the defines string
  16362. */
  16363. getEffectDefines(): string;
  16364. /**
  16365. * Returns the string "PointParticleEmitter"
  16366. * @returns a string containing the class name
  16367. */
  16368. getClassName(): string;
  16369. /**
  16370. * Serializes the particle system to a JSON object.
  16371. * @returns the JSON object
  16372. */
  16373. serialize(): any;
  16374. /**
  16375. * Parse properties from a JSON object
  16376. * @param serializationObject defines the JSON object
  16377. */
  16378. parse(serializationObject: any): void;
  16379. }
  16380. }
  16381. declare module BABYLON {
  16382. /**
  16383. * Particle emitter emitting particles from the inside of a box.
  16384. * It emits the particles randomly between 2 given directions.
  16385. */
  16386. export class MeshParticleEmitter implements IParticleEmitterType {
  16387. private _indices;
  16388. private _positions;
  16389. private _normals;
  16390. private _storedNormal;
  16391. private _mesh;
  16392. /**
  16393. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16394. */
  16395. direction1: Vector3;
  16396. /**
  16397. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16398. */
  16399. direction2: Vector3;
  16400. /**
  16401. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16402. */
  16403. useMeshNormalsForDirection: boolean;
  16404. /** Defines the mesh to use as source */
  16405. get mesh(): Nullable<AbstractMesh>;
  16406. set mesh(value: Nullable<AbstractMesh>);
  16407. /**
  16408. * Creates a new instance MeshParticleEmitter
  16409. * @param mesh defines the mesh to use as source
  16410. */
  16411. constructor(mesh?: Nullable<AbstractMesh>);
  16412. /**
  16413. * Called by the particle System when the direction is computed for the created particle.
  16414. * @param worldMatrix is the world matrix of the particle system
  16415. * @param directionToUpdate is the direction vector to update with the result
  16416. * @param particle is the particle we are computed the direction for
  16417. * @param isLocal defines if the direction should be set in local space
  16418. */
  16419. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16420. /**
  16421. * Called by the particle System when the position is computed for the created particle.
  16422. * @param worldMatrix is the world matrix of the particle system
  16423. * @param positionToUpdate is the position vector to update with the result
  16424. * @param particle is the particle we are computed the position for
  16425. * @param isLocal defines if the position should be set in local space
  16426. */
  16427. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16428. /**
  16429. * Clones the current emitter and returns a copy of it
  16430. * @returns the new emitter
  16431. */
  16432. clone(): MeshParticleEmitter;
  16433. /**
  16434. * Called by the GPUParticleSystem to setup the update shader
  16435. * @param effect defines the update shader
  16436. */
  16437. applyToShader(effect: Effect): void;
  16438. /**
  16439. * Returns a string to use to update the GPU particles update shader
  16440. * @returns a string containng the defines string
  16441. */
  16442. getEffectDefines(): string;
  16443. /**
  16444. * Returns the string "BoxParticleEmitter"
  16445. * @returns a string containing the class name
  16446. */
  16447. getClassName(): string;
  16448. /**
  16449. * Serializes the particle system to a JSON object.
  16450. * @returns the JSON object
  16451. */
  16452. serialize(): any;
  16453. /**
  16454. * Parse properties from a JSON object
  16455. * @param serializationObject defines the JSON object
  16456. * @param scene defines the hosting scene
  16457. */
  16458. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16459. }
  16460. }
  16461. declare module BABYLON {
  16462. /**
  16463. * Interface representing a particle system in Babylon.js.
  16464. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16465. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16466. */
  16467. export interface IParticleSystem {
  16468. /**
  16469. * List of animations used by the particle system.
  16470. */
  16471. animations: Animation[];
  16472. /**
  16473. * The id of the Particle system.
  16474. */
  16475. id: string;
  16476. /**
  16477. * The name of the Particle system.
  16478. */
  16479. name: string;
  16480. /**
  16481. * The emitter represents the Mesh or position we are attaching the particle system to.
  16482. */
  16483. emitter: Nullable<AbstractMesh | Vector3>;
  16484. /**
  16485. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16486. */
  16487. isBillboardBased: boolean;
  16488. /**
  16489. * The rendering group used by the Particle system to chose when to render.
  16490. */
  16491. renderingGroupId: number;
  16492. /**
  16493. * The layer mask we are rendering the particles through.
  16494. */
  16495. layerMask: number;
  16496. /**
  16497. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16498. */
  16499. updateSpeed: number;
  16500. /**
  16501. * The amount of time the particle system is running (depends of the overall update speed).
  16502. */
  16503. targetStopDuration: number;
  16504. /**
  16505. * The texture used to render each particle. (this can be a spritesheet)
  16506. */
  16507. particleTexture: Nullable<BaseTexture>;
  16508. /**
  16509. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16510. */
  16511. blendMode: number;
  16512. /**
  16513. * Minimum life time of emitting particles.
  16514. */
  16515. minLifeTime: number;
  16516. /**
  16517. * Maximum life time of emitting particles.
  16518. */
  16519. maxLifeTime: number;
  16520. /**
  16521. * Minimum Size of emitting particles.
  16522. */
  16523. minSize: number;
  16524. /**
  16525. * Maximum Size of emitting particles.
  16526. */
  16527. maxSize: number;
  16528. /**
  16529. * Minimum scale of emitting particles on X axis.
  16530. */
  16531. minScaleX: number;
  16532. /**
  16533. * Maximum scale of emitting particles on X axis.
  16534. */
  16535. maxScaleX: number;
  16536. /**
  16537. * Minimum scale of emitting particles on Y axis.
  16538. */
  16539. minScaleY: number;
  16540. /**
  16541. * Maximum scale of emitting particles on Y axis.
  16542. */
  16543. maxScaleY: number;
  16544. /**
  16545. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16546. */
  16547. color1: Color4;
  16548. /**
  16549. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16550. */
  16551. color2: Color4;
  16552. /**
  16553. * Color the particle will have at the end of its lifetime.
  16554. */
  16555. colorDead: Color4;
  16556. /**
  16557. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16558. */
  16559. emitRate: number;
  16560. /**
  16561. * You can use gravity if you want to give an orientation to your particles.
  16562. */
  16563. gravity: Vector3;
  16564. /**
  16565. * Minimum power of emitting particles.
  16566. */
  16567. minEmitPower: number;
  16568. /**
  16569. * Maximum power of emitting particles.
  16570. */
  16571. maxEmitPower: number;
  16572. /**
  16573. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16574. */
  16575. minAngularSpeed: number;
  16576. /**
  16577. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16578. */
  16579. maxAngularSpeed: number;
  16580. /**
  16581. * Gets or sets the minimal initial rotation in radians.
  16582. */
  16583. minInitialRotation: number;
  16584. /**
  16585. * Gets or sets the maximal initial rotation in radians.
  16586. */
  16587. maxInitialRotation: number;
  16588. /**
  16589. * The particle emitter type defines the emitter used by the particle system.
  16590. * It can be for example box, sphere, or cone...
  16591. */
  16592. particleEmitterType: Nullable<IParticleEmitterType>;
  16593. /**
  16594. * Defines the delay in milliseconds before starting the system (0 by default)
  16595. */
  16596. startDelay: number;
  16597. /**
  16598. * 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
  16599. */
  16600. preWarmCycles: number;
  16601. /**
  16602. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16603. */
  16604. preWarmStepOffset: number;
  16605. /**
  16606. * 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)
  16607. */
  16608. spriteCellChangeSpeed: number;
  16609. /**
  16610. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16611. */
  16612. startSpriteCellID: number;
  16613. /**
  16614. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16615. */
  16616. endSpriteCellID: number;
  16617. /**
  16618. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16619. */
  16620. spriteCellWidth: number;
  16621. /**
  16622. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16623. */
  16624. spriteCellHeight: number;
  16625. /**
  16626. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16627. */
  16628. spriteRandomStartCell: boolean;
  16629. /**
  16630. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16631. */
  16632. isAnimationSheetEnabled: boolean;
  16633. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16634. translationPivot: Vector2;
  16635. /**
  16636. * Gets or sets a texture used to add random noise to particle positions
  16637. */
  16638. noiseTexture: Nullable<BaseTexture>;
  16639. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16640. noiseStrength: Vector3;
  16641. /**
  16642. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16643. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16644. */
  16645. billboardMode: number;
  16646. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16647. limitVelocityDamping: number;
  16648. /**
  16649. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16650. */
  16651. beginAnimationOnStart: boolean;
  16652. /**
  16653. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16654. */
  16655. beginAnimationFrom: number;
  16656. /**
  16657. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16658. */
  16659. beginAnimationTo: number;
  16660. /**
  16661. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16662. */
  16663. beginAnimationLoop: boolean;
  16664. /**
  16665. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16666. */
  16667. disposeOnStop: boolean;
  16668. /**
  16669. * Specifies if the particles are updated in emitter local space or world space
  16670. */
  16671. isLocal: boolean;
  16672. /** Snippet ID if the particle system was created from the snippet server */
  16673. snippetId: string;
  16674. /** Gets or sets a matrix to use to compute projection */
  16675. defaultProjectionMatrix: Matrix;
  16676. /**
  16677. * Gets the maximum number of particles active at the same time.
  16678. * @returns The max number of active particles.
  16679. */
  16680. getCapacity(): number;
  16681. /**
  16682. * Gets the number of particles active at the same time.
  16683. * @returns The number of active particles.
  16684. */
  16685. getActiveCount(): number;
  16686. /**
  16687. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16688. * @returns True if it has been started, otherwise false.
  16689. */
  16690. isStarted(): boolean;
  16691. /**
  16692. * Animates the particle system for this frame.
  16693. */
  16694. animate(): void;
  16695. /**
  16696. * Renders the particle system in its current state.
  16697. * @returns the current number of particles
  16698. */
  16699. render(): number;
  16700. /**
  16701. * Dispose the particle system and frees its associated resources.
  16702. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16703. */
  16704. dispose(disposeTexture?: boolean): void;
  16705. /**
  16706. * An event triggered when the system is disposed
  16707. */
  16708. onDisposeObservable: Observable<IParticleSystem>;
  16709. /**
  16710. * An event triggered when the system is stopped
  16711. */
  16712. onStoppedObservable: Observable<IParticleSystem>;
  16713. /**
  16714. * Clones the particle system.
  16715. * @param name The name of the cloned object
  16716. * @param newEmitter The new emitter to use
  16717. * @returns the cloned particle system
  16718. */
  16719. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16720. /**
  16721. * Serializes the particle system to a JSON object
  16722. * @param serializeTexture defines if the texture must be serialized as well
  16723. * @returns the JSON object
  16724. */
  16725. serialize(serializeTexture: boolean): any;
  16726. /**
  16727. * Rebuild the particle system
  16728. */
  16729. rebuild(): void;
  16730. /** Force the system to rebuild all gradients that need to be resync */
  16731. forceRefreshGradients(): void;
  16732. /**
  16733. * Starts the particle system and begins to emit
  16734. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16735. */
  16736. start(delay?: number): void;
  16737. /**
  16738. * Stops the particle system.
  16739. */
  16740. stop(): void;
  16741. /**
  16742. * Remove all active particles
  16743. */
  16744. reset(): void;
  16745. /**
  16746. * Gets a boolean indicating that the system is stopping
  16747. * @returns true if the system is currently stopping
  16748. */
  16749. isStopping(): boolean;
  16750. /**
  16751. * Is this system ready to be used/rendered
  16752. * @return true if the system is ready
  16753. */
  16754. isReady(): boolean;
  16755. /**
  16756. * Returns the string "ParticleSystem"
  16757. * @returns a string containing the class name
  16758. */
  16759. getClassName(): string;
  16760. /**
  16761. * Gets the custom effect used to render the particles
  16762. * @param blendMode Blend mode for which the effect should be retrieved
  16763. * @returns The effect
  16764. */
  16765. getCustomEffect(blendMode: number): Nullable<Effect>;
  16766. /**
  16767. * Sets the custom effect used to render the particles
  16768. * @param effect The effect to set
  16769. * @param blendMode Blend mode for which the effect should be set
  16770. */
  16771. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  16772. /**
  16773. * Fill the defines array according to the current settings of the particle system
  16774. * @param defines Array to be updated
  16775. * @param blendMode blend mode to take into account when updating the array
  16776. */
  16777. fillDefines(defines: Array<string>, blendMode: number): void;
  16778. /**
  16779. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  16780. * @param uniforms Uniforms array to fill
  16781. * @param attributes Attributes array to fill
  16782. * @param samplers Samplers array to fill
  16783. */
  16784. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  16785. /**
  16786. * Observable that will be called just before the particles are drawn
  16787. */
  16788. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  16789. /**
  16790. * Gets the name of the particle vertex shader
  16791. */
  16792. vertexShaderName: string;
  16793. /**
  16794. * Adds a new color gradient
  16795. * @param gradient defines the gradient to use (between 0 and 1)
  16796. * @param color1 defines the color to affect to the specified gradient
  16797. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16798. * @returns the current particle system
  16799. */
  16800. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16801. /**
  16802. * Remove a specific color gradient
  16803. * @param gradient defines the gradient to remove
  16804. * @returns the current particle system
  16805. */
  16806. removeColorGradient(gradient: number): IParticleSystem;
  16807. /**
  16808. * Adds a new size gradient
  16809. * @param gradient defines the gradient to use (between 0 and 1)
  16810. * @param factor defines the size factor to affect to the specified gradient
  16811. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16812. * @returns the current particle system
  16813. */
  16814. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16815. /**
  16816. * Remove a specific size gradient
  16817. * @param gradient defines the gradient to remove
  16818. * @returns the current particle system
  16819. */
  16820. removeSizeGradient(gradient: number): IParticleSystem;
  16821. /**
  16822. * Gets the current list of color gradients.
  16823. * You must use addColorGradient and removeColorGradient to udpate this list
  16824. * @returns the list of color gradients
  16825. */
  16826. getColorGradients(): Nullable<Array<ColorGradient>>;
  16827. /**
  16828. * Gets the current list of size gradients.
  16829. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16830. * @returns the list of size gradients
  16831. */
  16832. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16833. /**
  16834. * Gets the current list of angular speed gradients.
  16835. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16836. * @returns the list of angular speed gradients
  16837. */
  16838. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16839. /**
  16840. * Adds a new angular speed gradient
  16841. * @param gradient defines the gradient to use (between 0 and 1)
  16842. * @param factor defines the angular speed to affect to the specified gradient
  16843. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16844. * @returns the current particle system
  16845. */
  16846. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16847. /**
  16848. * Remove a specific angular speed gradient
  16849. * @param gradient defines the gradient to remove
  16850. * @returns the current particle system
  16851. */
  16852. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16853. /**
  16854. * Gets the current list of velocity gradients.
  16855. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16856. * @returns the list of velocity gradients
  16857. */
  16858. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16859. /**
  16860. * Adds a new velocity gradient
  16861. * @param gradient defines the gradient to use (between 0 and 1)
  16862. * @param factor defines the velocity to affect to the specified gradient
  16863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16864. * @returns the current particle system
  16865. */
  16866. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16867. /**
  16868. * Remove a specific velocity gradient
  16869. * @param gradient defines the gradient to remove
  16870. * @returns the current particle system
  16871. */
  16872. removeVelocityGradient(gradient: number): IParticleSystem;
  16873. /**
  16874. * Gets the current list of limit velocity gradients.
  16875. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16876. * @returns the list of limit velocity gradients
  16877. */
  16878. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16879. /**
  16880. * Adds a new limit velocity gradient
  16881. * @param gradient defines the gradient to use (between 0 and 1)
  16882. * @param factor defines the limit velocity to affect to the specified gradient
  16883. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16884. * @returns the current particle system
  16885. */
  16886. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16887. /**
  16888. * Remove a specific limit velocity gradient
  16889. * @param gradient defines the gradient to remove
  16890. * @returns the current particle system
  16891. */
  16892. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16893. /**
  16894. * Adds a new drag gradient
  16895. * @param gradient defines the gradient to use (between 0 and 1)
  16896. * @param factor defines the drag to affect to the specified gradient
  16897. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16898. * @returns the current particle system
  16899. */
  16900. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16901. /**
  16902. * Remove a specific drag gradient
  16903. * @param gradient defines the gradient to remove
  16904. * @returns the current particle system
  16905. */
  16906. removeDragGradient(gradient: number): IParticleSystem;
  16907. /**
  16908. * Gets the current list of drag gradients.
  16909. * You must use addDragGradient and removeDragGradient to udpate this list
  16910. * @returns the list of drag gradients
  16911. */
  16912. getDragGradients(): Nullable<Array<FactorGradient>>;
  16913. /**
  16914. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16915. * @param gradient defines the gradient to use (between 0 and 1)
  16916. * @param factor defines the emit rate to affect to the specified gradient
  16917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16918. * @returns the current particle system
  16919. */
  16920. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16921. /**
  16922. * Remove a specific emit rate gradient
  16923. * @param gradient defines the gradient to remove
  16924. * @returns the current particle system
  16925. */
  16926. removeEmitRateGradient(gradient: number): IParticleSystem;
  16927. /**
  16928. * Gets the current list of emit rate gradients.
  16929. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16930. * @returns the list of emit rate gradients
  16931. */
  16932. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16933. /**
  16934. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16935. * @param gradient defines the gradient to use (between 0 and 1)
  16936. * @param factor defines the start size to affect to the specified gradient
  16937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16938. * @returns the current particle system
  16939. */
  16940. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16941. /**
  16942. * Remove a specific start size gradient
  16943. * @param gradient defines the gradient to remove
  16944. * @returns the current particle system
  16945. */
  16946. removeStartSizeGradient(gradient: number): IParticleSystem;
  16947. /**
  16948. * Gets the current list of start size gradients.
  16949. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16950. * @returns the list of start size gradients
  16951. */
  16952. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16953. /**
  16954. * Adds a new life time gradient
  16955. * @param gradient defines the gradient to use (between 0 and 1)
  16956. * @param factor defines the life time factor to affect to the specified gradient
  16957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16958. * @returns the current particle system
  16959. */
  16960. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16961. /**
  16962. * Remove a specific life time gradient
  16963. * @param gradient defines the gradient to remove
  16964. * @returns the current particle system
  16965. */
  16966. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16967. /**
  16968. * Gets the current list of life time gradients.
  16969. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16970. * @returns the list of life time gradients
  16971. */
  16972. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16973. /**
  16974. * Gets the current list of color gradients.
  16975. * You must use addColorGradient and removeColorGradient to udpate this list
  16976. * @returns the list of color gradients
  16977. */
  16978. getColorGradients(): Nullable<Array<ColorGradient>>;
  16979. /**
  16980. * Adds a new ramp gradient used to remap particle colors
  16981. * @param gradient defines the gradient to use (between 0 and 1)
  16982. * @param color defines the color to affect to the specified gradient
  16983. * @returns the current particle system
  16984. */
  16985. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16986. /**
  16987. * Gets the current list of ramp gradients.
  16988. * You must use addRampGradient and removeRampGradient to udpate this list
  16989. * @returns the list of ramp gradients
  16990. */
  16991. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16992. /** Gets or sets a boolean indicating that ramp gradients must be used
  16993. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16994. */
  16995. useRampGradients: boolean;
  16996. /**
  16997. * Adds a new color remap gradient
  16998. * @param gradient defines the gradient to use (between 0 and 1)
  16999. * @param min defines the color remap minimal range
  17000. * @param max defines the color remap maximal range
  17001. * @returns the current particle system
  17002. */
  17003. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17004. /**
  17005. * Gets the current list of color remap gradients.
  17006. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17007. * @returns the list of color remap gradients
  17008. */
  17009. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17010. /**
  17011. * Adds a new alpha remap gradient
  17012. * @param gradient defines the gradient to use (between 0 and 1)
  17013. * @param min defines the alpha remap minimal range
  17014. * @param max defines the alpha remap maximal range
  17015. * @returns the current particle system
  17016. */
  17017. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17018. /**
  17019. * Gets the current list of alpha remap gradients.
  17020. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17021. * @returns the list of alpha remap gradients
  17022. */
  17023. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17024. /**
  17025. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17026. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17027. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17028. * @returns the emitter
  17029. */
  17030. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17031. /**
  17032. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17033. * @param radius The radius of the hemisphere to emit from
  17034. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17035. * @returns the emitter
  17036. */
  17037. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17038. /**
  17039. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17040. * @param radius The radius of the sphere to emit from
  17041. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17042. * @returns the emitter
  17043. */
  17044. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17045. /**
  17046. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17047. * @param radius The radius of the sphere to emit from
  17048. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17049. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17050. * @returns the emitter
  17051. */
  17052. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17053. /**
  17054. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17055. * @param radius The radius of the emission cylinder
  17056. * @param height The height of the emission cylinder
  17057. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17058. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17059. * @returns the emitter
  17060. */
  17061. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17062. /**
  17063. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17064. * @param radius The radius of the cylinder to emit from
  17065. * @param height The height of the emission cylinder
  17066. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17067. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17068. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17069. * @returns the emitter
  17070. */
  17071. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17072. /**
  17073. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17074. * @param radius The radius of the cone to emit from
  17075. * @param angle The base angle of the cone
  17076. * @returns the emitter
  17077. */
  17078. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17079. /**
  17080. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17081. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17082. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17083. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17084. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17085. * @returns the emitter
  17086. */
  17087. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17088. /**
  17089. * Get hosting scene
  17090. * @returns the scene
  17091. */
  17092. getScene(): Nullable<Scene>;
  17093. }
  17094. }
  17095. declare module BABYLON {
  17096. /**
  17097. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17098. */
  17099. export class ColorSplitterBlock extends NodeMaterialBlock {
  17100. /**
  17101. * Create a new ColorSplitterBlock
  17102. * @param name defines the block name
  17103. */
  17104. constructor(name: string);
  17105. /**
  17106. * Gets the current class name
  17107. * @returns the class name
  17108. */
  17109. getClassName(): string;
  17110. /**
  17111. * Gets the rgba component (input)
  17112. */
  17113. get rgba(): NodeMaterialConnectionPoint;
  17114. /**
  17115. * Gets the rgb component (input)
  17116. */
  17117. get rgbIn(): NodeMaterialConnectionPoint;
  17118. /**
  17119. * Gets the rgb component (output)
  17120. */
  17121. get rgbOut(): NodeMaterialConnectionPoint;
  17122. /**
  17123. * Gets the r component (output)
  17124. */
  17125. get r(): NodeMaterialConnectionPoint;
  17126. /**
  17127. * Gets the g component (output)
  17128. */
  17129. get g(): NodeMaterialConnectionPoint;
  17130. /**
  17131. * Gets the b component (output)
  17132. */
  17133. get b(): NodeMaterialConnectionPoint;
  17134. /**
  17135. * Gets the a component (output)
  17136. */
  17137. get a(): NodeMaterialConnectionPoint;
  17138. protected _inputRename(name: string): string;
  17139. protected _outputRename(name: string): string;
  17140. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17141. }
  17142. }
  17143. declare module BABYLON {
  17144. /**
  17145. * Operations supported by the Trigonometry block
  17146. */
  17147. export enum TrigonometryBlockOperations {
  17148. /** Cos */
  17149. Cos = 0,
  17150. /** Sin */
  17151. Sin = 1,
  17152. /** Abs */
  17153. Abs = 2,
  17154. /** Exp */
  17155. Exp = 3,
  17156. /** Exp2 */
  17157. Exp2 = 4,
  17158. /** Round */
  17159. Round = 5,
  17160. /** Floor */
  17161. Floor = 6,
  17162. /** Ceiling */
  17163. Ceiling = 7,
  17164. /** Square root */
  17165. Sqrt = 8,
  17166. /** Log */
  17167. Log = 9,
  17168. /** Tangent */
  17169. Tan = 10,
  17170. /** Arc tangent */
  17171. ArcTan = 11,
  17172. /** Arc cosinus */
  17173. ArcCos = 12,
  17174. /** Arc sinus */
  17175. ArcSin = 13,
  17176. /** Fraction */
  17177. Fract = 14,
  17178. /** Sign */
  17179. Sign = 15,
  17180. /** To radians (from degrees) */
  17181. Radians = 16,
  17182. /** To degrees (from radians) */
  17183. Degrees = 17
  17184. }
  17185. /**
  17186. * Block used to apply trigonometry operation to floats
  17187. */
  17188. export class TrigonometryBlock extends NodeMaterialBlock {
  17189. /**
  17190. * Gets or sets the operation applied by the block
  17191. */
  17192. operation: TrigonometryBlockOperations;
  17193. /**
  17194. * Creates a new TrigonometryBlock
  17195. * @param name defines the block name
  17196. */
  17197. constructor(name: string);
  17198. /**
  17199. * Gets the current class name
  17200. * @returns the class name
  17201. */
  17202. getClassName(): string;
  17203. /**
  17204. * Gets the input component
  17205. */
  17206. get input(): NodeMaterialConnectionPoint;
  17207. /**
  17208. * Gets the output component
  17209. */
  17210. get output(): NodeMaterialConnectionPoint;
  17211. protected _buildBlock(state: NodeMaterialBuildState): this;
  17212. serialize(): any;
  17213. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17214. protected _dumpPropertiesCode(): string;
  17215. }
  17216. }
  17217. declare module BABYLON {
  17218. /**
  17219. * Interface used to configure the node material editor
  17220. */
  17221. export interface INodeMaterialEditorOptions {
  17222. /** Define the URl to load node editor script */
  17223. editorURL?: string;
  17224. }
  17225. /** @hidden */
  17226. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17227. NORMAL: boolean;
  17228. TANGENT: boolean;
  17229. UV1: boolean;
  17230. /** BONES */
  17231. NUM_BONE_INFLUENCERS: number;
  17232. BonesPerMesh: number;
  17233. BONETEXTURE: boolean;
  17234. /** MORPH TARGETS */
  17235. MORPHTARGETS: boolean;
  17236. MORPHTARGETS_NORMAL: boolean;
  17237. MORPHTARGETS_TANGENT: boolean;
  17238. MORPHTARGETS_UV: boolean;
  17239. NUM_MORPH_INFLUENCERS: number;
  17240. /** IMAGE PROCESSING */
  17241. IMAGEPROCESSING: boolean;
  17242. VIGNETTE: boolean;
  17243. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17244. VIGNETTEBLENDMODEOPAQUE: boolean;
  17245. TONEMAPPING: boolean;
  17246. TONEMAPPING_ACES: boolean;
  17247. CONTRAST: boolean;
  17248. EXPOSURE: boolean;
  17249. COLORCURVES: boolean;
  17250. COLORGRADING: boolean;
  17251. COLORGRADING3D: boolean;
  17252. SAMPLER3DGREENDEPTH: boolean;
  17253. SAMPLER3DBGRMAP: boolean;
  17254. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17255. /** MISC. */
  17256. BUMPDIRECTUV: number;
  17257. constructor();
  17258. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17259. }
  17260. /**
  17261. * Class used to configure NodeMaterial
  17262. */
  17263. export interface INodeMaterialOptions {
  17264. /**
  17265. * Defines if blocks should emit comments
  17266. */
  17267. emitComments: boolean;
  17268. }
  17269. /**
  17270. * Class used to create a node based material built by assembling shader blocks
  17271. */
  17272. export class NodeMaterial extends PushMaterial {
  17273. private static _BuildIdGenerator;
  17274. private _options;
  17275. private _vertexCompilationState;
  17276. private _fragmentCompilationState;
  17277. private _sharedData;
  17278. private _buildId;
  17279. private _buildWasSuccessful;
  17280. private _cachedWorldViewMatrix;
  17281. private _cachedWorldViewProjectionMatrix;
  17282. private _optimizers;
  17283. private _animationFrame;
  17284. /** Define the Url to load node editor script */
  17285. static EditorURL: string;
  17286. /** Define the Url to load snippets */
  17287. static SnippetUrl: string;
  17288. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17289. static IgnoreTexturesAtLoadTime: boolean;
  17290. private BJSNODEMATERIALEDITOR;
  17291. /** Get the inspector from bundle or global */
  17292. private _getGlobalNodeMaterialEditor;
  17293. /**
  17294. * Snippet ID if the material was created from the snippet server
  17295. */
  17296. snippetId: string;
  17297. /**
  17298. * Gets or sets data used by visual editor
  17299. * @see https://nme.babylonjs.com
  17300. */
  17301. editorData: any;
  17302. /**
  17303. * 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)
  17304. */
  17305. ignoreAlpha: boolean;
  17306. /**
  17307. * Defines the maximum number of lights that can be used in the material
  17308. */
  17309. maxSimultaneousLights: number;
  17310. /**
  17311. * Observable raised when the material is built
  17312. */
  17313. onBuildObservable: Observable<NodeMaterial>;
  17314. /**
  17315. * Gets or sets the root nodes of the material vertex shader
  17316. */
  17317. _vertexOutputNodes: NodeMaterialBlock[];
  17318. /**
  17319. * Gets or sets the root nodes of the material fragment (pixel) shader
  17320. */
  17321. _fragmentOutputNodes: NodeMaterialBlock[];
  17322. /** Gets or sets options to control the node material overall behavior */
  17323. get options(): INodeMaterialOptions;
  17324. set options(options: INodeMaterialOptions);
  17325. /**
  17326. * Default configuration related to image processing available in the standard Material.
  17327. */
  17328. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17329. /**
  17330. * Gets the image processing configuration used either in this material.
  17331. */
  17332. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17333. /**
  17334. * Sets the Default image processing configuration used either in the this material.
  17335. *
  17336. * If sets to null, the scene one is in use.
  17337. */
  17338. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17339. /**
  17340. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17341. */
  17342. attachedBlocks: NodeMaterialBlock[];
  17343. /**
  17344. * Specifies the mode of the node material
  17345. * @hidden
  17346. */
  17347. _mode: NodeMaterialModes;
  17348. /**
  17349. * Gets the mode property
  17350. */
  17351. get mode(): NodeMaterialModes;
  17352. /**
  17353. * A free comment about the material
  17354. */
  17355. comment: string;
  17356. /**
  17357. * Create a new node based material
  17358. * @param name defines the material name
  17359. * @param scene defines the hosting scene
  17360. * @param options defines creation option
  17361. */
  17362. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17363. /**
  17364. * Gets the current class name of the material e.g. "NodeMaterial"
  17365. * @returns the class name
  17366. */
  17367. getClassName(): string;
  17368. /**
  17369. * Keep track of the image processing observer to allow dispose and replace.
  17370. */
  17371. private _imageProcessingObserver;
  17372. /**
  17373. * Attaches a new image processing configuration to the Standard Material.
  17374. * @param configuration
  17375. */
  17376. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17377. /**
  17378. * Get a block by its name
  17379. * @param name defines the name of the block to retrieve
  17380. * @returns the required block or null if not found
  17381. */
  17382. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17383. /**
  17384. * Get a block by its name
  17385. * @param predicate defines the predicate used to find the good candidate
  17386. * @returns the required block or null if not found
  17387. */
  17388. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17389. /**
  17390. * Get an input block by its name
  17391. * @param predicate defines the predicate used to find the good candidate
  17392. * @returns the required input block or null if not found
  17393. */
  17394. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17395. /**
  17396. * Gets the list of input blocks attached to this material
  17397. * @returns an array of InputBlocks
  17398. */
  17399. getInputBlocks(): InputBlock[];
  17400. /**
  17401. * Adds a new optimizer to the list of optimizers
  17402. * @param optimizer defines the optimizers to add
  17403. * @returns the current material
  17404. */
  17405. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17406. /**
  17407. * Remove an optimizer from the list of optimizers
  17408. * @param optimizer defines the optimizers to remove
  17409. * @returns the current material
  17410. */
  17411. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17412. /**
  17413. * Add a new block to the list of output nodes
  17414. * @param node defines the node to add
  17415. * @returns the current material
  17416. */
  17417. addOutputNode(node: NodeMaterialBlock): this;
  17418. /**
  17419. * Remove a block from the list of root nodes
  17420. * @param node defines the node to remove
  17421. * @returns the current material
  17422. */
  17423. removeOutputNode(node: NodeMaterialBlock): this;
  17424. private _addVertexOutputNode;
  17425. private _removeVertexOutputNode;
  17426. private _addFragmentOutputNode;
  17427. private _removeFragmentOutputNode;
  17428. /**
  17429. * Specifies if the material will require alpha blending
  17430. * @returns a boolean specifying if alpha blending is needed
  17431. */
  17432. needAlphaBlending(): boolean;
  17433. /**
  17434. * Specifies if this material should be rendered in alpha test mode
  17435. * @returns a boolean specifying if an alpha test is needed.
  17436. */
  17437. needAlphaTesting(): boolean;
  17438. private _initializeBlock;
  17439. private _resetDualBlocks;
  17440. /**
  17441. * Remove a block from the current node material
  17442. * @param block defines the block to remove
  17443. */
  17444. removeBlock(block: NodeMaterialBlock): void;
  17445. /**
  17446. * Build the material and generates the inner effect
  17447. * @param verbose defines if the build should log activity
  17448. */
  17449. build(verbose?: boolean): void;
  17450. /**
  17451. * Runs an otpimization phase to try to improve the shader code
  17452. */
  17453. optimize(): void;
  17454. private _prepareDefinesForAttributes;
  17455. /**
  17456. * Create a post process from the material
  17457. * @param camera The camera to apply the render pass to.
  17458. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  17459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  17460. * @param engine The engine which the post process will be applied. (default: current engine)
  17461. * @param reusable If the post process can be reused on the same frame. (default: false)
  17462. * @param textureType Type of textures used when performing the post process. (default: 0)
  17463. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  17464. * @returns the post process created
  17465. */
  17466. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  17467. /**
  17468. * Create the post process effect from the material
  17469. * @param postProcess The post process to create the effect for
  17470. */
  17471. createEffectForPostProcess(postProcess: PostProcess): void;
  17472. private _createEffectForPostProcess;
  17473. /**
  17474. * Create a new procedural texture based on this node material
  17475. * @param size defines the size of the texture
  17476. * @param scene defines the hosting scene
  17477. * @returns the new procedural texture attached to this node material
  17478. */
  17479. createProceduralTexture(size: number | {
  17480. width: number;
  17481. height: number;
  17482. layers?: number;
  17483. }, scene: Scene): Nullable<ProceduralTexture>;
  17484. private _createEffectForParticles;
  17485. private _checkInternals;
  17486. /**
  17487. * Create the effect to be used as the custom effect for a particle system
  17488. * @param particleSystem Particle system to create the effect for
  17489. * @param onCompiled defines a function to call when the effect creation is successful
  17490. * @param onError defines a function to call when the effect creation has failed
  17491. */
  17492. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  17493. private _processDefines;
  17494. /**
  17495. * Get if the submesh is ready to be used and all its information available.
  17496. * Child classes can use it to update shaders
  17497. * @param mesh defines the mesh to check
  17498. * @param subMesh defines which submesh to check
  17499. * @param useInstances specifies that instances should be used
  17500. * @returns a boolean indicating that the submesh is ready or not
  17501. */
  17502. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17503. /**
  17504. * Get a string representing the shaders built by the current node graph
  17505. */
  17506. get compiledShaders(): string;
  17507. /**
  17508. * Binds the world matrix to the material
  17509. * @param world defines the world transformation matrix
  17510. */
  17511. bindOnlyWorldMatrix(world: Matrix): void;
  17512. /**
  17513. * Binds the submesh to this material by preparing the effect and shader to draw
  17514. * @param world defines the world transformation matrix
  17515. * @param mesh defines the mesh containing the submesh
  17516. * @param subMesh defines the submesh to bind the material to
  17517. */
  17518. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17519. /**
  17520. * Gets the active textures from the material
  17521. * @returns an array of textures
  17522. */
  17523. getActiveTextures(): BaseTexture[];
  17524. /**
  17525. * Gets the list of texture blocks
  17526. * @returns an array of texture blocks
  17527. */
  17528. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  17529. /**
  17530. * Specifies if the material uses a texture
  17531. * @param texture defines the texture to check against the material
  17532. * @returns a boolean specifying if the material uses the texture
  17533. */
  17534. hasTexture(texture: BaseTexture): boolean;
  17535. /**
  17536. * Disposes the material
  17537. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17538. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17539. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17540. */
  17541. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17542. /** Creates the node editor window. */
  17543. private _createNodeEditor;
  17544. /**
  17545. * Launch the node material editor
  17546. * @param config Define the configuration of the editor
  17547. * @return a promise fulfilled when the node editor is visible
  17548. */
  17549. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  17550. /**
  17551. * Clear the current material
  17552. */
  17553. clear(): void;
  17554. /**
  17555. * Clear the current material and set it to a default state
  17556. */
  17557. setToDefault(): void;
  17558. /**
  17559. * Clear the current material and set it to a default state for post process
  17560. */
  17561. setToDefaultPostProcess(): void;
  17562. /**
  17563. * Clear the current material and set it to a default state for procedural texture
  17564. */
  17565. setToDefaultProceduralTexture(): void;
  17566. /**
  17567. * Clear the current material and set it to a default state for particle
  17568. */
  17569. setToDefaultParticle(): void;
  17570. /**
  17571. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  17572. * @param url defines the url to load from
  17573. * @returns a promise that will fullfil when the material is fully loaded
  17574. */
  17575. loadAsync(url: string): Promise<void>;
  17576. private _gatherBlocks;
  17577. /**
  17578. * Generate a string containing the code declaration required to create an equivalent of this material
  17579. * @returns a string
  17580. */
  17581. generateCode(): string;
  17582. /**
  17583. * Serializes this material in a JSON representation
  17584. * @returns the serialized material object
  17585. */
  17586. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  17587. private _restoreConnections;
  17588. /**
  17589. * Clear the current graph and load a new one from a serialization object
  17590. * @param source defines the JSON representation of the material
  17591. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17592. * @param merge defines whether or not the source must be merged or replace the current content
  17593. */
  17594. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  17595. /**
  17596. * Makes a duplicate of the current material.
  17597. * @param name - name to use for the new material.
  17598. */
  17599. clone(name: string): NodeMaterial;
  17600. /**
  17601. * Creates a node material from parsed material data
  17602. * @param source defines the JSON representation of the material
  17603. * @param scene defines the hosting scene
  17604. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17605. * @returns a new node material
  17606. */
  17607. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  17608. /**
  17609. * Creates a node material from a snippet saved in a remote file
  17610. * @param name defines the name of the material to create
  17611. * @param url defines the url to load from
  17612. * @param scene defines the hosting scene
  17613. * @returns a promise that will resolve to the new node material
  17614. */
  17615. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  17616. /**
  17617. * Creates a node material from a snippet saved by the node material editor
  17618. * @param snippetId defines the snippet to load
  17619. * @param scene defines the hosting scene
  17620. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17621. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  17622. * @returns a promise that will resolve to the new node material
  17623. */
  17624. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  17625. /**
  17626. * Creates a new node material set to default basic configuration
  17627. * @param name defines the name of the material
  17628. * @param scene defines the hosting scene
  17629. * @returns a new NodeMaterial
  17630. */
  17631. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  17632. }
  17633. }
  17634. declare module BABYLON {
  17635. interface ThinEngine {
  17636. /**
  17637. * Unbind a list of render target textures from the webGL context
  17638. * This is used only when drawBuffer extension or webGL2 are active
  17639. * @param textures defines the render target textures to unbind
  17640. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  17641. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  17642. */
  17643. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  17644. /**
  17645. * Create a multi render target texture
  17646. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  17647. * @param size defines the size of the texture
  17648. * @param options defines the creation options
  17649. * @returns the cube texture as an InternalTexture
  17650. */
  17651. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  17652. /**
  17653. * Update the sample count for a given multiple render target texture
  17654. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  17655. * @param textures defines the textures to update
  17656. * @param samples defines the sample count to set
  17657. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  17658. */
  17659. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  17660. /**
  17661. * Select a subsets of attachments to draw to.
  17662. * @param attachments gl attachments
  17663. */
  17664. bindAttachments(attachments: number[]): void;
  17665. /**
  17666. * Creates a layout object to draw/clear on specific textures in a MRT
  17667. * @param textureStatus textureStatus[i] indicates if the i-th is active
  17668. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  17669. */
  17670. buildTextureLayout(textureStatus: boolean[]): number[];
  17671. /**
  17672. * Restores the webgl state to only draw on the main color attachment
  17673. */
  17674. restoreSingleAttachment(): void;
  17675. }
  17676. }
  17677. declare module BABYLON {
  17678. /**
  17679. * Creation options of the multi render target texture.
  17680. */
  17681. export interface IMultiRenderTargetOptions {
  17682. /**
  17683. * Define if the texture needs to create mip maps after render.
  17684. */
  17685. generateMipMaps?: boolean;
  17686. /**
  17687. * Define the types of all the draw buffers we want to create
  17688. */
  17689. types?: number[];
  17690. /**
  17691. * Define the sampling modes of all the draw buffers we want to create
  17692. */
  17693. samplingModes?: number[];
  17694. /**
  17695. * Define if a depth buffer is required
  17696. */
  17697. generateDepthBuffer?: boolean;
  17698. /**
  17699. * Define if a stencil buffer is required
  17700. */
  17701. generateStencilBuffer?: boolean;
  17702. /**
  17703. * Define if a depth texture is required instead of a depth buffer
  17704. */
  17705. generateDepthTexture?: boolean;
  17706. /**
  17707. * Define the number of desired draw buffers
  17708. */
  17709. textureCount?: number;
  17710. /**
  17711. * Define if aspect ratio should be adapted to the texture or stay the scene one
  17712. */
  17713. doNotChangeAspectRatio?: boolean;
  17714. /**
  17715. * Define the default type of the buffers we are creating
  17716. */
  17717. defaultType?: number;
  17718. }
  17719. /**
  17720. * A multi render target, like a render target provides the ability to render to a texture.
  17721. * Unlike the render target, it can render to several draw buffers in one draw.
  17722. * This is specially interesting in deferred rendering or for any effects requiring more than
  17723. * just one color from a single pass.
  17724. */
  17725. export class MultiRenderTarget extends RenderTargetTexture {
  17726. private _internalTextures;
  17727. private _textures;
  17728. private _multiRenderTargetOptions;
  17729. private _count;
  17730. /**
  17731. * Get if draw buffers are currently supported by the used hardware and browser.
  17732. */
  17733. get isSupported(): boolean;
  17734. /**
  17735. * Get the list of textures generated by the multi render target.
  17736. */
  17737. get textures(): Texture[];
  17738. /**
  17739. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  17740. */
  17741. get count(): number;
  17742. /**
  17743. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  17744. */
  17745. get depthTexture(): Texture;
  17746. /**
  17747. * Set the wrapping mode on U of all the textures we are rendering to.
  17748. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17749. */
  17750. set wrapU(wrap: number);
  17751. /**
  17752. * Set the wrapping mode on V of all the textures we are rendering to.
  17753. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  17754. */
  17755. set wrapV(wrap: number);
  17756. /**
  17757. * Instantiate a new multi render target texture.
  17758. * A multi render target, like a render target provides the ability to render to a texture.
  17759. * Unlike the render target, it can render to several draw buffers in one draw.
  17760. * This is specially interesting in deferred rendering or for any effects requiring more than
  17761. * just one color from a single pass.
  17762. * @param name Define the name of the texture
  17763. * @param size Define the size of the buffers to render to
  17764. * @param count Define the number of target we are rendering into
  17765. * @param scene Define the scene the texture belongs to
  17766. * @param options Define the options used to create the multi render target
  17767. */
  17768. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  17769. private _initTypes;
  17770. /** @hidden */
  17771. _rebuild(forceFullRebuild?: boolean): void;
  17772. private _createInternalTextures;
  17773. private _createTextures;
  17774. /**
  17775. * Replaces a texture within the MRT.
  17776. * @param texture The new texture to insert in the MRT
  17777. * @param index The index of the texture to replace
  17778. */
  17779. replaceTexture(texture: Texture, index: number): void;
  17780. /**
  17781. * Define the number of samples used if MSAA is enabled.
  17782. */
  17783. get samples(): number;
  17784. set samples(value: number);
  17785. /**
  17786. * Resize all the textures in the multi render target.
  17787. * Be careful as it will recreate all the data in the new texture.
  17788. * @param size Define the new size
  17789. */
  17790. resize(size: any): void;
  17791. /**
  17792. * Changes the number of render targets in this MRT
  17793. * Be careful as it will recreate all the data in the new texture.
  17794. * @param count new texture count
  17795. * @param options Specifies texture types and sampling modes for new textures
  17796. */
  17797. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  17798. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17799. /**
  17800. * Dispose the render targets and their associated resources
  17801. */
  17802. dispose(): void;
  17803. /**
  17804. * Release all the underlying texture used as draw buffers.
  17805. */
  17806. releaseInternalTextures(): void;
  17807. }
  17808. }
  17809. declare module BABYLON {
  17810. /** @hidden */
  17811. export var imageProcessingPixelShader: {
  17812. name: string;
  17813. shader: string;
  17814. };
  17815. }
  17816. declare module BABYLON {
  17817. /**
  17818. * ImageProcessingPostProcess
  17819. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  17820. */
  17821. export class ImageProcessingPostProcess extends PostProcess {
  17822. /**
  17823. * Default configuration related to image processing available in the PBR Material.
  17824. */
  17825. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17826. /**
  17827. * Gets the image processing configuration used either in this material.
  17828. */
  17829. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17830. /**
  17831. * Sets the Default image processing configuration used either in the this material.
  17832. *
  17833. * If sets to null, the scene one is in use.
  17834. */
  17835. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17836. /**
  17837. * Keep track of the image processing observer to allow dispose and replace.
  17838. */
  17839. private _imageProcessingObserver;
  17840. /**
  17841. * Attaches a new image processing configuration to the PBR Material.
  17842. * @param configuration
  17843. */
  17844. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  17845. /**
  17846. * If the post process is supported.
  17847. */
  17848. get isSupported(): boolean;
  17849. /**
  17850. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17851. */
  17852. get colorCurves(): Nullable<ColorCurves>;
  17853. /**
  17854. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  17855. */
  17856. set colorCurves(value: Nullable<ColorCurves>);
  17857. /**
  17858. * Gets wether the color curves effect is enabled.
  17859. */
  17860. get colorCurvesEnabled(): boolean;
  17861. /**
  17862. * Sets wether the color curves effect is enabled.
  17863. */
  17864. set colorCurvesEnabled(value: boolean);
  17865. /**
  17866. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17867. */
  17868. get colorGradingTexture(): Nullable<BaseTexture>;
  17869. /**
  17870. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  17871. */
  17872. set colorGradingTexture(value: Nullable<BaseTexture>);
  17873. /**
  17874. * Gets wether the color grading effect is enabled.
  17875. */
  17876. get colorGradingEnabled(): boolean;
  17877. /**
  17878. * Gets wether the color grading effect is enabled.
  17879. */
  17880. set colorGradingEnabled(value: boolean);
  17881. /**
  17882. * Gets exposure used in the effect.
  17883. */
  17884. get exposure(): number;
  17885. /**
  17886. * Sets exposure used in the effect.
  17887. */
  17888. set exposure(value: number);
  17889. /**
  17890. * Gets wether tonemapping is enabled or not.
  17891. */
  17892. get toneMappingEnabled(): boolean;
  17893. /**
  17894. * Sets wether tonemapping is enabled or not
  17895. */
  17896. set toneMappingEnabled(value: boolean);
  17897. /**
  17898. * Gets the type of tone mapping effect.
  17899. */
  17900. get toneMappingType(): number;
  17901. /**
  17902. * Sets the type of tone mapping effect.
  17903. */
  17904. set toneMappingType(value: number);
  17905. /**
  17906. * Gets contrast used in the effect.
  17907. */
  17908. get contrast(): number;
  17909. /**
  17910. * Sets contrast used in the effect.
  17911. */
  17912. set contrast(value: number);
  17913. /**
  17914. * Gets Vignette stretch size.
  17915. */
  17916. get vignetteStretch(): number;
  17917. /**
  17918. * Sets Vignette stretch size.
  17919. */
  17920. set vignetteStretch(value: number);
  17921. /**
  17922. * Gets Vignette centre X Offset.
  17923. */
  17924. get vignetteCentreX(): number;
  17925. /**
  17926. * Sets Vignette centre X Offset.
  17927. */
  17928. set vignetteCentreX(value: number);
  17929. /**
  17930. * Gets Vignette centre Y Offset.
  17931. */
  17932. get vignetteCentreY(): number;
  17933. /**
  17934. * Sets Vignette centre Y Offset.
  17935. */
  17936. set vignetteCentreY(value: number);
  17937. /**
  17938. * Gets Vignette weight or intensity of the vignette effect.
  17939. */
  17940. get vignetteWeight(): number;
  17941. /**
  17942. * Sets Vignette weight or intensity of the vignette effect.
  17943. */
  17944. set vignetteWeight(value: number);
  17945. /**
  17946. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17947. * if vignetteEnabled is set to true.
  17948. */
  17949. get vignetteColor(): Color4;
  17950. /**
  17951. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  17952. * if vignetteEnabled is set to true.
  17953. */
  17954. set vignetteColor(value: Color4);
  17955. /**
  17956. * Gets Camera field of view used by the Vignette effect.
  17957. */
  17958. get vignetteCameraFov(): number;
  17959. /**
  17960. * Sets Camera field of view used by the Vignette effect.
  17961. */
  17962. set vignetteCameraFov(value: number);
  17963. /**
  17964. * Gets the vignette blend mode allowing different kind of effect.
  17965. */
  17966. get vignetteBlendMode(): number;
  17967. /**
  17968. * Sets the vignette blend mode allowing different kind of effect.
  17969. */
  17970. set vignetteBlendMode(value: number);
  17971. /**
  17972. * Gets wether the vignette effect is enabled.
  17973. */
  17974. get vignetteEnabled(): boolean;
  17975. /**
  17976. * Sets wether the vignette effect is enabled.
  17977. */
  17978. set vignetteEnabled(value: boolean);
  17979. private _fromLinearSpace;
  17980. /**
  17981. * Gets wether the input of the processing is in Gamma or Linear Space.
  17982. */
  17983. get fromLinearSpace(): boolean;
  17984. /**
  17985. * Sets wether the input of the processing is in Gamma or Linear Space.
  17986. */
  17987. set fromLinearSpace(value: boolean);
  17988. /**
  17989. * Defines cache preventing GC.
  17990. */
  17991. private _defines;
  17992. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  17993. /**
  17994. * "ImageProcessingPostProcess"
  17995. * @returns "ImageProcessingPostProcess"
  17996. */
  17997. getClassName(): string;
  17998. /**
  17999. * @hidden
  18000. */
  18001. _updateParameters(): void;
  18002. dispose(camera?: Camera): void;
  18003. }
  18004. }
  18005. declare module BABYLON {
  18006. /**
  18007. * Interface for defining prepass effects in the prepass post-process pipeline
  18008. */
  18009. export interface PrePassEffectConfiguration {
  18010. /**
  18011. * Name of the effect
  18012. */
  18013. name: string;
  18014. /**
  18015. * Post process to attach for this effect
  18016. */
  18017. postProcess?: PostProcess;
  18018. /**
  18019. * Textures required in the MRT
  18020. */
  18021. texturesRequired: number[];
  18022. /**
  18023. * Is the effect enabled
  18024. */
  18025. enabled: boolean;
  18026. /**
  18027. * Disposes the effect configuration
  18028. */
  18029. dispose?: () => void;
  18030. /**
  18031. * Creates the associated post process
  18032. */
  18033. createPostProcess?: () => PostProcess;
  18034. }
  18035. }
  18036. declare module BABYLON {
  18037. /**
  18038. * Options to be used when creating a FresnelParameters.
  18039. */
  18040. export type IFresnelParametersCreationOptions = {
  18041. /**
  18042. * Define the color used on edges (grazing angle)
  18043. */
  18044. leftColor?: Color3;
  18045. /**
  18046. * Define the color used on center
  18047. */
  18048. rightColor?: Color3;
  18049. /**
  18050. * Define bias applied to computed fresnel term
  18051. */
  18052. bias?: number;
  18053. /**
  18054. * Defined the power exponent applied to fresnel term
  18055. */
  18056. power?: number;
  18057. /**
  18058. * Define if the fresnel effect is enable or not.
  18059. */
  18060. isEnabled?: boolean;
  18061. };
  18062. /**
  18063. * Serialized format for FresnelParameters.
  18064. */
  18065. export type IFresnelParametersSerialized = {
  18066. /**
  18067. * Define the color used on edges (grazing angle) [as an array]
  18068. */
  18069. leftColor: number[];
  18070. /**
  18071. * Define the color used on center [as an array]
  18072. */
  18073. rightColor: number[];
  18074. /**
  18075. * Define bias applied to computed fresnel term
  18076. */
  18077. bias: number;
  18078. /**
  18079. * Defined the power exponent applied to fresnel term
  18080. */
  18081. power?: number;
  18082. /**
  18083. * Define if the fresnel effect is enable or not.
  18084. */
  18085. isEnabled: boolean;
  18086. };
  18087. /**
  18088. * This represents all the required information to add a fresnel effect on a material:
  18089. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18090. */
  18091. export class FresnelParameters {
  18092. private _isEnabled;
  18093. /**
  18094. * Define if the fresnel effect is enable or not.
  18095. */
  18096. get isEnabled(): boolean;
  18097. set isEnabled(value: boolean);
  18098. /**
  18099. * Define the color used on edges (grazing angle)
  18100. */
  18101. leftColor: Color3;
  18102. /**
  18103. * Define the color used on center
  18104. */
  18105. rightColor: Color3;
  18106. /**
  18107. * Define bias applied to computed fresnel term
  18108. */
  18109. bias: number;
  18110. /**
  18111. * Defined the power exponent applied to fresnel term
  18112. */
  18113. power: number;
  18114. /**
  18115. * Creates a new FresnelParameters object.
  18116. *
  18117. * @param options provide your own settings to optionally to override defaults
  18118. */
  18119. constructor(options?: IFresnelParametersCreationOptions);
  18120. /**
  18121. * Clones the current fresnel and its valuues
  18122. * @returns a clone fresnel configuration
  18123. */
  18124. clone(): FresnelParameters;
  18125. /**
  18126. * Determines equality between FresnelParameters objects
  18127. * @param otherFresnelParameters defines the second operand
  18128. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18129. */
  18130. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18131. /**
  18132. * Serializes the current fresnel parameters to a JSON representation.
  18133. * @return the JSON serialization
  18134. */
  18135. serialize(): IFresnelParametersSerialized;
  18136. /**
  18137. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18138. * @param parsedFresnelParameters Define the JSON representation
  18139. * @returns the parsed parameters
  18140. */
  18141. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18142. }
  18143. }
  18144. declare module BABYLON {
  18145. /**
  18146. * This groups all the flags used to control the materials channel.
  18147. */
  18148. export class MaterialFlags {
  18149. private static _DiffuseTextureEnabled;
  18150. /**
  18151. * Are diffuse textures enabled in the application.
  18152. */
  18153. static get DiffuseTextureEnabled(): boolean;
  18154. static set DiffuseTextureEnabled(value: boolean);
  18155. private static _DetailTextureEnabled;
  18156. /**
  18157. * Are detail textures enabled in the application.
  18158. */
  18159. static get DetailTextureEnabled(): boolean;
  18160. static set DetailTextureEnabled(value: boolean);
  18161. private static _AmbientTextureEnabled;
  18162. /**
  18163. * Are ambient textures enabled in the application.
  18164. */
  18165. static get AmbientTextureEnabled(): boolean;
  18166. static set AmbientTextureEnabled(value: boolean);
  18167. private static _OpacityTextureEnabled;
  18168. /**
  18169. * Are opacity textures enabled in the application.
  18170. */
  18171. static get OpacityTextureEnabled(): boolean;
  18172. static set OpacityTextureEnabled(value: boolean);
  18173. private static _ReflectionTextureEnabled;
  18174. /**
  18175. * Are reflection textures enabled in the application.
  18176. */
  18177. static get ReflectionTextureEnabled(): boolean;
  18178. static set ReflectionTextureEnabled(value: boolean);
  18179. private static _EmissiveTextureEnabled;
  18180. /**
  18181. * Are emissive textures enabled in the application.
  18182. */
  18183. static get EmissiveTextureEnabled(): boolean;
  18184. static set EmissiveTextureEnabled(value: boolean);
  18185. private static _SpecularTextureEnabled;
  18186. /**
  18187. * Are specular textures enabled in the application.
  18188. */
  18189. static get SpecularTextureEnabled(): boolean;
  18190. static set SpecularTextureEnabled(value: boolean);
  18191. private static _BumpTextureEnabled;
  18192. /**
  18193. * Are bump textures enabled in the application.
  18194. */
  18195. static get BumpTextureEnabled(): boolean;
  18196. static set BumpTextureEnabled(value: boolean);
  18197. private static _LightmapTextureEnabled;
  18198. /**
  18199. * Are lightmap textures enabled in the application.
  18200. */
  18201. static get LightmapTextureEnabled(): boolean;
  18202. static set LightmapTextureEnabled(value: boolean);
  18203. private static _RefractionTextureEnabled;
  18204. /**
  18205. * Are refraction textures enabled in the application.
  18206. */
  18207. static get RefractionTextureEnabled(): boolean;
  18208. static set RefractionTextureEnabled(value: boolean);
  18209. private static _ColorGradingTextureEnabled;
  18210. /**
  18211. * Are color grading textures enabled in the application.
  18212. */
  18213. static get ColorGradingTextureEnabled(): boolean;
  18214. static set ColorGradingTextureEnabled(value: boolean);
  18215. private static _FresnelEnabled;
  18216. /**
  18217. * Are fresnels enabled in the application.
  18218. */
  18219. static get FresnelEnabled(): boolean;
  18220. static set FresnelEnabled(value: boolean);
  18221. private static _ClearCoatTextureEnabled;
  18222. /**
  18223. * Are clear coat textures enabled in the application.
  18224. */
  18225. static get ClearCoatTextureEnabled(): boolean;
  18226. static set ClearCoatTextureEnabled(value: boolean);
  18227. private static _ClearCoatBumpTextureEnabled;
  18228. /**
  18229. * Are clear coat bump textures enabled in the application.
  18230. */
  18231. static get ClearCoatBumpTextureEnabled(): boolean;
  18232. static set ClearCoatBumpTextureEnabled(value: boolean);
  18233. private static _ClearCoatTintTextureEnabled;
  18234. /**
  18235. * Are clear coat tint textures enabled in the application.
  18236. */
  18237. static get ClearCoatTintTextureEnabled(): boolean;
  18238. static set ClearCoatTintTextureEnabled(value: boolean);
  18239. private static _SheenTextureEnabled;
  18240. /**
  18241. * Are sheen textures enabled in the application.
  18242. */
  18243. static get SheenTextureEnabled(): boolean;
  18244. static set SheenTextureEnabled(value: boolean);
  18245. private static _AnisotropicTextureEnabled;
  18246. /**
  18247. * Are anisotropic textures enabled in the application.
  18248. */
  18249. static get AnisotropicTextureEnabled(): boolean;
  18250. static set AnisotropicTextureEnabled(value: boolean);
  18251. private static _ThicknessTextureEnabled;
  18252. /**
  18253. * Are thickness textures enabled in the application.
  18254. */
  18255. static get ThicknessTextureEnabled(): boolean;
  18256. static set ThicknessTextureEnabled(value: boolean);
  18257. }
  18258. }
  18259. declare module BABYLON {
  18260. /** @hidden */
  18261. export var defaultFragmentDeclaration: {
  18262. name: string;
  18263. shader: string;
  18264. };
  18265. }
  18266. declare module BABYLON {
  18267. /** @hidden */
  18268. export var defaultUboDeclaration: {
  18269. name: string;
  18270. shader: string;
  18271. };
  18272. }
  18273. declare module BABYLON {
  18274. /** @hidden */
  18275. export var prePassDeclaration: {
  18276. name: string;
  18277. shader: string;
  18278. };
  18279. }
  18280. declare module BABYLON {
  18281. /** @hidden */
  18282. export var lightFragmentDeclaration: {
  18283. name: string;
  18284. shader: string;
  18285. };
  18286. }
  18287. declare module BABYLON {
  18288. /** @hidden */
  18289. export var lightUboDeclaration: {
  18290. name: string;
  18291. shader: string;
  18292. };
  18293. }
  18294. declare module BABYLON {
  18295. /** @hidden */
  18296. export var lightsFragmentFunctions: {
  18297. name: string;
  18298. shader: string;
  18299. };
  18300. }
  18301. declare module BABYLON {
  18302. /** @hidden */
  18303. export var shadowsFragmentFunctions: {
  18304. name: string;
  18305. shader: string;
  18306. };
  18307. }
  18308. declare module BABYLON {
  18309. /** @hidden */
  18310. export var fresnelFunction: {
  18311. name: string;
  18312. shader: string;
  18313. };
  18314. }
  18315. declare module BABYLON {
  18316. /** @hidden */
  18317. export var bumpFragmentMainFunctions: {
  18318. name: string;
  18319. shader: string;
  18320. };
  18321. }
  18322. declare module BABYLON {
  18323. /** @hidden */
  18324. export var bumpFragmentFunctions: {
  18325. name: string;
  18326. shader: string;
  18327. };
  18328. }
  18329. declare module BABYLON {
  18330. /** @hidden */
  18331. export var logDepthDeclaration: {
  18332. name: string;
  18333. shader: string;
  18334. };
  18335. }
  18336. declare module BABYLON {
  18337. /** @hidden */
  18338. export var fogFragmentDeclaration: {
  18339. name: string;
  18340. shader: string;
  18341. };
  18342. }
  18343. declare module BABYLON {
  18344. /** @hidden */
  18345. export var bumpFragment: {
  18346. name: string;
  18347. shader: string;
  18348. };
  18349. }
  18350. declare module BABYLON {
  18351. /** @hidden */
  18352. export var depthPrePass: {
  18353. name: string;
  18354. shader: string;
  18355. };
  18356. }
  18357. declare module BABYLON {
  18358. /** @hidden */
  18359. export var lightFragment: {
  18360. name: string;
  18361. shader: string;
  18362. };
  18363. }
  18364. declare module BABYLON {
  18365. /** @hidden */
  18366. export var logDepthFragment: {
  18367. name: string;
  18368. shader: string;
  18369. };
  18370. }
  18371. declare module BABYLON {
  18372. /** @hidden */
  18373. export var fogFragment: {
  18374. name: string;
  18375. shader: string;
  18376. };
  18377. }
  18378. declare module BABYLON {
  18379. /** @hidden */
  18380. export var defaultPixelShader: {
  18381. name: string;
  18382. shader: string;
  18383. };
  18384. }
  18385. declare module BABYLON {
  18386. /** @hidden */
  18387. export var defaultVertexDeclaration: {
  18388. name: string;
  18389. shader: string;
  18390. };
  18391. }
  18392. declare module BABYLON {
  18393. /** @hidden */
  18394. export var bonesDeclaration: {
  18395. name: string;
  18396. shader: string;
  18397. };
  18398. }
  18399. declare module BABYLON {
  18400. /** @hidden */
  18401. export var instancesDeclaration: {
  18402. name: string;
  18403. shader: string;
  18404. };
  18405. }
  18406. declare module BABYLON {
  18407. /** @hidden */
  18408. export var prePassVertexDeclaration: {
  18409. name: string;
  18410. shader: string;
  18411. };
  18412. }
  18413. declare module BABYLON {
  18414. /** @hidden */
  18415. export var bumpVertexDeclaration: {
  18416. name: string;
  18417. shader: string;
  18418. };
  18419. }
  18420. declare module BABYLON {
  18421. /** @hidden */
  18422. export var fogVertexDeclaration: {
  18423. name: string;
  18424. shader: string;
  18425. };
  18426. }
  18427. declare module BABYLON {
  18428. /** @hidden */
  18429. export var morphTargetsVertexGlobalDeclaration: {
  18430. name: string;
  18431. shader: string;
  18432. };
  18433. }
  18434. declare module BABYLON {
  18435. /** @hidden */
  18436. export var morphTargetsVertexDeclaration: {
  18437. name: string;
  18438. shader: string;
  18439. };
  18440. }
  18441. declare module BABYLON {
  18442. /** @hidden */
  18443. export var morphTargetsVertex: {
  18444. name: string;
  18445. shader: string;
  18446. };
  18447. }
  18448. declare module BABYLON {
  18449. /** @hidden */
  18450. export var instancesVertex: {
  18451. name: string;
  18452. shader: string;
  18453. };
  18454. }
  18455. declare module BABYLON {
  18456. /** @hidden */
  18457. export var bonesVertex: {
  18458. name: string;
  18459. shader: string;
  18460. };
  18461. }
  18462. declare module BABYLON {
  18463. /** @hidden */
  18464. export var prePassVertex: {
  18465. name: string;
  18466. shader: string;
  18467. };
  18468. }
  18469. declare module BABYLON {
  18470. /** @hidden */
  18471. export var bumpVertex: {
  18472. name: string;
  18473. shader: string;
  18474. };
  18475. }
  18476. declare module BABYLON {
  18477. /** @hidden */
  18478. export var fogVertex: {
  18479. name: string;
  18480. shader: string;
  18481. };
  18482. }
  18483. declare module BABYLON {
  18484. /** @hidden */
  18485. export var shadowsVertex: {
  18486. name: string;
  18487. shader: string;
  18488. };
  18489. }
  18490. declare module BABYLON {
  18491. /** @hidden */
  18492. export var pointCloudVertex: {
  18493. name: string;
  18494. shader: string;
  18495. };
  18496. }
  18497. declare module BABYLON {
  18498. /** @hidden */
  18499. export var logDepthVertex: {
  18500. name: string;
  18501. shader: string;
  18502. };
  18503. }
  18504. declare module BABYLON {
  18505. /** @hidden */
  18506. export var defaultVertexShader: {
  18507. name: string;
  18508. shader: string;
  18509. };
  18510. }
  18511. declare module BABYLON {
  18512. /**
  18513. * @hidden
  18514. */
  18515. export interface IMaterialDetailMapDefines {
  18516. DETAIL: boolean;
  18517. DETAILDIRECTUV: number;
  18518. DETAIL_NORMALBLENDMETHOD: number;
  18519. /** @hidden */
  18520. _areTexturesDirty: boolean;
  18521. }
  18522. /**
  18523. * Define the code related to the detail map parameters of a material
  18524. *
  18525. * Inspired from:
  18526. * 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
  18527. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  18528. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  18529. */
  18530. export class DetailMapConfiguration {
  18531. private _texture;
  18532. /**
  18533. * The detail texture of the material.
  18534. */
  18535. texture: Nullable<BaseTexture>;
  18536. /**
  18537. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  18538. * Bigger values mean stronger blending
  18539. */
  18540. diffuseBlendLevel: number;
  18541. /**
  18542. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  18543. * Bigger values mean stronger blending. Only used with PBR materials
  18544. */
  18545. roughnessBlendLevel: number;
  18546. /**
  18547. * Defines how strong the bump effect from the detail map is
  18548. * Bigger values mean stronger effect
  18549. */
  18550. bumpLevel: number;
  18551. private _normalBlendMethod;
  18552. /**
  18553. * The method used to blend the bump and detail normals together
  18554. */
  18555. normalBlendMethod: number;
  18556. private _isEnabled;
  18557. /**
  18558. * Enable or disable the detail map on this material
  18559. */
  18560. isEnabled: boolean;
  18561. /** @hidden */
  18562. private _internalMarkAllSubMeshesAsTexturesDirty;
  18563. /** @hidden */
  18564. _markAllSubMeshesAsTexturesDirty(): void;
  18565. /**
  18566. * Instantiate a new detail map
  18567. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  18568. */
  18569. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  18570. /**
  18571. * Gets whether the submesh is ready to be used or not.
  18572. * @param defines the list of "defines" to update.
  18573. * @param scene defines the scene the material belongs to.
  18574. * @returns - boolean indicating that the submesh is ready or not.
  18575. */
  18576. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  18577. /**
  18578. * Update the defines for detail map usage
  18579. * @param defines the list of "defines" to update.
  18580. * @param scene defines the scene the material belongs to.
  18581. */
  18582. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  18583. /**
  18584. * Binds the material data.
  18585. * @param uniformBuffer defines the Uniform buffer to fill in.
  18586. * @param scene defines the scene the material belongs to.
  18587. * @param isFrozen defines whether the material is frozen or not.
  18588. */
  18589. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  18590. /**
  18591. * Checks to see if a texture is used in the material.
  18592. * @param texture - Base texture to use.
  18593. * @returns - Boolean specifying if a texture is used in the material.
  18594. */
  18595. hasTexture(texture: BaseTexture): boolean;
  18596. /**
  18597. * Returns an array of the actively used textures.
  18598. * @param activeTextures Array of BaseTextures
  18599. */
  18600. getActiveTextures(activeTextures: BaseTexture[]): void;
  18601. /**
  18602. * Returns the animatable textures.
  18603. * @param animatables Array of animatable textures.
  18604. */
  18605. getAnimatables(animatables: IAnimatable[]): void;
  18606. /**
  18607. * Disposes the resources of the material.
  18608. * @param forceDisposeTextures - Forces the disposal of all textures.
  18609. */
  18610. dispose(forceDisposeTextures?: boolean): void;
  18611. /**
  18612. * Get the current class name useful for serialization or dynamic coding.
  18613. * @returns "DetailMap"
  18614. */
  18615. getClassName(): string;
  18616. /**
  18617. * Add the required uniforms to the current list.
  18618. * @param uniforms defines the current uniform list.
  18619. */
  18620. static AddUniforms(uniforms: string[]): void;
  18621. /**
  18622. * Add the required samplers to the current list.
  18623. * @param samplers defines the current sampler list.
  18624. */
  18625. static AddSamplers(samplers: string[]): void;
  18626. /**
  18627. * Add the required uniforms to the current buffer.
  18628. * @param uniformBuffer defines the current uniform buffer.
  18629. */
  18630. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  18631. /**
  18632. * Makes a duplicate of the current instance into another one.
  18633. * @param detailMap define the instance where to copy the info
  18634. */
  18635. copyTo(detailMap: DetailMapConfiguration): void;
  18636. /**
  18637. * Serializes this detail map instance
  18638. * @returns - An object with the serialized instance.
  18639. */
  18640. serialize(): any;
  18641. /**
  18642. * Parses a detail map setting from a serialized object.
  18643. * @param source - Serialized object.
  18644. * @param scene Defines the scene we are parsing for
  18645. * @param rootUrl Defines the rootUrl to load from
  18646. */
  18647. parse(source: any, scene: Scene, rootUrl: string): void;
  18648. }
  18649. }
  18650. declare module BABYLON {
  18651. /** @hidden */
  18652. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  18653. MAINUV1: boolean;
  18654. MAINUV2: boolean;
  18655. DIFFUSE: boolean;
  18656. DIFFUSEDIRECTUV: number;
  18657. DETAIL: boolean;
  18658. DETAILDIRECTUV: number;
  18659. DETAIL_NORMALBLENDMETHOD: number;
  18660. AMBIENT: boolean;
  18661. AMBIENTDIRECTUV: number;
  18662. OPACITY: boolean;
  18663. OPACITYDIRECTUV: number;
  18664. OPACITYRGB: boolean;
  18665. REFLECTION: boolean;
  18666. EMISSIVE: boolean;
  18667. EMISSIVEDIRECTUV: number;
  18668. SPECULAR: boolean;
  18669. SPECULARDIRECTUV: number;
  18670. BUMP: boolean;
  18671. BUMPDIRECTUV: number;
  18672. PARALLAX: boolean;
  18673. PARALLAXOCCLUSION: boolean;
  18674. SPECULAROVERALPHA: boolean;
  18675. CLIPPLANE: boolean;
  18676. CLIPPLANE2: boolean;
  18677. CLIPPLANE3: boolean;
  18678. CLIPPLANE4: boolean;
  18679. CLIPPLANE5: boolean;
  18680. CLIPPLANE6: boolean;
  18681. ALPHATEST: boolean;
  18682. DEPTHPREPASS: boolean;
  18683. ALPHAFROMDIFFUSE: boolean;
  18684. POINTSIZE: boolean;
  18685. FOG: boolean;
  18686. SPECULARTERM: boolean;
  18687. DIFFUSEFRESNEL: boolean;
  18688. OPACITYFRESNEL: boolean;
  18689. REFLECTIONFRESNEL: boolean;
  18690. REFRACTIONFRESNEL: boolean;
  18691. EMISSIVEFRESNEL: boolean;
  18692. FRESNEL: boolean;
  18693. NORMAL: boolean;
  18694. UV1: boolean;
  18695. UV2: boolean;
  18696. VERTEXCOLOR: boolean;
  18697. VERTEXALPHA: boolean;
  18698. NUM_BONE_INFLUENCERS: number;
  18699. BonesPerMesh: number;
  18700. BONETEXTURE: boolean;
  18701. BONES_VELOCITY_ENABLED: boolean;
  18702. INSTANCES: boolean;
  18703. THIN_INSTANCES: boolean;
  18704. GLOSSINESS: boolean;
  18705. ROUGHNESS: boolean;
  18706. EMISSIVEASILLUMINATION: boolean;
  18707. LINKEMISSIVEWITHDIFFUSE: boolean;
  18708. REFLECTIONFRESNELFROMSPECULAR: boolean;
  18709. LIGHTMAP: boolean;
  18710. LIGHTMAPDIRECTUV: number;
  18711. OBJECTSPACE_NORMALMAP: boolean;
  18712. USELIGHTMAPASSHADOWMAP: boolean;
  18713. REFLECTIONMAP_3D: boolean;
  18714. REFLECTIONMAP_SPHERICAL: boolean;
  18715. REFLECTIONMAP_PLANAR: boolean;
  18716. REFLECTIONMAP_CUBIC: boolean;
  18717. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  18718. REFLECTIONMAP_PROJECTION: boolean;
  18719. REFLECTIONMAP_SKYBOX: boolean;
  18720. REFLECTIONMAP_EXPLICIT: boolean;
  18721. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  18722. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  18723. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  18724. INVERTCUBICMAP: boolean;
  18725. LOGARITHMICDEPTH: boolean;
  18726. REFRACTION: boolean;
  18727. REFRACTIONMAP_3D: boolean;
  18728. REFLECTIONOVERALPHA: boolean;
  18729. TWOSIDEDLIGHTING: boolean;
  18730. SHADOWFLOAT: boolean;
  18731. MORPHTARGETS: boolean;
  18732. MORPHTARGETS_NORMAL: boolean;
  18733. MORPHTARGETS_TANGENT: boolean;
  18734. MORPHTARGETS_UV: boolean;
  18735. NUM_MORPH_INFLUENCERS: number;
  18736. NONUNIFORMSCALING: boolean;
  18737. PREMULTIPLYALPHA: boolean;
  18738. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  18739. ALPHABLEND: boolean;
  18740. PREPASS: boolean;
  18741. PREPASS_IRRADIANCE: boolean;
  18742. PREPASS_IRRADIANCE_INDEX: number;
  18743. PREPASS_ALBEDO: boolean;
  18744. PREPASS_ALBEDO_INDEX: number;
  18745. PREPASS_DEPTHNORMAL: boolean;
  18746. PREPASS_DEPTHNORMAL_INDEX: number;
  18747. PREPASS_POSITION: boolean;
  18748. PREPASS_POSITION_INDEX: number;
  18749. PREPASS_VELOCITY: boolean;
  18750. PREPASS_VELOCITY_INDEX: number;
  18751. PREPASS_REFLECTIVITY: boolean;
  18752. PREPASS_REFLECTIVITY_INDEX: number;
  18753. SCENE_MRT_COUNT: number;
  18754. RGBDLIGHTMAP: boolean;
  18755. RGBDREFLECTION: boolean;
  18756. RGBDREFRACTION: boolean;
  18757. IMAGEPROCESSING: boolean;
  18758. VIGNETTE: boolean;
  18759. VIGNETTEBLENDMODEMULTIPLY: boolean;
  18760. VIGNETTEBLENDMODEOPAQUE: boolean;
  18761. TONEMAPPING: boolean;
  18762. TONEMAPPING_ACES: boolean;
  18763. CONTRAST: boolean;
  18764. COLORCURVES: boolean;
  18765. COLORGRADING: boolean;
  18766. COLORGRADING3D: boolean;
  18767. SAMPLER3DGREENDEPTH: boolean;
  18768. SAMPLER3DBGRMAP: boolean;
  18769. IMAGEPROCESSINGPOSTPROCESS: boolean;
  18770. MULTIVIEW: boolean;
  18771. /**
  18772. * If the reflection texture on this material is in linear color space
  18773. * @hidden
  18774. */
  18775. IS_REFLECTION_LINEAR: boolean;
  18776. /**
  18777. * If the refraction texture on this material is in linear color space
  18778. * @hidden
  18779. */
  18780. IS_REFRACTION_LINEAR: boolean;
  18781. EXPOSURE: boolean;
  18782. constructor();
  18783. setReflectionMode(modeToEnable: string): void;
  18784. }
  18785. /**
  18786. * This is the default material used in Babylon. It is the best trade off between quality
  18787. * and performances.
  18788. * @see https://doc.babylonjs.com/babylon101/materials
  18789. */
  18790. export class StandardMaterial extends PushMaterial {
  18791. private _diffuseTexture;
  18792. /**
  18793. * The basic texture of the material as viewed under a light.
  18794. */
  18795. diffuseTexture: Nullable<BaseTexture>;
  18796. private _ambientTexture;
  18797. /**
  18798. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  18799. */
  18800. ambientTexture: Nullable<BaseTexture>;
  18801. private _opacityTexture;
  18802. /**
  18803. * Define the transparency of the material from a texture.
  18804. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  18805. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  18806. */
  18807. opacityTexture: Nullable<BaseTexture>;
  18808. private _reflectionTexture;
  18809. /**
  18810. * Define the texture used to display the reflection.
  18811. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18812. */
  18813. reflectionTexture: Nullable<BaseTexture>;
  18814. private _emissiveTexture;
  18815. /**
  18816. * Define texture of the material as if self lit.
  18817. * This will be mixed in the final result even in the absence of light.
  18818. */
  18819. emissiveTexture: Nullable<BaseTexture>;
  18820. private _specularTexture;
  18821. /**
  18822. * Define how the color and intensity of the highlight given by the light in the material.
  18823. */
  18824. specularTexture: Nullable<BaseTexture>;
  18825. private _bumpTexture;
  18826. /**
  18827. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  18828. * 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.
  18829. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  18830. */
  18831. bumpTexture: Nullable<BaseTexture>;
  18832. private _lightmapTexture;
  18833. /**
  18834. * Complex lighting can be computationally expensive to compute at runtime.
  18835. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  18836. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  18837. */
  18838. lightmapTexture: Nullable<BaseTexture>;
  18839. private _refractionTexture;
  18840. /**
  18841. * Define the texture used to display the refraction.
  18842. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18843. */
  18844. refractionTexture: Nullable<BaseTexture>;
  18845. /**
  18846. * The color of the material lit by the environmental background lighting.
  18847. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  18848. */
  18849. ambientColor: Color3;
  18850. /**
  18851. * The basic color of the material as viewed under a light.
  18852. */
  18853. diffuseColor: Color3;
  18854. /**
  18855. * Define how the color and intensity of the highlight given by the light in the material.
  18856. */
  18857. specularColor: Color3;
  18858. /**
  18859. * Define the color of the material as if self lit.
  18860. * This will be mixed in the final result even in the absence of light.
  18861. */
  18862. emissiveColor: Color3;
  18863. /**
  18864. * Defines how sharp are the highlights in the material.
  18865. * The bigger the value the sharper giving a more glossy feeling to the result.
  18866. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  18867. */
  18868. specularPower: number;
  18869. private _useAlphaFromDiffuseTexture;
  18870. /**
  18871. * Does the transparency come from the diffuse texture alpha channel.
  18872. */
  18873. useAlphaFromDiffuseTexture: boolean;
  18874. private _useEmissiveAsIllumination;
  18875. /**
  18876. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  18877. */
  18878. useEmissiveAsIllumination: boolean;
  18879. private _linkEmissiveWithDiffuse;
  18880. /**
  18881. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  18882. * the emissive level when the final color is close to one.
  18883. */
  18884. linkEmissiveWithDiffuse: boolean;
  18885. private _useSpecularOverAlpha;
  18886. /**
  18887. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  18888. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  18889. */
  18890. useSpecularOverAlpha: boolean;
  18891. private _useReflectionOverAlpha;
  18892. /**
  18893. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  18894. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  18895. */
  18896. useReflectionOverAlpha: boolean;
  18897. private _disableLighting;
  18898. /**
  18899. * Does lights from the scene impacts this material.
  18900. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  18901. */
  18902. disableLighting: boolean;
  18903. private _useObjectSpaceNormalMap;
  18904. /**
  18905. * Allows using an object space normal map (instead of tangent space).
  18906. */
  18907. useObjectSpaceNormalMap: boolean;
  18908. private _useParallax;
  18909. /**
  18910. * Is parallax enabled or not.
  18911. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18912. */
  18913. useParallax: boolean;
  18914. private _useParallaxOcclusion;
  18915. /**
  18916. * Is parallax occlusion enabled or not.
  18917. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  18918. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  18919. */
  18920. useParallaxOcclusion: boolean;
  18921. /**
  18922. * 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.
  18923. */
  18924. parallaxScaleBias: number;
  18925. private _roughness;
  18926. /**
  18927. * Helps to define how blurry the reflections should appears in the material.
  18928. */
  18929. roughness: number;
  18930. /**
  18931. * In case of refraction, define the value of the index of refraction.
  18932. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18933. */
  18934. indexOfRefraction: number;
  18935. /**
  18936. * Invert the refraction texture alongside the y axis.
  18937. * It can be useful with procedural textures or probe for instance.
  18938. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  18939. */
  18940. invertRefractionY: boolean;
  18941. /**
  18942. * Defines the alpha limits in alpha test mode.
  18943. */
  18944. alphaCutOff: number;
  18945. private _useLightmapAsShadowmap;
  18946. /**
  18947. * In case of light mapping, define whether the map contains light or shadow informations.
  18948. */
  18949. useLightmapAsShadowmap: boolean;
  18950. private _diffuseFresnelParameters;
  18951. /**
  18952. * Define the diffuse fresnel parameters of the material.
  18953. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18954. */
  18955. diffuseFresnelParameters: FresnelParameters;
  18956. private _opacityFresnelParameters;
  18957. /**
  18958. * Define the opacity fresnel parameters of the material.
  18959. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18960. */
  18961. opacityFresnelParameters: FresnelParameters;
  18962. private _reflectionFresnelParameters;
  18963. /**
  18964. * Define the reflection fresnel parameters of the material.
  18965. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18966. */
  18967. reflectionFresnelParameters: FresnelParameters;
  18968. private _refractionFresnelParameters;
  18969. /**
  18970. * Define the refraction fresnel parameters of the material.
  18971. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18972. */
  18973. refractionFresnelParameters: FresnelParameters;
  18974. private _emissiveFresnelParameters;
  18975. /**
  18976. * Define the emissive fresnel parameters of the material.
  18977. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18978. */
  18979. emissiveFresnelParameters: FresnelParameters;
  18980. private _useReflectionFresnelFromSpecular;
  18981. /**
  18982. * If true automatically deducts the fresnels values from the material specularity.
  18983. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18984. */
  18985. useReflectionFresnelFromSpecular: boolean;
  18986. private _useGlossinessFromSpecularMapAlpha;
  18987. /**
  18988. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  18989. */
  18990. useGlossinessFromSpecularMapAlpha: boolean;
  18991. private _maxSimultaneousLights;
  18992. /**
  18993. * Defines the maximum number of lights that can be used in the material
  18994. */
  18995. maxSimultaneousLights: number;
  18996. private _invertNormalMapX;
  18997. /**
  18998. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  18999. */
  19000. invertNormalMapX: boolean;
  19001. private _invertNormalMapY;
  19002. /**
  19003. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19004. */
  19005. invertNormalMapY: boolean;
  19006. private _twoSidedLighting;
  19007. /**
  19008. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19009. */
  19010. twoSidedLighting: boolean;
  19011. /**
  19012. * Default configuration related to image processing available in the standard Material.
  19013. */
  19014. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19015. /**
  19016. * Gets the image processing configuration used either in this material.
  19017. */
  19018. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19019. /**
  19020. * Sets the Default image processing configuration used either in the this material.
  19021. *
  19022. * If sets to null, the scene one is in use.
  19023. */
  19024. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19025. /**
  19026. * Keep track of the image processing observer to allow dispose and replace.
  19027. */
  19028. private _imageProcessingObserver;
  19029. /**
  19030. * Attaches a new image processing configuration to the Standard Material.
  19031. * @param configuration
  19032. */
  19033. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19034. /**
  19035. * Defines additionnal PrePass parameters for the material.
  19036. */
  19037. readonly prePassConfiguration: PrePassConfiguration;
  19038. /**
  19039. * Gets wether the color curves effect is enabled.
  19040. */
  19041. get cameraColorCurvesEnabled(): boolean;
  19042. /**
  19043. * Sets wether the color curves effect is enabled.
  19044. */
  19045. set cameraColorCurvesEnabled(value: boolean);
  19046. /**
  19047. * Gets wether the color grading effect is enabled.
  19048. */
  19049. get cameraColorGradingEnabled(): boolean;
  19050. /**
  19051. * Gets wether the color grading effect is enabled.
  19052. */
  19053. set cameraColorGradingEnabled(value: boolean);
  19054. /**
  19055. * Gets wether tonemapping is enabled or not.
  19056. */
  19057. get cameraToneMappingEnabled(): boolean;
  19058. /**
  19059. * Sets wether tonemapping is enabled or not
  19060. */
  19061. set cameraToneMappingEnabled(value: boolean);
  19062. /**
  19063. * The camera exposure used on this material.
  19064. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19065. * This corresponds to a photographic exposure.
  19066. */
  19067. get cameraExposure(): number;
  19068. /**
  19069. * The camera exposure used on this material.
  19070. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19071. * This corresponds to a photographic exposure.
  19072. */
  19073. set cameraExposure(value: number);
  19074. /**
  19075. * Gets The camera contrast used on this material.
  19076. */
  19077. get cameraContrast(): number;
  19078. /**
  19079. * Sets The camera contrast used on this material.
  19080. */
  19081. set cameraContrast(value: number);
  19082. /**
  19083. * Gets the Color Grading 2D Lookup Texture.
  19084. */
  19085. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19086. /**
  19087. * Sets the Color Grading 2D Lookup Texture.
  19088. */
  19089. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19090. /**
  19091. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19092. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19093. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  19094. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19095. */
  19096. get cameraColorCurves(): Nullable<ColorCurves>;
  19097. /**
  19098. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19099. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19100. * 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;
  19101. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19102. */
  19103. set cameraColorCurves(value: Nullable<ColorCurves>);
  19104. /**
  19105. * Can this material render to several textures at once
  19106. */
  19107. get canRenderToMRT(): boolean;
  19108. /**
  19109. * Defines the detail map parameters for the material.
  19110. */
  19111. readonly detailMap: DetailMapConfiguration;
  19112. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19113. protected _worldViewProjectionMatrix: Matrix;
  19114. protected _globalAmbientColor: Color3;
  19115. protected _useLogarithmicDepth: boolean;
  19116. protected _rebuildInParallel: boolean;
  19117. /**
  19118. * Instantiates a new standard material.
  19119. * This is the default material used in Babylon. It is the best trade off between quality
  19120. * and performances.
  19121. * @see https://doc.babylonjs.com/babylon101/materials
  19122. * @param name Define the name of the material in the scene
  19123. * @param scene Define the scene the material belong to
  19124. */
  19125. constructor(name: string, scene: Scene);
  19126. /**
  19127. * Gets a boolean indicating that current material needs to register RTT
  19128. */
  19129. get hasRenderTargetTextures(): boolean;
  19130. /**
  19131. * Gets the current class name of the material e.g. "StandardMaterial"
  19132. * Mainly use in serialization.
  19133. * @returns the class name
  19134. */
  19135. getClassName(): string;
  19136. /**
  19137. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19138. * You can try switching to logarithmic depth.
  19139. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19140. */
  19141. get useLogarithmicDepth(): boolean;
  19142. set useLogarithmicDepth(value: boolean);
  19143. /**
  19144. * Specifies if the material will require alpha blending
  19145. * @returns a boolean specifying if alpha blending is needed
  19146. */
  19147. needAlphaBlending(): boolean;
  19148. /**
  19149. * Specifies if this material should be rendered in alpha test mode
  19150. * @returns a boolean specifying if an alpha test is needed.
  19151. */
  19152. needAlphaTesting(): boolean;
  19153. /**
  19154. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19155. */
  19156. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19157. /**
  19158. * Specifies whether or not there is a usable alpha channel for transparency.
  19159. */
  19160. protected _hasAlphaChannel(): boolean;
  19161. /**
  19162. * Get the texture used for alpha test purpose.
  19163. * @returns the diffuse texture in case of the standard material.
  19164. */
  19165. getAlphaTestTexture(): Nullable<BaseTexture>;
  19166. /**
  19167. * Get if the submesh is ready to be used and all its information available.
  19168. * Child classes can use it to update shaders
  19169. * @param mesh defines the mesh to check
  19170. * @param subMesh defines which submesh to check
  19171. * @param useInstances specifies that instances should be used
  19172. * @returns a boolean indicating that the submesh is ready or not
  19173. */
  19174. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19175. /**
  19176. * Builds the material UBO layouts.
  19177. * Used internally during the effect preparation.
  19178. */
  19179. buildUniformLayout(): void;
  19180. /**
  19181. * Unbinds the material from the mesh
  19182. */
  19183. unbind(): void;
  19184. /**
  19185. * Binds the submesh to this material by preparing the effect and shader to draw
  19186. * @param world defines the world transformation matrix
  19187. * @param mesh defines the mesh containing the submesh
  19188. * @param subMesh defines the submesh to bind the material to
  19189. */
  19190. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19191. /**
  19192. * Get the list of animatables in the material.
  19193. * @returns the list of animatables object used in the material
  19194. */
  19195. getAnimatables(): IAnimatable[];
  19196. /**
  19197. * Gets the active textures from the material
  19198. * @returns an array of textures
  19199. */
  19200. getActiveTextures(): BaseTexture[];
  19201. /**
  19202. * Specifies if the material uses a texture
  19203. * @param texture defines the texture to check against the material
  19204. * @returns a boolean specifying if the material uses the texture
  19205. */
  19206. hasTexture(texture: BaseTexture): boolean;
  19207. /**
  19208. * Disposes the material
  19209. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19210. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19211. */
  19212. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19213. /**
  19214. * Makes a duplicate of the material, and gives it a new name
  19215. * @param name defines the new name for the duplicated material
  19216. * @returns the cloned material
  19217. */
  19218. clone(name: string): StandardMaterial;
  19219. /**
  19220. * Serializes this material in a JSON representation
  19221. * @returns the serialized material object
  19222. */
  19223. serialize(): any;
  19224. /**
  19225. * Creates a standard material from parsed material data
  19226. * @param source defines the JSON representation of the material
  19227. * @param scene defines the hosting scene
  19228. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19229. * @returns a new standard material
  19230. */
  19231. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19232. /**
  19233. * Are diffuse textures enabled in the application.
  19234. */
  19235. static get DiffuseTextureEnabled(): boolean;
  19236. static set DiffuseTextureEnabled(value: boolean);
  19237. /**
  19238. * Are detail textures enabled in the application.
  19239. */
  19240. static get DetailTextureEnabled(): boolean;
  19241. static set DetailTextureEnabled(value: boolean);
  19242. /**
  19243. * Are ambient textures enabled in the application.
  19244. */
  19245. static get AmbientTextureEnabled(): boolean;
  19246. static set AmbientTextureEnabled(value: boolean);
  19247. /**
  19248. * Are opacity textures enabled in the application.
  19249. */
  19250. static get OpacityTextureEnabled(): boolean;
  19251. static set OpacityTextureEnabled(value: boolean);
  19252. /**
  19253. * Are reflection textures enabled in the application.
  19254. */
  19255. static get ReflectionTextureEnabled(): boolean;
  19256. static set ReflectionTextureEnabled(value: boolean);
  19257. /**
  19258. * Are emissive textures enabled in the application.
  19259. */
  19260. static get EmissiveTextureEnabled(): boolean;
  19261. static set EmissiveTextureEnabled(value: boolean);
  19262. /**
  19263. * Are specular textures enabled in the application.
  19264. */
  19265. static get SpecularTextureEnabled(): boolean;
  19266. static set SpecularTextureEnabled(value: boolean);
  19267. /**
  19268. * Are bump textures enabled in the application.
  19269. */
  19270. static get BumpTextureEnabled(): boolean;
  19271. static set BumpTextureEnabled(value: boolean);
  19272. /**
  19273. * Are lightmap textures enabled in the application.
  19274. */
  19275. static get LightmapTextureEnabled(): boolean;
  19276. static set LightmapTextureEnabled(value: boolean);
  19277. /**
  19278. * Are refraction textures enabled in the application.
  19279. */
  19280. static get RefractionTextureEnabled(): boolean;
  19281. static set RefractionTextureEnabled(value: boolean);
  19282. /**
  19283. * Are color grading textures enabled in the application.
  19284. */
  19285. static get ColorGradingTextureEnabled(): boolean;
  19286. static set ColorGradingTextureEnabled(value: boolean);
  19287. /**
  19288. * Are fresnels enabled in the application.
  19289. */
  19290. static get FresnelEnabled(): boolean;
  19291. static set FresnelEnabled(value: boolean);
  19292. }
  19293. }
  19294. declare module BABYLON {
  19295. /** @hidden */
  19296. export var rgbdDecodePixelShader: {
  19297. name: string;
  19298. shader: string;
  19299. };
  19300. }
  19301. declare module BABYLON {
  19302. /**
  19303. * Class used to host RGBD texture specific utilities
  19304. */
  19305. export class RGBDTextureTools {
  19306. /**
  19307. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19308. * @param texture the texture to expand.
  19309. */
  19310. static ExpandRGBDTexture(texture: Texture): void;
  19311. }
  19312. }
  19313. declare module BABYLON {
  19314. /**
  19315. * Class used to host texture specific utilities
  19316. */
  19317. export class BRDFTextureTools {
  19318. /**
  19319. * Prevents texture cache collision
  19320. */
  19321. private static _instanceNumber;
  19322. /**
  19323. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  19324. * @param scene defines the hosting scene
  19325. * @returns the environment BRDF texture
  19326. */
  19327. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  19328. private static _environmentBRDFBase64Texture;
  19329. }
  19330. }
  19331. declare module BABYLON {
  19332. /**
  19333. * @hidden
  19334. */
  19335. export interface IMaterialClearCoatDefines {
  19336. CLEARCOAT: boolean;
  19337. CLEARCOAT_DEFAULTIOR: boolean;
  19338. CLEARCOAT_TEXTURE: boolean;
  19339. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  19340. CLEARCOAT_TEXTUREDIRECTUV: number;
  19341. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  19342. CLEARCOAT_BUMP: boolean;
  19343. CLEARCOAT_BUMPDIRECTUV: number;
  19344. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19345. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19346. CLEARCOAT_REMAP_F0: boolean;
  19347. CLEARCOAT_TINT: boolean;
  19348. CLEARCOAT_TINT_TEXTURE: boolean;
  19349. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  19350. /** @hidden */
  19351. _areTexturesDirty: boolean;
  19352. }
  19353. /**
  19354. * Define the code related to the clear coat parameters of the pbr material.
  19355. */
  19356. export class PBRClearCoatConfiguration {
  19357. /**
  19358. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19359. * The default fits with a polyurethane material.
  19360. * @hidden
  19361. */
  19362. static readonly _DefaultIndexOfRefraction: number;
  19363. private _isEnabled;
  19364. /**
  19365. * Defines if the clear coat is enabled in the material.
  19366. */
  19367. isEnabled: boolean;
  19368. /**
  19369. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  19370. */
  19371. intensity: number;
  19372. /**
  19373. * Defines the clear coat layer roughness.
  19374. */
  19375. roughness: number;
  19376. private _indexOfRefraction;
  19377. /**
  19378. * Defines the index of refraction of the clear coat.
  19379. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  19380. * The default fits with a polyurethane material.
  19381. * Changing the default value is more performance intensive.
  19382. */
  19383. indexOfRefraction: number;
  19384. private _texture;
  19385. /**
  19386. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  19387. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  19388. * if textureRoughness is not empty, else no texture roughness is used
  19389. */
  19390. texture: Nullable<BaseTexture>;
  19391. private _useRoughnessFromMainTexture;
  19392. /**
  19393. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  19394. * If false, the green channel from textureRoughness is used for roughness
  19395. */
  19396. useRoughnessFromMainTexture: boolean;
  19397. private _textureRoughness;
  19398. /**
  19399. * Stores the clear coat roughness in a texture (green channel)
  19400. * Not used if useRoughnessFromMainTexture is true
  19401. */
  19402. textureRoughness: Nullable<BaseTexture>;
  19403. private _remapF0OnInterfaceChange;
  19404. /**
  19405. * Defines if the F0 value should be remapped to account for the interface change in the material.
  19406. */
  19407. remapF0OnInterfaceChange: boolean;
  19408. private _bumpTexture;
  19409. /**
  19410. * Define the clear coat specific bump texture.
  19411. */
  19412. bumpTexture: Nullable<BaseTexture>;
  19413. private _isTintEnabled;
  19414. /**
  19415. * Defines if the clear coat tint is enabled in the material.
  19416. */
  19417. isTintEnabled: boolean;
  19418. /**
  19419. * Defines the clear coat tint of the material.
  19420. * This is only use if tint is enabled
  19421. */
  19422. tintColor: Color3;
  19423. /**
  19424. * Defines the distance at which the tint color should be found in the
  19425. * clear coat media.
  19426. * This is only use if tint is enabled
  19427. */
  19428. tintColorAtDistance: number;
  19429. /**
  19430. * Defines the clear coat layer thickness.
  19431. * This is only use if tint is enabled
  19432. */
  19433. tintThickness: number;
  19434. private _tintTexture;
  19435. /**
  19436. * Stores the clear tint values in a texture.
  19437. * rgb is tint
  19438. * a is a thickness factor
  19439. */
  19440. tintTexture: Nullable<BaseTexture>;
  19441. /** @hidden */
  19442. private _internalMarkAllSubMeshesAsTexturesDirty;
  19443. /** @hidden */
  19444. _markAllSubMeshesAsTexturesDirty(): void;
  19445. /**
  19446. * Instantiate a new istance of clear coat configuration.
  19447. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19448. */
  19449. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19450. /**
  19451. * Gets wehter the submesh is ready to be used or not.
  19452. * @param defines the list of "defines" to update.
  19453. * @param scene defines the scene the material belongs to.
  19454. * @param engine defines the engine the material belongs to.
  19455. * @param disableBumpMap defines wether the material disables bump or not.
  19456. * @returns - boolean indicating that the submesh is ready or not.
  19457. */
  19458. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  19459. /**
  19460. * Checks to see if a texture is used in the material.
  19461. * @param defines the list of "defines" to update.
  19462. * @param scene defines the scene to the material belongs to.
  19463. */
  19464. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  19465. /**
  19466. * Binds the material data.
  19467. * @param uniformBuffer defines the Uniform buffer to fill in.
  19468. * @param scene defines the scene the material belongs to.
  19469. * @param engine defines the engine the material belongs to.
  19470. * @param disableBumpMap defines wether the material disables bump or not.
  19471. * @param isFrozen defines wether the material is frozen or not.
  19472. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  19473. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  19474. * @param subMesh the submesh to bind data for
  19475. */
  19476. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  19477. /**
  19478. * Checks to see if a texture is used in the material.
  19479. * @param texture - Base texture to use.
  19480. * @returns - Boolean specifying if a texture is used in the material.
  19481. */
  19482. hasTexture(texture: BaseTexture): boolean;
  19483. /**
  19484. * Returns an array of the actively used textures.
  19485. * @param activeTextures Array of BaseTextures
  19486. */
  19487. getActiveTextures(activeTextures: BaseTexture[]): void;
  19488. /**
  19489. * Returns the animatable textures.
  19490. * @param animatables Array of animatable textures.
  19491. */
  19492. getAnimatables(animatables: IAnimatable[]): void;
  19493. /**
  19494. * Disposes the resources of the material.
  19495. * @param forceDisposeTextures - Forces the disposal of all textures.
  19496. */
  19497. dispose(forceDisposeTextures?: boolean): void;
  19498. /**
  19499. * Get the current class name of the texture useful for serialization or dynamic coding.
  19500. * @returns "PBRClearCoatConfiguration"
  19501. */
  19502. getClassName(): string;
  19503. /**
  19504. * Add fallbacks to the effect fallbacks list.
  19505. * @param defines defines the Base texture to use.
  19506. * @param fallbacks defines the current fallback list.
  19507. * @param currentRank defines the current fallback rank.
  19508. * @returns the new fallback rank.
  19509. */
  19510. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19511. /**
  19512. * Add the required uniforms to the current list.
  19513. * @param uniforms defines the current uniform list.
  19514. */
  19515. static AddUniforms(uniforms: string[]): void;
  19516. /**
  19517. * Add the required samplers to the current list.
  19518. * @param samplers defines the current sampler list.
  19519. */
  19520. static AddSamplers(samplers: string[]): void;
  19521. /**
  19522. * Add the required uniforms to the current buffer.
  19523. * @param uniformBuffer defines the current uniform buffer.
  19524. */
  19525. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19526. /**
  19527. * Makes a duplicate of the current configuration into another one.
  19528. * @param clearCoatConfiguration define the config where to copy the info
  19529. */
  19530. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  19531. /**
  19532. * Serializes this clear coat configuration.
  19533. * @returns - An object with the serialized config.
  19534. */
  19535. serialize(): any;
  19536. /**
  19537. * Parses a anisotropy Configuration from a serialized object.
  19538. * @param source - Serialized object.
  19539. * @param scene Defines the scene we are parsing for
  19540. * @param rootUrl Defines the rootUrl to load from
  19541. */
  19542. parse(source: any, scene: Scene, rootUrl: string): void;
  19543. }
  19544. }
  19545. declare module BABYLON {
  19546. /**
  19547. * @hidden
  19548. */
  19549. export interface IMaterialAnisotropicDefines {
  19550. ANISOTROPIC: boolean;
  19551. ANISOTROPIC_TEXTURE: boolean;
  19552. ANISOTROPIC_TEXTUREDIRECTUV: number;
  19553. MAINUV1: boolean;
  19554. _areTexturesDirty: boolean;
  19555. _needUVs: boolean;
  19556. }
  19557. /**
  19558. * Define the code related to the anisotropic parameters of the pbr material.
  19559. */
  19560. export class PBRAnisotropicConfiguration {
  19561. private _isEnabled;
  19562. /**
  19563. * Defines if the anisotropy is enabled in the material.
  19564. */
  19565. isEnabled: boolean;
  19566. /**
  19567. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  19568. */
  19569. intensity: number;
  19570. /**
  19571. * Defines if the effect is along the tangents, bitangents or in between.
  19572. * By default, the effect is "strectching" the highlights along the tangents.
  19573. */
  19574. direction: Vector2;
  19575. private _texture;
  19576. /**
  19577. * Stores the anisotropy values in a texture.
  19578. * rg is direction (like normal from -1 to 1)
  19579. * b is a intensity
  19580. */
  19581. texture: Nullable<BaseTexture>;
  19582. /** @hidden */
  19583. private _internalMarkAllSubMeshesAsTexturesDirty;
  19584. /** @hidden */
  19585. _markAllSubMeshesAsTexturesDirty(): void;
  19586. /**
  19587. * Instantiate a new istance of anisotropy configuration.
  19588. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19589. */
  19590. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19591. /**
  19592. * Specifies that the submesh is ready to be used.
  19593. * @param defines the list of "defines" to update.
  19594. * @param scene defines the scene the material belongs to.
  19595. * @returns - boolean indicating that the submesh is ready or not.
  19596. */
  19597. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  19598. /**
  19599. * Checks to see if a texture is used in the material.
  19600. * @param defines the list of "defines" to update.
  19601. * @param mesh the mesh we are preparing the defines for.
  19602. * @param scene defines the scene the material belongs to.
  19603. */
  19604. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  19605. /**
  19606. * Binds the material data.
  19607. * @param uniformBuffer defines the Uniform buffer to fill in.
  19608. * @param scene defines the scene the material belongs to.
  19609. * @param isFrozen defines wether the material is frozen or not.
  19610. */
  19611. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19612. /**
  19613. * Checks to see if a texture is used in the material.
  19614. * @param texture - Base texture to use.
  19615. * @returns - Boolean specifying if a texture is used in the material.
  19616. */
  19617. hasTexture(texture: BaseTexture): boolean;
  19618. /**
  19619. * Returns an array of the actively used textures.
  19620. * @param activeTextures Array of BaseTextures
  19621. */
  19622. getActiveTextures(activeTextures: BaseTexture[]): void;
  19623. /**
  19624. * Returns the animatable textures.
  19625. * @param animatables Array of animatable textures.
  19626. */
  19627. getAnimatables(animatables: IAnimatable[]): void;
  19628. /**
  19629. * Disposes the resources of the material.
  19630. * @param forceDisposeTextures - Forces the disposal of all textures.
  19631. */
  19632. dispose(forceDisposeTextures?: boolean): void;
  19633. /**
  19634. * Get the current class name of the texture useful for serialization or dynamic coding.
  19635. * @returns "PBRAnisotropicConfiguration"
  19636. */
  19637. getClassName(): string;
  19638. /**
  19639. * Add fallbacks to the effect fallbacks list.
  19640. * @param defines defines the Base texture to use.
  19641. * @param fallbacks defines the current fallback list.
  19642. * @param currentRank defines the current fallback rank.
  19643. * @returns the new fallback rank.
  19644. */
  19645. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19646. /**
  19647. * Add the required uniforms to the current list.
  19648. * @param uniforms defines the current uniform list.
  19649. */
  19650. static AddUniforms(uniforms: string[]): void;
  19651. /**
  19652. * Add the required uniforms to the current buffer.
  19653. * @param uniformBuffer defines the current uniform buffer.
  19654. */
  19655. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19656. /**
  19657. * Add the required samplers to the current list.
  19658. * @param samplers defines the current sampler list.
  19659. */
  19660. static AddSamplers(samplers: string[]): void;
  19661. /**
  19662. * Makes a duplicate of the current configuration into another one.
  19663. * @param anisotropicConfiguration define the config where to copy the info
  19664. */
  19665. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  19666. /**
  19667. * Serializes this anisotropy configuration.
  19668. * @returns - An object with the serialized config.
  19669. */
  19670. serialize(): any;
  19671. /**
  19672. * Parses a anisotropy Configuration from a serialized object.
  19673. * @param source - Serialized object.
  19674. * @param scene Defines the scene we are parsing for
  19675. * @param rootUrl Defines the rootUrl to load from
  19676. */
  19677. parse(source: any, scene: Scene, rootUrl: string): void;
  19678. }
  19679. }
  19680. declare module BABYLON {
  19681. /**
  19682. * @hidden
  19683. */
  19684. export interface IMaterialBRDFDefines {
  19685. BRDF_V_HEIGHT_CORRELATED: boolean;
  19686. MS_BRDF_ENERGY_CONSERVATION: boolean;
  19687. SPHERICAL_HARMONICS: boolean;
  19688. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  19689. /** @hidden */
  19690. _areMiscDirty: boolean;
  19691. }
  19692. /**
  19693. * Define the code related to the BRDF parameters of the pbr material.
  19694. */
  19695. export class PBRBRDFConfiguration {
  19696. /**
  19697. * Default value used for the energy conservation.
  19698. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19699. */
  19700. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  19701. /**
  19702. * Default value used for the Smith Visibility Height Correlated mode.
  19703. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  19704. */
  19705. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  19706. /**
  19707. * Default value used for the IBL diffuse part.
  19708. * This can help switching back to the polynomials mode globally which is a tiny bit
  19709. * less GPU intensive at the drawback of a lower quality.
  19710. */
  19711. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  19712. /**
  19713. * Default value used for activating energy conservation for the specular workflow.
  19714. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19715. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19716. */
  19717. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  19718. private _useEnergyConservation;
  19719. /**
  19720. * Defines if the material uses energy conservation.
  19721. */
  19722. useEnergyConservation: boolean;
  19723. private _useSmithVisibilityHeightCorrelated;
  19724. /**
  19725. * LEGACY Mode set to false
  19726. * Defines if the material uses height smith correlated visibility term.
  19727. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  19728. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  19729. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  19730. * Not relying on height correlated will also disable energy conservation.
  19731. */
  19732. useSmithVisibilityHeightCorrelated: boolean;
  19733. private _useSphericalHarmonics;
  19734. /**
  19735. * LEGACY Mode set to false
  19736. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  19737. * diffuse part of the IBL.
  19738. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  19739. * to the ground truth.
  19740. */
  19741. useSphericalHarmonics: boolean;
  19742. private _useSpecularGlossinessInputEnergyConservation;
  19743. /**
  19744. * Defines if the material uses energy conservation, when the specular workflow is active.
  19745. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  19746. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  19747. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  19748. */
  19749. useSpecularGlossinessInputEnergyConservation: boolean;
  19750. /** @hidden */
  19751. private _internalMarkAllSubMeshesAsMiscDirty;
  19752. /** @hidden */
  19753. _markAllSubMeshesAsMiscDirty(): void;
  19754. /**
  19755. * Instantiate a new istance of clear coat configuration.
  19756. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  19757. */
  19758. constructor(markAllSubMeshesAsMiscDirty: () => void);
  19759. /**
  19760. * Checks to see if a texture is used in the material.
  19761. * @param defines the list of "defines" to update.
  19762. */
  19763. prepareDefines(defines: IMaterialBRDFDefines): void;
  19764. /**
  19765. * Get the current class name of the texture useful for serialization or dynamic coding.
  19766. * @returns "PBRClearCoatConfiguration"
  19767. */
  19768. getClassName(): string;
  19769. /**
  19770. * Makes a duplicate of the current configuration into another one.
  19771. * @param brdfConfiguration define the config where to copy the info
  19772. */
  19773. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  19774. /**
  19775. * Serializes this BRDF configuration.
  19776. * @returns - An object with the serialized config.
  19777. */
  19778. serialize(): any;
  19779. /**
  19780. * Parses a anisotropy Configuration from a serialized object.
  19781. * @param source - Serialized object.
  19782. * @param scene Defines the scene we are parsing for
  19783. * @param rootUrl Defines the rootUrl to load from
  19784. */
  19785. parse(source: any, scene: Scene, rootUrl: string): void;
  19786. }
  19787. }
  19788. declare module BABYLON {
  19789. /**
  19790. * @hidden
  19791. */
  19792. export interface IMaterialSheenDefines {
  19793. SHEEN: boolean;
  19794. SHEEN_TEXTURE: boolean;
  19795. SHEEN_TEXTURE_ROUGHNESS: boolean;
  19796. SHEEN_TEXTUREDIRECTUV: number;
  19797. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  19798. SHEEN_LINKWITHALBEDO: boolean;
  19799. SHEEN_ROUGHNESS: boolean;
  19800. SHEEN_ALBEDOSCALING: boolean;
  19801. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  19802. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  19803. /** @hidden */
  19804. _areTexturesDirty: boolean;
  19805. }
  19806. /**
  19807. * Define the code related to the Sheen parameters of the pbr material.
  19808. */
  19809. export class PBRSheenConfiguration {
  19810. private _isEnabled;
  19811. /**
  19812. * Defines if the material uses sheen.
  19813. */
  19814. isEnabled: boolean;
  19815. private _linkSheenWithAlbedo;
  19816. /**
  19817. * Defines if the sheen is linked to the sheen color.
  19818. */
  19819. linkSheenWithAlbedo: boolean;
  19820. /**
  19821. * Defines the sheen intensity.
  19822. */
  19823. intensity: number;
  19824. /**
  19825. * Defines the sheen color.
  19826. */
  19827. color: Color3;
  19828. private _texture;
  19829. /**
  19830. * Stores the sheen tint values in a texture.
  19831. * rgb is tint
  19832. * 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)
  19833. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  19834. */
  19835. texture: Nullable<BaseTexture>;
  19836. private _useRoughnessFromMainTexture;
  19837. /**
  19838. * Indicates that the alpha channel of the texture property will be used for roughness.
  19839. * Has no effect if the roughness (and texture!) property is not defined
  19840. */
  19841. useRoughnessFromMainTexture: boolean;
  19842. private _roughness;
  19843. /**
  19844. * Defines the sheen roughness.
  19845. * It is not taken into account if linkSheenWithAlbedo is true.
  19846. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  19847. */
  19848. roughness: Nullable<number>;
  19849. private _textureRoughness;
  19850. /**
  19851. * Stores the sheen roughness in a texture.
  19852. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  19853. */
  19854. textureRoughness: Nullable<BaseTexture>;
  19855. private _albedoScaling;
  19856. /**
  19857. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  19858. * It allows the strength of the sheen effect to not depend on the base color of the material,
  19859. * making it easier to setup and tweak the effect
  19860. */
  19861. albedoScaling: boolean;
  19862. /** @hidden */
  19863. private _internalMarkAllSubMeshesAsTexturesDirty;
  19864. /** @hidden */
  19865. _markAllSubMeshesAsTexturesDirty(): void;
  19866. /**
  19867. * Instantiate a new istance of clear coat configuration.
  19868. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19869. */
  19870. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19871. /**
  19872. * Specifies that the submesh is ready to be used.
  19873. * @param defines the list of "defines" to update.
  19874. * @param scene defines the scene the material belongs to.
  19875. * @returns - boolean indicating that the submesh is ready or not.
  19876. */
  19877. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  19878. /**
  19879. * Checks to see if a texture is used in the material.
  19880. * @param defines the list of "defines" to update.
  19881. * @param scene defines the scene the material belongs to.
  19882. */
  19883. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  19884. /**
  19885. * Binds the material data.
  19886. * @param uniformBuffer defines the Uniform buffer to fill in.
  19887. * @param scene defines the scene the material belongs to.
  19888. * @param isFrozen defines wether the material is frozen or not.
  19889. * @param subMesh the submesh to bind data for
  19890. */
  19891. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  19892. /**
  19893. * Checks to see if a texture is used in the material.
  19894. * @param texture - Base texture to use.
  19895. * @returns - Boolean specifying if a texture is used in the material.
  19896. */
  19897. hasTexture(texture: BaseTexture): boolean;
  19898. /**
  19899. * Returns an array of the actively used textures.
  19900. * @param activeTextures Array of BaseTextures
  19901. */
  19902. getActiveTextures(activeTextures: BaseTexture[]): void;
  19903. /**
  19904. * Returns the animatable textures.
  19905. * @param animatables Array of animatable textures.
  19906. */
  19907. getAnimatables(animatables: IAnimatable[]): void;
  19908. /**
  19909. * Disposes the resources of the material.
  19910. * @param forceDisposeTextures - Forces the disposal of all textures.
  19911. */
  19912. dispose(forceDisposeTextures?: boolean): void;
  19913. /**
  19914. * Get the current class name of the texture useful for serialization or dynamic coding.
  19915. * @returns "PBRSheenConfiguration"
  19916. */
  19917. getClassName(): string;
  19918. /**
  19919. * Add fallbacks to the effect fallbacks list.
  19920. * @param defines defines the Base texture to use.
  19921. * @param fallbacks defines the current fallback list.
  19922. * @param currentRank defines the current fallback rank.
  19923. * @returns the new fallback rank.
  19924. */
  19925. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  19926. /**
  19927. * Add the required uniforms to the current list.
  19928. * @param uniforms defines the current uniform list.
  19929. */
  19930. static AddUniforms(uniforms: string[]): void;
  19931. /**
  19932. * Add the required uniforms to the current buffer.
  19933. * @param uniformBuffer defines the current uniform buffer.
  19934. */
  19935. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19936. /**
  19937. * Add the required samplers to the current list.
  19938. * @param samplers defines the current sampler list.
  19939. */
  19940. static AddSamplers(samplers: string[]): void;
  19941. /**
  19942. * Makes a duplicate of the current configuration into another one.
  19943. * @param sheenConfiguration define the config where to copy the info
  19944. */
  19945. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  19946. /**
  19947. * Serializes this BRDF configuration.
  19948. * @returns - An object with the serialized config.
  19949. */
  19950. serialize(): any;
  19951. /**
  19952. * Parses a anisotropy Configuration from a serialized object.
  19953. * @param source - Serialized object.
  19954. * @param scene Defines the scene we are parsing for
  19955. * @param rootUrl Defines the rootUrl to load from
  19956. */
  19957. parse(source: any, scene: Scene, rootUrl: string): void;
  19958. }
  19959. }
  19960. declare module BABYLON {
  19961. /**
  19962. * @hidden
  19963. */
  19964. export interface IMaterialSubSurfaceDefines {
  19965. SUBSURFACE: boolean;
  19966. SS_REFRACTION: boolean;
  19967. SS_TRANSLUCENCY: boolean;
  19968. SS_SCATTERING: boolean;
  19969. SS_THICKNESSANDMASK_TEXTURE: boolean;
  19970. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  19971. SS_REFRACTIONMAP_3D: boolean;
  19972. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  19973. SS_LODINREFRACTIONALPHA: boolean;
  19974. SS_GAMMAREFRACTION: boolean;
  19975. SS_RGBDREFRACTION: boolean;
  19976. SS_LINEARSPECULARREFRACTION: boolean;
  19977. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  19978. SS_ALBEDOFORREFRACTIONTINT: boolean;
  19979. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  19980. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  19981. /** @hidden */
  19982. _areTexturesDirty: boolean;
  19983. }
  19984. /**
  19985. * Define the code related to the sub surface parameters of the pbr material.
  19986. */
  19987. export class PBRSubSurfaceConfiguration {
  19988. private _isRefractionEnabled;
  19989. /**
  19990. * Defines if the refraction is enabled in the material.
  19991. */
  19992. isRefractionEnabled: boolean;
  19993. private _isTranslucencyEnabled;
  19994. /**
  19995. * Defines if the translucency is enabled in the material.
  19996. */
  19997. isTranslucencyEnabled: boolean;
  19998. private _isScatteringEnabled;
  19999. /**
  20000. * Defines if the sub surface scattering is enabled in the material.
  20001. */
  20002. isScatteringEnabled: boolean;
  20003. private _scatteringDiffusionProfileIndex;
  20004. /**
  20005. * Diffusion profile for subsurface scattering.
  20006. * Useful for better scattering in the skins or foliages.
  20007. */
  20008. get scatteringDiffusionProfile(): Nullable<Color3>;
  20009. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20010. /**
  20011. * Defines the refraction intensity of the material.
  20012. * The refraction when enabled replaces the Diffuse part of the material.
  20013. * The intensity helps transitionning between diffuse and refraction.
  20014. */
  20015. refractionIntensity: number;
  20016. /**
  20017. * Defines the translucency intensity of the material.
  20018. * When translucency has been enabled, this defines how much of the "translucency"
  20019. * is addded to the diffuse part of the material.
  20020. */
  20021. translucencyIntensity: number;
  20022. /**
  20023. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20024. */
  20025. useAlbedoToTintRefraction: boolean;
  20026. private _thicknessTexture;
  20027. /**
  20028. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20029. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20030. * 0 would mean minimumThickness
  20031. * 1 would mean maximumThickness
  20032. * The other channels might be use as a mask to vary the different effects intensity.
  20033. */
  20034. thicknessTexture: Nullable<BaseTexture>;
  20035. private _refractionTexture;
  20036. /**
  20037. * Defines the texture to use for refraction.
  20038. */
  20039. refractionTexture: Nullable<BaseTexture>;
  20040. private _indexOfRefraction;
  20041. /**
  20042. * Index of refraction of the material base layer.
  20043. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20044. *
  20045. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20046. *
  20047. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20048. */
  20049. indexOfRefraction: number;
  20050. private _volumeIndexOfRefraction;
  20051. /**
  20052. * Index of refraction of the material's volume.
  20053. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20054. *
  20055. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20056. * the volume will use the same IOR as the surface.
  20057. */
  20058. get volumeIndexOfRefraction(): number;
  20059. set volumeIndexOfRefraction(value: number);
  20060. private _invertRefractionY;
  20061. /**
  20062. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20063. */
  20064. invertRefractionY: boolean;
  20065. private _linkRefractionWithTransparency;
  20066. /**
  20067. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20068. * Materials half opaque for instance using refraction could benefit from this control.
  20069. */
  20070. linkRefractionWithTransparency: boolean;
  20071. /**
  20072. * Defines the minimum thickness stored in the thickness map.
  20073. * If no thickness map is defined, this value will be used to simulate thickness.
  20074. */
  20075. minimumThickness: number;
  20076. /**
  20077. * Defines the maximum thickness stored in the thickness map.
  20078. */
  20079. maximumThickness: number;
  20080. /**
  20081. * Defines the volume tint of the material.
  20082. * This is used for both translucency and scattering.
  20083. */
  20084. tintColor: Color3;
  20085. /**
  20086. * Defines the distance at which the tint color should be found in the media.
  20087. * This is used for refraction only.
  20088. */
  20089. tintColorAtDistance: number;
  20090. /**
  20091. * Defines how far each channel transmit through the media.
  20092. * It is defined as a color to simplify it selection.
  20093. */
  20094. diffusionDistance: Color3;
  20095. private _useMaskFromThicknessTexture;
  20096. /**
  20097. * Stores the intensity of the different subsurface effects in the thickness texture.
  20098. * * the green channel is the translucency intensity.
  20099. * * the blue channel is the scattering intensity.
  20100. * * the alpha channel is the refraction intensity.
  20101. */
  20102. useMaskFromThicknessTexture: boolean;
  20103. private _scene;
  20104. private _useMaskFromThicknessTextureGltf;
  20105. /**
  20106. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20107. * matches the channel-packing that is used by glTF.
  20108. * * the red channel is the transmission/translucency intensity.
  20109. * * the green channel is the thickness.
  20110. */
  20111. useMaskFromThicknessTextureGltf: boolean;
  20112. /** @hidden */
  20113. private _internalMarkAllSubMeshesAsTexturesDirty;
  20114. private _internalMarkScenePrePassDirty;
  20115. /** @hidden */
  20116. _markAllSubMeshesAsTexturesDirty(): void;
  20117. /** @hidden */
  20118. _markScenePrePassDirty(): void;
  20119. /**
  20120. * Instantiate a new istance of sub surface configuration.
  20121. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20122. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20123. * @param scene The scene
  20124. */
  20125. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20126. /**
  20127. * Gets wehter the submesh is ready to be used or not.
  20128. * @param defines the list of "defines" to update.
  20129. * @param scene defines the scene the material belongs to.
  20130. * @returns - boolean indicating that the submesh is ready or not.
  20131. */
  20132. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20133. /**
  20134. * Checks to see if a texture is used in the material.
  20135. * @param defines the list of "defines" to update.
  20136. * @param scene defines the scene to the material belongs to.
  20137. */
  20138. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20139. /**
  20140. * Binds the material data.
  20141. * @param uniformBuffer defines the Uniform buffer to fill in.
  20142. * @param scene defines the scene the material belongs to.
  20143. * @param engine defines the engine the material belongs to.
  20144. * @param isFrozen defines whether the material is frozen or not.
  20145. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20146. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20147. */
  20148. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20149. /**
  20150. * Unbinds the material from the mesh.
  20151. * @param activeEffect defines the effect that should be unbound from.
  20152. * @returns true if unbound, otherwise false
  20153. */
  20154. unbind(activeEffect: Effect): boolean;
  20155. /**
  20156. * Returns the texture used for refraction or null if none is used.
  20157. * @param scene defines the scene the material belongs to.
  20158. * @returns - Refraction texture if present. If no refraction texture and refraction
  20159. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20160. */
  20161. private _getRefractionTexture;
  20162. /**
  20163. * Returns true if alpha blending should be disabled.
  20164. */
  20165. get disableAlphaBlending(): boolean;
  20166. /**
  20167. * Fills the list of render target textures.
  20168. * @param renderTargets the list of render targets to update
  20169. */
  20170. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20171. /**
  20172. * Checks to see if a texture is used in the material.
  20173. * @param texture - Base texture to use.
  20174. * @returns - Boolean specifying if a texture is used in the material.
  20175. */
  20176. hasTexture(texture: BaseTexture): boolean;
  20177. /**
  20178. * Gets a boolean indicating that current material needs to register RTT
  20179. * @returns true if this uses a render target otherwise false.
  20180. */
  20181. hasRenderTargetTextures(): boolean;
  20182. /**
  20183. * Returns an array of the actively used textures.
  20184. * @param activeTextures Array of BaseTextures
  20185. */
  20186. getActiveTextures(activeTextures: BaseTexture[]): void;
  20187. /**
  20188. * Returns the animatable textures.
  20189. * @param animatables Array of animatable textures.
  20190. */
  20191. getAnimatables(animatables: IAnimatable[]): void;
  20192. /**
  20193. * Disposes the resources of the material.
  20194. * @param forceDisposeTextures - Forces the disposal of all textures.
  20195. */
  20196. dispose(forceDisposeTextures?: boolean): void;
  20197. /**
  20198. * Get the current class name of the texture useful for serialization or dynamic coding.
  20199. * @returns "PBRSubSurfaceConfiguration"
  20200. */
  20201. getClassName(): string;
  20202. /**
  20203. * Add fallbacks to the effect fallbacks list.
  20204. * @param defines defines the Base texture to use.
  20205. * @param fallbacks defines the current fallback list.
  20206. * @param currentRank defines the current fallback rank.
  20207. * @returns the new fallback rank.
  20208. */
  20209. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20210. /**
  20211. * Add the required uniforms to the current list.
  20212. * @param uniforms defines the current uniform list.
  20213. */
  20214. static AddUniforms(uniforms: string[]): void;
  20215. /**
  20216. * Add the required samplers to the current list.
  20217. * @param samplers defines the current sampler list.
  20218. */
  20219. static AddSamplers(samplers: string[]): void;
  20220. /**
  20221. * Add the required uniforms to the current buffer.
  20222. * @param uniformBuffer defines the current uniform buffer.
  20223. */
  20224. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20225. /**
  20226. * Makes a duplicate of the current configuration into another one.
  20227. * @param configuration define the config where to copy the info
  20228. */
  20229. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20230. /**
  20231. * Serializes this Sub Surface configuration.
  20232. * @returns - An object with the serialized config.
  20233. */
  20234. serialize(): any;
  20235. /**
  20236. * Parses a anisotropy Configuration from a serialized object.
  20237. * @param source - Serialized object.
  20238. * @param scene Defines the scene we are parsing for
  20239. * @param rootUrl Defines the rootUrl to load from
  20240. */
  20241. parse(source: any, scene: Scene, rootUrl: string): void;
  20242. }
  20243. }
  20244. declare module BABYLON {
  20245. /**
  20246. * Class representing spherical harmonics coefficients to the 3rd degree
  20247. */
  20248. export class SphericalHarmonics {
  20249. /**
  20250. * Defines whether or not the harmonics have been prescaled for rendering.
  20251. */
  20252. preScaled: boolean;
  20253. /**
  20254. * The l0,0 coefficients of the spherical harmonics
  20255. */
  20256. l00: Vector3;
  20257. /**
  20258. * The l1,-1 coefficients of the spherical harmonics
  20259. */
  20260. l1_1: Vector3;
  20261. /**
  20262. * The l1,0 coefficients of the spherical harmonics
  20263. */
  20264. l10: Vector3;
  20265. /**
  20266. * The l1,1 coefficients of the spherical harmonics
  20267. */
  20268. l11: Vector3;
  20269. /**
  20270. * The l2,-2 coefficients of the spherical harmonics
  20271. */
  20272. l2_2: Vector3;
  20273. /**
  20274. * The l2,-1 coefficients of the spherical harmonics
  20275. */
  20276. l2_1: Vector3;
  20277. /**
  20278. * The l2,0 coefficients of the spherical harmonics
  20279. */
  20280. l20: Vector3;
  20281. /**
  20282. * The l2,1 coefficients of the spherical harmonics
  20283. */
  20284. l21: Vector3;
  20285. /**
  20286. * The l2,2 coefficients of the spherical harmonics
  20287. */
  20288. l22: Vector3;
  20289. /**
  20290. * Adds a light to the spherical harmonics
  20291. * @param direction the direction of the light
  20292. * @param color the color of the light
  20293. * @param deltaSolidAngle the delta solid angle of the light
  20294. */
  20295. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20296. /**
  20297. * Scales the spherical harmonics by the given amount
  20298. * @param scale the amount to scale
  20299. */
  20300. scaleInPlace(scale: number): void;
  20301. /**
  20302. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20303. *
  20304. * ```
  20305. * E_lm = A_l * L_lm
  20306. * ```
  20307. *
  20308. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20309. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20310. * the scaling factors are given in equation 9.
  20311. */
  20312. convertIncidentRadianceToIrradiance(): void;
  20313. /**
  20314. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20315. *
  20316. * ```
  20317. * L = (1/pi) * E * rho
  20318. * ```
  20319. *
  20320. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  20321. */
  20322. convertIrradianceToLambertianRadiance(): void;
  20323. /**
  20324. * Integrates the reconstruction coefficients directly in to the SH preventing further
  20325. * required operations at run time.
  20326. *
  20327. * This is simply done by scaling back the SH with Ylm constants parameter.
  20328. * The trigonometric part being applied by the shader at run time.
  20329. */
  20330. preScaleForRendering(): void;
  20331. /**
  20332. * Constructs a spherical harmonics from an array.
  20333. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  20334. * @returns the spherical harmonics
  20335. */
  20336. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  20337. /**
  20338. * Gets the spherical harmonics from polynomial
  20339. * @param polynomial the spherical polynomial
  20340. * @returns the spherical harmonics
  20341. */
  20342. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  20343. }
  20344. /**
  20345. * Class representing spherical polynomial coefficients to the 3rd degree
  20346. */
  20347. export class SphericalPolynomial {
  20348. private _harmonics;
  20349. /**
  20350. * The spherical harmonics used to create the polynomials.
  20351. */
  20352. get preScaledHarmonics(): SphericalHarmonics;
  20353. /**
  20354. * The x coefficients of the spherical polynomial
  20355. */
  20356. x: Vector3;
  20357. /**
  20358. * The y coefficients of the spherical polynomial
  20359. */
  20360. y: Vector3;
  20361. /**
  20362. * The z coefficients of the spherical polynomial
  20363. */
  20364. z: Vector3;
  20365. /**
  20366. * The xx coefficients of the spherical polynomial
  20367. */
  20368. xx: Vector3;
  20369. /**
  20370. * The yy coefficients of the spherical polynomial
  20371. */
  20372. yy: Vector3;
  20373. /**
  20374. * The zz coefficients of the spherical polynomial
  20375. */
  20376. zz: Vector3;
  20377. /**
  20378. * The xy coefficients of the spherical polynomial
  20379. */
  20380. xy: Vector3;
  20381. /**
  20382. * The yz coefficients of the spherical polynomial
  20383. */
  20384. yz: Vector3;
  20385. /**
  20386. * The zx coefficients of the spherical polynomial
  20387. */
  20388. zx: Vector3;
  20389. /**
  20390. * Adds an ambient color to the spherical polynomial
  20391. * @param color the color to add
  20392. */
  20393. addAmbient(color: Color3): void;
  20394. /**
  20395. * Scales the spherical polynomial by the given amount
  20396. * @param scale the amount to scale
  20397. */
  20398. scaleInPlace(scale: number): void;
  20399. /**
  20400. * Gets the spherical polynomial from harmonics
  20401. * @param harmonics the spherical harmonics
  20402. * @returns the spherical polynomial
  20403. */
  20404. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  20405. /**
  20406. * Constructs a spherical polynomial from an array.
  20407. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  20408. * @returns the spherical polynomial
  20409. */
  20410. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  20411. }
  20412. }
  20413. declare module BABYLON {
  20414. /**
  20415. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  20416. */
  20417. export interface CubeMapInfo {
  20418. /**
  20419. * The pixel array for the front face.
  20420. * This is stored in format, left to right, up to down format.
  20421. */
  20422. front: Nullable<ArrayBufferView>;
  20423. /**
  20424. * The pixel array for the back face.
  20425. * This is stored in format, left to right, up to down format.
  20426. */
  20427. back: Nullable<ArrayBufferView>;
  20428. /**
  20429. * The pixel array for the left face.
  20430. * This is stored in format, left to right, up to down format.
  20431. */
  20432. left: Nullable<ArrayBufferView>;
  20433. /**
  20434. * The pixel array for the right face.
  20435. * This is stored in format, left to right, up to down format.
  20436. */
  20437. right: Nullable<ArrayBufferView>;
  20438. /**
  20439. * The pixel array for the up face.
  20440. * This is stored in format, left to right, up to down format.
  20441. */
  20442. up: Nullable<ArrayBufferView>;
  20443. /**
  20444. * The pixel array for the down face.
  20445. * This is stored in format, left to right, up to down format.
  20446. */
  20447. down: Nullable<ArrayBufferView>;
  20448. /**
  20449. * The size of the cubemap stored.
  20450. *
  20451. * Each faces will be size * size pixels.
  20452. */
  20453. size: number;
  20454. /**
  20455. * The format of the texture.
  20456. *
  20457. * RGBA, RGB.
  20458. */
  20459. format: number;
  20460. /**
  20461. * The type of the texture data.
  20462. *
  20463. * UNSIGNED_INT, FLOAT.
  20464. */
  20465. type: number;
  20466. /**
  20467. * Specifies whether the texture is in gamma space.
  20468. */
  20469. gammaSpace: boolean;
  20470. }
  20471. /**
  20472. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  20473. */
  20474. export class PanoramaToCubeMapTools {
  20475. private static FACE_LEFT;
  20476. private static FACE_RIGHT;
  20477. private static FACE_FRONT;
  20478. private static FACE_BACK;
  20479. private static FACE_DOWN;
  20480. private static FACE_UP;
  20481. /**
  20482. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  20483. *
  20484. * @param float32Array The source data.
  20485. * @param inputWidth The width of the input panorama.
  20486. * @param inputHeight The height of the input panorama.
  20487. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  20488. * @return The cubemap data
  20489. */
  20490. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  20491. private static CreateCubemapTexture;
  20492. private static CalcProjectionSpherical;
  20493. }
  20494. }
  20495. declare module BABYLON {
  20496. /**
  20497. * Helper class dealing with the extraction of spherical polynomial dataArray
  20498. * from a cube map.
  20499. */
  20500. export class CubeMapToSphericalPolynomialTools {
  20501. private static FileFaces;
  20502. /**
  20503. * Converts a texture to the according Spherical Polynomial data.
  20504. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20505. *
  20506. * @param texture The texture to extract the information from.
  20507. * @return The Spherical Polynomial data.
  20508. */
  20509. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  20510. /**
  20511. * Converts a cubemap to the according Spherical Polynomial data.
  20512. * This extracts the first 3 orders only as they are the only one used in the lighting.
  20513. *
  20514. * @param cubeInfo The Cube map to extract the information from.
  20515. * @return The Spherical Polynomial data.
  20516. */
  20517. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  20518. }
  20519. }
  20520. declare module BABYLON {
  20521. interface BaseTexture {
  20522. /**
  20523. * Get the polynomial representation of the texture data.
  20524. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  20525. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  20526. */
  20527. sphericalPolynomial: Nullable<SphericalPolynomial>;
  20528. }
  20529. }
  20530. declare module BABYLON {
  20531. /** @hidden */
  20532. export var pbrFragmentDeclaration: {
  20533. name: string;
  20534. shader: string;
  20535. };
  20536. }
  20537. declare module BABYLON {
  20538. /** @hidden */
  20539. export var pbrUboDeclaration: {
  20540. name: string;
  20541. shader: string;
  20542. };
  20543. }
  20544. declare module BABYLON {
  20545. /** @hidden */
  20546. export var pbrFragmentExtraDeclaration: {
  20547. name: string;
  20548. shader: string;
  20549. };
  20550. }
  20551. declare module BABYLON {
  20552. /** @hidden */
  20553. export var pbrFragmentSamplersDeclaration: {
  20554. name: string;
  20555. shader: string;
  20556. };
  20557. }
  20558. declare module BABYLON {
  20559. /** @hidden */
  20560. export var subSurfaceScatteringFunctions: {
  20561. name: string;
  20562. shader: string;
  20563. };
  20564. }
  20565. declare module BABYLON {
  20566. /** @hidden */
  20567. export var importanceSampling: {
  20568. name: string;
  20569. shader: string;
  20570. };
  20571. }
  20572. declare module BABYLON {
  20573. /** @hidden */
  20574. export var pbrHelperFunctions: {
  20575. name: string;
  20576. shader: string;
  20577. };
  20578. }
  20579. declare module BABYLON {
  20580. /** @hidden */
  20581. export var harmonicsFunctions: {
  20582. name: string;
  20583. shader: string;
  20584. };
  20585. }
  20586. declare module BABYLON {
  20587. /** @hidden */
  20588. export var pbrDirectLightingSetupFunctions: {
  20589. name: string;
  20590. shader: string;
  20591. };
  20592. }
  20593. declare module BABYLON {
  20594. /** @hidden */
  20595. export var pbrDirectLightingFalloffFunctions: {
  20596. name: string;
  20597. shader: string;
  20598. };
  20599. }
  20600. declare module BABYLON {
  20601. /** @hidden */
  20602. export var pbrBRDFFunctions: {
  20603. name: string;
  20604. shader: string;
  20605. };
  20606. }
  20607. declare module BABYLON {
  20608. /** @hidden */
  20609. export var hdrFilteringFunctions: {
  20610. name: string;
  20611. shader: string;
  20612. };
  20613. }
  20614. declare module BABYLON {
  20615. /** @hidden */
  20616. export var pbrDirectLightingFunctions: {
  20617. name: string;
  20618. shader: string;
  20619. };
  20620. }
  20621. declare module BABYLON {
  20622. /** @hidden */
  20623. export var pbrIBLFunctions: {
  20624. name: string;
  20625. shader: string;
  20626. };
  20627. }
  20628. declare module BABYLON {
  20629. /** @hidden */
  20630. export var pbrBlockAlbedoOpacity: {
  20631. name: string;
  20632. shader: string;
  20633. };
  20634. }
  20635. declare module BABYLON {
  20636. /** @hidden */
  20637. export var pbrBlockReflectivity: {
  20638. name: string;
  20639. shader: string;
  20640. };
  20641. }
  20642. declare module BABYLON {
  20643. /** @hidden */
  20644. export var pbrBlockAmbientOcclusion: {
  20645. name: string;
  20646. shader: string;
  20647. };
  20648. }
  20649. declare module BABYLON {
  20650. /** @hidden */
  20651. export var pbrBlockAlphaFresnel: {
  20652. name: string;
  20653. shader: string;
  20654. };
  20655. }
  20656. declare module BABYLON {
  20657. /** @hidden */
  20658. export var pbrBlockAnisotropic: {
  20659. name: string;
  20660. shader: string;
  20661. };
  20662. }
  20663. declare module BABYLON {
  20664. /** @hidden */
  20665. export var pbrBlockReflection: {
  20666. name: string;
  20667. shader: string;
  20668. };
  20669. }
  20670. declare module BABYLON {
  20671. /** @hidden */
  20672. export var pbrBlockSheen: {
  20673. name: string;
  20674. shader: string;
  20675. };
  20676. }
  20677. declare module BABYLON {
  20678. /** @hidden */
  20679. export var pbrBlockClearcoat: {
  20680. name: string;
  20681. shader: string;
  20682. };
  20683. }
  20684. declare module BABYLON {
  20685. /** @hidden */
  20686. export var pbrBlockSubSurface: {
  20687. name: string;
  20688. shader: string;
  20689. };
  20690. }
  20691. declare module BABYLON {
  20692. /** @hidden */
  20693. export var pbrBlockNormalGeometric: {
  20694. name: string;
  20695. shader: string;
  20696. };
  20697. }
  20698. declare module BABYLON {
  20699. /** @hidden */
  20700. export var pbrBlockNormalFinal: {
  20701. name: string;
  20702. shader: string;
  20703. };
  20704. }
  20705. declare module BABYLON {
  20706. /** @hidden */
  20707. export var pbrBlockLightmapInit: {
  20708. name: string;
  20709. shader: string;
  20710. };
  20711. }
  20712. declare module BABYLON {
  20713. /** @hidden */
  20714. export var pbrBlockGeometryInfo: {
  20715. name: string;
  20716. shader: string;
  20717. };
  20718. }
  20719. declare module BABYLON {
  20720. /** @hidden */
  20721. export var pbrBlockReflectance0: {
  20722. name: string;
  20723. shader: string;
  20724. };
  20725. }
  20726. declare module BABYLON {
  20727. /** @hidden */
  20728. export var pbrBlockReflectance: {
  20729. name: string;
  20730. shader: string;
  20731. };
  20732. }
  20733. declare module BABYLON {
  20734. /** @hidden */
  20735. export var pbrBlockDirectLighting: {
  20736. name: string;
  20737. shader: string;
  20738. };
  20739. }
  20740. declare module BABYLON {
  20741. /** @hidden */
  20742. export var pbrBlockFinalLitComponents: {
  20743. name: string;
  20744. shader: string;
  20745. };
  20746. }
  20747. declare module BABYLON {
  20748. /** @hidden */
  20749. export var pbrBlockFinalUnlitComponents: {
  20750. name: string;
  20751. shader: string;
  20752. };
  20753. }
  20754. declare module BABYLON {
  20755. /** @hidden */
  20756. export var pbrBlockFinalColorComposition: {
  20757. name: string;
  20758. shader: string;
  20759. };
  20760. }
  20761. declare module BABYLON {
  20762. /** @hidden */
  20763. export var pbrBlockImageProcessing: {
  20764. name: string;
  20765. shader: string;
  20766. };
  20767. }
  20768. declare module BABYLON {
  20769. /** @hidden */
  20770. export var pbrDebug: {
  20771. name: string;
  20772. shader: string;
  20773. };
  20774. }
  20775. declare module BABYLON {
  20776. /** @hidden */
  20777. export var pbrPixelShader: {
  20778. name: string;
  20779. shader: string;
  20780. };
  20781. }
  20782. declare module BABYLON {
  20783. /** @hidden */
  20784. export var pbrVertexDeclaration: {
  20785. name: string;
  20786. shader: string;
  20787. };
  20788. }
  20789. declare module BABYLON {
  20790. /** @hidden */
  20791. export var pbrVertexShader: {
  20792. name: string;
  20793. shader: string;
  20794. };
  20795. }
  20796. declare module BABYLON {
  20797. /**
  20798. * Manages the defines for the PBR Material.
  20799. * @hidden
  20800. */
  20801. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  20802. PBR: boolean;
  20803. NUM_SAMPLES: string;
  20804. REALTIME_FILTERING: boolean;
  20805. MAINUV1: boolean;
  20806. MAINUV2: boolean;
  20807. UV1: boolean;
  20808. UV2: boolean;
  20809. ALBEDO: boolean;
  20810. GAMMAALBEDO: boolean;
  20811. ALBEDODIRECTUV: number;
  20812. VERTEXCOLOR: boolean;
  20813. DETAIL: boolean;
  20814. DETAILDIRECTUV: number;
  20815. DETAIL_NORMALBLENDMETHOD: number;
  20816. AMBIENT: boolean;
  20817. AMBIENTDIRECTUV: number;
  20818. AMBIENTINGRAYSCALE: boolean;
  20819. OPACITY: boolean;
  20820. VERTEXALPHA: boolean;
  20821. OPACITYDIRECTUV: number;
  20822. OPACITYRGB: boolean;
  20823. ALPHATEST: boolean;
  20824. DEPTHPREPASS: boolean;
  20825. ALPHABLEND: boolean;
  20826. ALPHAFROMALBEDO: boolean;
  20827. ALPHATESTVALUE: string;
  20828. SPECULAROVERALPHA: boolean;
  20829. RADIANCEOVERALPHA: boolean;
  20830. ALPHAFRESNEL: boolean;
  20831. LINEARALPHAFRESNEL: boolean;
  20832. PREMULTIPLYALPHA: boolean;
  20833. EMISSIVE: boolean;
  20834. EMISSIVEDIRECTUV: number;
  20835. REFLECTIVITY: boolean;
  20836. REFLECTIVITYDIRECTUV: number;
  20837. SPECULARTERM: boolean;
  20838. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  20839. MICROSURFACEAUTOMATIC: boolean;
  20840. LODBASEDMICROSFURACE: boolean;
  20841. MICROSURFACEMAP: boolean;
  20842. MICROSURFACEMAPDIRECTUV: number;
  20843. METALLICWORKFLOW: boolean;
  20844. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  20845. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  20846. METALLNESSSTOREINMETALMAPBLUE: boolean;
  20847. AOSTOREINMETALMAPRED: boolean;
  20848. METALLIC_REFLECTANCE: boolean;
  20849. METALLIC_REFLECTANCEDIRECTUV: number;
  20850. ENVIRONMENTBRDF: boolean;
  20851. ENVIRONMENTBRDF_RGBD: boolean;
  20852. NORMAL: boolean;
  20853. TANGENT: boolean;
  20854. BUMP: boolean;
  20855. BUMPDIRECTUV: number;
  20856. OBJECTSPACE_NORMALMAP: boolean;
  20857. PARALLAX: boolean;
  20858. PARALLAXOCCLUSION: boolean;
  20859. NORMALXYSCALE: boolean;
  20860. LIGHTMAP: boolean;
  20861. LIGHTMAPDIRECTUV: number;
  20862. USELIGHTMAPASSHADOWMAP: boolean;
  20863. GAMMALIGHTMAP: boolean;
  20864. RGBDLIGHTMAP: boolean;
  20865. REFLECTION: boolean;
  20866. REFLECTIONMAP_3D: boolean;
  20867. REFLECTIONMAP_SPHERICAL: boolean;
  20868. REFLECTIONMAP_PLANAR: boolean;
  20869. REFLECTIONMAP_CUBIC: boolean;
  20870. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  20871. REFLECTIONMAP_PROJECTION: boolean;
  20872. REFLECTIONMAP_SKYBOX: boolean;
  20873. REFLECTIONMAP_EXPLICIT: boolean;
  20874. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  20875. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  20876. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  20877. INVERTCUBICMAP: boolean;
  20878. USESPHERICALFROMREFLECTIONMAP: boolean;
  20879. USEIRRADIANCEMAP: boolean;
  20880. SPHERICAL_HARMONICS: boolean;
  20881. USESPHERICALINVERTEX: boolean;
  20882. REFLECTIONMAP_OPPOSITEZ: boolean;
  20883. LODINREFLECTIONALPHA: boolean;
  20884. GAMMAREFLECTION: boolean;
  20885. RGBDREFLECTION: boolean;
  20886. LINEARSPECULARREFLECTION: boolean;
  20887. RADIANCEOCCLUSION: boolean;
  20888. HORIZONOCCLUSION: boolean;
  20889. INSTANCES: boolean;
  20890. THIN_INSTANCES: boolean;
  20891. PREPASS: boolean;
  20892. PREPASS_IRRADIANCE: boolean;
  20893. PREPASS_IRRADIANCE_INDEX: number;
  20894. PREPASS_ALBEDO: boolean;
  20895. PREPASS_ALBEDO_INDEX: number;
  20896. PREPASS_DEPTHNORMAL: boolean;
  20897. PREPASS_DEPTHNORMAL_INDEX: number;
  20898. PREPASS_POSITION: boolean;
  20899. PREPASS_POSITION_INDEX: number;
  20900. PREPASS_VELOCITY: boolean;
  20901. PREPASS_VELOCITY_INDEX: number;
  20902. PREPASS_REFLECTIVITY: boolean;
  20903. PREPASS_REFLECTIVITY_INDEX: number;
  20904. SCENE_MRT_COUNT: number;
  20905. NUM_BONE_INFLUENCERS: number;
  20906. BonesPerMesh: number;
  20907. BONETEXTURE: boolean;
  20908. BONES_VELOCITY_ENABLED: boolean;
  20909. NONUNIFORMSCALING: boolean;
  20910. MORPHTARGETS: boolean;
  20911. MORPHTARGETS_NORMAL: boolean;
  20912. MORPHTARGETS_TANGENT: boolean;
  20913. MORPHTARGETS_UV: boolean;
  20914. NUM_MORPH_INFLUENCERS: number;
  20915. IMAGEPROCESSING: boolean;
  20916. VIGNETTE: boolean;
  20917. VIGNETTEBLENDMODEMULTIPLY: boolean;
  20918. VIGNETTEBLENDMODEOPAQUE: boolean;
  20919. TONEMAPPING: boolean;
  20920. TONEMAPPING_ACES: boolean;
  20921. CONTRAST: boolean;
  20922. COLORCURVES: boolean;
  20923. COLORGRADING: boolean;
  20924. COLORGRADING3D: boolean;
  20925. SAMPLER3DGREENDEPTH: boolean;
  20926. SAMPLER3DBGRMAP: boolean;
  20927. IMAGEPROCESSINGPOSTPROCESS: boolean;
  20928. EXPOSURE: boolean;
  20929. MULTIVIEW: boolean;
  20930. USEPHYSICALLIGHTFALLOFF: boolean;
  20931. USEGLTFLIGHTFALLOFF: boolean;
  20932. TWOSIDEDLIGHTING: boolean;
  20933. SHADOWFLOAT: boolean;
  20934. CLIPPLANE: boolean;
  20935. CLIPPLANE2: boolean;
  20936. CLIPPLANE3: boolean;
  20937. CLIPPLANE4: boolean;
  20938. CLIPPLANE5: boolean;
  20939. CLIPPLANE6: boolean;
  20940. POINTSIZE: boolean;
  20941. FOG: boolean;
  20942. LOGARITHMICDEPTH: boolean;
  20943. FORCENORMALFORWARD: boolean;
  20944. SPECULARAA: boolean;
  20945. CLEARCOAT: boolean;
  20946. CLEARCOAT_DEFAULTIOR: boolean;
  20947. CLEARCOAT_TEXTURE: boolean;
  20948. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20949. CLEARCOAT_TEXTUREDIRECTUV: number;
  20950. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20951. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20952. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20953. CLEARCOAT_BUMP: boolean;
  20954. CLEARCOAT_BUMPDIRECTUV: number;
  20955. CLEARCOAT_REMAP_F0: boolean;
  20956. CLEARCOAT_TINT: boolean;
  20957. CLEARCOAT_TINT_TEXTURE: boolean;
  20958. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20959. ANISOTROPIC: boolean;
  20960. ANISOTROPIC_TEXTURE: boolean;
  20961. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20962. BRDF_V_HEIGHT_CORRELATED: boolean;
  20963. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20964. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20965. SHEEN: boolean;
  20966. SHEEN_TEXTURE: boolean;
  20967. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20968. SHEEN_TEXTUREDIRECTUV: number;
  20969. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20970. SHEEN_LINKWITHALBEDO: boolean;
  20971. SHEEN_ROUGHNESS: boolean;
  20972. SHEEN_ALBEDOSCALING: boolean;
  20973. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20974. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20975. SUBSURFACE: boolean;
  20976. SS_REFRACTION: boolean;
  20977. SS_TRANSLUCENCY: boolean;
  20978. SS_SCATTERING: boolean;
  20979. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20980. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20981. SS_REFRACTIONMAP_3D: boolean;
  20982. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20983. SS_LODINREFRACTIONALPHA: boolean;
  20984. SS_GAMMAREFRACTION: boolean;
  20985. SS_RGBDREFRACTION: boolean;
  20986. SS_LINEARSPECULARREFRACTION: boolean;
  20987. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20988. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20989. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20990. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20991. UNLIT: boolean;
  20992. DEBUGMODE: number;
  20993. /**
  20994. * Initializes the PBR Material defines.
  20995. */
  20996. constructor();
  20997. /**
  20998. * Resets the PBR Material defines.
  20999. */
  21000. reset(): void;
  21001. }
  21002. /**
  21003. * The Physically based material base class of BJS.
  21004. *
  21005. * This offers the main features of a standard PBR material.
  21006. * For more information, please refer to the documentation :
  21007. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21008. */
  21009. export abstract class PBRBaseMaterial extends PushMaterial {
  21010. /**
  21011. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21012. */
  21013. static readonly PBRMATERIAL_OPAQUE: number;
  21014. /**
  21015. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21016. */
  21017. static readonly PBRMATERIAL_ALPHATEST: number;
  21018. /**
  21019. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21020. */
  21021. static readonly PBRMATERIAL_ALPHABLEND: number;
  21022. /**
  21023. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21024. * They are also discarded below the alpha cutoff threshold to improve performances.
  21025. */
  21026. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21027. /**
  21028. * Defines the default value of how much AO map is occluding the analytical lights
  21029. * (point spot...).
  21030. */
  21031. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21032. /**
  21033. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21034. */
  21035. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21036. /**
  21037. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21038. * to enhance interoperability with other engines.
  21039. */
  21040. static readonly LIGHTFALLOFF_GLTF: number;
  21041. /**
  21042. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21043. * to enhance interoperability with other materials.
  21044. */
  21045. static readonly LIGHTFALLOFF_STANDARD: number;
  21046. /**
  21047. * Intensity of the direct lights e.g. the four lights available in your scene.
  21048. * This impacts both the direct diffuse and specular highlights.
  21049. */
  21050. protected _directIntensity: number;
  21051. /**
  21052. * Intensity of the emissive part of the material.
  21053. * This helps controlling the emissive effect without modifying the emissive color.
  21054. */
  21055. protected _emissiveIntensity: number;
  21056. /**
  21057. * Intensity of the environment e.g. how much the environment will light the object
  21058. * either through harmonics for rough material or through the refelction for shiny ones.
  21059. */
  21060. protected _environmentIntensity: number;
  21061. /**
  21062. * This is a special control allowing the reduction of the specular highlights coming from the
  21063. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21064. */
  21065. protected _specularIntensity: number;
  21066. /**
  21067. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21068. */
  21069. private _lightingInfos;
  21070. /**
  21071. * Debug Control allowing disabling the bump map on this material.
  21072. */
  21073. protected _disableBumpMap: boolean;
  21074. /**
  21075. * AKA Diffuse Texture in standard nomenclature.
  21076. */
  21077. protected _albedoTexture: Nullable<BaseTexture>;
  21078. /**
  21079. * AKA Occlusion Texture in other nomenclature.
  21080. */
  21081. protected _ambientTexture: Nullable<BaseTexture>;
  21082. /**
  21083. * AKA Occlusion Texture Intensity in other nomenclature.
  21084. */
  21085. protected _ambientTextureStrength: number;
  21086. /**
  21087. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21088. * 1 means it completely occludes it
  21089. * 0 mean it has no impact
  21090. */
  21091. protected _ambientTextureImpactOnAnalyticalLights: number;
  21092. /**
  21093. * Stores the alpha values in a texture.
  21094. */
  21095. protected _opacityTexture: Nullable<BaseTexture>;
  21096. /**
  21097. * Stores the reflection values in a texture.
  21098. */
  21099. protected _reflectionTexture: Nullable<BaseTexture>;
  21100. /**
  21101. * Stores the emissive values in a texture.
  21102. */
  21103. protected _emissiveTexture: Nullable<BaseTexture>;
  21104. /**
  21105. * AKA Specular texture in other nomenclature.
  21106. */
  21107. protected _reflectivityTexture: Nullable<BaseTexture>;
  21108. /**
  21109. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21110. */
  21111. protected _metallicTexture: Nullable<BaseTexture>;
  21112. /**
  21113. * Specifies the metallic scalar of the metallic/roughness workflow.
  21114. * Can also be used to scale the metalness values of the metallic texture.
  21115. */
  21116. protected _metallic: Nullable<number>;
  21117. /**
  21118. * Specifies the roughness scalar of the metallic/roughness workflow.
  21119. * Can also be used to scale the roughness values of the metallic texture.
  21120. */
  21121. protected _roughness: Nullable<number>;
  21122. /**
  21123. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21124. * By default the indexOfrefraction is used to compute F0;
  21125. *
  21126. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21127. *
  21128. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21129. * F90 = metallicReflectanceColor;
  21130. */
  21131. protected _metallicF0Factor: number;
  21132. /**
  21133. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21134. * By default the F90 is always 1;
  21135. *
  21136. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21137. *
  21138. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21139. * F90 = metallicReflectanceColor;
  21140. */
  21141. protected _metallicReflectanceColor: Color3;
  21142. /**
  21143. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21144. * This is multiply against the scalar values defined in the material.
  21145. */
  21146. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21147. /**
  21148. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21149. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21150. */
  21151. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21152. /**
  21153. * Stores surface normal data used to displace a mesh in a texture.
  21154. */
  21155. protected _bumpTexture: Nullable<BaseTexture>;
  21156. /**
  21157. * Stores the pre-calculated light information of a mesh in a texture.
  21158. */
  21159. protected _lightmapTexture: Nullable<BaseTexture>;
  21160. /**
  21161. * The color of a material in ambient lighting.
  21162. */
  21163. protected _ambientColor: Color3;
  21164. /**
  21165. * AKA Diffuse Color in other nomenclature.
  21166. */
  21167. protected _albedoColor: Color3;
  21168. /**
  21169. * AKA Specular Color in other nomenclature.
  21170. */
  21171. protected _reflectivityColor: Color3;
  21172. /**
  21173. * The color applied when light is reflected from a material.
  21174. */
  21175. protected _reflectionColor: Color3;
  21176. /**
  21177. * The color applied when light is emitted from a material.
  21178. */
  21179. protected _emissiveColor: Color3;
  21180. /**
  21181. * AKA Glossiness in other nomenclature.
  21182. */
  21183. protected _microSurface: number;
  21184. /**
  21185. * Specifies that the material will use the light map as a show map.
  21186. */
  21187. protected _useLightmapAsShadowmap: boolean;
  21188. /**
  21189. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21190. * makes the reflect vector face the model (under horizon).
  21191. */
  21192. protected _useHorizonOcclusion: boolean;
  21193. /**
  21194. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21195. * too much the area relying on ambient texture to define their ambient occlusion.
  21196. */
  21197. protected _useRadianceOcclusion: boolean;
  21198. /**
  21199. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21200. */
  21201. protected _useAlphaFromAlbedoTexture: boolean;
  21202. /**
  21203. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21204. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21205. */
  21206. protected _useSpecularOverAlpha: boolean;
  21207. /**
  21208. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21209. */
  21210. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21211. /**
  21212. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21213. */
  21214. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21215. /**
  21216. * Specifies if the metallic texture contains the roughness information in its green channel.
  21217. */
  21218. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21219. /**
  21220. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21221. */
  21222. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21223. /**
  21224. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21225. */
  21226. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21227. /**
  21228. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21229. */
  21230. protected _useAmbientInGrayScale: boolean;
  21231. /**
  21232. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21233. * The material will try to infer what glossiness each pixel should be.
  21234. */
  21235. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21236. /**
  21237. * Defines the falloff type used in this material.
  21238. * It by default is Physical.
  21239. */
  21240. protected _lightFalloff: number;
  21241. /**
  21242. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21243. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21244. */
  21245. protected _useRadianceOverAlpha: boolean;
  21246. /**
  21247. * Allows using an object space normal map (instead of tangent space).
  21248. */
  21249. protected _useObjectSpaceNormalMap: boolean;
  21250. /**
  21251. * Allows using the bump map in parallax mode.
  21252. */
  21253. protected _useParallax: boolean;
  21254. /**
  21255. * Allows using the bump map in parallax occlusion mode.
  21256. */
  21257. protected _useParallaxOcclusion: boolean;
  21258. /**
  21259. * Controls the scale bias of the parallax mode.
  21260. */
  21261. protected _parallaxScaleBias: number;
  21262. /**
  21263. * If sets to true, disables all the lights affecting the material.
  21264. */
  21265. protected _disableLighting: boolean;
  21266. /**
  21267. * Number of Simultaneous lights allowed on the material.
  21268. */
  21269. protected _maxSimultaneousLights: number;
  21270. /**
  21271. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21272. */
  21273. protected _invertNormalMapX: boolean;
  21274. /**
  21275. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21276. */
  21277. protected _invertNormalMapY: boolean;
  21278. /**
  21279. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21280. */
  21281. protected _twoSidedLighting: boolean;
  21282. /**
  21283. * Defines the alpha limits in alpha test mode.
  21284. */
  21285. protected _alphaCutOff: number;
  21286. /**
  21287. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21288. */
  21289. protected _forceAlphaTest: boolean;
  21290. /**
  21291. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21292. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21293. */
  21294. protected _useAlphaFresnel: boolean;
  21295. /**
  21296. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21297. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21298. */
  21299. protected _useLinearAlphaFresnel: boolean;
  21300. /**
  21301. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21302. * from cos thetav and roughness:
  21303. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21304. */
  21305. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21306. /**
  21307. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21308. */
  21309. protected _forceIrradianceInFragment: boolean;
  21310. private _realTimeFiltering;
  21311. /**
  21312. * Enables realtime filtering on the texture.
  21313. */
  21314. get realTimeFiltering(): boolean;
  21315. set realTimeFiltering(b: boolean);
  21316. private _realTimeFilteringQuality;
  21317. /**
  21318. * Quality switch for realtime filtering
  21319. */
  21320. get realTimeFilteringQuality(): number;
  21321. set realTimeFilteringQuality(n: number);
  21322. /**
  21323. * Can this material render to several textures at once
  21324. */
  21325. get canRenderToMRT(): boolean;
  21326. /**
  21327. * Force normal to face away from face.
  21328. */
  21329. protected _forceNormalForward: boolean;
  21330. /**
  21331. * Enables specular anti aliasing in the PBR shader.
  21332. * It will both interacts on the Geometry for analytical and IBL lighting.
  21333. * It also prefilter the roughness map based on the bump values.
  21334. */
  21335. protected _enableSpecularAntiAliasing: boolean;
  21336. /**
  21337. * Default configuration related to image processing available in the PBR Material.
  21338. */
  21339. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  21340. /**
  21341. * Keep track of the image processing observer to allow dispose and replace.
  21342. */
  21343. private _imageProcessingObserver;
  21344. /**
  21345. * Attaches a new image processing configuration to the PBR Material.
  21346. * @param configuration
  21347. */
  21348. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  21349. /**
  21350. * Stores the available render targets.
  21351. */
  21352. private _renderTargets;
  21353. /**
  21354. * Sets the global ambient color for the material used in lighting calculations.
  21355. */
  21356. private _globalAmbientColor;
  21357. /**
  21358. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  21359. */
  21360. private _useLogarithmicDepth;
  21361. /**
  21362. * If set to true, no lighting calculations will be applied.
  21363. */
  21364. private _unlit;
  21365. private _debugMode;
  21366. /**
  21367. * @hidden
  21368. * This is reserved for the inspector.
  21369. * Defines the material debug mode.
  21370. * It helps seeing only some components of the material while troubleshooting.
  21371. */
  21372. debugMode: number;
  21373. /**
  21374. * @hidden
  21375. * This is reserved for the inspector.
  21376. * Specify from where on screen the debug mode should start.
  21377. * The value goes from -1 (full screen) to 1 (not visible)
  21378. * It helps with side by side comparison against the final render
  21379. * This defaults to -1
  21380. */
  21381. private debugLimit;
  21382. /**
  21383. * @hidden
  21384. * This is reserved for the inspector.
  21385. * As the default viewing range might not be enough (if the ambient is really small for instance)
  21386. * You can use the factor to better multiply the final value.
  21387. */
  21388. private debugFactor;
  21389. /**
  21390. * Defines the clear coat layer parameters for the material.
  21391. */
  21392. readonly clearCoat: PBRClearCoatConfiguration;
  21393. /**
  21394. * Defines the anisotropic parameters for the material.
  21395. */
  21396. readonly anisotropy: PBRAnisotropicConfiguration;
  21397. /**
  21398. * Defines the BRDF parameters for the material.
  21399. */
  21400. readonly brdf: PBRBRDFConfiguration;
  21401. /**
  21402. * Defines the Sheen parameters for the material.
  21403. */
  21404. readonly sheen: PBRSheenConfiguration;
  21405. /**
  21406. * Defines the SubSurface parameters for the material.
  21407. */
  21408. readonly subSurface: PBRSubSurfaceConfiguration;
  21409. /**
  21410. * Defines additionnal PrePass parameters for the material.
  21411. */
  21412. readonly prePassConfiguration: PrePassConfiguration;
  21413. /**
  21414. * Defines the detail map parameters for the material.
  21415. */
  21416. readonly detailMap: DetailMapConfiguration;
  21417. protected _rebuildInParallel: boolean;
  21418. /**
  21419. * Instantiates a new PBRMaterial instance.
  21420. *
  21421. * @param name The material name
  21422. * @param scene The scene the material will be use in.
  21423. */
  21424. constructor(name: string, scene: Scene);
  21425. /**
  21426. * Gets a boolean indicating that current material needs to register RTT
  21427. */
  21428. get hasRenderTargetTextures(): boolean;
  21429. /**
  21430. * Gets the name of the material class.
  21431. */
  21432. getClassName(): string;
  21433. /**
  21434. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21435. */
  21436. get useLogarithmicDepth(): boolean;
  21437. /**
  21438. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  21439. */
  21440. set useLogarithmicDepth(value: boolean);
  21441. /**
  21442. * Returns true if alpha blending should be disabled.
  21443. */
  21444. protected get _disableAlphaBlending(): boolean;
  21445. /**
  21446. * Specifies whether or not this material should be rendered in alpha blend mode.
  21447. */
  21448. needAlphaBlending(): boolean;
  21449. /**
  21450. * Specifies whether or not this material should be rendered in alpha test mode.
  21451. */
  21452. needAlphaTesting(): boolean;
  21453. /**
  21454. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  21455. */
  21456. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  21457. /**
  21458. * Specifies whether or not there is a usable alpha channel for transparency.
  21459. */
  21460. protected _hasAlphaChannel(): boolean;
  21461. /**
  21462. * Gets the texture used for the alpha test.
  21463. */
  21464. getAlphaTestTexture(): Nullable<BaseTexture>;
  21465. /**
  21466. * Specifies that the submesh is ready to be used.
  21467. * @param mesh - BJS mesh.
  21468. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  21469. * @param useInstances - Specifies that instances should be used.
  21470. * @returns - boolean indicating that the submesh is ready or not.
  21471. */
  21472. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  21473. /**
  21474. * Specifies if the material uses metallic roughness workflow.
  21475. * @returns boolean specifiying if the material uses metallic roughness workflow.
  21476. */
  21477. isMetallicWorkflow(): boolean;
  21478. private _prepareEffect;
  21479. private _prepareDefines;
  21480. /**
  21481. * Force shader compilation
  21482. */
  21483. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  21484. /**
  21485. * Initializes the uniform buffer layout for the shader.
  21486. */
  21487. buildUniformLayout(): void;
  21488. /**
  21489. * Unbinds the material from the mesh
  21490. */
  21491. unbind(): void;
  21492. /**
  21493. * Binds the submesh data.
  21494. * @param world - The world matrix.
  21495. * @param mesh - The BJS mesh.
  21496. * @param subMesh - A submesh of the BJS mesh.
  21497. */
  21498. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21499. /**
  21500. * Returns the animatable textures.
  21501. * @returns - Array of animatable textures.
  21502. */
  21503. getAnimatables(): IAnimatable[];
  21504. /**
  21505. * Returns the texture used for reflections.
  21506. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  21507. */
  21508. private _getReflectionTexture;
  21509. /**
  21510. * Returns an array of the actively used textures.
  21511. * @returns - Array of BaseTextures
  21512. */
  21513. getActiveTextures(): BaseTexture[];
  21514. /**
  21515. * Checks to see if a texture is used in the material.
  21516. * @param texture - Base texture to use.
  21517. * @returns - Boolean specifying if a texture is used in the material.
  21518. */
  21519. hasTexture(texture: BaseTexture): boolean;
  21520. /**
  21521. * Sets the required values to the prepass renderer.
  21522. * @param prePassRenderer defines the prepass renderer to setup
  21523. */
  21524. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  21525. /**
  21526. * Disposes the resources of the material.
  21527. * @param forceDisposeEffect - Forces the disposal of effects.
  21528. * @param forceDisposeTextures - Forces the disposal of all textures.
  21529. */
  21530. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  21531. }
  21532. }
  21533. declare module BABYLON {
  21534. /**
  21535. * The Physically based material of BJS.
  21536. *
  21537. * This offers the main features of a standard PBR material.
  21538. * For more information, please refer to the documentation :
  21539. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21540. */
  21541. export class PBRMaterial extends PBRBaseMaterial {
  21542. /**
  21543. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21544. */
  21545. static readonly PBRMATERIAL_OPAQUE: number;
  21546. /**
  21547. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21548. */
  21549. static readonly PBRMATERIAL_ALPHATEST: number;
  21550. /**
  21551. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21552. */
  21553. static readonly PBRMATERIAL_ALPHABLEND: number;
  21554. /**
  21555. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21556. * They are also discarded below the alpha cutoff threshold to improve performances.
  21557. */
  21558. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21559. /**
  21560. * Defines the default value of how much AO map is occluding the analytical lights
  21561. * (point spot...).
  21562. */
  21563. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21564. /**
  21565. * Intensity of the direct lights e.g. the four lights available in your scene.
  21566. * This impacts both the direct diffuse and specular highlights.
  21567. */
  21568. directIntensity: number;
  21569. /**
  21570. * Intensity of the emissive part of the material.
  21571. * This helps controlling the emissive effect without modifying the emissive color.
  21572. */
  21573. emissiveIntensity: number;
  21574. /**
  21575. * Intensity of the environment e.g. how much the environment will light the object
  21576. * either through harmonics for rough material or through the refelction for shiny ones.
  21577. */
  21578. environmentIntensity: number;
  21579. /**
  21580. * This is a special control allowing the reduction of the specular highlights coming from the
  21581. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21582. */
  21583. specularIntensity: number;
  21584. /**
  21585. * Debug Control allowing disabling the bump map on this material.
  21586. */
  21587. disableBumpMap: boolean;
  21588. /**
  21589. * AKA Diffuse Texture in standard nomenclature.
  21590. */
  21591. albedoTexture: BaseTexture;
  21592. /**
  21593. * AKA Occlusion Texture in other nomenclature.
  21594. */
  21595. ambientTexture: BaseTexture;
  21596. /**
  21597. * AKA Occlusion Texture Intensity in other nomenclature.
  21598. */
  21599. ambientTextureStrength: number;
  21600. /**
  21601. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21602. * 1 means it completely occludes it
  21603. * 0 mean it has no impact
  21604. */
  21605. ambientTextureImpactOnAnalyticalLights: number;
  21606. /**
  21607. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  21608. */
  21609. opacityTexture: BaseTexture;
  21610. /**
  21611. * Stores the reflection values in a texture.
  21612. */
  21613. reflectionTexture: Nullable<BaseTexture>;
  21614. /**
  21615. * Stores the emissive values in a texture.
  21616. */
  21617. emissiveTexture: BaseTexture;
  21618. /**
  21619. * AKA Specular texture in other nomenclature.
  21620. */
  21621. reflectivityTexture: BaseTexture;
  21622. /**
  21623. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21624. */
  21625. metallicTexture: BaseTexture;
  21626. /**
  21627. * Specifies the metallic scalar of the metallic/roughness workflow.
  21628. * Can also be used to scale the metalness values of the metallic texture.
  21629. */
  21630. metallic: Nullable<number>;
  21631. /**
  21632. * Specifies the roughness scalar of the metallic/roughness workflow.
  21633. * Can also be used to scale the roughness values of the metallic texture.
  21634. */
  21635. roughness: Nullable<number>;
  21636. /**
  21637. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21638. * By default the indexOfrefraction is used to compute F0;
  21639. *
  21640. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21641. *
  21642. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21643. * F90 = metallicReflectanceColor;
  21644. */
  21645. metallicF0Factor: number;
  21646. /**
  21647. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21648. * By default the F90 is always 1;
  21649. *
  21650. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21651. *
  21652. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21653. * F90 = metallicReflectanceColor;
  21654. */
  21655. metallicReflectanceColor: Color3;
  21656. /**
  21657. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21658. * This is multiply against the scalar values defined in the material.
  21659. */
  21660. metallicReflectanceTexture: Nullable<BaseTexture>;
  21661. /**
  21662. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21663. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21664. */
  21665. microSurfaceTexture: BaseTexture;
  21666. /**
  21667. * Stores surface normal data used to displace a mesh in a texture.
  21668. */
  21669. bumpTexture: BaseTexture;
  21670. /**
  21671. * Stores the pre-calculated light information of a mesh in a texture.
  21672. */
  21673. lightmapTexture: BaseTexture;
  21674. /**
  21675. * Stores the refracted light information in a texture.
  21676. */
  21677. get refractionTexture(): Nullable<BaseTexture>;
  21678. set refractionTexture(value: Nullable<BaseTexture>);
  21679. /**
  21680. * The color of a material in ambient lighting.
  21681. */
  21682. ambientColor: Color3;
  21683. /**
  21684. * AKA Diffuse Color in other nomenclature.
  21685. */
  21686. albedoColor: Color3;
  21687. /**
  21688. * AKA Specular Color in other nomenclature.
  21689. */
  21690. reflectivityColor: Color3;
  21691. /**
  21692. * The color reflected from the material.
  21693. */
  21694. reflectionColor: Color3;
  21695. /**
  21696. * The color emitted from the material.
  21697. */
  21698. emissiveColor: Color3;
  21699. /**
  21700. * AKA Glossiness in other nomenclature.
  21701. */
  21702. microSurface: number;
  21703. /**
  21704. * Index of refraction of the material base layer.
  21705. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  21706. *
  21707. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  21708. *
  21709. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  21710. */
  21711. get indexOfRefraction(): number;
  21712. set indexOfRefraction(value: number);
  21713. /**
  21714. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21715. */
  21716. get invertRefractionY(): boolean;
  21717. set invertRefractionY(value: boolean);
  21718. /**
  21719. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21720. * Materials half opaque for instance using refraction could benefit from this control.
  21721. */
  21722. get linkRefractionWithTransparency(): boolean;
  21723. set linkRefractionWithTransparency(value: boolean);
  21724. /**
  21725. * If true, the light map contains occlusion information instead of lighting info.
  21726. */
  21727. useLightmapAsShadowmap: boolean;
  21728. /**
  21729. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21730. */
  21731. useAlphaFromAlbedoTexture: boolean;
  21732. /**
  21733. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21734. */
  21735. forceAlphaTest: boolean;
  21736. /**
  21737. * Defines the alpha limits in alpha test mode.
  21738. */
  21739. alphaCutOff: number;
  21740. /**
  21741. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  21742. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21743. */
  21744. useSpecularOverAlpha: boolean;
  21745. /**
  21746. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21747. */
  21748. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21749. /**
  21750. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21751. */
  21752. useRoughnessFromMetallicTextureAlpha: boolean;
  21753. /**
  21754. * Specifies if the metallic texture contains the roughness information in its green channel.
  21755. */
  21756. useRoughnessFromMetallicTextureGreen: boolean;
  21757. /**
  21758. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21759. */
  21760. useMetallnessFromMetallicTextureBlue: boolean;
  21761. /**
  21762. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21763. */
  21764. useAmbientOcclusionFromMetallicTextureRed: boolean;
  21765. /**
  21766. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21767. */
  21768. useAmbientInGrayScale: boolean;
  21769. /**
  21770. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21771. * The material will try to infer what glossiness each pixel should be.
  21772. */
  21773. useAutoMicroSurfaceFromReflectivityMap: boolean;
  21774. /**
  21775. * BJS is using an harcoded light falloff based on a manually sets up range.
  21776. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21777. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21778. */
  21779. get usePhysicalLightFalloff(): boolean;
  21780. /**
  21781. * BJS is using an harcoded light falloff based on a manually sets up range.
  21782. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  21783. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  21784. */
  21785. set usePhysicalLightFalloff(value: boolean);
  21786. /**
  21787. * In order to support the falloff compatibility with gltf, a special mode has been added
  21788. * to reproduce the gltf light falloff.
  21789. */
  21790. get useGLTFLightFalloff(): boolean;
  21791. /**
  21792. * In order to support the falloff compatibility with gltf, a special mode has been added
  21793. * to reproduce the gltf light falloff.
  21794. */
  21795. set useGLTFLightFalloff(value: boolean);
  21796. /**
  21797. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21798. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21799. */
  21800. useRadianceOverAlpha: boolean;
  21801. /**
  21802. * Allows using an object space normal map (instead of tangent space).
  21803. */
  21804. useObjectSpaceNormalMap: boolean;
  21805. /**
  21806. * Allows using the bump map in parallax mode.
  21807. */
  21808. useParallax: boolean;
  21809. /**
  21810. * Allows using the bump map in parallax occlusion mode.
  21811. */
  21812. useParallaxOcclusion: boolean;
  21813. /**
  21814. * Controls the scale bias of the parallax mode.
  21815. */
  21816. parallaxScaleBias: number;
  21817. /**
  21818. * If sets to true, disables all the lights affecting the material.
  21819. */
  21820. disableLighting: boolean;
  21821. /**
  21822. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21823. */
  21824. forceIrradianceInFragment: boolean;
  21825. /**
  21826. * Number of Simultaneous lights allowed on the material.
  21827. */
  21828. maxSimultaneousLights: number;
  21829. /**
  21830. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  21831. */
  21832. invertNormalMapX: boolean;
  21833. /**
  21834. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  21835. */
  21836. invertNormalMapY: boolean;
  21837. /**
  21838. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21839. */
  21840. twoSidedLighting: boolean;
  21841. /**
  21842. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21843. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21844. */
  21845. useAlphaFresnel: boolean;
  21846. /**
  21847. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21848. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21849. */
  21850. useLinearAlphaFresnel: boolean;
  21851. /**
  21852. * Let user defines the brdf lookup texture used for IBL.
  21853. * A default 8bit version is embedded but you could point at :
  21854. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  21855. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  21856. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  21857. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  21858. */
  21859. environmentBRDFTexture: Nullable<BaseTexture>;
  21860. /**
  21861. * Force normal to face away from face.
  21862. */
  21863. forceNormalForward: boolean;
  21864. /**
  21865. * Enables specular anti aliasing in the PBR shader.
  21866. * It will both interacts on the Geometry for analytical and IBL lighting.
  21867. * It also prefilter the roughness map based on the bump values.
  21868. */
  21869. enableSpecularAntiAliasing: boolean;
  21870. /**
  21871. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21872. * makes the reflect vector face the model (under horizon).
  21873. */
  21874. useHorizonOcclusion: boolean;
  21875. /**
  21876. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21877. * too much the area relying on ambient texture to define their ambient occlusion.
  21878. */
  21879. useRadianceOcclusion: boolean;
  21880. /**
  21881. * If set to true, no lighting calculations will be applied.
  21882. */
  21883. unlit: boolean;
  21884. /**
  21885. * Gets the image processing configuration used either in this material.
  21886. */
  21887. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  21888. /**
  21889. * Sets the Default image processing configuration used either in the this material.
  21890. *
  21891. * If sets to null, the scene one is in use.
  21892. */
  21893. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  21894. /**
  21895. * Gets wether the color curves effect is enabled.
  21896. */
  21897. get cameraColorCurvesEnabled(): boolean;
  21898. /**
  21899. * Sets wether the color curves effect is enabled.
  21900. */
  21901. set cameraColorCurvesEnabled(value: boolean);
  21902. /**
  21903. * Gets wether the color grading effect is enabled.
  21904. */
  21905. get cameraColorGradingEnabled(): boolean;
  21906. /**
  21907. * Gets wether the color grading effect is enabled.
  21908. */
  21909. set cameraColorGradingEnabled(value: boolean);
  21910. /**
  21911. * Gets wether tonemapping is enabled or not.
  21912. */
  21913. get cameraToneMappingEnabled(): boolean;
  21914. /**
  21915. * Sets wether tonemapping is enabled or not
  21916. */
  21917. set cameraToneMappingEnabled(value: boolean);
  21918. /**
  21919. * The camera exposure used on this material.
  21920. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21921. * This corresponds to a photographic exposure.
  21922. */
  21923. get cameraExposure(): number;
  21924. /**
  21925. * The camera exposure used on this material.
  21926. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21927. * This corresponds to a photographic exposure.
  21928. */
  21929. set cameraExposure(value: number);
  21930. /**
  21931. * Gets The camera contrast used on this material.
  21932. */
  21933. get cameraContrast(): number;
  21934. /**
  21935. * Sets The camera contrast used on this material.
  21936. */
  21937. set cameraContrast(value: number);
  21938. /**
  21939. * Gets the Color Grading 2D Lookup Texture.
  21940. */
  21941. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  21942. /**
  21943. * Sets the Color Grading 2D Lookup Texture.
  21944. */
  21945. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  21946. /**
  21947. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21948. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21949. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  21950. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21951. */
  21952. get cameraColorCurves(): Nullable<ColorCurves>;
  21953. /**
  21954. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21955. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21956. * 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;
  21957. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21958. */
  21959. set cameraColorCurves(value: Nullable<ColorCurves>);
  21960. /**
  21961. * Instantiates a new PBRMaterial instance.
  21962. *
  21963. * @param name The material name
  21964. * @param scene The scene the material will be use in.
  21965. */
  21966. constructor(name: string, scene: Scene);
  21967. /**
  21968. * Returns the name of this material class.
  21969. */
  21970. getClassName(): string;
  21971. /**
  21972. * Makes a duplicate of the current material.
  21973. * @param name - name to use for the new material.
  21974. */
  21975. clone(name: string): PBRMaterial;
  21976. /**
  21977. * Serializes this PBR Material.
  21978. * @returns - An object with the serialized material.
  21979. */
  21980. serialize(): any;
  21981. /**
  21982. * Parses a PBR Material from a serialized object.
  21983. * @param source - Serialized object.
  21984. * @param scene - BJS scene instance.
  21985. * @param rootUrl - url for the scene object
  21986. * @returns - PBRMaterial
  21987. */
  21988. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  21989. }
  21990. }
  21991. declare module BABYLON {
  21992. /** @hidden */
  21993. export var mrtFragmentDeclaration: {
  21994. name: string;
  21995. shader: string;
  21996. };
  21997. }
  21998. declare module BABYLON {
  21999. /** @hidden */
  22000. export var geometryPixelShader: {
  22001. name: string;
  22002. shader: string;
  22003. };
  22004. }
  22005. declare module BABYLON {
  22006. /** @hidden */
  22007. export var geometryVertexShader: {
  22008. name: string;
  22009. shader: string;
  22010. };
  22011. }
  22012. declare module BABYLON {
  22013. /** @hidden */
  22014. interface ISavedTransformationMatrix {
  22015. world: Matrix;
  22016. viewProjection: Matrix;
  22017. }
  22018. /**
  22019. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22020. */
  22021. export class GeometryBufferRenderer {
  22022. /**
  22023. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22024. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22025. */
  22026. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22027. /**
  22028. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22029. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22030. */
  22031. static readonly POSITION_TEXTURE_TYPE: number;
  22032. /**
  22033. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22034. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22035. */
  22036. static readonly VELOCITY_TEXTURE_TYPE: number;
  22037. /**
  22038. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22039. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22040. */
  22041. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22042. /**
  22043. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22044. * in order to compute objects velocities when enableVelocity is set to "true"
  22045. * @hidden
  22046. */
  22047. _previousTransformationMatrices: {
  22048. [index: number]: ISavedTransformationMatrix;
  22049. };
  22050. /**
  22051. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22052. * in order to compute objects velocities when enableVelocity is set to "true"
  22053. * @hidden
  22054. */
  22055. _previousBonesTransformationMatrices: {
  22056. [index: number]: Float32Array;
  22057. };
  22058. /**
  22059. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22060. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22061. */
  22062. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22063. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22064. renderTransparentMeshes: boolean;
  22065. private _scene;
  22066. private _resizeObserver;
  22067. private _multiRenderTarget;
  22068. private _ratio;
  22069. private _enablePosition;
  22070. private _enableVelocity;
  22071. private _enableReflectivity;
  22072. private _positionIndex;
  22073. private _velocityIndex;
  22074. private _reflectivityIndex;
  22075. private _depthNormalIndex;
  22076. private _linkedWithPrePass;
  22077. private _prePassRenderer;
  22078. private _attachments;
  22079. protected _effect: Effect;
  22080. protected _cachedDefines: string;
  22081. /**
  22082. * @hidden
  22083. * Sets up internal structures to share outputs with PrePassRenderer
  22084. * This method should only be called by the PrePassRenderer itself
  22085. */
  22086. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22087. /**
  22088. * @hidden
  22089. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22090. * This method should only be called by the PrePassRenderer itself
  22091. */
  22092. _unlinkPrePassRenderer(): void;
  22093. /**
  22094. * @hidden
  22095. * Resets the geometry buffer layout
  22096. */
  22097. _resetLayout(): void;
  22098. /**
  22099. * @hidden
  22100. * Replaces a texture in the geometry buffer renderer
  22101. * Useful when linking textures of the prepass renderer
  22102. */
  22103. _forceTextureType(geometryBufferType: number, index: number): void;
  22104. /**
  22105. * @hidden
  22106. * Sets texture attachments
  22107. * Useful when linking textures of the prepass renderer
  22108. */
  22109. _setAttachments(attachments: number[]): void;
  22110. /**
  22111. * @hidden
  22112. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22113. * Useful when linking textures of the prepass renderer
  22114. */
  22115. _linkInternalTexture(internalTexture: InternalTexture): void;
  22116. /**
  22117. * Gets the render list (meshes to be rendered) used in the G buffer.
  22118. */
  22119. get renderList(): Nullable<AbstractMesh[]>;
  22120. /**
  22121. * Set the render list (meshes to be rendered) used in the G buffer.
  22122. */
  22123. set renderList(meshes: Nullable<AbstractMesh[]>);
  22124. /**
  22125. * Gets wether or not G buffer are supported by the running hardware.
  22126. * This requires draw buffer supports
  22127. */
  22128. get isSupported(): boolean;
  22129. /**
  22130. * Returns the index of the given texture type in the G-Buffer textures array
  22131. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22132. * @returns the index of the given texture type in the G-Buffer textures array
  22133. */
  22134. getTextureIndex(textureType: number): number;
  22135. /**
  22136. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22137. */
  22138. get enablePosition(): boolean;
  22139. /**
  22140. * Sets whether or not objects positions are enabled for the G buffer.
  22141. */
  22142. set enablePosition(enable: boolean);
  22143. /**
  22144. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22145. */
  22146. get enableVelocity(): boolean;
  22147. /**
  22148. * Sets wether or not objects velocities are enabled for the G buffer.
  22149. */
  22150. set enableVelocity(enable: boolean);
  22151. /**
  22152. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22153. */
  22154. get enableReflectivity(): boolean;
  22155. /**
  22156. * Sets wether or not objects roughness are enabled for the G buffer.
  22157. */
  22158. set enableReflectivity(enable: boolean);
  22159. /**
  22160. * Gets the scene associated with the buffer.
  22161. */
  22162. get scene(): Scene;
  22163. /**
  22164. * Gets the ratio used by the buffer during its creation.
  22165. * How big is the buffer related to the main canvas.
  22166. */
  22167. get ratio(): number;
  22168. /** @hidden */
  22169. static _SceneComponentInitialization: (scene: Scene) => void;
  22170. /**
  22171. * Creates a new G Buffer for the scene
  22172. * @param scene The scene the buffer belongs to
  22173. * @param ratio How big is the buffer related to the main canvas.
  22174. */
  22175. constructor(scene: Scene, ratio?: number);
  22176. /**
  22177. * Checks wether everything is ready to render a submesh to the G buffer.
  22178. * @param subMesh the submesh to check readiness for
  22179. * @param useInstances is the mesh drawn using instance or not
  22180. * @returns true if ready otherwise false
  22181. */
  22182. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22183. /**
  22184. * Gets the current underlying G Buffer.
  22185. * @returns the buffer
  22186. */
  22187. getGBuffer(): MultiRenderTarget;
  22188. /**
  22189. * Gets the number of samples used to render the buffer (anti aliasing).
  22190. */
  22191. get samples(): number;
  22192. /**
  22193. * Sets the number of samples used to render the buffer (anti aliasing).
  22194. */
  22195. set samples(value: number);
  22196. /**
  22197. * Disposes the renderer and frees up associated resources.
  22198. */
  22199. dispose(): void;
  22200. private _assignRenderTargetIndices;
  22201. protected _createRenderTargets(): void;
  22202. private _copyBonesTransformationMatrices;
  22203. }
  22204. }
  22205. declare module BABYLON {
  22206. /**
  22207. * Renders a pre pass of the scene
  22208. * This means every mesh in the scene will be rendered to a render target texture
  22209. * And then this texture will be composited to the rendering canvas with post processes
  22210. * It is necessary for effects like subsurface scattering or deferred shading
  22211. */
  22212. export class PrePassRenderer {
  22213. /** @hidden */
  22214. static _SceneComponentInitialization: (scene: Scene) => void;
  22215. private _textureFormats;
  22216. /**
  22217. * To save performance, we can excluded skinned meshes from the prepass
  22218. */
  22219. excludedSkinnedMesh: AbstractMesh[];
  22220. /**
  22221. * Force material to be excluded from the prepass
  22222. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22223. * and you don't want a material to show in the effect.
  22224. */
  22225. excludedMaterials: Material[];
  22226. private _textureIndices;
  22227. private _scene;
  22228. private _engine;
  22229. private _isDirty;
  22230. /**
  22231. * Number of textures in the multi render target texture where the scene is directly rendered
  22232. */
  22233. mrtCount: number;
  22234. /**
  22235. * The render target where the scene is directly rendered
  22236. */
  22237. prePassRT: MultiRenderTarget;
  22238. private _multiRenderAttachments;
  22239. private _defaultAttachments;
  22240. private _clearAttachments;
  22241. private _postProcesses;
  22242. private readonly _clearColor;
  22243. /**
  22244. * Image processing post process for composition
  22245. */
  22246. imageProcessingPostProcess: ImageProcessingPostProcess;
  22247. /**
  22248. * Configuration for prepass effects
  22249. */
  22250. private _effectConfigurations;
  22251. private _mrtFormats;
  22252. private _mrtLayout;
  22253. private _enabled;
  22254. /**
  22255. * Indicates if the prepass is enabled
  22256. */
  22257. get enabled(): boolean;
  22258. /**
  22259. * How many samples are used for MSAA of the scene render target
  22260. */
  22261. get samples(): number;
  22262. set samples(n: number);
  22263. private _geometryBuffer;
  22264. private _useGeometryBufferFallback;
  22265. /**
  22266. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22267. */
  22268. get useGeometryBufferFallback(): boolean;
  22269. set useGeometryBufferFallback(value: boolean);
  22270. /**
  22271. * Set to true to disable gamma transform in PrePass.
  22272. * Can be useful in case you already proceed to gamma transform on a material level
  22273. * and your post processes don't need to be in linear color space.
  22274. */
  22275. disableGammaTransform: boolean;
  22276. /**
  22277. * Instanciates a prepass renderer
  22278. * @param scene The scene
  22279. */
  22280. constructor(scene: Scene);
  22281. private _initializeAttachments;
  22282. private _createCompositionEffect;
  22283. /**
  22284. * Indicates if rendering a prepass is supported
  22285. */
  22286. get isSupported(): boolean;
  22287. /**
  22288. * Sets the proper output textures to draw in the engine.
  22289. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22290. * @param subMesh Submesh on which the effect is applied
  22291. */
  22292. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22293. /**
  22294. * Restores attachments for single texture draw.
  22295. */
  22296. restoreAttachments(): void;
  22297. /**
  22298. * @hidden
  22299. */
  22300. _beforeCameraDraw(): void;
  22301. /**
  22302. * @hidden
  22303. */
  22304. _afterCameraDraw(): void;
  22305. private _checkRTSize;
  22306. private _bindFrameBuffer;
  22307. /**
  22308. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  22309. */
  22310. clear(): void;
  22311. private _setState;
  22312. private _updateGeometryBufferLayout;
  22313. /**
  22314. * Adds an effect configuration to the prepass.
  22315. * If an effect has already been added, it won't add it twice and will return the configuration
  22316. * already present.
  22317. * @param cfg the effect configuration
  22318. * @return the effect configuration now used by the prepass
  22319. */
  22320. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  22321. /**
  22322. * Returns the index of a texture in the multi render target texture array.
  22323. * @param type Texture type
  22324. * @return The index
  22325. */
  22326. getIndex(type: number): number;
  22327. private _enable;
  22328. private _disable;
  22329. private _resetLayout;
  22330. private _resetPostProcessChain;
  22331. private _bindPostProcessChain;
  22332. /**
  22333. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  22334. */
  22335. markAsDirty(): void;
  22336. /**
  22337. * Enables a texture on the MultiRenderTarget for prepass
  22338. */
  22339. private _enableTextures;
  22340. private _update;
  22341. private _markAllMaterialsAsPrePassDirty;
  22342. /**
  22343. * Disposes the prepass renderer.
  22344. */
  22345. dispose(): void;
  22346. }
  22347. }
  22348. declare module BABYLON {
  22349. /**
  22350. * Size options for a post process
  22351. */
  22352. export type PostProcessOptions = {
  22353. width: number;
  22354. height: number;
  22355. };
  22356. /**
  22357. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22358. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22359. */
  22360. export class PostProcess {
  22361. /**
  22362. * Gets or sets the unique id of the post process
  22363. */
  22364. uniqueId: number;
  22365. /** Name of the PostProcess. */
  22366. name: string;
  22367. /**
  22368. * Width of the texture to apply the post process on
  22369. */
  22370. width: number;
  22371. /**
  22372. * Height of the texture to apply the post process on
  22373. */
  22374. height: number;
  22375. /**
  22376. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22377. */
  22378. nodeMaterialSource: Nullable<NodeMaterial>;
  22379. /**
  22380. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22381. * @hidden
  22382. */
  22383. _outputTexture: Nullable<InternalTexture>;
  22384. /**
  22385. * Sampling mode used by the shader
  22386. * See https://doc.babylonjs.com/classes/3.1/texture
  22387. */
  22388. renderTargetSamplingMode: number;
  22389. /**
  22390. * Clear color to use when screen clearing
  22391. */
  22392. clearColor: Color4;
  22393. /**
  22394. * If the buffer needs to be cleared before applying the post process. (default: true)
  22395. * Should be set to false if shader will overwrite all previous pixels.
  22396. */
  22397. autoClear: boolean;
  22398. /**
  22399. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22400. */
  22401. alphaMode: number;
  22402. /**
  22403. * Sets the setAlphaBlendConstants of the babylon engine
  22404. */
  22405. alphaConstants: Color4;
  22406. /**
  22407. * Animations to be used for the post processing
  22408. */
  22409. animations: Animation[];
  22410. /**
  22411. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22412. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22413. */
  22414. enablePixelPerfectMode: boolean;
  22415. /**
  22416. * Force the postprocess to be applied without taking in account viewport
  22417. */
  22418. forceFullscreenViewport: boolean;
  22419. /**
  22420. * List of inspectable custom properties (used by the Inspector)
  22421. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22422. */
  22423. inspectableCustomProperties: IInspectable[];
  22424. /**
  22425. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22426. *
  22427. * | Value | Type | Description |
  22428. * | ----- | ----------------------------------- | ----------- |
  22429. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22430. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22431. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22432. *
  22433. */
  22434. scaleMode: number;
  22435. /**
  22436. * Force textures to be a power of two (default: false)
  22437. */
  22438. alwaysForcePOT: boolean;
  22439. private _samples;
  22440. /**
  22441. * Number of sample textures (default: 1)
  22442. */
  22443. get samples(): number;
  22444. set samples(n: number);
  22445. /**
  22446. * Modify the scale of the post process to be the same as the viewport (default: false)
  22447. */
  22448. adaptScaleToCurrentViewport: boolean;
  22449. private _camera;
  22450. protected _scene: Scene;
  22451. private _engine;
  22452. private _options;
  22453. private _reusable;
  22454. private _textureType;
  22455. private _textureFormat;
  22456. /**
  22457. * Smart array of input and output textures for the post process.
  22458. * @hidden
  22459. */
  22460. _textures: SmartArray<InternalTexture>;
  22461. /**
  22462. * The index in _textures that corresponds to the output texture.
  22463. * @hidden
  22464. */
  22465. _currentRenderTextureInd: number;
  22466. private _effect;
  22467. private _samplers;
  22468. private _fragmentUrl;
  22469. private _vertexUrl;
  22470. private _parameters;
  22471. private _scaleRatio;
  22472. protected _indexParameters: any;
  22473. private _shareOutputWithPostProcess;
  22474. private _texelSize;
  22475. private _forcedOutputTexture;
  22476. /**
  22477. * Prepass configuration in case this post process needs a texture from prepass
  22478. * @hidden
  22479. */
  22480. _prePassEffectConfiguration: PrePassEffectConfiguration;
  22481. /**
  22482. * Returns the fragment url or shader name used in the post process.
  22483. * @returns the fragment url or name in the shader store.
  22484. */
  22485. getEffectName(): string;
  22486. /**
  22487. * An event triggered when the postprocess is activated.
  22488. */
  22489. onActivateObservable: Observable<Camera>;
  22490. private _onActivateObserver;
  22491. /**
  22492. * A function that is added to the onActivateObservable
  22493. */
  22494. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22495. /**
  22496. * An event triggered when the postprocess changes its size.
  22497. */
  22498. onSizeChangedObservable: Observable<PostProcess>;
  22499. private _onSizeChangedObserver;
  22500. /**
  22501. * A function that is added to the onSizeChangedObservable
  22502. */
  22503. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22504. /**
  22505. * An event triggered when the postprocess applies its effect.
  22506. */
  22507. onApplyObservable: Observable<Effect>;
  22508. private _onApplyObserver;
  22509. /**
  22510. * A function that is added to the onApplyObservable
  22511. */
  22512. set onApply(callback: (effect: Effect) => void);
  22513. /**
  22514. * An event triggered before rendering the postprocess
  22515. */
  22516. onBeforeRenderObservable: Observable<Effect>;
  22517. private _onBeforeRenderObserver;
  22518. /**
  22519. * A function that is added to the onBeforeRenderObservable
  22520. */
  22521. set onBeforeRender(callback: (effect: Effect) => void);
  22522. /**
  22523. * An event triggered after rendering the postprocess
  22524. */
  22525. onAfterRenderObservable: Observable<Effect>;
  22526. private _onAfterRenderObserver;
  22527. /**
  22528. * A function that is added to the onAfterRenderObservable
  22529. */
  22530. set onAfterRender(callback: (efect: Effect) => void);
  22531. /**
  22532. * 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
  22533. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22534. */
  22535. get inputTexture(): InternalTexture;
  22536. set inputTexture(value: InternalTexture);
  22537. /**
  22538. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22539. * the only way to unset it is to use this function to restore its internal state
  22540. */
  22541. restoreDefaultInputTexture(): void;
  22542. /**
  22543. * Gets the camera which post process is applied to.
  22544. * @returns The camera the post process is applied to.
  22545. */
  22546. getCamera(): Camera;
  22547. /**
  22548. * Gets the texel size of the postprocess.
  22549. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22550. */
  22551. get texelSize(): Vector2;
  22552. /**
  22553. * Creates a new instance PostProcess
  22554. * @param name The name of the PostProcess.
  22555. * @param fragmentUrl The url of the fragment shader to be used.
  22556. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22557. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22558. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22559. * @param camera The camera to apply the render pass to.
  22560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22561. * @param engine The engine which the post process will be applied. (default: current engine)
  22562. * @param reusable If the post process can be reused on the same frame. (default: false)
  22563. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22564. * @param textureType Type of textures used when performing the post process. (default: 0)
  22565. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22566. * @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
  22567. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  22568. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22569. */
  22570. 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);
  22571. /**
  22572. * Gets a string identifying the name of the class
  22573. * @returns "PostProcess" string
  22574. */
  22575. getClassName(): string;
  22576. /**
  22577. * Gets the engine which this post process belongs to.
  22578. * @returns The engine the post process was enabled with.
  22579. */
  22580. getEngine(): Engine;
  22581. /**
  22582. * The effect that is created when initializing the post process.
  22583. * @returns The created effect corresponding the the postprocess.
  22584. */
  22585. getEffect(): Effect;
  22586. /**
  22587. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22588. * @param postProcess The post process to share the output with.
  22589. * @returns This post process.
  22590. */
  22591. shareOutputWith(postProcess: PostProcess): PostProcess;
  22592. /**
  22593. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22594. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22595. */
  22596. useOwnOutput(): void;
  22597. /**
  22598. * Updates the effect with the current post process compile time values and recompiles the shader.
  22599. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22600. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22601. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22602. * @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
  22603. * @param onCompiled Called when the shader has been compiled.
  22604. * @param onError Called if there is an error when compiling a shader.
  22605. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22606. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22607. */
  22608. 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;
  22609. /**
  22610. * The post process is reusable if it can be used multiple times within one frame.
  22611. * @returns If the post process is reusable
  22612. */
  22613. isReusable(): boolean;
  22614. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22615. markTextureDirty(): void;
  22616. /**
  22617. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22618. * 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.
  22619. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22620. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22621. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22622. * @returns The target texture that was bound to be written to.
  22623. */
  22624. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22625. /**
  22626. * If the post process is supported.
  22627. */
  22628. get isSupported(): boolean;
  22629. /**
  22630. * The aspect ratio of the output texture.
  22631. */
  22632. get aspectRatio(): number;
  22633. /**
  22634. * Get a value indicating if the post-process is ready to be used
  22635. * @returns true if the post-process is ready (shader is compiled)
  22636. */
  22637. isReady(): boolean;
  22638. /**
  22639. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22640. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22641. */
  22642. apply(): Nullable<Effect>;
  22643. private _disposeTextures;
  22644. /**
  22645. * Sets the required values to the prepass renderer.
  22646. * @param prePassRenderer defines the prepass renderer to setup.
  22647. * @returns true if the pre pass is needed.
  22648. */
  22649. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22650. /**
  22651. * Disposes the post process.
  22652. * @param camera The camera to dispose the post process on.
  22653. */
  22654. dispose(camera?: Camera): void;
  22655. /**
  22656. * Serializes the particle system to a JSON object
  22657. * @returns the JSON object
  22658. */
  22659. serialize(): any;
  22660. /**
  22661. * Creates a material from parsed material data
  22662. * @param parsedPostProcess defines parsed post process data
  22663. * @param scene defines the hosting scene
  22664. * @param rootUrl defines the root URL to use to load textures
  22665. * @returns a new post process
  22666. */
  22667. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  22668. }
  22669. }
  22670. declare module BABYLON {
  22671. /** @hidden */
  22672. export var kernelBlurVaryingDeclaration: {
  22673. name: string;
  22674. shader: string;
  22675. };
  22676. }
  22677. declare module BABYLON {
  22678. /** @hidden */
  22679. export var packingFunctions: {
  22680. name: string;
  22681. shader: string;
  22682. };
  22683. }
  22684. declare module BABYLON {
  22685. /** @hidden */
  22686. export var kernelBlurFragment: {
  22687. name: string;
  22688. shader: string;
  22689. };
  22690. }
  22691. declare module BABYLON {
  22692. /** @hidden */
  22693. export var kernelBlurFragment2: {
  22694. name: string;
  22695. shader: string;
  22696. };
  22697. }
  22698. declare module BABYLON {
  22699. /** @hidden */
  22700. export var kernelBlurPixelShader: {
  22701. name: string;
  22702. shader: string;
  22703. };
  22704. }
  22705. declare module BABYLON {
  22706. /** @hidden */
  22707. export var kernelBlurVertex: {
  22708. name: string;
  22709. shader: string;
  22710. };
  22711. }
  22712. declare module BABYLON {
  22713. /** @hidden */
  22714. export var kernelBlurVertexShader: {
  22715. name: string;
  22716. shader: string;
  22717. };
  22718. }
  22719. declare module BABYLON {
  22720. /**
  22721. * The Blur Post Process which blurs an image based on a kernel and direction.
  22722. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22723. */
  22724. export class BlurPostProcess extends PostProcess {
  22725. private blockCompilation;
  22726. protected _kernel: number;
  22727. protected _idealKernel: number;
  22728. protected _packedFloat: boolean;
  22729. private _staticDefines;
  22730. /** The direction in which to blur the image. */
  22731. direction: Vector2;
  22732. /**
  22733. * Sets the length in pixels of the blur sample region
  22734. */
  22735. set kernel(v: number);
  22736. /**
  22737. * Gets the length in pixels of the blur sample region
  22738. */
  22739. get kernel(): number;
  22740. /**
  22741. * Sets wether or not the blur needs to unpack/repack floats
  22742. */
  22743. set packedFloat(v: boolean);
  22744. /**
  22745. * Gets wether or not the blur is unpacking/repacking floats
  22746. */
  22747. get packedFloat(): boolean;
  22748. /**
  22749. * Gets a string identifying the name of the class
  22750. * @returns "BlurPostProcess" string
  22751. */
  22752. getClassName(): string;
  22753. /**
  22754. * Creates a new instance BlurPostProcess
  22755. * @param name The name of the effect.
  22756. * @param direction The direction in which to blur the image.
  22757. * @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.
  22758. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22759. * @param camera The camera to apply the render pass to.
  22760. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22761. * @param engine The engine which the post process will be applied. (default: current engine)
  22762. * @param reusable If the post process can be reused on the same frame. (default: false)
  22763. * @param textureType Type of textures used when performing the post process. (default: 0)
  22764. * @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)
  22765. */
  22766. 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);
  22767. /**
  22768. * Updates the effect with the current post process compile time values and recompiles the shader.
  22769. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22770. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22771. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22772. * @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
  22773. * @param onCompiled Called when the shader has been compiled.
  22774. * @param onError Called if there is an error when compiling a shader.
  22775. */
  22776. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22777. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22778. /**
  22779. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22780. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22781. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22782. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22783. * The gaps between physical kernels are compensated for in the weighting of the samples
  22784. * @param idealKernel Ideal blur kernel.
  22785. * @return Nearest best kernel.
  22786. */
  22787. protected _nearestBestKernel(idealKernel: number): number;
  22788. /**
  22789. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22790. * @param x The point on the Gaussian distribution to sample.
  22791. * @return the value of the Gaussian function at x.
  22792. */
  22793. protected _gaussianWeight(x: number): number;
  22794. /**
  22795. * Generates a string that can be used as a floating point number in GLSL.
  22796. * @param x Value to print.
  22797. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22798. * @return GLSL float string.
  22799. */
  22800. protected _glslFloat(x: number, decimalFigures?: number): string;
  22801. /** @hidden */
  22802. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  22803. }
  22804. }
  22805. declare module BABYLON {
  22806. /**
  22807. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22808. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22809. * You can then easily use it as a reflectionTexture on a flat surface.
  22810. * In case the surface is not a plane, please consider relying on reflection probes.
  22811. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22812. */
  22813. export class MirrorTexture extends RenderTargetTexture {
  22814. private scene;
  22815. /**
  22816. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22817. * 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.
  22818. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22819. */
  22820. mirrorPlane: Plane;
  22821. /**
  22822. * Define the blur ratio used to blur the reflection if needed.
  22823. */
  22824. set blurRatio(value: number);
  22825. get blurRatio(): number;
  22826. /**
  22827. * Define the adaptive blur kernel used to blur the reflection if needed.
  22828. * This will autocompute the closest best match for the `blurKernel`
  22829. */
  22830. set adaptiveBlurKernel(value: number);
  22831. /**
  22832. * Define the blur kernel used to blur the reflection if needed.
  22833. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22834. */
  22835. set blurKernel(value: number);
  22836. /**
  22837. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22838. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22839. */
  22840. set blurKernelX(value: number);
  22841. get blurKernelX(): number;
  22842. /**
  22843. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22844. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22845. */
  22846. set blurKernelY(value: number);
  22847. get blurKernelY(): number;
  22848. private _autoComputeBlurKernel;
  22849. protected _onRatioRescale(): void;
  22850. private _updateGammaSpace;
  22851. private _imageProcessingConfigChangeObserver;
  22852. private _transformMatrix;
  22853. private _mirrorMatrix;
  22854. private _savedViewMatrix;
  22855. private _blurX;
  22856. private _blurY;
  22857. private _adaptiveBlurKernel;
  22858. private _blurKernelX;
  22859. private _blurKernelY;
  22860. private _blurRatio;
  22861. /**
  22862. * Instantiates a Mirror Texture.
  22863. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22864. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22865. * You can then easily use it as a reflectionTexture on a flat surface.
  22866. * In case the surface is not a plane, please consider relying on reflection probes.
  22867. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22868. * @param name
  22869. * @param size
  22870. * @param scene
  22871. * @param generateMipMaps
  22872. * @param type
  22873. * @param samplingMode
  22874. * @param generateDepthBuffer
  22875. */
  22876. constructor(name: string, size: number | {
  22877. width: number;
  22878. height: number;
  22879. } | {
  22880. ratio: number;
  22881. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22882. private _preparePostProcesses;
  22883. /**
  22884. * Clone the mirror texture.
  22885. * @returns the cloned texture
  22886. */
  22887. clone(): MirrorTexture;
  22888. /**
  22889. * Serialize the texture to a JSON representation you could use in Parse later on
  22890. * @returns the serialized JSON representation
  22891. */
  22892. serialize(): any;
  22893. /**
  22894. * Dispose the texture and release its associated resources.
  22895. */
  22896. dispose(): void;
  22897. }
  22898. }
  22899. declare module BABYLON {
  22900. /**
  22901. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22902. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22903. */
  22904. export class Texture extends BaseTexture {
  22905. /**
  22906. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22907. */
  22908. static SerializeBuffers: boolean;
  22909. /**
  22910. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  22911. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  22912. */
  22913. static ForceSerializeBuffers: boolean;
  22914. /** @hidden */
  22915. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22916. /** @hidden */
  22917. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22918. /** @hidden */
  22919. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22920. /** nearest is mag = nearest and min = nearest and mip = linear */
  22921. static readonly NEAREST_SAMPLINGMODE: number;
  22922. /** nearest is mag = nearest and min = nearest and mip = linear */
  22923. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22924. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22925. static readonly BILINEAR_SAMPLINGMODE: number;
  22926. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22927. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22928. /** Trilinear is mag = linear and min = linear and mip = linear */
  22929. static readonly TRILINEAR_SAMPLINGMODE: number;
  22930. /** Trilinear is mag = linear and min = linear and mip = linear */
  22931. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22932. /** mag = nearest and min = nearest and mip = nearest */
  22933. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22934. /** mag = nearest and min = linear and mip = nearest */
  22935. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22936. /** mag = nearest and min = linear and mip = linear */
  22937. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22938. /** mag = nearest and min = linear and mip = none */
  22939. static readonly NEAREST_LINEAR: number;
  22940. /** mag = nearest and min = nearest and mip = none */
  22941. static readonly NEAREST_NEAREST: number;
  22942. /** mag = linear and min = nearest and mip = nearest */
  22943. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22944. /** mag = linear and min = nearest and mip = linear */
  22945. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22946. /** mag = linear and min = linear and mip = none */
  22947. static readonly LINEAR_LINEAR: number;
  22948. /** mag = linear and min = nearest and mip = none */
  22949. static readonly LINEAR_NEAREST: number;
  22950. /** Explicit coordinates mode */
  22951. static readonly EXPLICIT_MODE: number;
  22952. /** Spherical coordinates mode */
  22953. static readonly SPHERICAL_MODE: number;
  22954. /** Planar coordinates mode */
  22955. static readonly PLANAR_MODE: number;
  22956. /** Cubic coordinates mode */
  22957. static readonly CUBIC_MODE: number;
  22958. /** Projection coordinates mode */
  22959. static readonly PROJECTION_MODE: number;
  22960. /** Inverse Cubic coordinates mode */
  22961. static readonly SKYBOX_MODE: number;
  22962. /** Inverse Cubic coordinates mode */
  22963. static readonly INVCUBIC_MODE: number;
  22964. /** Equirectangular coordinates mode */
  22965. static readonly EQUIRECTANGULAR_MODE: number;
  22966. /** Equirectangular Fixed coordinates mode */
  22967. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22968. /** Equirectangular Fixed Mirrored coordinates mode */
  22969. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22970. /** Texture is not repeating outside of 0..1 UVs */
  22971. static readonly CLAMP_ADDRESSMODE: number;
  22972. /** Texture is repeating outside of 0..1 UVs */
  22973. static readonly WRAP_ADDRESSMODE: number;
  22974. /** Texture is repeating and mirrored */
  22975. static readonly MIRROR_ADDRESSMODE: number;
  22976. /**
  22977. * 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
  22978. */
  22979. static UseSerializedUrlIfAny: boolean;
  22980. /**
  22981. * Define the url of the texture.
  22982. */
  22983. url: Nullable<string>;
  22984. /**
  22985. * Define an offset on the texture to offset the u coordinates of the UVs
  22986. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22987. */
  22988. uOffset: number;
  22989. /**
  22990. * Define an offset on the texture to offset the v coordinates of the UVs
  22991. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22992. */
  22993. vOffset: number;
  22994. /**
  22995. * Define an offset on the texture to scale the u coordinates of the UVs
  22996. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22997. */
  22998. uScale: number;
  22999. /**
  23000. * Define an offset on the texture to scale the v coordinates of the UVs
  23001. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23002. */
  23003. vScale: number;
  23004. /**
  23005. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23006. * @see https://doc.babylonjs.com/how_to/more_materials
  23007. */
  23008. uAng: number;
  23009. /**
  23010. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23011. * @see https://doc.babylonjs.com/how_to/more_materials
  23012. */
  23013. vAng: number;
  23014. /**
  23015. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23016. * @see https://doc.babylonjs.com/how_to/more_materials
  23017. */
  23018. wAng: number;
  23019. /**
  23020. * Defines the center of rotation (U)
  23021. */
  23022. uRotationCenter: number;
  23023. /**
  23024. * Defines the center of rotation (V)
  23025. */
  23026. vRotationCenter: number;
  23027. /**
  23028. * Defines the center of rotation (W)
  23029. */
  23030. wRotationCenter: number;
  23031. /**
  23032. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23033. */
  23034. homogeneousRotationInUVTransform: boolean;
  23035. /**
  23036. * Are mip maps generated for this texture or not.
  23037. */
  23038. get noMipmap(): boolean;
  23039. /**
  23040. * List of inspectable custom properties (used by the Inspector)
  23041. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23042. */
  23043. inspectableCustomProperties: Nullable<IInspectable[]>;
  23044. private _noMipmap;
  23045. /** @hidden */
  23046. _invertY: boolean;
  23047. private _rowGenerationMatrix;
  23048. private _cachedTextureMatrix;
  23049. private _projectionModeMatrix;
  23050. private _t0;
  23051. private _t1;
  23052. private _t2;
  23053. private _cachedUOffset;
  23054. private _cachedVOffset;
  23055. private _cachedUScale;
  23056. private _cachedVScale;
  23057. private _cachedUAng;
  23058. private _cachedVAng;
  23059. private _cachedWAng;
  23060. private _cachedProjectionMatrixId;
  23061. private _cachedURotationCenter;
  23062. private _cachedVRotationCenter;
  23063. private _cachedWRotationCenter;
  23064. private _cachedHomogeneousRotationInUVTransform;
  23065. private _cachedCoordinatesMode;
  23066. /** @hidden */
  23067. protected _initialSamplingMode: number;
  23068. /** @hidden */
  23069. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23070. private _deleteBuffer;
  23071. protected _format: Nullable<number>;
  23072. private _delayedOnLoad;
  23073. private _delayedOnError;
  23074. private _mimeType?;
  23075. private _loaderOptions?;
  23076. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23077. get mimeType(): string | undefined;
  23078. /**
  23079. * Observable triggered once the texture has been loaded.
  23080. */
  23081. onLoadObservable: Observable<Texture>;
  23082. protected _isBlocking: boolean;
  23083. /**
  23084. * Is the texture preventing material to render while loading.
  23085. * If false, a default texture will be used instead of the loading one during the preparation step.
  23086. */
  23087. set isBlocking(value: boolean);
  23088. get isBlocking(): boolean;
  23089. /**
  23090. * Get the current sampling mode associated with the texture.
  23091. */
  23092. get samplingMode(): number;
  23093. /**
  23094. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23095. */
  23096. get invertY(): boolean;
  23097. /**
  23098. * Instantiates a new texture.
  23099. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23100. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23101. * @param url defines the url of the picture to load as a texture
  23102. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23103. * @param noMipmap defines if the texture will require mip maps or not
  23104. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23105. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23106. * @param onLoad defines a callback triggered when the texture has been loaded
  23107. * @param onError defines a callback triggered when an error occurred during the loading session
  23108. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23109. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23110. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23111. * @param mimeType defines an optional mime type information
  23112. * @param loaderOptions options to be passed to the loader
  23113. */
  23114. 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);
  23115. /**
  23116. * Update the url (and optional buffer) of this texture if url was null during construction.
  23117. * @param url the url of the texture
  23118. * @param buffer the buffer of the texture (defaults to null)
  23119. * @param onLoad callback called when the texture is loaded (defaults to null)
  23120. */
  23121. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23122. /**
  23123. * Finish the loading sequence of a texture flagged as delayed load.
  23124. * @hidden
  23125. */
  23126. delayLoad(): void;
  23127. private _prepareRowForTextureGeneration;
  23128. /**
  23129. * Checks if the texture has the same transform matrix than another texture
  23130. * @param texture texture to check against
  23131. * @returns true if the transforms are the same, else false
  23132. */
  23133. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23134. /**
  23135. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23136. * @returns the transform matrix of the texture.
  23137. */
  23138. getTextureMatrix(uBase?: number): Matrix;
  23139. /**
  23140. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23141. * @returns The reflection texture transform
  23142. */
  23143. getReflectionTextureMatrix(): Matrix;
  23144. /**
  23145. * Clones the texture.
  23146. * @returns the cloned texture
  23147. */
  23148. clone(): Texture;
  23149. /**
  23150. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23151. * @returns The JSON representation of the texture
  23152. */
  23153. serialize(): any;
  23154. /**
  23155. * Get the current class name of the texture useful for serialization or dynamic coding.
  23156. * @returns "Texture"
  23157. */
  23158. getClassName(): string;
  23159. /**
  23160. * Dispose the texture and release its associated resources.
  23161. */
  23162. dispose(): void;
  23163. /**
  23164. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23165. * @param parsedTexture Define the JSON representation of the texture
  23166. * @param scene Define the scene the parsed texture should be instantiated in
  23167. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23168. * @returns The parsed texture if successful
  23169. */
  23170. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23171. /**
  23172. * Creates a texture from its base 64 representation.
  23173. * @param data Define the base64 payload without the data: prefix
  23174. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23175. * @param scene Define the scene the texture should belong to
  23176. * @param noMipmap Forces the texture to not create mip map information if true
  23177. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23178. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23179. * @param onLoad define a callback triggered when the texture has been loaded
  23180. * @param onError define a callback triggered when an error occurred during the loading session
  23181. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23182. * @returns the created texture
  23183. */
  23184. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23185. /**
  23186. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23187. * @param data Define the base64 payload without the data: prefix
  23188. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23189. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23190. * @param scene Define the scene the texture should belong to
  23191. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23192. * @param noMipmap Forces the texture to not create mip map information if true
  23193. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23194. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23195. * @param onLoad define a callback triggered when the texture has been loaded
  23196. * @param onError define a callback triggered when an error occurred during the loading session
  23197. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23198. * @returns the created texture
  23199. */
  23200. 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;
  23201. }
  23202. }
  23203. declare module BABYLON {
  23204. /**
  23205. * ThinSprite Class used to represent a thin sprite
  23206. * This is the base class for sprites but can also directly be used with ThinEngine
  23207. * @see https://doc.babylonjs.com/babylon101/sprites
  23208. */
  23209. export class ThinSprite {
  23210. /** Gets or sets the cell index in the sprite sheet */
  23211. cellIndex: number;
  23212. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23213. cellRef: string;
  23214. /** Gets or sets the current world position */
  23215. position: IVector3Like;
  23216. /** Gets or sets the main color */
  23217. color: IColor4Like;
  23218. /** Gets or sets the width */
  23219. width: number;
  23220. /** Gets or sets the height */
  23221. height: number;
  23222. /** Gets or sets rotation angle */
  23223. angle: number;
  23224. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23225. invertU: boolean;
  23226. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23227. invertV: boolean;
  23228. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23229. isVisible: boolean;
  23230. /**
  23231. * Returns a boolean indicating if the animation is started
  23232. */
  23233. get animationStarted(): boolean;
  23234. /** Gets the initial key for the animation (setting it will restart the animation) */
  23235. get fromIndex(): number;
  23236. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23237. get toIndex(): number;
  23238. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23239. get loopAnimation(): boolean;
  23240. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23241. get delay(): number;
  23242. /** @hidden */
  23243. _xOffset: number;
  23244. /** @hidden */
  23245. _yOffset: number;
  23246. /** @hidden */
  23247. _xSize: number;
  23248. /** @hidden */
  23249. _ySize: number;
  23250. private _animationStarted;
  23251. protected _loopAnimation: boolean;
  23252. protected _fromIndex: number;
  23253. protected _toIndex: number;
  23254. protected _delay: number;
  23255. private _direction;
  23256. private _time;
  23257. private _onBaseAnimationEnd;
  23258. /**
  23259. * Creates a new Thin Sprite
  23260. */
  23261. constructor();
  23262. /**
  23263. * Starts an animation
  23264. * @param from defines the initial key
  23265. * @param to defines the end key
  23266. * @param loop defines if the animation must loop
  23267. * @param delay defines the start delay (in ms)
  23268. * @param onAnimationEnd defines a callback for when the animation ends
  23269. */
  23270. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23271. /** Stops current animation (if any) */
  23272. stopAnimation(): void;
  23273. /** @hidden */
  23274. _animate(deltaTime: number): void;
  23275. }
  23276. }
  23277. declare module BABYLON {
  23278. /** @hidden */
  23279. export var imageProcessingCompatibility: {
  23280. name: string;
  23281. shader: string;
  23282. };
  23283. }
  23284. declare module BABYLON {
  23285. /** @hidden */
  23286. export var spritesPixelShader: {
  23287. name: string;
  23288. shader: string;
  23289. };
  23290. }
  23291. declare module BABYLON {
  23292. /** @hidden */
  23293. export var spritesVertexShader: {
  23294. name: string;
  23295. shader: string;
  23296. };
  23297. }
  23298. declare module BABYLON {
  23299. /**
  23300. * Class used to render sprites.
  23301. *
  23302. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23303. */
  23304. export class SpriteRenderer {
  23305. /**
  23306. * Defines the texture of the spritesheet
  23307. */
  23308. texture: Nullable<ThinTexture>;
  23309. /**
  23310. * Defines the default width of a cell in the spritesheet
  23311. */
  23312. cellWidth: number;
  23313. /**
  23314. * Defines the default height of a cell in the spritesheet
  23315. */
  23316. cellHeight: number;
  23317. /**
  23318. * Blend mode use to render the particle, it can be any of
  23319. * the static Constants.ALPHA_x properties provided in this class.
  23320. * Default value is Constants.ALPHA_COMBINE
  23321. */
  23322. blendMode: number;
  23323. /**
  23324. * Gets or sets a boolean indicating if alpha mode is automatically
  23325. * reset.
  23326. */
  23327. autoResetAlpha: boolean;
  23328. /**
  23329. * Disables writing to the depth buffer when rendering the sprites.
  23330. * It can be handy to disable depth writing when using textures without alpha channel
  23331. * and setting some specific blend modes.
  23332. */
  23333. disableDepthWrite: boolean;
  23334. /**
  23335. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  23336. */
  23337. fogEnabled: boolean;
  23338. /**
  23339. * Gets the capacity of the manager
  23340. */
  23341. get capacity(): number;
  23342. private readonly _engine;
  23343. private readonly _useVAO;
  23344. private readonly _useInstancing;
  23345. private readonly _scene;
  23346. private readonly _capacity;
  23347. private readonly _epsilon;
  23348. private _vertexBufferSize;
  23349. private _vertexData;
  23350. private _buffer;
  23351. private _vertexBuffers;
  23352. private _spriteBuffer;
  23353. private _indexBuffer;
  23354. private _effectBase;
  23355. private _effectFog;
  23356. private _vertexArrayObject;
  23357. /**
  23358. * Creates a new sprite Renderer
  23359. * @param engine defines the engine the renderer works with
  23360. * @param capacity defines the maximum allowed number of sprites
  23361. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23362. * @param scene defines the hosting scene
  23363. */
  23364. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  23365. /**
  23366. * Render all child sprites
  23367. * @param sprites defines the list of sprites to render
  23368. * @param deltaTime defines the time since last frame
  23369. * @param viewMatrix defines the viewMatrix to use to render the sprites
  23370. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  23371. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  23372. */
  23373. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  23374. private _appendSpriteVertex;
  23375. /**
  23376. * Release associated resources
  23377. */
  23378. dispose(): void;
  23379. }
  23380. }
  23381. declare module BABYLON {
  23382. /**
  23383. * Defines the minimum interface to fullfil in order to be a sprite manager.
  23384. */
  23385. export interface ISpriteManager extends IDisposable {
  23386. /**
  23387. * Gets manager's name
  23388. */
  23389. name: string;
  23390. /**
  23391. * Restricts the camera to viewing objects with the same layerMask.
  23392. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  23393. */
  23394. layerMask: number;
  23395. /**
  23396. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23397. */
  23398. isPickable: boolean;
  23399. /**
  23400. * Gets the hosting scene
  23401. */
  23402. scene: Scene;
  23403. /**
  23404. * Specifies the rendering group id for this mesh (0 by default)
  23405. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23406. */
  23407. renderingGroupId: number;
  23408. /**
  23409. * Defines the list of sprites managed by the manager.
  23410. */
  23411. sprites: Array<Sprite>;
  23412. /**
  23413. * Gets or sets the spritesheet texture
  23414. */
  23415. texture: Texture;
  23416. /** Defines the default width of a cell in the spritesheet */
  23417. cellWidth: number;
  23418. /** Defines the default height of a cell in the spritesheet */
  23419. cellHeight: number;
  23420. /**
  23421. * Tests the intersection of a sprite with a specific ray.
  23422. * @param ray The ray we are sending to test the collision
  23423. * @param camera The camera space we are sending rays in
  23424. * @param predicate A predicate allowing excluding sprites from the list of object to test
  23425. * @param fastCheck defines if the first intersection will be used (and not the closest)
  23426. * @returns picking info or null.
  23427. */
  23428. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23429. /**
  23430. * Intersects the sprites with a ray
  23431. * @param ray defines the ray to intersect with
  23432. * @param camera defines the current active camera
  23433. * @param predicate defines a predicate used to select candidate sprites
  23434. * @returns null if no hit or a PickingInfo array
  23435. */
  23436. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23437. /**
  23438. * Renders the list of sprites on screen.
  23439. */
  23440. render(): void;
  23441. }
  23442. /**
  23443. * Class used to manage multiple sprites on the same spritesheet
  23444. * @see https://doc.babylonjs.com/babylon101/sprites
  23445. */
  23446. export class SpriteManager implements ISpriteManager {
  23447. /** defines the manager's name */
  23448. name: string;
  23449. /** Define the Url to load snippets */
  23450. static SnippetUrl: string;
  23451. /** Snippet ID if the manager was created from the snippet server */
  23452. snippetId: string;
  23453. /** Gets the list of sprites */
  23454. sprites: Sprite[];
  23455. /** Gets or sets the rendering group id (0 by default) */
  23456. renderingGroupId: number;
  23457. /** Gets or sets camera layer mask */
  23458. layerMask: number;
  23459. /** Gets or sets a boolean indicating if the sprites are pickable */
  23460. isPickable: boolean;
  23461. /**
  23462. * An event triggered when the manager is disposed.
  23463. */
  23464. onDisposeObservable: Observable<SpriteManager>;
  23465. /**
  23466. * Callback called when the manager is disposed
  23467. */
  23468. set onDispose(callback: () => void);
  23469. /**
  23470. * Gets or sets the unique id of the sprite
  23471. */
  23472. uniqueId: number;
  23473. /**
  23474. * Gets the array of sprites
  23475. */
  23476. get children(): Sprite[];
  23477. /**
  23478. * Gets the hosting scene
  23479. */
  23480. get scene(): Scene;
  23481. /**
  23482. * Gets the capacity of the manager
  23483. */
  23484. get capacity(): number;
  23485. /**
  23486. * Gets or sets the spritesheet texture
  23487. */
  23488. get texture(): Texture;
  23489. set texture(value: Texture);
  23490. /** Defines the default width of a cell in the spritesheet */
  23491. get cellWidth(): number;
  23492. set cellWidth(value: number);
  23493. /** Defines the default height of a cell in the spritesheet */
  23494. get cellHeight(): number;
  23495. set cellHeight(value: number);
  23496. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  23497. get fogEnabled(): boolean;
  23498. set fogEnabled(value: boolean);
  23499. /**
  23500. * Blend mode use to render the particle, it can be any of
  23501. * the static Constants.ALPHA_x properties provided in this class.
  23502. * Default value is Constants.ALPHA_COMBINE
  23503. */
  23504. get blendMode(): number;
  23505. set blendMode(blendMode: number);
  23506. /** Disables writing to the depth buffer when rendering the sprites.
  23507. * It can be handy to disable depth writing when using textures without alpha channel
  23508. * and setting some specific blend modes.
  23509. */
  23510. disableDepthWrite: boolean;
  23511. private _spriteRenderer;
  23512. /** Associative array from JSON sprite data file */
  23513. private _cellData;
  23514. /** Array of sprite names from JSON sprite data file */
  23515. private _spriteMap;
  23516. /** True when packed cell data from JSON file is ready*/
  23517. private _packedAndReady;
  23518. private _textureContent;
  23519. private _onDisposeObserver;
  23520. private _fromPacked;
  23521. private _scene;
  23522. /**
  23523. * Creates a new sprite manager
  23524. * @param name defines the manager's name
  23525. * @param imgUrl defines the sprite sheet url
  23526. * @param capacity defines the maximum allowed number of sprites
  23527. * @param cellSize defines the size of a sprite cell
  23528. * @param scene defines the hosting scene
  23529. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  23530. * @param samplingMode defines the smapling mode to use with spritesheet
  23531. * @param fromPacked set to false; do not alter
  23532. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  23533. */
  23534. constructor(
  23535. /** defines the manager's name */
  23536. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  23537. /**
  23538. * Returns the string "SpriteManager"
  23539. * @returns "SpriteManager"
  23540. */
  23541. getClassName(): string;
  23542. private _makePacked;
  23543. private _checkTextureAlpha;
  23544. /**
  23545. * Intersects the sprites with a ray
  23546. * @param ray defines the ray to intersect with
  23547. * @param camera defines the current active camera
  23548. * @param predicate defines a predicate used to select candidate sprites
  23549. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  23550. * @returns null if no hit or a PickingInfo
  23551. */
  23552. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  23553. /**
  23554. * Intersects the sprites with a ray
  23555. * @param ray defines the ray to intersect with
  23556. * @param camera defines the current active camera
  23557. * @param predicate defines a predicate used to select candidate sprites
  23558. * @returns null if no hit or a PickingInfo array
  23559. */
  23560. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  23561. /**
  23562. * Render all child sprites
  23563. */
  23564. render(): void;
  23565. private _customUpdate;
  23566. /**
  23567. * Release associated resources
  23568. */
  23569. dispose(): void;
  23570. /**
  23571. * Serializes the sprite manager to a JSON object
  23572. * @param serializeTexture defines if the texture must be serialized as well
  23573. * @returns the JSON object
  23574. */
  23575. serialize(serializeTexture?: boolean): any;
  23576. /**
  23577. * Parses a JSON object to create a new sprite manager.
  23578. * @param parsedManager The JSON object to parse
  23579. * @param scene The scene to create the sprite managerin
  23580. * @param rootUrl The root url to use to load external dependencies like texture
  23581. * @returns the new sprite manager
  23582. */
  23583. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  23584. /**
  23585. * Creates a sprite manager from a snippet saved in a remote file
  23586. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  23587. * @param url defines the url to load from
  23588. * @param scene defines the hosting scene
  23589. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23590. * @returns a promise that will resolve to the new sprite manager
  23591. */
  23592. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23593. /**
  23594. * Creates a sprite manager from a snippet saved by the sprite editor
  23595. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  23596. * @param scene defines the hosting scene
  23597. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23598. * @returns a promise that will resolve to the new sprite manager
  23599. */
  23600. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  23601. }
  23602. }
  23603. declare module BABYLON {
  23604. /**
  23605. * Class used to represent a sprite
  23606. * @see https://doc.babylonjs.com/babylon101/sprites
  23607. */
  23608. export class Sprite extends ThinSprite implements IAnimatable {
  23609. /** defines the name */
  23610. name: string;
  23611. /** Gets or sets the current world position */
  23612. position: Vector3;
  23613. /** Gets or sets the main color */
  23614. color: Color4;
  23615. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  23616. disposeWhenFinishedAnimating: boolean;
  23617. /** Gets the list of attached animations */
  23618. animations: Nullable<Array<Animation>>;
  23619. /** Gets or sets a boolean indicating if the sprite can be picked */
  23620. isPickable: boolean;
  23621. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  23622. useAlphaForPicking: boolean;
  23623. /**
  23624. * Gets or sets the associated action manager
  23625. */
  23626. actionManager: Nullable<ActionManager>;
  23627. /**
  23628. * An event triggered when the control has been disposed
  23629. */
  23630. onDisposeObservable: Observable<Sprite>;
  23631. private _manager;
  23632. private _onAnimationEnd;
  23633. /**
  23634. * Gets or sets the sprite size
  23635. */
  23636. get size(): number;
  23637. set size(value: number);
  23638. /**
  23639. * Gets or sets the unique id of the sprite
  23640. */
  23641. uniqueId: number;
  23642. /**
  23643. * Gets the manager of this sprite
  23644. */
  23645. get manager(): ISpriteManager;
  23646. /**
  23647. * Creates a new Sprite
  23648. * @param name defines the name
  23649. * @param manager defines the manager
  23650. */
  23651. constructor(
  23652. /** defines the name */
  23653. name: string, manager: ISpriteManager);
  23654. /**
  23655. * Returns the string "Sprite"
  23656. * @returns "Sprite"
  23657. */
  23658. getClassName(): string;
  23659. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  23660. get fromIndex(): number;
  23661. set fromIndex(value: number);
  23662. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23663. get toIndex(): number;
  23664. set toIndex(value: number);
  23665. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23666. get loopAnimation(): boolean;
  23667. set loopAnimation(value: boolean);
  23668. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23669. get delay(): number;
  23670. set delay(value: number);
  23671. /**
  23672. * Starts an animation
  23673. * @param from defines the initial key
  23674. * @param to defines the end key
  23675. * @param loop defines if the animation must loop
  23676. * @param delay defines the start delay (in ms)
  23677. * @param onAnimationEnd defines a callback to call when animation ends
  23678. */
  23679. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  23680. private _endAnimation;
  23681. /** Release associated resources */
  23682. dispose(): void;
  23683. /**
  23684. * Serializes the sprite to a JSON object
  23685. * @returns the JSON object
  23686. */
  23687. serialize(): any;
  23688. /**
  23689. * Parses a JSON object to create a new sprite
  23690. * @param parsedSprite The JSON object to parse
  23691. * @param manager defines the hosting manager
  23692. * @returns the new sprite
  23693. */
  23694. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  23695. }
  23696. }
  23697. declare module BABYLON {
  23698. /**
  23699. * Information about the result of picking within a scene
  23700. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23701. */
  23702. export class PickingInfo {
  23703. /** @hidden */
  23704. _pickingUnavailable: boolean;
  23705. /**
  23706. * If the pick collided with an object
  23707. */
  23708. hit: boolean;
  23709. /**
  23710. * Distance away where the pick collided
  23711. */
  23712. distance: number;
  23713. /**
  23714. * The location of pick collision
  23715. */
  23716. pickedPoint: Nullable<Vector3>;
  23717. /**
  23718. * The mesh corresponding the the pick collision
  23719. */
  23720. pickedMesh: Nullable<AbstractMesh>;
  23721. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  23722. bu: number;
  23723. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  23724. bv: number;
  23725. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23726. faceId: number;
  23727. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23728. subMeshFaceId: number;
  23729. /** Id of the the submesh that was picked */
  23730. subMeshId: number;
  23731. /** If a sprite was picked, this will be the sprite the pick collided with */
  23732. pickedSprite: Nullable<Sprite>;
  23733. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  23734. thinInstanceIndex: number;
  23735. /**
  23736. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23737. */
  23738. originMesh: Nullable<AbstractMesh>;
  23739. /**
  23740. * The ray that was used to perform the picking.
  23741. */
  23742. ray: Nullable<Ray>;
  23743. /**
  23744. * Gets the normal correspodning to the face the pick collided with
  23745. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23746. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23747. * @returns The normal correspodning to the face the pick collided with
  23748. */
  23749. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  23750. /**
  23751. * Gets the texture coordinates of where the pick occured
  23752. * @returns the vector containing the coordnates of the texture
  23753. */
  23754. getTextureCoordinates(): Nullable<Vector2>;
  23755. }
  23756. }
  23757. declare module BABYLON {
  23758. /**
  23759. * Gather the list of pointer event types as constants.
  23760. */
  23761. export class PointerEventTypes {
  23762. /**
  23763. * 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.
  23764. */
  23765. static readonly POINTERDOWN: number;
  23766. /**
  23767. * The pointerup event is fired when a pointer is no longer active.
  23768. */
  23769. static readonly POINTERUP: number;
  23770. /**
  23771. * The pointermove event is fired when a pointer changes coordinates.
  23772. */
  23773. static readonly POINTERMOVE: number;
  23774. /**
  23775. * The pointerwheel event is fired when a mouse wheel has been rotated.
  23776. */
  23777. static readonly POINTERWHEEL: number;
  23778. /**
  23779. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  23780. */
  23781. static readonly POINTERPICK: number;
  23782. /**
  23783. * The pointertap event is fired when a the object has been touched and released without drag.
  23784. */
  23785. static readonly POINTERTAP: number;
  23786. /**
  23787. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  23788. */
  23789. static readonly POINTERDOUBLETAP: number;
  23790. }
  23791. /**
  23792. * Base class of pointer info types.
  23793. */
  23794. export class PointerInfoBase {
  23795. /**
  23796. * Defines the type of event (PointerEventTypes)
  23797. */
  23798. type: number;
  23799. /**
  23800. * Defines the related dom event
  23801. */
  23802. event: PointerEvent | MouseWheelEvent;
  23803. /**
  23804. * Instantiates the base class of pointers info.
  23805. * @param type Defines the type of event (PointerEventTypes)
  23806. * @param event Defines the related dom event
  23807. */
  23808. constructor(
  23809. /**
  23810. * Defines the type of event (PointerEventTypes)
  23811. */
  23812. type: number,
  23813. /**
  23814. * Defines the related dom event
  23815. */
  23816. event: PointerEvent | MouseWheelEvent);
  23817. }
  23818. /**
  23819. * This class is used to store pointer related info for the onPrePointerObservable event.
  23820. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  23821. */
  23822. export class PointerInfoPre extends PointerInfoBase {
  23823. /**
  23824. * Ray from a pointer if availible (eg. 6dof controller)
  23825. */
  23826. ray: Nullable<Ray>;
  23827. /**
  23828. * Defines the local position of the pointer on the canvas.
  23829. */
  23830. localPosition: Vector2;
  23831. /**
  23832. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  23833. */
  23834. skipOnPointerObservable: boolean;
  23835. /**
  23836. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  23837. * @param type Defines the type of event (PointerEventTypes)
  23838. * @param event Defines the related dom event
  23839. * @param localX Defines the local x coordinates of the pointer when the event occured
  23840. * @param localY Defines the local y coordinates of the pointer when the event occured
  23841. */
  23842. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  23843. }
  23844. /**
  23845. * This type contains all the data related to a pointer event in Babylon.js.
  23846. * 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.
  23847. */
  23848. export class PointerInfo extends PointerInfoBase {
  23849. /**
  23850. * Defines the picking info associated to the info (if any)\
  23851. */
  23852. pickInfo: Nullable<PickingInfo>;
  23853. /**
  23854. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  23855. * @param type Defines the type of event (PointerEventTypes)
  23856. * @param event Defines the related dom event
  23857. * @param pickInfo Defines the picking info associated to the info (if any)\
  23858. */
  23859. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  23860. /**
  23861. * Defines the picking info associated to the info (if any)\
  23862. */
  23863. pickInfo: Nullable<PickingInfo>);
  23864. }
  23865. /**
  23866. * Data relating to a touch event on the screen.
  23867. */
  23868. export interface PointerTouch {
  23869. /**
  23870. * X coordinate of touch.
  23871. */
  23872. x: number;
  23873. /**
  23874. * Y coordinate of touch.
  23875. */
  23876. y: number;
  23877. /**
  23878. * Id of touch. Unique for each finger.
  23879. */
  23880. pointerId: number;
  23881. /**
  23882. * Event type passed from DOM.
  23883. */
  23884. type: any;
  23885. }
  23886. }
  23887. declare module BABYLON {
  23888. /**
  23889. * Manage the mouse inputs to control the movement of a free camera.
  23890. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23891. */
  23892. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  23893. /**
  23894. * Define if touch is enabled in the mouse input
  23895. */
  23896. touchEnabled: boolean;
  23897. /**
  23898. * Defines the camera the input is attached to.
  23899. */
  23900. camera: FreeCamera;
  23901. /**
  23902. * Defines the buttons associated with the input to handle camera move.
  23903. */
  23904. buttons: number[];
  23905. /**
  23906. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  23907. */
  23908. angularSensibility: number;
  23909. private _pointerInput;
  23910. private _onMouseMove;
  23911. private _observer;
  23912. private previousPosition;
  23913. /**
  23914. * Observable for when a pointer move event occurs containing the move offset
  23915. */
  23916. onPointerMovedObservable: Observable<{
  23917. offsetX: number;
  23918. offsetY: number;
  23919. }>;
  23920. /**
  23921. * @hidden
  23922. * If the camera should be rotated automatically based on pointer movement
  23923. */
  23924. _allowCameraRotation: boolean;
  23925. /**
  23926. * Manage the mouse inputs to control the movement of a free camera.
  23927. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  23928. * @param touchEnabled Defines if touch is enabled or not
  23929. */
  23930. constructor(
  23931. /**
  23932. * Define if touch is enabled in the mouse input
  23933. */
  23934. touchEnabled?: boolean);
  23935. /**
  23936. * Attach the input controls to a specific dom element to get the input from.
  23937. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  23938. */
  23939. attachControl(noPreventDefault?: boolean): void;
  23940. /**
  23941. * Called on JS contextmenu event.
  23942. * Override this method to provide functionality.
  23943. */
  23944. protected onContextMenu(evt: PointerEvent): void;
  23945. /**
  23946. * Detach the current controls from the specified dom element.
  23947. */
  23948. detachControl(): void;
  23949. /**
  23950. * Gets the class name of the current intput.
  23951. * @returns the class name
  23952. */
  23953. getClassName(): string;
  23954. /**
  23955. * Get the friendly name associated with the input class.
  23956. * @returns the input friendly name
  23957. */
  23958. getSimpleName(): string;
  23959. }
  23960. }
  23961. declare module BABYLON {
  23962. /**
  23963. * Base class for mouse wheel input..
  23964. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  23965. * for example usage.
  23966. */
  23967. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  23968. /**
  23969. * Defines the camera the input is attached to.
  23970. */
  23971. abstract camera: Camera;
  23972. /**
  23973. * How fast is the camera moves in relation to X axis mouseWheel events.
  23974. * Use negative value to reverse direction.
  23975. */
  23976. wheelPrecisionX: number;
  23977. /**
  23978. * How fast is the camera moves in relation to Y axis mouseWheel events.
  23979. * Use negative value to reverse direction.
  23980. */
  23981. wheelPrecisionY: number;
  23982. /**
  23983. * How fast is the camera moves in relation to Z axis mouseWheel events.
  23984. * Use negative value to reverse direction.
  23985. */
  23986. wheelPrecisionZ: number;
  23987. /**
  23988. * Observable for when a mouse wheel move event occurs.
  23989. */
  23990. onChangedObservable: Observable<{
  23991. wheelDeltaX: number;
  23992. wheelDeltaY: number;
  23993. wheelDeltaZ: number;
  23994. }>;
  23995. private _wheel;
  23996. private _observer;
  23997. /**
  23998. * Attach the input controls to a specific dom element to get the input from.
  23999. * @param noPreventDefault Defines whether event caught by the controls
  24000. * should call preventdefault().
  24001. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24002. */
  24003. attachControl(noPreventDefault?: boolean): void;
  24004. /**
  24005. * Detach the current controls from the specified dom element.
  24006. */
  24007. detachControl(): void;
  24008. /**
  24009. * Called for each rendered frame.
  24010. */
  24011. checkInputs(): void;
  24012. /**
  24013. * Gets the class name of the current intput.
  24014. * @returns the class name
  24015. */
  24016. getClassName(): string;
  24017. /**
  24018. * Get the friendly name associated with the input class.
  24019. * @returns the input friendly name
  24020. */
  24021. getSimpleName(): string;
  24022. /**
  24023. * Incremental value of multiple mouse wheel movements of the X axis.
  24024. * Should be zero-ed when read.
  24025. */
  24026. protected _wheelDeltaX: number;
  24027. /**
  24028. * Incremental value of multiple mouse wheel movements of the Y axis.
  24029. * Should be zero-ed when read.
  24030. */
  24031. protected _wheelDeltaY: number;
  24032. /**
  24033. * Incremental value of multiple mouse wheel movements of the Z axis.
  24034. * Should be zero-ed when read.
  24035. */
  24036. protected _wheelDeltaZ: number;
  24037. /**
  24038. * Firefox uses a different scheme to report scroll distances to other
  24039. * browsers. Rather than use complicated methods to calculate the exact
  24040. * multiple we need to apply, let's just cheat and use a constant.
  24041. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24042. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24043. */
  24044. private readonly _ffMultiplier;
  24045. /**
  24046. * Different event attributes for wheel data fall into a few set ranges.
  24047. * Some relevant but dated date here:
  24048. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24049. */
  24050. private readonly _normalize;
  24051. }
  24052. }
  24053. declare module BABYLON {
  24054. /**
  24055. * Manage the mouse wheel inputs to control a free camera.
  24056. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24057. */
  24058. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24059. /**
  24060. * Defines the camera the input is attached to.
  24061. */
  24062. camera: FreeCamera;
  24063. /**
  24064. * Gets the class name of the current input.
  24065. * @returns the class name
  24066. */
  24067. getClassName(): string;
  24068. /**
  24069. * Set which movement axis (relative to camera's orientation) the mouse
  24070. * wheel's X axis controls.
  24071. * @param axis The axis to be moved. Set null to clear.
  24072. */
  24073. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24074. /**
  24075. * Get the configured movement axis (relative to camera's orientation) the
  24076. * mouse wheel's X axis controls.
  24077. * @returns The configured axis or null if none.
  24078. */
  24079. get wheelXMoveRelative(): Nullable<Coordinate>;
  24080. /**
  24081. * Set which movement axis (relative to camera's orientation) the mouse
  24082. * wheel's Y axis controls.
  24083. * @param axis The axis to be moved. Set null to clear.
  24084. */
  24085. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24086. /**
  24087. * Get the configured movement axis (relative to camera's orientation) the
  24088. * mouse wheel's Y axis controls.
  24089. * @returns The configured axis or null if none.
  24090. */
  24091. get wheelYMoveRelative(): Nullable<Coordinate>;
  24092. /**
  24093. * Set which movement axis (relative to camera's orientation) the mouse
  24094. * wheel's Z axis controls.
  24095. * @param axis The axis to be moved. Set null to clear.
  24096. */
  24097. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24098. /**
  24099. * Get the configured movement axis (relative to camera's orientation) the
  24100. * mouse wheel's Z axis controls.
  24101. * @returns The configured axis or null if none.
  24102. */
  24103. get wheelZMoveRelative(): Nullable<Coordinate>;
  24104. /**
  24105. * Set which rotation axis (relative to camera's orientation) the mouse
  24106. * wheel's X axis controls.
  24107. * @param axis The axis to be moved. Set null to clear.
  24108. */
  24109. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24110. /**
  24111. * Get the configured rotation axis (relative to camera's orientation) the
  24112. * mouse wheel's X axis controls.
  24113. * @returns The configured axis or null if none.
  24114. */
  24115. get wheelXRotateRelative(): Nullable<Coordinate>;
  24116. /**
  24117. * Set which rotation axis (relative to camera's orientation) the mouse
  24118. * wheel's Y axis controls.
  24119. * @param axis The axis to be moved. Set null to clear.
  24120. */
  24121. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24122. /**
  24123. * Get the configured rotation axis (relative to camera's orientation) the
  24124. * mouse wheel's Y axis controls.
  24125. * @returns The configured axis or null if none.
  24126. */
  24127. get wheelYRotateRelative(): Nullable<Coordinate>;
  24128. /**
  24129. * Set which rotation axis (relative to camera's orientation) the mouse
  24130. * wheel's Z axis controls.
  24131. * @param axis The axis to be moved. Set null to clear.
  24132. */
  24133. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24134. /**
  24135. * Get the configured rotation axis (relative to camera's orientation) the
  24136. * mouse wheel's Z axis controls.
  24137. * @returns The configured axis or null if none.
  24138. */
  24139. get wheelZRotateRelative(): Nullable<Coordinate>;
  24140. /**
  24141. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24142. * controls.
  24143. * @param axis The axis to be moved. Set null to clear.
  24144. */
  24145. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24146. /**
  24147. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24148. * X axis controls.
  24149. * @returns The configured axis or null if none.
  24150. */
  24151. get wheelXMoveScene(): Nullable<Coordinate>;
  24152. /**
  24153. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24154. * controls.
  24155. * @param axis The axis to be moved. Set null to clear.
  24156. */
  24157. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24158. /**
  24159. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24160. * Y axis controls.
  24161. * @returns The configured axis or null if none.
  24162. */
  24163. get wheelYMoveScene(): Nullable<Coordinate>;
  24164. /**
  24165. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24166. * controls.
  24167. * @param axis The axis to be moved. Set null to clear.
  24168. */
  24169. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24170. /**
  24171. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24172. * Z axis controls.
  24173. * @returns The configured axis or null if none.
  24174. */
  24175. get wheelZMoveScene(): Nullable<Coordinate>;
  24176. /**
  24177. * Called for each rendered frame.
  24178. */
  24179. checkInputs(): void;
  24180. private _moveRelative;
  24181. private _rotateRelative;
  24182. private _moveScene;
  24183. /**
  24184. * These are set to the desired default behaviour.
  24185. */
  24186. private _wheelXAction;
  24187. private _wheelXActionCoordinate;
  24188. private _wheelYAction;
  24189. private _wheelYActionCoordinate;
  24190. private _wheelZAction;
  24191. private _wheelZActionCoordinate;
  24192. /**
  24193. * Update the camera according to any configured properties for the 3
  24194. * mouse-wheel axis.
  24195. */
  24196. private _updateCamera;
  24197. }
  24198. }
  24199. declare module BABYLON {
  24200. /**
  24201. * Manage the touch inputs to control the movement of a free camera.
  24202. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24203. */
  24204. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24205. /**
  24206. * Define if mouse events can be treated as touch events
  24207. */
  24208. allowMouse: boolean;
  24209. /**
  24210. * Defines the camera the input is attached to.
  24211. */
  24212. camera: FreeCamera;
  24213. /**
  24214. * Defines the touch sensibility for rotation.
  24215. * The higher the faster.
  24216. */
  24217. touchAngularSensibility: number;
  24218. /**
  24219. * Defines the touch sensibility for move.
  24220. * The higher the faster.
  24221. */
  24222. touchMoveSensibility: number;
  24223. private _offsetX;
  24224. private _offsetY;
  24225. private _pointerPressed;
  24226. private _pointerInput?;
  24227. private _observer;
  24228. private _onLostFocus;
  24229. /**
  24230. * Manage the touch inputs to control the movement of a free camera.
  24231. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24232. * @param allowMouse Defines if mouse events can be treated as touch events
  24233. */
  24234. constructor(
  24235. /**
  24236. * Define if mouse events can be treated as touch events
  24237. */
  24238. allowMouse?: boolean);
  24239. /**
  24240. * Attach the input controls to a specific dom element to get the input from.
  24241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24242. */
  24243. attachControl(noPreventDefault?: boolean): void;
  24244. /**
  24245. * Detach the current controls from the specified dom element.
  24246. */
  24247. detachControl(): void;
  24248. /**
  24249. * Update the current camera state depending on the inputs that have been used this frame.
  24250. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24251. */
  24252. checkInputs(): void;
  24253. /**
  24254. * Gets the class name of the current intput.
  24255. * @returns the class name
  24256. */
  24257. getClassName(): string;
  24258. /**
  24259. * Get the friendly name associated with the input class.
  24260. * @returns the input friendly name
  24261. */
  24262. getSimpleName(): string;
  24263. }
  24264. }
  24265. declare module BABYLON {
  24266. /**
  24267. * Default Inputs manager for the FreeCamera.
  24268. * It groups all the default supported inputs for ease of use.
  24269. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24270. */
  24271. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24272. /**
  24273. * @hidden
  24274. */
  24275. _mouseInput: Nullable<FreeCameraMouseInput>;
  24276. /**
  24277. * @hidden
  24278. */
  24279. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24280. /**
  24281. * Instantiates a new FreeCameraInputsManager.
  24282. * @param camera Defines the camera the inputs belong to
  24283. */
  24284. constructor(camera: FreeCamera);
  24285. /**
  24286. * Add keyboard input support to the input manager.
  24287. * @returns the current input manager
  24288. */
  24289. addKeyboard(): FreeCameraInputsManager;
  24290. /**
  24291. * Add mouse input support to the input manager.
  24292. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24293. * @returns the current input manager
  24294. */
  24295. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24296. /**
  24297. * Removes the mouse input support from the manager
  24298. * @returns the current input manager
  24299. */
  24300. removeMouse(): FreeCameraInputsManager;
  24301. /**
  24302. * Add mouse wheel input support to the input manager.
  24303. * @returns the current input manager
  24304. */
  24305. addMouseWheel(): FreeCameraInputsManager;
  24306. /**
  24307. * Removes the mouse wheel input support from the manager
  24308. * @returns the current input manager
  24309. */
  24310. removeMouseWheel(): FreeCameraInputsManager;
  24311. /**
  24312. * Add touch input support to the input manager.
  24313. * @returns the current input manager
  24314. */
  24315. addTouch(): FreeCameraInputsManager;
  24316. /**
  24317. * Remove all attached input methods from a camera
  24318. */
  24319. clear(): void;
  24320. }
  24321. }
  24322. declare module BABYLON {
  24323. /**
  24324. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24325. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  24326. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24327. */
  24328. export class FreeCamera extends TargetCamera {
  24329. /**
  24330. * Define the collision ellipsoid of the camera.
  24331. * This is helpful to simulate a camera body like the player body around the camera
  24332. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  24333. */
  24334. ellipsoid: Vector3;
  24335. /**
  24336. * Define an offset for the position of the ellipsoid around the camera.
  24337. * This can be helpful to determine the center of the body near the gravity center of the body
  24338. * instead of its head.
  24339. */
  24340. ellipsoidOffset: Vector3;
  24341. /**
  24342. * Enable or disable collisions of the camera with the rest of the scene objects.
  24343. */
  24344. checkCollisions: boolean;
  24345. /**
  24346. * Enable or disable gravity on the camera.
  24347. */
  24348. applyGravity: boolean;
  24349. /**
  24350. * Define the input manager associated to the camera.
  24351. */
  24352. inputs: FreeCameraInputsManager;
  24353. /**
  24354. * Gets the input sensibility for a mouse input. (default is 2000.0)
  24355. * Higher values reduce sensitivity.
  24356. */
  24357. get angularSensibility(): number;
  24358. /**
  24359. * Sets the input sensibility for a mouse input. (default is 2000.0)
  24360. * Higher values reduce sensitivity.
  24361. */
  24362. set angularSensibility(value: number);
  24363. /**
  24364. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  24365. */
  24366. get keysUp(): number[];
  24367. set keysUp(value: number[]);
  24368. /**
  24369. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  24370. */
  24371. get keysUpward(): number[];
  24372. set keysUpward(value: number[]);
  24373. /**
  24374. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  24375. */
  24376. get keysDown(): number[];
  24377. set keysDown(value: number[]);
  24378. /**
  24379. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  24380. */
  24381. get keysDownward(): number[];
  24382. set keysDownward(value: number[]);
  24383. /**
  24384. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  24385. */
  24386. get keysLeft(): number[];
  24387. set keysLeft(value: number[]);
  24388. /**
  24389. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  24390. */
  24391. get keysRight(): number[];
  24392. set keysRight(value: number[]);
  24393. /**
  24394. * Event raised when the camera collide with a mesh in the scene.
  24395. */
  24396. onCollide: (collidedMesh: AbstractMesh) => void;
  24397. private _collider;
  24398. private _needMoveForGravity;
  24399. private _oldPosition;
  24400. private _diffPosition;
  24401. private _newPosition;
  24402. /** @hidden */
  24403. _localDirection: Vector3;
  24404. /** @hidden */
  24405. _transformedDirection: Vector3;
  24406. /**
  24407. * Instantiates a Free Camera.
  24408. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  24409. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  24410. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  24411. * @param name Define the name of the camera in the scene
  24412. * @param position Define the start position of the camera in the scene
  24413. * @param scene Define the scene the camera belongs to
  24414. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  24415. */
  24416. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24417. /**
  24418. * Attach the input controls to a specific dom element to get the input from.
  24419. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24420. */
  24421. attachControl(noPreventDefault?: boolean): void;
  24422. /**
  24423. * Attach the input controls to a specific dom element to get the input from.
  24424. * @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
  24425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24426. * BACK COMPAT SIGNATURE ONLY.
  24427. */
  24428. attachControl(ignored: any, noPreventDefault?: boolean): void;
  24429. /**
  24430. * Detach the current controls from the specified dom element.
  24431. */
  24432. detachControl(): void;
  24433. /**
  24434. * Detach the current controls from the specified dom element.
  24435. * @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
  24436. */
  24437. detachControl(ignored: any): void;
  24438. private _collisionMask;
  24439. /**
  24440. * Define a collision mask to limit the list of object the camera can collide with
  24441. */
  24442. get collisionMask(): number;
  24443. set collisionMask(mask: number);
  24444. /** @hidden */
  24445. _collideWithWorld(displacement: Vector3): void;
  24446. private _onCollisionPositionChange;
  24447. /** @hidden */
  24448. _checkInputs(): void;
  24449. /** @hidden */
  24450. _decideIfNeedsToMove(): boolean;
  24451. /** @hidden */
  24452. _updatePosition(): void;
  24453. /**
  24454. * Destroy the camera and release the current resources hold by it.
  24455. */
  24456. dispose(): void;
  24457. /**
  24458. * Gets the current object class name.
  24459. * @return the class name
  24460. */
  24461. getClassName(): string;
  24462. }
  24463. }
  24464. declare module BABYLON {
  24465. /**
  24466. * Represents a gamepad control stick position
  24467. */
  24468. export class StickValues {
  24469. /**
  24470. * The x component of the control stick
  24471. */
  24472. x: number;
  24473. /**
  24474. * The y component of the control stick
  24475. */
  24476. y: number;
  24477. /**
  24478. * Initializes the gamepad x and y control stick values
  24479. * @param x The x component of the gamepad control stick value
  24480. * @param y The y component of the gamepad control stick value
  24481. */
  24482. constructor(
  24483. /**
  24484. * The x component of the control stick
  24485. */
  24486. x: number,
  24487. /**
  24488. * The y component of the control stick
  24489. */
  24490. y: number);
  24491. }
  24492. /**
  24493. * An interface which manages callbacks for gamepad button changes
  24494. */
  24495. export interface GamepadButtonChanges {
  24496. /**
  24497. * Called when a gamepad has been changed
  24498. */
  24499. changed: boolean;
  24500. /**
  24501. * Called when a gamepad press event has been triggered
  24502. */
  24503. pressChanged: boolean;
  24504. /**
  24505. * Called when a touch event has been triggered
  24506. */
  24507. touchChanged: boolean;
  24508. /**
  24509. * Called when a value has changed
  24510. */
  24511. valueChanged: boolean;
  24512. }
  24513. /**
  24514. * Represents a gamepad
  24515. */
  24516. export class Gamepad {
  24517. /**
  24518. * The id of the gamepad
  24519. */
  24520. id: string;
  24521. /**
  24522. * The index of the gamepad
  24523. */
  24524. index: number;
  24525. /**
  24526. * The browser gamepad
  24527. */
  24528. browserGamepad: any;
  24529. /**
  24530. * Specifies what type of gamepad this represents
  24531. */
  24532. type: number;
  24533. private _leftStick;
  24534. private _rightStick;
  24535. /** @hidden */
  24536. _isConnected: boolean;
  24537. private _leftStickAxisX;
  24538. private _leftStickAxisY;
  24539. private _rightStickAxisX;
  24540. private _rightStickAxisY;
  24541. /**
  24542. * Triggered when the left control stick has been changed
  24543. */
  24544. private _onleftstickchanged;
  24545. /**
  24546. * Triggered when the right control stick has been changed
  24547. */
  24548. private _onrightstickchanged;
  24549. /**
  24550. * Represents a gamepad controller
  24551. */
  24552. static GAMEPAD: number;
  24553. /**
  24554. * Represents a generic controller
  24555. */
  24556. static GENERIC: number;
  24557. /**
  24558. * Represents an XBox controller
  24559. */
  24560. static XBOX: number;
  24561. /**
  24562. * Represents a pose-enabled controller
  24563. */
  24564. static POSE_ENABLED: number;
  24565. /**
  24566. * Represents an Dual Shock controller
  24567. */
  24568. static DUALSHOCK: number;
  24569. /**
  24570. * Specifies whether the left control stick should be Y-inverted
  24571. */
  24572. protected _invertLeftStickY: boolean;
  24573. /**
  24574. * Specifies if the gamepad has been connected
  24575. */
  24576. get isConnected(): boolean;
  24577. /**
  24578. * Initializes the gamepad
  24579. * @param id The id of the gamepad
  24580. * @param index The index of the gamepad
  24581. * @param browserGamepad The browser gamepad
  24582. * @param leftStickX The x component of the left joystick
  24583. * @param leftStickY The y component of the left joystick
  24584. * @param rightStickX The x component of the right joystick
  24585. * @param rightStickY The y component of the right joystick
  24586. */
  24587. constructor(
  24588. /**
  24589. * The id of the gamepad
  24590. */
  24591. id: string,
  24592. /**
  24593. * The index of the gamepad
  24594. */
  24595. index: number,
  24596. /**
  24597. * The browser gamepad
  24598. */
  24599. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  24600. /**
  24601. * Callback triggered when the left joystick has changed
  24602. * @param callback
  24603. */
  24604. onleftstickchanged(callback: (values: StickValues) => void): void;
  24605. /**
  24606. * Callback triggered when the right joystick has changed
  24607. * @param callback
  24608. */
  24609. onrightstickchanged(callback: (values: StickValues) => void): void;
  24610. /**
  24611. * Gets the left joystick
  24612. */
  24613. get leftStick(): StickValues;
  24614. /**
  24615. * Sets the left joystick values
  24616. */
  24617. set leftStick(newValues: StickValues);
  24618. /**
  24619. * Gets the right joystick
  24620. */
  24621. get rightStick(): StickValues;
  24622. /**
  24623. * Sets the right joystick value
  24624. */
  24625. set rightStick(newValues: StickValues);
  24626. /**
  24627. * Updates the gamepad joystick positions
  24628. */
  24629. update(): void;
  24630. /**
  24631. * Disposes the gamepad
  24632. */
  24633. dispose(): void;
  24634. }
  24635. /**
  24636. * Represents a generic gamepad
  24637. */
  24638. export class GenericPad extends Gamepad {
  24639. private _buttons;
  24640. private _onbuttondown;
  24641. private _onbuttonup;
  24642. /**
  24643. * Observable triggered when a button has been pressed
  24644. */
  24645. onButtonDownObservable: Observable<number>;
  24646. /**
  24647. * Observable triggered when a button has been released
  24648. */
  24649. onButtonUpObservable: Observable<number>;
  24650. /**
  24651. * Callback triggered when a button has been pressed
  24652. * @param callback Called when a button has been pressed
  24653. */
  24654. onbuttondown(callback: (buttonPressed: number) => void): void;
  24655. /**
  24656. * Callback triggered when a button has been released
  24657. * @param callback Called when a button has been released
  24658. */
  24659. onbuttonup(callback: (buttonReleased: number) => void): void;
  24660. /**
  24661. * Initializes the generic gamepad
  24662. * @param id The id of the generic gamepad
  24663. * @param index The index of the generic gamepad
  24664. * @param browserGamepad The browser gamepad
  24665. */
  24666. constructor(id: string, index: number, browserGamepad: any);
  24667. private _setButtonValue;
  24668. /**
  24669. * Updates the generic gamepad
  24670. */
  24671. update(): void;
  24672. /**
  24673. * Disposes the generic gamepad
  24674. */
  24675. dispose(): void;
  24676. }
  24677. }
  24678. declare module BABYLON {
  24679. /**
  24680. * Defines a runtime animation
  24681. */
  24682. export class RuntimeAnimation {
  24683. private _events;
  24684. /**
  24685. * The current frame of the runtime animation
  24686. */
  24687. private _currentFrame;
  24688. /**
  24689. * The animation used by the runtime animation
  24690. */
  24691. private _animation;
  24692. /**
  24693. * The target of the runtime animation
  24694. */
  24695. private _target;
  24696. /**
  24697. * The initiating animatable
  24698. */
  24699. private _host;
  24700. /**
  24701. * The original value of the runtime animation
  24702. */
  24703. private _originalValue;
  24704. /**
  24705. * The original blend value of the runtime animation
  24706. */
  24707. private _originalBlendValue;
  24708. /**
  24709. * The offsets cache of the runtime animation
  24710. */
  24711. private _offsetsCache;
  24712. /**
  24713. * The high limits cache of the runtime animation
  24714. */
  24715. private _highLimitsCache;
  24716. /**
  24717. * Specifies if the runtime animation has been stopped
  24718. */
  24719. private _stopped;
  24720. /**
  24721. * The blending factor of the runtime animation
  24722. */
  24723. private _blendingFactor;
  24724. /**
  24725. * The BabylonJS scene
  24726. */
  24727. private _scene;
  24728. /**
  24729. * The current value of the runtime animation
  24730. */
  24731. private _currentValue;
  24732. /** @hidden */
  24733. _animationState: _IAnimationState;
  24734. /**
  24735. * The active target of the runtime animation
  24736. */
  24737. private _activeTargets;
  24738. private _currentActiveTarget;
  24739. private _directTarget;
  24740. /**
  24741. * The target path of the runtime animation
  24742. */
  24743. private _targetPath;
  24744. /**
  24745. * The weight of the runtime animation
  24746. */
  24747. private _weight;
  24748. /**
  24749. * The ratio offset of the runtime animation
  24750. */
  24751. private _ratioOffset;
  24752. /**
  24753. * The previous delay of the runtime animation
  24754. */
  24755. private _previousDelay;
  24756. /**
  24757. * The previous ratio of the runtime animation
  24758. */
  24759. private _previousRatio;
  24760. private _enableBlending;
  24761. private _keys;
  24762. private _minFrame;
  24763. private _maxFrame;
  24764. private _minValue;
  24765. private _maxValue;
  24766. private _targetIsArray;
  24767. /**
  24768. * Gets the current frame of the runtime animation
  24769. */
  24770. get currentFrame(): number;
  24771. /**
  24772. * Gets the weight of the runtime animation
  24773. */
  24774. get weight(): number;
  24775. /**
  24776. * Gets the current value of the runtime animation
  24777. */
  24778. get currentValue(): any;
  24779. /**
  24780. * Gets the target path of the runtime animation
  24781. */
  24782. get targetPath(): string;
  24783. /**
  24784. * Gets the actual target of the runtime animation
  24785. */
  24786. get target(): any;
  24787. /**
  24788. * Gets the additive state of the runtime animation
  24789. */
  24790. get isAdditive(): boolean;
  24791. /** @hidden */
  24792. _onLoop: () => void;
  24793. /**
  24794. * Create a new RuntimeAnimation object
  24795. * @param target defines the target of the animation
  24796. * @param animation defines the source animation object
  24797. * @param scene defines the hosting scene
  24798. * @param host defines the initiating Animatable
  24799. */
  24800. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  24801. private _preparePath;
  24802. /**
  24803. * Gets the animation from the runtime animation
  24804. */
  24805. get animation(): Animation;
  24806. /**
  24807. * Resets the runtime animation to the beginning
  24808. * @param restoreOriginal defines whether to restore the target property to the original value
  24809. */
  24810. reset(restoreOriginal?: boolean): void;
  24811. /**
  24812. * Specifies if the runtime animation is stopped
  24813. * @returns Boolean specifying if the runtime animation is stopped
  24814. */
  24815. isStopped(): boolean;
  24816. /**
  24817. * Disposes of the runtime animation
  24818. */
  24819. dispose(): void;
  24820. /**
  24821. * Apply the interpolated value to the target
  24822. * @param currentValue defines the value computed by the animation
  24823. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  24824. */
  24825. setValue(currentValue: any, weight: number): void;
  24826. private _getOriginalValues;
  24827. private _setValue;
  24828. /**
  24829. * Gets the loop pmode of the runtime animation
  24830. * @returns Loop Mode
  24831. */
  24832. private _getCorrectLoopMode;
  24833. /**
  24834. * Move the current animation to a given frame
  24835. * @param frame defines the frame to move to
  24836. */
  24837. goToFrame(frame: number): void;
  24838. /**
  24839. * @hidden Internal use only
  24840. */
  24841. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  24842. /**
  24843. * Execute the current animation
  24844. * @param delay defines the delay to add to the current frame
  24845. * @param from defines the lower bound of the animation range
  24846. * @param to defines the upper bound of the animation range
  24847. * @param loop defines if the current animation must loop
  24848. * @param speedRatio defines the current speed ratio
  24849. * @param weight defines the weight of the animation (default is -1 so no weight)
  24850. * @param onLoop optional callback called when animation loops
  24851. * @returns a boolean indicating if the animation is running
  24852. */
  24853. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  24854. }
  24855. }
  24856. declare module BABYLON {
  24857. /**
  24858. * Class used to store an actual running animation
  24859. */
  24860. export class Animatable {
  24861. /** defines the target object */
  24862. target: any;
  24863. /** defines the starting frame number (default is 0) */
  24864. fromFrame: number;
  24865. /** defines the ending frame number (default is 100) */
  24866. toFrame: number;
  24867. /** defines if the animation must loop (default is false) */
  24868. loopAnimation: boolean;
  24869. /** defines a callback to call when animation ends if it is not looping */
  24870. onAnimationEnd?: (() => void) | null | undefined;
  24871. /** defines a callback to call when animation loops */
  24872. onAnimationLoop?: (() => void) | null | undefined;
  24873. /** defines whether the animation should be evaluated additively */
  24874. isAdditive: boolean;
  24875. private _localDelayOffset;
  24876. private _pausedDelay;
  24877. private _runtimeAnimations;
  24878. private _paused;
  24879. private _scene;
  24880. private _speedRatio;
  24881. private _weight;
  24882. private _syncRoot;
  24883. /**
  24884. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24885. * This will only apply for non looping animation (default is true)
  24886. */
  24887. disposeOnEnd: boolean;
  24888. /**
  24889. * Gets a boolean indicating if the animation has started
  24890. */
  24891. animationStarted: boolean;
  24892. /**
  24893. * Observer raised when the animation ends
  24894. */
  24895. onAnimationEndObservable: Observable<Animatable>;
  24896. /**
  24897. * Observer raised when the animation loops
  24898. */
  24899. onAnimationLoopObservable: Observable<Animatable>;
  24900. /**
  24901. * Gets the root Animatable used to synchronize and normalize animations
  24902. */
  24903. get syncRoot(): Nullable<Animatable>;
  24904. /**
  24905. * Gets the current frame of the first RuntimeAnimation
  24906. * Used to synchronize Animatables
  24907. */
  24908. get masterFrame(): number;
  24909. /**
  24910. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24911. */
  24912. get weight(): number;
  24913. set weight(value: number);
  24914. /**
  24915. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24916. */
  24917. get speedRatio(): number;
  24918. set speedRatio(value: number);
  24919. /**
  24920. * Creates a new Animatable
  24921. * @param scene defines the hosting scene
  24922. * @param target defines the target object
  24923. * @param fromFrame defines the starting frame number (default is 0)
  24924. * @param toFrame defines the ending frame number (default is 100)
  24925. * @param loopAnimation defines if the animation must loop (default is false)
  24926. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24927. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24928. * @param animations defines a group of animation to add to the new Animatable
  24929. * @param onAnimationLoop defines a callback to call when animation loops
  24930. * @param isAdditive defines whether the animation should be evaluated additively
  24931. */
  24932. constructor(scene: Scene,
  24933. /** defines the target object */
  24934. target: any,
  24935. /** defines the starting frame number (default is 0) */
  24936. fromFrame?: number,
  24937. /** defines the ending frame number (default is 100) */
  24938. toFrame?: number,
  24939. /** defines if the animation must loop (default is false) */
  24940. loopAnimation?: boolean, speedRatio?: number,
  24941. /** defines a callback to call when animation ends if it is not looping */
  24942. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24943. /** defines a callback to call when animation loops */
  24944. onAnimationLoop?: (() => void) | null | undefined,
  24945. /** defines whether the animation should be evaluated additively */
  24946. isAdditive?: boolean);
  24947. /**
  24948. * Synchronize and normalize current Animatable with a source Animatable
  24949. * This is useful when using animation weights and when animations are not of the same length
  24950. * @param root defines the root Animatable to synchronize with
  24951. * @returns the current Animatable
  24952. */
  24953. syncWith(root: Animatable): Animatable;
  24954. /**
  24955. * Gets the list of runtime animations
  24956. * @returns an array of RuntimeAnimation
  24957. */
  24958. getAnimations(): RuntimeAnimation[];
  24959. /**
  24960. * Adds more animations to the current animatable
  24961. * @param target defines the target of the animations
  24962. * @param animations defines the new animations to add
  24963. */
  24964. appendAnimations(target: any, animations: Animation[]): void;
  24965. /**
  24966. * Gets the source animation for a specific property
  24967. * @param property defines the propertyu to look for
  24968. * @returns null or the source animation for the given property
  24969. */
  24970. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24971. /**
  24972. * Gets the runtime animation for a specific property
  24973. * @param property defines the propertyu to look for
  24974. * @returns null or the runtime animation for the given property
  24975. */
  24976. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24977. /**
  24978. * Resets the animatable to its original state
  24979. */
  24980. reset(): void;
  24981. /**
  24982. * Allows the animatable to blend with current running animations
  24983. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24984. * @param blendingSpeed defines the blending speed to use
  24985. */
  24986. enableBlending(blendingSpeed: number): void;
  24987. /**
  24988. * Disable animation blending
  24989. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  24990. */
  24991. disableBlending(): void;
  24992. /**
  24993. * Jump directly to a given frame
  24994. * @param frame defines the frame to jump to
  24995. */
  24996. goToFrame(frame: number): void;
  24997. /**
  24998. * Pause the animation
  24999. */
  25000. pause(): void;
  25001. /**
  25002. * Restart the animation
  25003. */
  25004. restart(): void;
  25005. private _raiseOnAnimationEnd;
  25006. /**
  25007. * Stop and delete the current animation
  25008. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25009. * @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)
  25010. */
  25011. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25012. /**
  25013. * Wait asynchronously for the animation to end
  25014. * @returns a promise which will be fullfilled when the animation ends
  25015. */
  25016. waitAsync(): Promise<Animatable>;
  25017. /** @hidden */
  25018. _animate(delay: number): boolean;
  25019. }
  25020. interface Scene {
  25021. /** @hidden */
  25022. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25023. /** @hidden */
  25024. _processLateAnimationBindingsForMatrices(holder: {
  25025. totalWeight: number;
  25026. totalAdditiveWeight: number;
  25027. animations: RuntimeAnimation[];
  25028. additiveAnimations: RuntimeAnimation[];
  25029. originalValue: Matrix;
  25030. }): any;
  25031. /** @hidden */
  25032. _processLateAnimationBindingsForQuaternions(holder: {
  25033. totalWeight: number;
  25034. totalAdditiveWeight: number;
  25035. animations: RuntimeAnimation[];
  25036. additiveAnimations: RuntimeAnimation[];
  25037. originalValue: Quaternion;
  25038. }, refQuaternion: Quaternion): Quaternion;
  25039. /** @hidden */
  25040. _processLateAnimationBindings(): void;
  25041. /**
  25042. * Will start the animation sequence of a given target
  25043. * @param target defines the target
  25044. * @param from defines from which frame should animation start
  25045. * @param to defines until which frame should animation run.
  25046. * @param weight defines the weight to apply to the animation (1.0 by default)
  25047. * @param loop defines if the animation loops
  25048. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25049. * @param onAnimationEnd defines the function to be executed when the animation ends
  25050. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25051. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25052. * @param onAnimationLoop defines the callback to call when an animation loops
  25053. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25054. * @returns the animatable object created for this animation
  25055. */
  25056. 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;
  25057. /**
  25058. * Will start the animation sequence of a given target
  25059. * @param target defines the target
  25060. * @param from defines from which frame should animation start
  25061. * @param to defines until which frame should animation run.
  25062. * @param loop defines if the animation loops
  25063. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25064. * @param onAnimationEnd defines the function to be executed when the animation ends
  25065. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25066. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25067. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25068. * @param onAnimationLoop defines the callback to call when an animation loops
  25069. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25070. * @returns the animatable object created for this animation
  25071. */
  25072. 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;
  25073. /**
  25074. * Will start the animation sequence of a given target and its hierarchy
  25075. * @param target defines the target
  25076. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  25077. * @param from defines from which frame should animation start
  25078. * @param to defines until which frame should animation run.
  25079. * @param loop defines if the animation loops
  25080. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25081. * @param onAnimationEnd defines the function to be executed when the animation ends
  25082. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25083. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25084. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25085. * @param onAnimationLoop defines the callback to call when an animation loops
  25086. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25087. * @returns the list of created animatables
  25088. */
  25089. 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[];
  25090. /**
  25091. * Begin a new animation on a given node
  25092. * @param target defines the target where the animation will take place
  25093. * @param animations defines the list of animations to start
  25094. * @param from defines the initial value
  25095. * @param to defines the final value
  25096. * @param loop defines if you want animation to loop (off by default)
  25097. * @param speedRatio defines the speed ratio to apply to all animations
  25098. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25099. * @param onAnimationLoop defines the callback to call when an animation loops
  25100. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25101. * @returns the list of created animatables
  25102. */
  25103. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25104. /**
  25105. * Begin a new animation on a given node and its hierarchy
  25106. * @param target defines the root node where the animation will take place
  25107. * @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.
  25108. * @param animations defines the list of animations to start
  25109. * @param from defines the initial value
  25110. * @param to defines the final value
  25111. * @param loop defines if you want animation to loop (off by default)
  25112. * @param speedRatio defines the speed ratio to apply to all animations
  25113. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25114. * @param onAnimationLoop defines the callback to call when an animation loops
  25115. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25116. * @returns the list of animatables created for all nodes
  25117. */
  25118. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25119. /**
  25120. * Gets the animatable associated with a specific target
  25121. * @param target defines the target of the animatable
  25122. * @returns the required animatable if found
  25123. */
  25124. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25125. /**
  25126. * Gets all animatables associated with a given target
  25127. * @param target defines the target to look animatables for
  25128. * @returns an array of Animatables
  25129. */
  25130. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25131. /**
  25132. * Stops and removes all animations that have been applied to the scene
  25133. */
  25134. stopAllAnimations(): void;
  25135. /**
  25136. * Gets the current delta time used by animation engine
  25137. */
  25138. deltaTime: number;
  25139. }
  25140. interface Bone {
  25141. /**
  25142. * Copy an animation range from another bone
  25143. * @param source defines the source bone
  25144. * @param rangeName defines the range name to copy
  25145. * @param frameOffset defines the frame offset
  25146. * @param rescaleAsRequired defines if rescaling must be applied if required
  25147. * @param skelDimensionsRatio defines the scaling ratio
  25148. * @returns true if operation was successful
  25149. */
  25150. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25151. }
  25152. }
  25153. declare module BABYLON {
  25154. /**
  25155. * Class used to override all child animations of a given target
  25156. */
  25157. export class AnimationPropertiesOverride {
  25158. /**
  25159. * Gets or sets a value indicating if animation blending must be used
  25160. */
  25161. enableBlending: boolean;
  25162. /**
  25163. * Gets or sets the blending speed to use when enableBlending is true
  25164. */
  25165. blendingSpeed: number;
  25166. /**
  25167. * Gets or sets the default loop mode to use
  25168. */
  25169. loopMode: number;
  25170. }
  25171. }
  25172. declare module BABYLON {
  25173. /**
  25174. * Class used to handle skinning animations
  25175. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25176. */
  25177. export class Skeleton implements IAnimatable {
  25178. /** defines the skeleton name */
  25179. name: string;
  25180. /** defines the skeleton Id */
  25181. id: string;
  25182. /**
  25183. * Defines the list of child bones
  25184. */
  25185. bones: Bone[];
  25186. /**
  25187. * Defines an estimate of the dimension of the skeleton at rest
  25188. */
  25189. dimensionsAtRest: Vector3;
  25190. /**
  25191. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25192. */
  25193. needInitialSkinMatrix: boolean;
  25194. /**
  25195. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25196. */
  25197. overrideMesh: Nullable<AbstractMesh>;
  25198. /**
  25199. * Gets the list of animations attached to this skeleton
  25200. */
  25201. animations: Array<Animation>;
  25202. private _scene;
  25203. private _isDirty;
  25204. private _transformMatrices;
  25205. private _transformMatrixTexture;
  25206. private _meshesWithPoseMatrix;
  25207. private _animatables;
  25208. private _identity;
  25209. private _synchronizedWithMesh;
  25210. private _ranges;
  25211. private _lastAbsoluteTransformsUpdateId;
  25212. private _canUseTextureForBones;
  25213. private _uniqueId;
  25214. /** @hidden */
  25215. _numBonesWithLinkedTransformNode: number;
  25216. /** @hidden */
  25217. _hasWaitingData: Nullable<boolean>;
  25218. /** @hidden */
  25219. _waitingOverrideMeshId: Nullable<string>;
  25220. /**
  25221. * Specifies if the skeleton should be serialized
  25222. */
  25223. doNotSerialize: boolean;
  25224. private _useTextureToStoreBoneMatrices;
  25225. /**
  25226. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25227. * Please note that this option is not available if the hardware does not support it
  25228. */
  25229. get useTextureToStoreBoneMatrices(): boolean;
  25230. set useTextureToStoreBoneMatrices(value: boolean);
  25231. private _animationPropertiesOverride;
  25232. /**
  25233. * Gets or sets the animation properties override
  25234. */
  25235. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25236. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25237. /**
  25238. * List of inspectable custom properties (used by the Inspector)
  25239. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25240. */
  25241. inspectableCustomProperties: IInspectable[];
  25242. /**
  25243. * An observable triggered before computing the skeleton's matrices
  25244. */
  25245. onBeforeComputeObservable: Observable<Skeleton>;
  25246. /**
  25247. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25248. */
  25249. get isUsingTextureForMatrices(): boolean;
  25250. /**
  25251. * Gets the unique ID of this skeleton
  25252. */
  25253. get uniqueId(): number;
  25254. /**
  25255. * Creates a new skeleton
  25256. * @param name defines the skeleton name
  25257. * @param id defines the skeleton Id
  25258. * @param scene defines the hosting scene
  25259. */
  25260. constructor(
  25261. /** defines the skeleton name */
  25262. name: string,
  25263. /** defines the skeleton Id */
  25264. id: string, scene: Scene);
  25265. /**
  25266. * Gets the current object class name.
  25267. * @return the class name
  25268. */
  25269. getClassName(): string;
  25270. /**
  25271. * Returns an array containing the root bones
  25272. * @returns an array containing the root bones
  25273. */
  25274. getChildren(): Array<Bone>;
  25275. /**
  25276. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25277. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25278. * @returns a Float32Array containing matrices data
  25279. */
  25280. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25281. /**
  25282. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25283. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25284. * @returns a raw texture containing the data
  25285. */
  25286. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25287. /**
  25288. * Gets the current hosting scene
  25289. * @returns a scene object
  25290. */
  25291. getScene(): Scene;
  25292. /**
  25293. * Gets a string representing the current skeleton data
  25294. * @param fullDetails defines a boolean indicating if we want a verbose version
  25295. * @returns a string representing the current skeleton data
  25296. */
  25297. toString(fullDetails?: boolean): string;
  25298. /**
  25299. * Get bone's index searching by name
  25300. * @param name defines bone's name to search for
  25301. * @return the indice of the bone. Returns -1 if not found
  25302. */
  25303. getBoneIndexByName(name: string): number;
  25304. /**
  25305. * Creater a new animation range
  25306. * @param name defines the name of the range
  25307. * @param from defines the start key
  25308. * @param to defines the end key
  25309. */
  25310. createAnimationRange(name: string, from: number, to: number): void;
  25311. /**
  25312. * Delete a specific animation range
  25313. * @param name defines the name of the range
  25314. * @param deleteFrames defines if frames must be removed as well
  25315. */
  25316. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25317. /**
  25318. * Gets a specific animation range
  25319. * @param name defines the name of the range to look for
  25320. * @returns the requested animation range or null if not found
  25321. */
  25322. getAnimationRange(name: string): Nullable<AnimationRange>;
  25323. /**
  25324. * Gets the list of all animation ranges defined on this skeleton
  25325. * @returns an array
  25326. */
  25327. getAnimationRanges(): Nullable<AnimationRange>[];
  25328. /**
  25329. * Copy animation range from a source skeleton.
  25330. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  25331. * @param source defines the source skeleton
  25332. * @param name defines the name of the range to copy
  25333. * @param rescaleAsRequired defines if rescaling must be applied if required
  25334. * @returns true if operation was successful
  25335. */
  25336. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  25337. /**
  25338. * Forces the skeleton to go to rest pose
  25339. */
  25340. returnToRest(): void;
  25341. private _getHighestAnimationFrame;
  25342. /**
  25343. * Begin a specific animation range
  25344. * @param name defines the name of the range to start
  25345. * @param loop defines if looping must be turned on (false by default)
  25346. * @param speedRatio defines the speed ratio to apply (1 by default)
  25347. * @param onAnimationEnd defines a callback which will be called when animation will end
  25348. * @returns a new animatable
  25349. */
  25350. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25351. /**
  25352. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  25353. * @param skeleton defines the Skeleton containing the animation range to convert
  25354. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  25355. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  25356. * @returns the original skeleton
  25357. */
  25358. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  25359. /** @hidden */
  25360. _markAsDirty(): void;
  25361. /** @hidden */
  25362. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25363. /** @hidden */
  25364. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  25365. private _computeTransformMatrices;
  25366. /**
  25367. * Build all resources required to render a skeleton
  25368. */
  25369. prepare(): void;
  25370. /**
  25371. * Gets the list of animatables currently running for this skeleton
  25372. * @returns an array of animatables
  25373. */
  25374. getAnimatables(): IAnimatable[];
  25375. /**
  25376. * Clone the current skeleton
  25377. * @param name defines the name of the new skeleton
  25378. * @param id defines the id of the new skeleton
  25379. * @returns the new skeleton
  25380. */
  25381. clone(name: string, id?: string): Skeleton;
  25382. /**
  25383. * Enable animation blending for this skeleton
  25384. * @param blendingSpeed defines the blending speed to apply
  25385. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25386. */
  25387. enableBlending(blendingSpeed?: number): void;
  25388. /**
  25389. * Releases all resources associated with the current skeleton
  25390. */
  25391. dispose(): void;
  25392. /**
  25393. * Serialize the skeleton in a JSON object
  25394. * @returns a JSON object
  25395. */
  25396. serialize(): any;
  25397. /**
  25398. * Creates a new skeleton from serialized data
  25399. * @param parsedSkeleton defines the serialized data
  25400. * @param scene defines the hosting scene
  25401. * @returns a new skeleton
  25402. */
  25403. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  25404. /**
  25405. * Compute all node absolute transforms
  25406. * @param forceUpdate defines if computation must be done even if cache is up to date
  25407. */
  25408. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  25409. /**
  25410. * Gets the root pose matrix
  25411. * @returns a matrix
  25412. */
  25413. getPoseMatrix(): Nullable<Matrix>;
  25414. /**
  25415. * Sorts bones per internal index
  25416. */
  25417. sortBones(): void;
  25418. private _sortBones;
  25419. /**
  25420. * Set the current local matrix as the restPose for all bones in the skeleton.
  25421. */
  25422. setCurrentPoseAsRest(): void;
  25423. }
  25424. }
  25425. declare module BABYLON {
  25426. /**
  25427. * Class used to store bone information
  25428. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25429. */
  25430. export class Bone extends Node {
  25431. /**
  25432. * defines the bone name
  25433. */
  25434. name: string;
  25435. private static _tmpVecs;
  25436. private static _tmpQuat;
  25437. private static _tmpMats;
  25438. /**
  25439. * Gets the list of child bones
  25440. */
  25441. children: Bone[];
  25442. /** Gets the animations associated with this bone */
  25443. animations: Animation[];
  25444. /**
  25445. * Gets or sets bone length
  25446. */
  25447. length: number;
  25448. /**
  25449. * @hidden Internal only
  25450. * Set this value to map this bone to a different index in the transform matrices
  25451. * Set this value to -1 to exclude the bone from the transform matrices
  25452. */
  25453. _index: Nullable<number>;
  25454. private _skeleton;
  25455. private _localMatrix;
  25456. private _restPose;
  25457. private _bindPose;
  25458. private _baseMatrix;
  25459. private _absoluteTransform;
  25460. private _invertedAbsoluteTransform;
  25461. private _parent;
  25462. private _scalingDeterminant;
  25463. private _worldTransform;
  25464. private _localScaling;
  25465. private _localRotation;
  25466. private _localPosition;
  25467. private _needToDecompose;
  25468. private _needToCompose;
  25469. /** @hidden */
  25470. _linkedTransformNode: Nullable<TransformNode>;
  25471. /** @hidden */
  25472. _waitingTransformNodeId: Nullable<string>;
  25473. /** @hidden */
  25474. get _matrix(): Matrix;
  25475. /** @hidden */
  25476. set _matrix(value: Matrix);
  25477. /**
  25478. * Create a new bone
  25479. * @param name defines the bone name
  25480. * @param skeleton defines the parent skeleton
  25481. * @param parentBone defines the parent (can be null if the bone is the root)
  25482. * @param localMatrix defines the local matrix
  25483. * @param restPose defines the rest pose matrix
  25484. * @param baseMatrix defines the base matrix
  25485. * @param index defines index of the bone in the hiearchy
  25486. */
  25487. constructor(
  25488. /**
  25489. * defines the bone name
  25490. */
  25491. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  25492. /**
  25493. * Gets the current object class name.
  25494. * @return the class name
  25495. */
  25496. getClassName(): string;
  25497. /**
  25498. * Gets the parent skeleton
  25499. * @returns a skeleton
  25500. */
  25501. getSkeleton(): Skeleton;
  25502. /**
  25503. * Gets parent bone
  25504. * @returns a bone or null if the bone is the root of the bone hierarchy
  25505. */
  25506. getParent(): Nullable<Bone>;
  25507. /**
  25508. * Returns an array containing the root bones
  25509. * @returns an array containing the root bones
  25510. */
  25511. getChildren(): Array<Bone>;
  25512. /**
  25513. * Gets the node index in matrix array generated for rendering
  25514. * @returns the node index
  25515. */
  25516. getIndex(): number;
  25517. /**
  25518. * Sets the parent bone
  25519. * @param parent defines the parent (can be null if the bone is the root)
  25520. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25521. */
  25522. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  25523. /**
  25524. * Gets the local matrix
  25525. * @returns a matrix
  25526. */
  25527. getLocalMatrix(): Matrix;
  25528. /**
  25529. * Gets the base matrix (initial matrix which remains unchanged)
  25530. * @returns a matrix
  25531. */
  25532. getBaseMatrix(): Matrix;
  25533. /**
  25534. * Gets the rest pose matrix
  25535. * @returns a matrix
  25536. */
  25537. getRestPose(): Matrix;
  25538. /**
  25539. * Sets the rest pose matrix
  25540. * @param matrix the local-space rest pose to set for this bone
  25541. */
  25542. setRestPose(matrix: Matrix): void;
  25543. /**
  25544. * Gets the bind pose matrix
  25545. * @returns the bind pose matrix
  25546. */
  25547. getBindPose(): Matrix;
  25548. /**
  25549. * Sets the bind pose matrix
  25550. * @param matrix the local-space bind pose to set for this bone
  25551. */
  25552. setBindPose(matrix: Matrix): void;
  25553. /**
  25554. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  25555. */
  25556. getWorldMatrix(): Matrix;
  25557. /**
  25558. * Sets the local matrix to rest pose matrix
  25559. */
  25560. returnToRest(): void;
  25561. /**
  25562. * Gets the inverse of the absolute transform matrix.
  25563. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  25564. * @returns a matrix
  25565. */
  25566. getInvertedAbsoluteTransform(): Matrix;
  25567. /**
  25568. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  25569. * @returns a matrix
  25570. */
  25571. getAbsoluteTransform(): Matrix;
  25572. /**
  25573. * Links with the given transform node.
  25574. * The local matrix of this bone is copied from the transform node every frame.
  25575. * @param transformNode defines the transform node to link to
  25576. */
  25577. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  25578. /**
  25579. * Gets the node used to drive the bone's transformation
  25580. * @returns a transform node or null
  25581. */
  25582. getTransformNode(): Nullable<TransformNode>;
  25583. /** Gets or sets current position (in local space) */
  25584. get position(): Vector3;
  25585. set position(newPosition: Vector3);
  25586. /** Gets or sets current rotation (in local space) */
  25587. get rotation(): Vector3;
  25588. set rotation(newRotation: Vector3);
  25589. /** Gets or sets current rotation quaternion (in local space) */
  25590. get rotationQuaternion(): Quaternion;
  25591. set rotationQuaternion(newRotation: Quaternion);
  25592. /** Gets or sets current scaling (in local space) */
  25593. get scaling(): Vector3;
  25594. set scaling(newScaling: Vector3);
  25595. /**
  25596. * Gets the animation properties override
  25597. */
  25598. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25599. private _decompose;
  25600. private _compose;
  25601. /**
  25602. * Update the base and local matrices
  25603. * @param matrix defines the new base or local matrix
  25604. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  25605. * @param updateLocalMatrix defines if the local matrix should be updated
  25606. */
  25607. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  25608. /** @hidden */
  25609. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  25610. /**
  25611. * Flag the bone as dirty (Forcing it to update everything)
  25612. */
  25613. markAsDirty(): void;
  25614. /** @hidden */
  25615. _markAsDirtyAndCompose(): void;
  25616. private _markAsDirtyAndDecompose;
  25617. /**
  25618. * Translate the bone in local or world space
  25619. * @param vec The amount to translate the bone
  25620. * @param space The space that the translation is in
  25621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25622. */
  25623. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25624. /**
  25625. * Set the postion of the bone in local or world space
  25626. * @param position The position to set the bone
  25627. * @param space The space that the position is in
  25628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25629. */
  25630. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25631. /**
  25632. * Set the absolute position of the bone (world space)
  25633. * @param position The position to set the bone
  25634. * @param mesh The mesh that this bone is attached to
  25635. */
  25636. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  25637. /**
  25638. * Scale the bone on the x, y and z axes (in local space)
  25639. * @param x The amount to scale the bone on the x axis
  25640. * @param y The amount to scale the bone on the y axis
  25641. * @param z The amount to scale the bone on the z axis
  25642. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  25643. */
  25644. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  25645. /**
  25646. * Set the bone scaling in local space
  25647. * @param scale defines the scaling vector
  25648. */
  25649. setScale(scale: Vector3): void;
  25650. /**
  25651. * Gets the current scaling in local space
  25652. * @returns the current scaling vector
  25653. */
  25654. getScale(): Vector3;
  25655. /**
  25656. * Gets the current scaling in local space and stores it in a target vector
  25657. * @param result defines the target vector
  25658. */
  25659. getScaleToRef(result: Vector3): void;
  25660. /**
  25661. * Set the yaw, pitch, and roll of the bone in local or world space
  25662. * @param yaw The rotation of the bone on the y axis
  25663. * @param pitch The rotation of the bone on the x axis
  25664. * @param roll The rotation of the bone on the z axis
  25665. * @param space The space that the axes of rotation are in
  25666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25667. */
  25668. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  25669. /**
  25670. * Add a rotation to the bone on an axis in local or world space
  25671. * @param axis The axis to rotate the bone on
  25672. * @param amount The amount to rotate the bone
  25673. * @param space The space that the axis is in
  25674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25675. */
  25676. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  25677. /**
  25678. * Set the rotation of the bone to a particular axis angle in local or world space
  25679. * @param axis The axis to rotate the bone on
  25680. * @param angle The angle that the bone should be rotated to
  25681. * @param space The space that the axis is in
  25682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25683. */
  25684. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  25685. /**
  25686. * Set the euler rotation of the bone in local or world space
  25687. * @param rotation The euler rotation that the bone should be set to
  25688. * @param space The space that the rotation is in
  25689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25690. */
  25691. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  25692. /**
  25693. * Set the quaternion rotation of the bone in local or world space
  25694. * @param quat The quaternion rotation that the bone should be set to
  25695. * @param space The space that the rotation is in
  25696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25697. */
  25698. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  25699. /**
  25700. * Set the rotation matrix of the bone in local or world space
  25701. * @param rotMat The rotation matrix that the bone should be set to
  25702. * @param space The space that the rotation is in
  25703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25704. */
  25705. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  25706. private _rotateWithMatrix;
  25707. private _getNegativeRotationToRef;
  25708. /**
  25709. * Get the position of the bone in local or world space
  25710. * @param space The space that the returned position is in
  25711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25712. * @returns The position of the bone
  25713. */
  25714. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25715. /**
  25716. * Copy the position of the bone to a vector3 in local or world space
  25717. * @param space The space that the returned position is in
  25718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25719. * @param result The vector3 to copy the position to
  25720. */
  25721. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  25722. /**
  25723. * Get the absolute position of the bone (world space)
  25724. * @param mesh The mesh that this bone is attached to
  25725. * @returns The absolute position of the bone
  25726. */
  25727. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  25728. /**
  25729. * Copy the absolute position of the bone (world space) to the result param
  25730. * @param mesh The mesh that this bone is attached to
  25731. * @param result The vector3 to copy the absolute position to
  25732. */
  25733. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  25734. /**
  25735. * Compute the absolute transforms of this bone and its children
  25736. */
  25737. computeAbsoluteTransforms(): void;
  25738. /**
  25739. * Get the world direction from an axis that is in the local space of the bone
  25740. * @param localAxis The local direction that is used to compute the world direction
  25741. * @param mesh The mesh that this bone is attached to
  25742. * @returns The world direction
  25743. */
  25744. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25745. /**
  25746. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  25747. * @param localAxis The local direction that is used to compute the world direction
  25748. * @param mesh The mesh that this bone is attached to
  25749. * @param result The vector3 that the world direction will be copied to
  25750. */
  25751. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25752. /**
  25753. * Get the euler rotation of the bone in local or world space
  25754. * @param space The space that the rotation should be in
  25755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25756. * @returns The euler rotation
  25757. */
  25758. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  25759. /**
  25760. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  25761. * @param space The space that the rotation should be in
  25762. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25763. * @param result The vector3 that the rotation should be copied to
  25764. */
  25765. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25766. /**
  25767. * Get the quaternion rotation of the bone in either local or world space
  25768. * @param space The space that the rotation should be in
  25769. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25770. * @returns The quaternion rotation
  25771. */
  25772. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  25773. /**
  25774. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  25775. * @param space The space that the rotation should be in
  25776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25777. * @param result The quaternion that the rotation should be copied to
  25778. */
  25779. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  25780. /**
  25781. * Get the rotation matrix of the bone in local or world space
  25782. * @param space The space that the rotation should be in
  25783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25784. * @returns The rotation matrix
  25785. */
  25786. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  25787. /**
  25788. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  25789. * @param space The space that the rotation should be in
  25790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  25791. * @param result The quaternion that the rotation should be copied to
  25792. */
  25793. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  25794. /**
  25795. * Get the world position of a point that is in the local space of the bone
  25796. * @param position The local position
  25797. * @param mesh The mesh that this bone is attached to
  25798. * @returns The world position
  25799. */
  25800. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25801. /**
  25802. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  25803. * @param position The local position
  25804. * @param mesh The mesh that this bone is attached to
  25805. * @param result The vector3 that the world position should be copied to
  25806. */
  25807. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25808. /**
  25809. * Get the local position of a point that is in world space
  25810. * @param position The world position
  25811. * @param mesh The mesh that this bone is attached to
  25812. * @returns The local position
  25813. */
  25814. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  25815. /**
  25816. * Get the local position of a point that is in world space and copy it to the result param
  25817. * @param position The world position
  25818. * @param mesh The mesh that this bone is attached to
  25819. * @param result The vector3 that the local position should be copied to
  25820. */
  25821. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  25822. /**
  25823. * Set the current local matrix as the restPose for this bone.
  25824. */
  25825. setCurrentPoseAsRest(): void;
  25826. }
  25827. }
  25828. declare module BABYLON {
  25829. /**
  25830. * 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.
  25831. * @see https://doc.babylonjs.com/how_to/transformnode
  25832. */
  25833. export class TransformNode extends Node {
  25834. /**
  25835. * Object will not rotate to face the camera
  25836. */
  25837. static BILLBOARDMODE_NONE: number;
  25838. /**
  25839. * Object will rotate to face the camera but only on the x axis
  25840. */
  25841. static BILLBOARDMODE_X: number;
  25842. /**
  25843. * Object will rotate to face the camera but only on the y axis
  25844. */
  25845. static BILLBOARDMODE_Y: number;
  25846. /**
  25847. * Object will rotate to face the camera but only on the z axis
  25848. */
  25849. static BILLBOARDMODE_Z: number;
  25850. /**
  25851. * Object will rotate to face the camera
  25852. */
  25853. static BILLBOARDMODE_ALL: number;
  25854. /**
  25855. * Object will rotate to face the camera's position instead of orientation
  25856. */
  25857. static BILLBOARDMODE_USE_POSITION: number;
  25858. private static _TmpRotation;
  25859. private static _TmpScaling;
  25860. private static _TmpTranslation;
  25861. private _forward;
  25862. private _forwardInverted;
  25863. private _up;
  25864. private _right;
  25865. private _rightInverted;
  25866. private _position;
  25867. private _rotation;
  25868. private _rotationQuaternion;
  25869. protected _scaling: Vector3;
  25870. protected _isDirty: boolean;
  25871. private _transformToBoneReferal;
  25872. private _isAbsoluteSynced;
  25873. private _billboardMode;
  25874. /**
  25875. * Gets or sets the billboard mode. Default is 0.
  25876. *
  25877. * | Value | Type | Description |
  25878. * | --- | --- | --- |
  25879. * | 0 | BILLBOARDMODE_NONE | |
  25880. * | 1 | BILLBOARDMODE_X | |
  25881. * | 2 | BILLBOARDMODE_Y | |
  25882. * | 4 | BILLBOARDMODE_Z | |
  25883. * | 7 | BILLBOARDMODE_ALL | |
  25884. *
  25885. */
  25886. get billboardMode(): number;
  25887. set billboardMode(value: number);
  25888. private _preserveParentRotationForBillboard;
  25889. /**
  25890. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  25891. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  25892. */
  25893. get preserveParentRotationForBillboard(): boolean;
  25894. set preserveParentRotationForBillboard(value: boolean);
  25895. /**
  25896. * 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
  25897. */
  25898. scalingDeterminant: number;
  25899. private _infiniteDistance;
  25900. /**
  25901. * Gets or sets the distance of the object to max, often used by skybox
  25902. */
  25903. get infiniteDistance(): boolean;
  25904. set infiniteDistance(value: boolean);
  25905. /**
  25906. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  25907. * By default the system will update normals to compensate
  25908. */
  25909. ignoreNonUniformScaling: boolean;
  25910. /**
  25911. * 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
  25912. */
  25913. reIntegrateRotationIntoRotationQuaternion: boolean;
  25914. /** @hidden */
  25915. _poseMatrix: Nullable<Matrix>;
  25916. /** @hidden */
  25917. _localMatrix: Matrix;
  25918. private _usePivotMatrix;
  25919. private _absolutePosition;
  25920. private _absoluteScaling;
  25921. private _absoluteRotationQuaternion;
  25922. private _pivotMatrix;
  25923. private _pivotMatrixInverse;
  25924. /** @hidden */
  25925. _postMultiplyPivotMatrix: boolean;
  25926. protected _isWorldMatrixFrozen: boolean;
  25927. /** @hidden */
  25928. _indexInSceneTransformNodesArray: number;
  25929. /**
  25930. * An event triggered after the world matrix is updated
  25931. */
  25932. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  25933. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  25934. /**
  25935. * Gets a string identifying the name of the class
  25936. * @returns "TransformNode" string
  25937. */
  25938. getClassName(): string;
  25939. /**
  25940. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  25941. */
  25942. get position(): Vector3;
  25943. set position(newPosition: Vector3);
  25944. /**
  25945. * 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)).
  25946. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  25947. */
  25948. get rotation(): Vector3;
  25949. set rotation(newRotation: Vector3);
  25950. /**
  25951. * 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)).
  25952. */
  25953. get scaling(): Vector3;
  25954. set scaling(newScaling: Vector3);
  25955. /**
  25956. * 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).
  25957. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  25958. */
  25959. get rotationQuaternion(): Nullable<Quaternion>;
  25960. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  25961. /**
  25962. * The forward direction of that transform in world space.
  25963. */
  25964. get forward(): Vector3;
  25965. /**
  25966. * The up direction of that transform in world space.
  25967. */
  25968. get up(): Vector3;
  25969. /**
  25970. * The right direction of that transform in world space.
  25971. */
  25972. get right(): Vector3;
  25973. /**
  25974. * Copies the parameter passed Matrix into the mesh Pose matrix.
  25975. * @param matrix the matrix to copy the pose from
  25976. * @returns this TransformNode.
  25977. */
  25978. updatePoseMatrix(matrix: Matrix): TransformNode;
  25979. /**
  25980. * Returns the mesh Pose matrix.
  25981. * @returns the pose matrix
  25982. */
  25983. getPoseMatrix(): Matrix;
  25984. /** @hidden */
  25985. _isSynchronized(): boolean;
  25986. /** @hidden */
  25987. _initCache(): void;
  25988. /**
  25989. * Flag the transform node as dirty (Forcing it to update everything)
  25990. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  25991. * @returns this transform node
  25992. */
  25993. markAsDirty(property: string): TransformNode;
  25994. /**
  25995. * Returns the current mesh absolute position.
  25996. * Returns a Vector3.
  25997. */
  25998. get absolutePosition(): Vector3;
  25999. /**
  26000. * Returns the current mesh absolute scaling.
  26001. * Returns a Vector3.
  26002. */
  26003. get absoluteScaling(): Vector3;
  26004. /**
  26005. * Returns the current mesh absolute rotation.
  26006. * Returns a Quaternion.
  26007. */
  26008. get absoluteRotationQuaternion(): Quaternion;
  26009. /**
  26010. * Sets a new matrix to apply before all other transformation
  26011. * @param matrix defines the transform matrix
  26012. * @returns the current TransformNode
  26013. */
  26014. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26015. /**
  26016. * Sets a new pivot matrix to the current node
  26017. * @param matrix defines the new pivot matrix to use
  26018. * @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
  26019. * @returns the current TransformNode
  26020. */
  26021. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26022. /**
  26023. * Returns the mesh pivot matrix.
  26024. * Default : Identity.
  26025. * @returns the matrix
  26026. */
  26027. getPivotMatrix(): Matrix;
  26028. /**
  26029. * Instantiate (when possible) or clone that node with its hierarchy
  26030. * @param newParent defines the new parent to use for the instance (or clone)
  26031. * @param options defines options to configure how copy is done
  26032. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26033. * @returns an instance (or a clone) of the current node with its hiearchy
  26034. */
  26035. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26036. doNotInstantiate: boolean;
  26037. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26038. /**
  26039. * Prevents the World matrix to be computed any longer
  26040. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26041. * @returns the TransformNode.
  26042. */
  26043. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26044. /**
  26045. * Allows back the World matrix computation.
  26046. * @returns the TransformNode.
  26047. */
  26048. unfreezeWorldMatrix(): this;
  26049. /**
  26050. * True if the World matrix has been frozen.
  26051. */
  26052. get isWorldMatrixFrozen(): boolean;
  26053. /**
  26054. * Retuns the mesh absolute position in the World.
  26055. * @returns a Vector3.
  26056. */
  26057. getAbsolutePosition(): Vector3;
  26058. /**
  26059. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26060. * @param absolutePosition the absolute position to set
  26061. * @returns the TransformNode.
  26062. */
  26063. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26064. /**
  26065. * Sets the mesh position in its local space.
  26066. * @param vector3 the position to set in localspace
  26067. * @returns the TransformNode.
  26068. */
  26069. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26070. /**
  26071. * Returns the mesh position in the local space from the current World matrix values.
  26072. * @returns a new Vector3.
  26073. */
  26074. getPositionExpressedInLocalSpace(): Vector3;
  26075. /**
  26076. * Translates the mesh along the passed Vector3 in its local space.
  26077. * @param vector3 the distance to translate in localspace
  26078. * @returns the TransformNode.
  26079. */
  26080. locallyTranslate(vector3: Vector3): TransformNode;
  26081. private static _lookAtVectorCache;
  26082. /**
  26083. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26084. * @param targetPoint the position (must be in same space as current mesh) to look at
  26085. * @param yawCor optional yaw (y-axis) correction in radians
  26086. * @param pitchCor optional pitch (x-axis) correction in radians
  26087. * @param rollCor optional roll (z-axis) correction in radians
  26088. * @param space the choosen space of the target
  26089. * @returns the TransformNode.
  26090. */
  26091. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26092. /**
  26093. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26094. * This Vector3 is expressed in the World space.
  26095. * @param localAxis axis to rotate
  26096. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26097. */
  26098. getDirection(localAxis: Vector3): Vector3;
  26099. /**
  26100. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26101. * localAxis is expressed in the mesh local space.
  26102. * result is computed in the Wordl space from the mesh World matrix.
  26103. * @param localAxis axis to rotate
  26104. * @param result the resulting transformnode
  26105. * @returns this TransformNode.
  26106. */
  26107. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26108. /**
  26109. * Sets this transform node rotation to the given local axis.
  26110. * @param localAxis the axis in local space
  26111. * @param yawCor optional yaw (y-axis) correction in radians
  26112. * @param pitchCor optional pitch (x-axis) correction in radians
  26113. * @param rollCor optional roll (z-axis) correction in radians
  26114. * @returns this TransformNode
  26115. */
  26116. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26117. /**
  26118. * Sets a new pivot point to the current node
  26119. * @param point defines the new pivot point to use
  26120. * @param space defines if the point is in world or local space (local by default)
  26121. * @returns the current TransformNode
  26122. */
  26123. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26124. /**
  26125. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26126. * @returns the pivot point
  26127. */
  26128. getPivotPoint(): Vector3;
  26129. /**
  26130. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26131. * @param result the vector3 to store the result
  26132. * @returns this TransformNode.
  26133. */
  26134. getPivotPointToRef(result: Vector3): TransformNode;
  26135. /**
  26136. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26137. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26138. */
  26139. getAbsolutePivotPoint(): Vector3;
  26140. /**
  26141. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26142. * @param result vector3 to store the result
  26143. * @returns this TransformNode.
  26144. */
  26145. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26146. /**
  26147. * Defines the passed node as the parent of the current node.
  26148. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26149. * @see https://doc.babylonjs.com/how_to/parenting
  26150. * @param node the node ot set as the parent
  26151. * @returns this TransformNode.
  26152. */
  26153. setParent(node: Nullable<Node>): TransformNode;
  26154. private _nonUniformScaling;
  26155. /**
  26156. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26157. */
  26158. get nonUniformScaling(): boolean;
  26159. /** @hidden */
  26160. _updateNonUniformScalingState(value: boolean): boolean;
  26161. /**
  26162. * Attach the current TransformNode to another TransformNode associated with a bone
  26163. * @param bone Bone affecting the TransformNode
  26164. * @param affectedTransformNode TransformNode associated with the bone
  26165. * @returns this object
  26166. */
  26167. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26168. /**
  26169. * Detach the transform node if its associated with a bone
  26170. * @returns this object
  26171. */
  26172. detachFromBone(): TransformNode;
  26173. private static _rotationAxisCache;
  26174. /**
  26175. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26176. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26177. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26178. * The passed axis is also normalized.
  26179. * @param axis the axis to rotate around
  26180. * @param amount the amount to rotate in radians
  26181. * @param space Space to rotate in (Default: local)
  26182. * @returns the TransformNode.
  26183. */
  26184. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26185. /**
  26186. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26187. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26188. * The passed axis is also normalized. .
  26189. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26190. * @param point the point to rotate around
  26191. * @param axis the axis to rotate around
  26192. * @param amount the amount to rotate in radians
  26193. * @returns the TransformNode
  26194. */
  26195. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26196. /**
  26197. * Translates the mesh along the axis vector for the passed distance in the given space.
  26198. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26199. * @param axis the axis to translate in
  26200. * @param distance the distance to translate
  26201. * @param space Space to rotate in (Default: local)
  26202. * @returns the TransformNode.
  26203. */
  26204. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26205. /**
  26206. * Adds a rotation step to the mesh current rotation.
  26207. * x, y, z are Euler angles expressed in radians.
  26208. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26209. * This means this rotation is made in the mesh local space only.
  26210. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26211. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26212. * ```javascript
  26213. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26214. * ```
  26215. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26216. * 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.
  26217. * @param x Rotation to add
  26218. * @param y Rotation to add
  26219. * @param z Rotation to add
  26220. * @returns the TransformNode.
  26221. */
  26222. addRotation(x: number, y: number, z: number): TransformNode;
  26223. /**
  26224. * @hidden
  26225. */
  26226. protected _getEffectiveParent(): Nullable<Node>;
  26227. /**
  26228. * Computes the world matrix of the node
  26229. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26230. * @returns the world matrix
  26231. */
  26232. computeWorldMatrix(force?: boolean): Matrix;
  26233. /**
  26234. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26235. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26236. */
  26237. resetLocalMatrix(independentOfChildren?: boolean): void;
  26238. protected _afterComputeWorldMatrix(): void;
  26239. /**
  26240. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26241. * @param func callback function to add
  26242. *
  26243. * @returns the TransformNode.
  26244. */
  26245. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26246. /**
  26247. * Removes a registered callback function.
  26248. * @param func callback function to remove
  26249. * @returns the TransformNode.
  26250. */
  26251. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26252. /**
  26253. * Gets the position of the current mesh in camera space
  26254. * @param camera defines the camera to use
  26255. * @returns a position
  26256. */
  26257. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26258. /**
  26259. * Returns the distance from the mesh to the active camera
  26260. * @param camera defines the camera to use
  26261. * @returns the distance
  26262. */
  26263. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26264. /**
  26265. * Clone the current transform node
  26266. * @param name Name of the new clone
  26267. * @param newParent New parent for the clone
  26268. * @param doNotCloneChildren Do not clone children hierarchy
  26269. * @returns the new transform node
  26270. */
  26271. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26272. /**
  26273. * Serializes the objects information.
  26274. * @param currentSerializationObject defines the object to serialize in
  26275. * @returns the serialized object
  26276. */
  26277. serialize(currentSerializationObject?: any): any;
  26278. /**
  26279. * Returns a new TransformNode object parsed from the source provided.
  26280. * @param parsedTransformNode is the source.
  26281. * @param scene the scne the object belongs to
  26282. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26283. * @returns a new TransformNode object parsed from the source provided.
  26284. */
  26285. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26286. /**
  26287. * Get all child-transformNodes of this node
  26288. * @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
  26289. * @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
  26290. * @returns an array of TransformNode
  26291. */
  26292. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26293. /**
  26294. * Releases resources associated with this transform node.
  26295. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26296. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26297. */
  26298. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26299. /**
  26300. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26301. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26302. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26303. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26304. * @returns the current mesh
  26305. */
  26306. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26307. private _syncAbsoluteScalingAndRotation;
  26308. }
  26309. }
  26310. declare module BABYLON {
  26311. /**
  26312. * Defines the types of pose enabled controllers that are supported
  26313. */
  26314. export enum PoseEnabledControllerType {
  26315. /**
  26316. * HTC Vive
  26317. */
  26318. VIVE = 0,
  26319. /**
  26320. * Oculus Rift
  26321. */
  26322. OCULUS = 1,
  26323. /**
  26324. * Windows mixed reality
  26325. */
  26326. WINDOWS = 2,
  26327. /**
  26328. * Samsung gear VR
  26329. */
  26330. GEAR_VR = 3,
  26331. /**
  26332. * Google Daydream
  26333. */
  26334. DAYDREAM = 4,
  26335. /**
  26336. * Generic
  26337. */
  26338. GENERIC = 5
  26339. }
  26340. /**
  26341. * Defines the MutableGamepadButton interface for the state of a gamepad button
  26342. */
  26343. export interface MutableGamepadButton {
  26344. /**
  26345. * Value of the button/trigger
  26346. */
  26347. value: number;
  26348. /**
  26349. * If the button/trigger is currently touched
  26350. */
  26351. touched: boolean;
  26352. /**
  26353. * If the button/trigger is currently pressed
  26354. */
  26355. pressed: boolean;
  26356. }
  26357. /**
  26358. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  26359. * @hidden
  26360. */
  26361. export interface ExtendedGamepadButton extends GamepadButton {
  26362. /**
  26363. * If the button/trigger is currently pressed
  26364. */
  26365. readonly pressed: boolean;
  26366. /**
  26367. * If the button/trigger is currently touched
  26368. */
  26369. readonly touched: boolean;
  26370. /**
  26371. * Value of the button/trigger
  26372. */
  26373. readonly value: number;
  26374. }
  26375. /** @hidden */
  26376. export interface _GamePadFactory {
  26377. /**
  26378. * Returns whether or not the current gamepad can be created for this type of controller.
  26379. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26380. * @returns true if it can be created, otherwise false
  26381. */
  26382. canCreate(gamepadInfo: any): boolean;
  26383. /**
  26384. * Creates a new instance of the Gamepad.
  26385. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  26386. * @returns the new gamepad instance
  26387. */
  26388. create(gamepadInfo: any): Gamepad;
  26389. }
  26390. /**
  26391. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26392. */
  26393. export class PoseEnabledControllerHelper {
  26394. /** @hidden */
  26395. static _ControllerFactories: _GamePadFactory[];
  26396. /** @hidden */
  26397. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  26398. /**
  26399. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  26400. * @param vrGamepad the gamepad to initialized
  26401. * @returns a vr controller of the type the gamepad identified as
  26402. */
  26403. static InitiateController(vrGamepad: any): Gamepad;
  26404. }
  26405. /**
  26406. * Defines the PoseEnabledController object that contains state of a vr capable controller
  26407. */
  26408. export class PoseEnabledController extends Gamepad implements PoseControlled {
  26409. /**
  26410. * If the controller is used in a webXR session
  26411. */
  26412. isXR: boolean;
  26413. private _deviceRoomPosition;
  26414. private _deviceRoomRotationQuaternion;
  26415. /**
  26416. * The device position in babylon space
  26417. */
  26418. devicePosition: Vector3;
  26419. /**
  26420. * The device rotation in babylon space
  26421. */
  26422. deviceRotationQuaternion: Quaternion;
  26423. /**
  26424. * The scale factor of the device in babylon space
  26425. */
  26426. deviceScaleFactor: number;
  26427. /**
  26428. * (Likely devicePosition should be used instead) The device position in its room space
  26429. */
  26430. position: Vector3;
  26431. /**
  26432. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  26433. */
  26434. rotationQuaternion: Quaternion;
  26435. /**
  26436. * The type of controller (Eg. Windows mixed reality)
  26437. */
  26438. controllerType: PoseEnabledControllerType;
  26439. protected _calculatedPosition: Vector3;
  26440. private _calculatedRotation;
  26441. /**
  26442. * The raw pose from the device
  26443. */
  26444. rawPose: DevicePose;
  26445. private _trackPosition;
  26446. private _maxRotationDistFromHeadset;
  26447. private _draggedRoomRotation;
  26448. /**
  26449. * @hidden
  26450. */
  26451. _disableTrackPosition(fixedPosition: Vector3): void;
  26452. /**
  26453. * Internal, the mesh attached to the controller
  26454. * @hidden
  26455. */
  26456. _mesh: Nullable<AbstractMesh>;
  26457. private _poseControlledCamera;
  26458. private _leftHandSystemQuaternion;
  26459. /**
  26460. * Internal, matrix used to convert room space to babylon space
  26461. * @hidden
  26462. */
  26463. _deviceToWorld: Matrix;
  26464. /**
  26465. * Node to be used when casting a ray from the controller
  26466. * @hidden
  26467. */
  26468. _pointingPoseNode: Nullable<TransformNode>;
  26469. /**
  26470. * Name of the child mesh that can be used to cast a ray from the controller
  26471. */
  26472. static readonly POINTING_POSE: string;
  26473. /**
  26474. * Creates a new PoseEnabledController from a gamepad
  26475. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  26476. */
  26477. constructor(browserGamepad: any);
  26478. private _workingMatrix;
  26479. /**
  26480. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  26481. */
  26482. update(): void;
  26483. /**
  26484. * Updates only the pose device and mesh without doing any button event checking
  26485. */
  26486. protected _updatePoseAndMesh(): void;
  26487. /**
  26488. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  26489. * @param poseData raw pose fromthe device
  26490. */
  26491. updateFromDevice(poseData: DevicePose): void;
  26492. /**
  26493. * @hidden
  26494. */
  26495. _meshAttachedObservable: Observable<AbstractMesh>;
  26496. /**
  26497. * Attaches a mesh to the controller
  26498. * @param mesh the mesh to be attached
  26499. */
  26500. attachToMesh(mesh: AbstractMesh): void;
  26501. /**
  26502. * Attaches the controllers mesh to a camera
  26503. * @param camera the camera the mesh should be attached to
  26504. */
  26505. attachToPoseControlledCamera(camera: TargetCamera): void;
  26506. /**
  26507. * Disposes of the controller
  26508. */
  26509. dispose(): void;
  26510. /**
  26511. * The mesh that is attached to the controller
  26512. */
  26513. get mesh(): Nullable<AbstractMesh>;
  26514. /**
  26515. * Gets the ray of the controller in the direction the controller is pointing
  26516. * @param length the length the resulting ray should be
  26517. * @returns a ray in the direction the controller is pointing
  26518. */
  26519. getForwardRay(length?: number): Ray;
  26520. }
  26521. }
  26522. declare module BABYLON {
  26523. /**
  26524. * Defines the WebVRController object that represents controllers tracked in 3D space
  26525. */
  26526. export abstract class WebVRController extends PoseEnabledController {
  26527. /**
  26528. * Internal, the default controller model for the controller
  26529. */
  26530. protected _defaultModel: Nullable<AbstractMesh>;
  26531. /**
  26532. * Fired when the trigger state has changed
  26533. */
  26534. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  26535. /**
  26536. * Fired when the main button state has changed
  26537. */
  26538. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26539. /**
  26540. * Fired when the secondary button state has changed
  26541. */
  26542. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  26543. /**
  26544. * Fired when the pad state has changed
  26545. */
  26546. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  26547. /**
  26548. * Fired when controllers stick values have changed
  26549. */
  26550. onPadValuesChangedObservable: Observable<StickValues>;
  26551. /**
  26552. * Array of button availible on the controller
  26553. */
  26554. protected _buttons: Array<MutableGamepadButton>;
  26555. private _onButtonStateChange;
  26556. /**
  26557. * Fired when a controller button's state has changed
  26558. * @param callback the callback containing the button that was modified
  26559. */
  26560. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  26561. /**
  26562. * X and Y axis corresponding to the controllers joystick
  26563. */
  26564. pad: StickValues;
  26565. /**
  26566. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  26567. */
  26568. hand: string;
  26569. /**
  26570. * The default controller model for the controller
  26571. */
  26572. get defaultModel(): Nullable<AbstractMesh>;
  26573. /**
  26574. * Creates a new WebVRController from a gamepad
  26575. * @param vrGamepad the gamepad that the WebVRController should be created from
  26576. */
  26577. constructor(vrGamepad: any);
  26578. /**
  26579. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  26580. */
  26581. update(): void;
  26582. /**
  26583. * Function to be called when a button is modified
  26584. */
  26585. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  26586. /**
  26587. * Loads a mesh and attaches it to the controller
  26588. * @param scene the scene the mesh should be added to
  26589. * @param meshLoaded callback for when the mesh has been loaded
  26590. */
  26591. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  26592. private _setButtonValue;
  26593. private _changes;
  26594. private _checkChanges;
  26595. /**
  26596. * Disposes of th webVRCOntroller
  26597. */
  26598. dispose(): void;
  26599. }
  26600. }
  26601. declare module BABYLON {
  26602. /**
  26603. * The HemisphericLight simulates the ambient environment light,
  26604. * so the passed direction is the light reflection direction, not the incoming direction.
  26605. */
  26606. export class HemisphericLight extends Light {
  26607. /**
  26608. * The groundColor is the light in the opposite direction to the one specified during creation.
  26609. * 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.
  26610. */
  26611. groundColor: Color3;
  26612. /**
  26613. * The light reflection direction, not the incoming direction.
  26614. */
  26615. direction: Vector3;
  26616. /**
  26617. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  26618. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  26619. * The HemisphericLight can't cast shadows.
  26620. * Documentation : https://doc.babylonjs.com/babylon101/lights
  26621. * @param name The friendly name of the light
  26622. * @param direction The direction of the light reflection
  26623. * @param scene The scene the light belongs to
  26624. */
  26625. constructor(name: string, direction: Vector3, scene: Scene);
  26626. protected _buildUniformLayout(): void;
  26627. /**
  26628. * Returns the string "HemisphericLight".
  26629. * @return The class name
  26630. */
  26631. getClassName(): string;
  26632. /**
  26633. * Sets the HemisphericLight direction towards the passed target (Vector3).
  26634. * Returns the updated direction.
  26635. * @param target The target the direction should point to
  26636. * @return The computed direction
  26637. */
  26638. setDirectionToTarget(target: Vector3): Vector3;
  26639. /**
  26640. * Returns the shadow generator associated to the light.
  26641. * @returns Always null for hemispheric lights because it does not support shadows.
  26642. */
  26643. getShadowGenerator(): Nullable<IShadowGenerator>;
  26644. /**
  26645. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  26646. * @param effect The effect to update
  26647. * @param lightIndex The index of the light in the effect to update
  26648. * @returns The hemispheric light
  26649. */
  26650. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  26651. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  26652. /**
  26653. * Computes the world matrix of the node
  26654. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26655. * @param useWasUpdatedFlag defines a reserved property
  26656. * @returns the world matrix
  26657. */
  26658. computeWorldMatrix(): Matrix;
  26659. /**
  26660. * Returns the integer 3.
  26661. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  26662. */
  26663. getTypeID(): number;
  26664. /**
  26665. * Prepares the list of defines specific to the light type.
  26666. * @param defines the list of defines
  26667. * @param lightIndex defines the index of the light for the effect
  26668. */
  26669. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  26670. }
  26671. }
  26672. declare module BABYLON {
  26673. /** @hidden */
  26674. export var vrMultiviewToSingleviewPixelShader: {
  26675. name: string;
  26676. shader: string;
  26677. };
  26678. }
  26679. declare module BABYLON {
  26680. /**
  26681. * Renders to multiple views with a single draw call
  26682. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  26683. */
  26684. export class MultiviewRenderTarget extends RenderTargetTexture {
  26685. /**
  26686. * Creates a multiview render target
  26687. * @param scene scene used with the render target
  26688. * @param size the size of the render target (used for each view)
  26689. */
  26690. constructor(scene: Scene, size?: number | {
  26691. width: number;
  26692. height: number;
  26693. } | {
  26694. ratio: number;
  26695. });
  26696. /**
  26697. * @hidden
  26698. * @param faceIndex the face index, if its a cube texture
  26699. */
  26700. _bindFrameBuffer(faceIndex?: number): void;
  26701. /**
  26702. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  26703. * @returns the view count
  26704. */
  26705. getViewCount(): number;
  26706. }
  26707. }
  26708. declare module BABYLON {
  26709. interface Engine {
  26710. /**
  26711. * Creates a new multiview render target
  26712. * @param width defines the width of the texture
  26713. * @param height defines the height of the texture
  26714. * @returns the created multiview texture
  26715. */
  26716. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  26717. /**
  26718. * Binds a multiview framebuffer to be drawn to
  26719. * @param multiviewTexture texture to bind
  26720. */
  26721. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  26722. }
  26723. interface Camera {
  26724. /**
  26725. * @hidden
  26726. * 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)
  26727. */
  26728. _useMultiviewToSingleView: boolean;
  26729. /**
  26730. * @hidden
  26731. * 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)
  26732. */
  26733. _multiviewTexture: Nullable<RenderTargetTexture>;
  26734. /**
  26735. * @hidden
  26736. * ensures the multiview texture of the camera exists and has the specified width/height
  26737. * @param width height to set on the multiview texture
  26738. * @param height width to set on the multiview texture
  26739. */
  26740. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  26741. }
  26742. interface Scene {
  26743. /** @hidden */
  26744. _transformMatrixR: Matrix;
  26745. /** @hidden */
  26746. _multiviewSceneUbo: Nullable<UniformBuffer>;
  26747. /** @hidden */
  26748. _createMultiviewUbo(): void;
  26749. /** @hidden */
  26750. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  26751. /** @hidden */
  26752. _renderMultiviewToSingleView(camera: Camera): void;
  26753. }
  26754. }
  26755. declare module BABYLON {
  26756. /**
  26757. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  26758. * This will not be used for webXR as it supports displaying texture arrays directly
  26759. */
  26760. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  26761. /**
  26762. * Gets a string identifying the name of the class
  26763. * @returns "VRMultiviewToSingleviewPostProcess" string
  26764. */
  26765. getClassName(): string;
  26766. /**
  26767. * Initializes a VRMultiviewToSingleview
  26768. * @param name name of the post process
  26769. * @param camera camera to be applied to
  26770. * @param scaleFactor scaling factor to the size of the output texture
  26771. */
  26772. constructor(name: string, camera: Camera, scaleFactor: number);
  26773. }
  26774. }
  26775. declare module BABYLON {
  26776. /**
  26777. * Interface used to define additional presentation attributes
  26778. */
  26779. export interface IVRPresentationAttributes {
  26780. /**
  26781. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  26782. */
  26783. highRefreshRate: boolean;
  26784. /**
  26785. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  26786. */
  26787. foveationLevel: number;
  26788. }
  26789. interface Engine {
  26790. /** @hidden */
  26791. _vrDisplay: any;
  26792. /** @hidden */
  26793. _vrSupported: boolean;
  26794. /** @hidden */
  26795. _oldSize: Size;
  26796. /** @hidden */
  26797. _oldHardwareScaleFactor: number;
  26798. /** @hidden */
  26799. _vrExclusivePointerMode: boolean;
  26800. /** @hidden */
  26801. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  26802. /** @hidden */
  26803. _onVRDisplayPointerRestricted: () => void;
  26804. /** @hidden */
  26805. _onVRDisplayPointerUnrestricted: () => void;
  26806. /** @hidden */
  26807. _onVrDisplayConnect: Nullable<(display: any) => void>;
  26808. /** @hidden */
  26809. _onVrDisplayDisconnect: Nullable<() => void>;
  26810. /** @hidden */
  26811. _onVrDisplayPresentChange: Nullable<() => void>;
  26812. /**
  26813. * Observable signaled when VR display mode changes
  26814. */
  26815. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26816. /**
  26817. * Observable signaled when VR request present is complete
  26818. */
  26819. onVRRequestPresentComplete: Observable<boolean>;
  26820. /**
  26821. * Observable signaled when VR request present starts
  26822. */
  26823. onVRRequestPresentStart: Observable<Engine>;
  26824. /**
  26825. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26826. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26827. */
  26828. isInVRExclusivePointerMode: boolean;
  26829. /**
  26830. * Gets a boolean indicating if a webVR device was detected
  26831. * @returns true if a webVR device was detected
  26832. */
  26833. isVRDevicePresent(): boolean;
  26834. /**
  26835. * Gets the current webVR device
  26836. * @returns the current webVR device (or null)
  26837. */
  26838. getVRDevice(): any;
  26839. /**
  26840. * Initializes a webVR display and starts listening to display change events
  26841. * The onVRDisplayChangedObservable will be notified upon these changes
  26842. * @returns A promise containing a VRDisplay and if vr is supported
  26843. */
  26844. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  26845. /** @hidden */
  26846. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  26847. /**
  26848. * Gets or sets the presentation attributes used to configure VR rendering
  26849. */
  26850. vrPresentationAttributes?: IVRPresentationAttributes;
  26851. /**
  26852. * Call this function to switch to webVR mode
  26853. * Will do nothing if webVR is not supported or if there is no webVR device
  26854. * @param options the webvr options provided to the camera. mainly used for multiview
  26855. * @see https://doc.babylonjs.com/how_to/webvr_camera
  26856. */
  26857. enableVR(options: WebVROptions): void;
  26858. /** @hidden */
  26859. _onVRFullScreenTriggered(): void;
  26860. }
  26861. }
  26862. declare module BABYLON {
  26863. /**
  26864. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  26865. * IMPORTANT!! The data is right-hand data.
  26866. * @export
  26867. * @interface DevicePose
  26868. */
  26869. export interface DevicePose {
  26870. /**
  26871. * The position of the device, values in array are [x,y,z].
  26872. */
  26873. readonly position: Nullable<Float32Array>;
  26874. /**
  26875. * The linearVelocity of the device, values in array are [x,y,z].
  26876. */
  26877. readonly linearVelocity: Nullable<Float32Array>;
  26878. /**
  26879. * The linearAcceleration of the device, values in array are [x,y,z].
  26880. */
  26881. readonly linearAcceleration: Nullable<Float32Array>;
  26882. /**
  26883. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  26884. */
  26885. readonly orientation: Nullable<Float32Array>;
  26886. /**
  26887. * The angularVelocity of the device, values in array are [x,y,z].
  26888. */
  26889. readonly angularVelocity: Nullable<Float32Array>;
  26890. /**
  26891. * The angularAcceleration of the device, values in array are [x,y,z].
  26892. */
  26893. readonly angularAcceleration: Nullable<Float32Array>;
  26894. }
  26895. /**
  26896. * Interface representing a pose controlled object in Babylon.
  26897. * A pose controlled object has both regular pose values as well as pose values
  26898. * from an external device such as a VR head mounted display
  26899. */
  26900. export interface PoseControlled {
  26901. /**
  26902. * The position of the object in babylon space.
  26903. */
  26904. position: Vector3;
  26905. /**
  26906. * The rotation quaternion of the object in babylon space.
  26907. */
  26908. rotationQuaternion: Quaternion;
  26909. /**
  26910. * The position of the device in babylon space.
  26911. */
  26912. devicePosition?: Vector3;
  26913. /**
  26914. * The rotation quaternion of the device in babylon space.
  26915. */
  26916. deviceRotationQuaternion: Quaternion;
  26917. /**
  26918. * The raw pose coming from the device.
  26919. */
  26920. rawPose: Nullable<DevicePose>;
  26921. /**
  26922. * The scale of the device to be used when translating from device space to babylon space.
  26923. */
  26924. deviceScaleFactor: number;
  26925. /**
  26926. * Updates the poseControlled values based on the input device pose.
  26927. * @param poseData the pose data to update the object with
  26928. */
  26929. updateFromDevice(poseData: DevicePose): void;
  26930. }
  26931. /**
  26932. * Set of options to customize the webVRCamera
  26933. */
  26934. export interface WebVROptions {
  26935. /**
  26936. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  26937. */
  26938. trackPosition?: boolean;
  26939. /**
  26940. * Sets the scale of the vrDevice in babylon space. (default: 1)
  26941. */
  26942. positionScale?: number;
  26943. /**
  26944. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  26945. */
  26946. displayName?: string;
  26947. /**
  26948. * Should the native controller meshes be initialized. (default: true)
  26949. */
  26950. controllerMeshes?: boolean;
  26951. /**
  26952. * Creating a default HemiLight only on controllers. (default: true)
  26953. */
  26954. defaultLightingOnControllers?: boolean;
  26955. /**
  26956. * If you don't want to use the default VR button of the helper. (default: false)
  26957. */
  26958. useCustomVRButton?: boolean;
  26959. /**
  26960. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  26961. */
  26962. customVRButton?: HTMLButtonElement;
  26963. /**
  26964. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  26965. */
  26966. rayLength?: number;
  26967. /**
  26968. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  26969. */
  26970. defaultHeight?: number;
  26971. /**
  26972. * If multiview should be used if availible (default: false)
  26973. */
  26974. useMultiview?: boolean;
  26975. }
  26976. /**
  26977. * This represents a WebVR camera.
  26978. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  26979. * @example https://doc.babylonjs.com/how_to/webvr_camera
  26980. */
  26981. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  26982. private webVROptions;
  26983. /**
  26984. * @hidden
  26985. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  26986. */
  26987. _vrDevice: any;
  26988. /**
  26989. * The rawPose of the vrDevice.
  26990. */
  26991. rawPose: Nullable<DevicePose>;
  26992. private _onVREnabled;
  26993. private _specsVersion;
  26994. private _attached;
  26995. private _frameData;
  26996. protected _descendants: Array<Node>;
  26997. private _deviceRoomPosition;
  26998. /** @hidden */
  26999. _deviceRoomRotationQuaternion: Quaternion;
  27000. private _standingMatrix;
  27001. /**
  27002. * Represents device position in babylon space.
  27003. */
  27004. devicePosition: Vector3;
  27005. /**
  27006. * Represents device rotation in babylon space.
  27007. */
  27008. deviceRotationQuaternion: Quaternion;
  27009. /**
  27010. * The scale of the device to be used when translating from device space to babylon space.
  27011. */
  27012. deviceScaleFactor: number;
  27013. private _deviceToWorld;
  27014. private _worldToDevice;
  27015. /**
  27016. * References to the webVR controllers for the vrDevice.
  27017. */
  27018. controllers: Array<WebVRController>;
  27019. /**
  27020. * Emits an event when a controller is attached.
  27021. */
  27022. onControllersAttachedObservable: Observable<WebVRController[]>;
  27023. /**
  27024. * Emits an event when a controller's mesh has been loaded;
  27025. */
  27026. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27027. /**
  27028. * Emits an event when the HMD's pose has been updated.
  27029. */
  27030. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27031. private _poseSet;
  27032. /**
  27033. * If the rig cameras be used as parent instead of this camera.
  27034. */
  27035. rigParenting: boolean;
  27036. private _lightOnControllers;
  27037. private _defaultHeight?;
  27038. /**
  27039. * Instantiates a WebVRFreeCamera.
  27040. * @param name The name of the WebVRFreeCamera
  27041. * @param position The starting anchor position for the camera
  27042. * @param scene The scene the camera belongs to
  27043. * @param webVROptions a set of customizable options for the webVRCamera
  27044. */
  27045. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27046. /**
  27047. * Gets the device distance from the ground in meters.
  27048. * @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.
  27049. */
  27050. deviceDistanceToRoomGround(): number;
  27051. /**
  27052. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27053. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27054. */
  27055. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27056. /**
  27057. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27058. * @returns A promise with a boolean set to if the standing matrix is supported.
  27059. */
  27060. useStandingMatrixAsync(): Promise<boolean>;
  27061. /**
  27062. * Disposes the camera
  27063. */
  27064. dispose(): void;
  27065. /**
  27066. * Gets a vrController by name.
  27067. * @param name The name of the controller to retreive
  27068. * @returns the controller matching the name specified or null if not found
  27069. */
  27070. getControllerByName(name: string): Nullable<WebVRController>;
  27071. private _leftController;
  27072. /**
  27073. * The controller corresponding to the users left hand.
  27074. */
  27075. get leftController(): Nullable<WebVRController>;
  27076. private _rightController;
  27077. /**
  27078. * The controller corresponding to the users right hand.
  27079. */
  27080. get rightController(): Nullable<WebVRController>;
  27081. /**
  27082. * Casts a ray forward from the vrCamera's gaze.
  27083. * @param length Length of the ray (default: 100)
  27084. * @returns the ray corresponding to the gaze
  27085. */
  27086. getForwardRay(length?: number): Ray;
  27087. /**
  27088. * @hidden
  27089. * Updates the camera based on device's frame data
  27090. */
  27091. _checkInputs(): void;
  27092. /**
  27093. * Updates the poseControlled values based on the input device pose.
  27094. * @param poseData Pose coming from the device
  27095. */
  27096. updateFromDevice(poseData: DevicePose): void;
  27097. private _detachIfAttached;
  27098. /**
  27099. * WebVR's attach control will start broadcasting frames to the device.
  27100. * Note that in certain browsers (chrome for example) this function must be called
  27101. * within a user-interaction callback. Example:
  27102. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27103. *
  27104. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27105. */
  27106. attachControl(noPreventDefault?: boolean): void;
  27107. /**
  27108. * Detach the current controls from the specified dom element.
  27109. */
  27110. detachControl(): void;
  27111. /**
  27112. * @returns the name of this class
  27113. */
  27114. getClassName(): string;
  27115. /**
  27116. * Calls resetPose on the vrDisplay
  27117. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27118. */
  27119. resetToCurrentRotation(): void;
  27120. /**
  27121. * @hidden
  27122. * Updates the rig cameras (left and right eye)
  27123. */
  27124. _updateRigCameras(): void;
  27125. private _workingVector;
  27126. private _oneVector;
  27127. private _workingMatrix;
  27128. private updateCacheCalled;
  27129. private _correctPositionIfNotTrackPosition;
  27130. /**
  27131. * @hidden
  27132. * Updates the cached values of the camera
  27133. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27134. */
  27135. _updateCache(ignoreParentClass?: boolean): void;
  27136. /**
  27137. * @hidden
  27138. * Get current device position in babylon world
  27139. */
  27140. _computeDevicePosition(): void;
  27141. /**
  27142. * Updates the current device position and rotation in the babylon world
  27143. */
  27144. update(): void;
  27145. /**
  27146. * @hidden
  27147. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27148. * @returns an identity matrix
  27149. */
  27150. _getViewMatrix(): Matrix;
  27151. private _tmpMatrix;
  27152. /**
  27153. * This function is called by the two RIG cameras.
  27154. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27155. * @hidden
  27156. */
  27157. _getWebVRViewMatrix(): Matrix;
  27158. /** @hidden */
  27159. _getWebVRProjectionMatrix(): Matrix;
  27160. private _onGamepadConnectedObserver;
  27161. private _onGamepadDisconnectedObserver;
  27162. private _updateCacheWhenTrackingDisabledObserver;
  27163. /**
  27164. * Initializes the controllers and their meshes
  27165. */
  27166. initControllers(): void;
  27167. }
  27168. }
  27169. declare module BABYLON {
  27170. /**
  27171. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27172. *
  27173. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27174. *
  27175. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27176. */
  27177. export class MaterialHelper {
  27178. /**
  27179. * Bind the current view position to an effect.
  27180. * @param effect The effect to be bound
  27181. * @param scene The scene the eyes position is used from
  27182. * @param variableName name of the shader variable that will hold the eye position
  27183. */
  27184. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  27185. /**
  27186. * Helps preparing the defines values about the UVs in used in the effect.
  27187. * UVs are shared as much as we can accross channels in the shaders.
  27188. * @param texture The texture we are preparing the UVs for
  27189. * @param defines The defines to update
  27190. * @param key The channel key "diffuse", "specular"... used in the shader
  27191. */
  27192. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27193. /**
  27194. * Binds a texture matrix value to its corrsponding uniform
  27195. * @param texture The texture to bind the matrix for
  27196. * @param uniformBuffer The uniform buffer receivin the data
  27197. * @param key The channel key "diffuse", "specular"... used in the shader
  27198. */
  27199. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27200. /**
  27201. * Gets the current status of the fog (should it be enabled?)
  27202. * @param mesh defines the mesh to evaluate for fog support
  27203. * @param scene defines the hosting scene
  27204. * @returns true if fog must be enabled
  27205. */
  27206. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27207. /**
  27208. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27209. * @param mesh defines the current mesh
  27210. * @param scene defines the current scene
  27211. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27212. * @param pointsCloud defines if point cloud rendering has to be turned on
  27213. * @param fogEnabled defines if fog has to be turned on
  27214. * @param alphaTest defines if alpha testing has to be turned on
  27215. * @param defines defines the current list of defines
  27216. */
  27217. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27218. /**
  27219. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27220. * @param scene defines the current scene
  27221. * @param engine defines the current engine
  27222. * @param defines specifies the list of active defines
  27223. * @param useInstances defines if instances have to be turned on
  27224. * @param useClipPlane defines if clip plane have to be turned on
  27225. * @param useInstances defines if instances have to be turned on
  27226. * @param useThinInstances defines if thin instances have to be turned on
  27227. */
  27228. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27229. /**
  27230. * Prepares the defines for bones
  27231. * @param mesh The mesh containing the geometry data we will draw
  27232. * @param defines The defines to update
  27233. */
  27234. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27235. /**
  27236. * Prepares the defines for morph targets
  27237. * @param mesh The mesh containing the geometry data we will draw
  27238. * @param defines The defines to update
  27239. */
  27240. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27241. /**
  27242. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27243. * @param mesh The mesh containing the geometry data we will draw
  27244. * @param defines The defines to update
  27245. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27246. * @param useBones Precise whether bones should be used or not (override mesh info)
  27247. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27248. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27249. * @returns false if defines are considered not dirty and have not been checked
  27250. */
  27251. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27252. /**
  27253. * Prepares the defines related to multiview
  27254. * @param scene The scene we are intending to draw
  27255. * @param defines The defines to update
  27256. */
  27257. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27258. /**
  27259. * Prepares the defines related to the prepass
  27260. * @param scene The scene we are intending to draw
  27261. * @param defines The defines to update
  27262. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27263. */
  27264. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27265. /**
  27266. * Prepares the defines related to the light information passed in parameter
  27267. * @param scene The scene we are intending to draw
  27268. * @param mesh The mesh the effect is compiling for
  27269. * @param light The light the effect is compiling for
  27270. * @param lightIndex The index of the light
  27271. * @param defines The defines to update
  27272. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27273. * @param state Defines the current state regarding what is needed (normals, etc...)
  27274. */
  27275. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27276. needNormals: boolean;
  27277. needRebuild: boolean;
  27278. shadowEnabled: boolean;
  27279. specularEnabled: boolean;
  27280. lightmapMode: boolean;
  27281. }): void;
  27282. /**
  27283. * Prepares the defines related to the light information passed in parameter
  27284. * @param scene The scene we are intending to draw
  27285. * @param mesh The mesh the effect is compiling for
  27286. * @param defines The defines to update
  27287. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27288. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27289. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27290. * @returns true if normals will be required for the rest of the effect
  27291. */
  27292. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27293. /**
  27294. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27295. * @param lightIndex defines the light index
  27296. * @param uniformsList The uniform list
  27297. * @param samplersList The sampler list
  27298. * @param projectedLightTexture defines if projected texture must be used
  27299. * @param uniformBuffersList defines an optional list of uniform buffers
  27300. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  27301. */
  27302. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  27303. /**
  27304. * Prepares the uniforms and samplers list to be used in the effect
  27305. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27306. * @param samplersList The sampler list
  27307. * @param defines The defines helping in the list generation
  27308. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27309. */
  27310. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27311. /**
  27312. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  27313. * @param defines The defines to update while falling back
  27314. * @param fallbacks The authorized effect fallbacks
  27315. * @param maxSimultaneousLights The maximum number of lights allowed
  27316. * @param rank the current rank of the Effect
  27317. * @returns The newly affected rank
  27318. */
  27319. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  27320. private static _TmpMorphInfluencers;
  27321. /**
  27322. * Prepares the list of attributes required for morph targets according to the effect defines.
  27323. * @param attribs The current list of supported attribs
  27324. * @param mesh The mesh to prepare the morph targets attributes for
  27325. * @param influencers The number of influencers
  27326. */
  27327. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  27328. /**
  27329. * Prepares the list of attributes required for morph targets according to the effect defines.
  27330. * @param attribs The current list of supported attribs
  27331. * @param mesh The mesh to prepare the morph targets attributes for
  27332. * @param defines The current Defines of the effect
  27333. */
  27334. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  27335. /**
  27336. * Prepares the list of attributes required for bones according to the effect defines.
  27337. * @param attribs The current list of supported attribs
  27338. * @param mesh The mesh to prepare the bones attributes for
  27339. * @param defines The current Defines of the effect
  27340. * @param fallbacks The current efffect fallback strategy
  27341. */
  27342. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  27343. /**
  27344. * Check and prepare the list of attributes required for instances according to the effect defines.
  27345. * @param attribs The current list of supported attribs
  27346. * @param defines The current MaterialDefines of the effect
  27347. */
  27348. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  27349. /**
  27350. * Add the list of attributes required for instances to the attribs array.
  27351. * @param attribs The current list of supported attribs
  27352. */
  27353. static PushAttributesForInstances(attribs: string[]): void;
  27354. /**
  27355. * Binds the light information to the effect.
  27356. * @param light The light containing the generator
  27357. * @param effect The effect we are binding the data to
  27358. * @param lightIndex The light index in the effect used to render
  27359. */
  27360. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  27361. /**
  27362. * Binds the lights information from the scene to the effect for the given mesh.
  27363. * @param light Light to bind
  27364. * @param lightIndex Light index
  27365. * @param scene The scene where the light belongs to
  27366. * @param effect The effect we are binding the data to
  27367. * @param useSpecular Defines if specular is supported
  27368. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27369. */
  27370. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  27371. /**
  27372. * Binds the lights information from the scene to the effect for the given mesh.
  27373. * @param scene The scene the lights belongs to
  27374. * @param mesh The mesh we are binding the information to render
  27375. * @param effect The effect we are binding the data to
  27376. * @param defines The generated defines for the effect
  27377. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  27378. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  27379. */
  27380. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  27381. private static _tempFogColor;
  27382. /**
  27383. * Binds the fog information from the scene to the effect for the given mesh.
  27384. * @param scene The scene the lights belongs to
  27385. * @param mesh The mesh we are binding the information to render
  27386. * @param effect The effect we are binding the data to
  27387. * @param linearSpace Defines if the fog effect is applied in linear space
  27388. */
  27389. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  27390. /**
  27391. * Binds the bones information from the mesh to the effect.
  27392. * @param mesh The mesh we are binding the information to render
  27393. * @param effect The effect we are binding the data to
  27394. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  27395. */
  27396. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  27397. private static _CopyBonesTransformationMatrices;
  27398. /**
  27399. * Binds the morph targets information from the mesh to the effect.
  27400. * @param abstractMesh The mesh we are binding the information to render
  27401. * @param effect The effect we are binding the data to
  27402. */
  27403. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  27404. /**
  27405. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  27406. * @param defines The generated defines used in the effect
  27407. * @param effect The effect we are binding the data to
  27408. * @param scene The scene we are willing to render with logarithmic scale for
  27409. */
  27410. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  27411. /**
  27412. * Binds the clip plane information from the scene to the effect.
  27413. * @param scene The scene the clip plane information are extracted from
  27414. * @param effect The effect we are binding the data to
  27415. */
  27416. static BindClipPlane(effect: Effect, scene: Scene): void;
  27417. }
  27418. }
  27419. declare module BABYLON {
  27420. /** @hidden */
  27421. export var bayerDitherFunctions: {
  27422. name: string;
  27423. shader: string;
  27424. };
  27425. }
  27426. declare module BABYLON {
  27427. /** @hidden */
  27428. export var shadowMapFragmentDeclaration: {
  27429. name: string;
  27430. shader: string;
  27431. };
  27432. }
  27433. declare module BABYLON {
  27434. /** @hidden */
  27435. export var shadowMapFragment: {
  27436. name: string;
  27437. shader: string;
  27438. };
  27439. }
  27440. declare module BABYLON {
  27441. /** @hidden */
  27442. export var shadowMapPixelShader: {
  27443. name: string;
  27444. shader: string;
  27445. };
  27446. }
  27447. declare module BABYLON {
  27448. /** @hidden */
  27449. export var shadowMapVertexDeclaration: {
  27450. name: string;
  27451. shader: string;
  27452. };
  27453. }
  27454. declare module BABYLON {
  27455. /** @hidden */
  27456. export var shadowMapVertexNormalBias: {
  27457. name: string;
  27458. shader: string;
  27459. };
  27460. }
  27461. declare module BABYLON {
  27462. /** @hidden */
  27463. export var shadowMapVertexMetric: {
  27464. name: string;
  27465. shader: string;
  27466. };
  27467. }
  27468. declare module BABYLON {
  27469. /** @hidden */
  27470. export var shadowMapVertexShader: {
  27471. name: string;
  27472. shader: string;
  27473. };
  27474. }
  27475. declare module BABYLON {
  27476. /** @hidden */
  27477. export var depthBoxBlurPixelShader: {
  27478. name: string;
  27479. shader: string;
  27480. };
  27481. }
  27482. declare module BABYLON {
  27483. /** @hidden */
  27484. export var shadowMapFragmentSoftTransparentShadow: {
  27485. name: string;
  27486. shader: string;
  27487. };
  27488. }
  27489. declare module BABYLON {
  27490. /**
  27491. * Creates an instance based on a source mesh.
  27492. */
  27493. export class InstancedMesh extends AbstractMesh {
  27494. private _sourceMesh;
  27495. private _currentLOD;
  27496. /** @hidden */
  27497. _indexInSourceMeshInstanceArray: number;
  27498. constructor(name: string, source: Mesh);
  27499. /**
  27500. * Returns the string "InstancedMesh".
  27501. */
  27502. getClassName(): string;
  27503. /** Gets the list of lights affecting that mesh */
  27504. get lightSources(): Light[];
  27505. _resyncLightSources(): void;
  27506. _resyncLightSource(light: Light): void;
  27507. _removeLightSource(light: Light, dispose: boolean): void;
  27508. /**
  27509. * If the source mesh receives shadows
  27510. */
  27511. get receiveShadows(): boolean;
  27512. /**
  27513. * The material of the source mesh
  27514. */
  27515. get material(): Nullable<Material>;
  27516. /**
  27517. * Visibility of the source mesh
  27518. */
  27519. get visibility(): number;
  27520. /**
  27521. * Skeleton of the source mesh
  27522. */
  27523. get skeleton(): Nullable<Skeleton>;
  27524. /**
  27525. * Rendering ground id of the source mesh
  27526. */
  27527. get renderingGroupId(): number;
  27528. set renderingGroupId(value: number);
  27529. /**
  27530. * Returns the total number of vertices (integer).
  27531. */
  27532. getTotalVertices(): number;
  27533. /**
  27534. * Returns a positive integer : the total number of indices in this mesh geometry.
  27535. * @returns the numner of indices or zero if the mesh has no geometry.
  27536. */
  27537. getTotalIndices(): number;
  27538. /**
  27539. * The source mesh of the instance
  27540. */
  27541. get sourceMesh(): Mesh;
  27542. /**
  27543. * Creates a new InstancedMesh object from the mesh model.
  27544. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27545. * @param name defines the name of the new instance
  27546. * @returns a new InstancedMesh
  27547. */
  27548. createInstance(name: string): InstancedMesh;
  27549. /**
  27550. * Is this node ready to be used/rendered
  27551. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27552. * @return {boolean} is it ready
  27553. */
  27554. isReady(completeCheck?: boolean): boolean;
  27555. /**
  27556. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27557. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  27558. * @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.
  27559. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  27560. */
  27561. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  27562. /**
  27563. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27564. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27565. * The `data` are either a numeric array either a Float32Array.
  27566. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  27567. * 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).
  27568. * Note that a new underlying VertexBuffer object is created each call.
  27569. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27570. *
  27571. * Possible `kind` values :
  27572. * - VertexBuffer.PositionKind
  27573. * - VertexBuffer.UVKind
  27574. * - VertexBuffer.UV2Kind
  27575. * - VertexBuffer.UV3Kind
  27576. * - VertexBuffer.UV4Kind
  27577. * - VertexBuffer.UV5Kind
  27578. * - VertexBuffer.UV6Kind
  27579. * - VertexBuffer.ColorKind
  27580. * - VertexBuffer.MatricesIndicesKind
  27581. * - VertexBuffer.MatricesIndicesExtraKind
  27582. * - VertexBuffer.MatricesWeightsKind
  27583. * - VertexBuffer.MatricesWeightsExtraKind
  27584. *
  27585. * Returns the Mesh.
  27586. */
  27587. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27588. /**
  27589. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27590. * If the mesh has no geometry, it is simply returned as it is.
  27591. * The `data` are either a numeric array either a Float32Array.
  27592. * No new underlying VertexBuffer object is created.
  27593. * 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.
  27594. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  27595. *
  27596. * Possible `kind` values :
  27597. * - VertexBuffer.PositionKind
  27598. * - VertexBuffer.UVKind
  27599. * - VertexBuffer.UV2Kind
  27600. * - VertexBuffer.UV3Kind
  27601. * - VertexBuffer.UV4Kind
  27602. * - VertexBuffer.UV5Kind
  27603. * - VertexBuffer.UV6Kind
  27604. * - VertexBuffer.ColorKind
  27605. * - VertexBuffer.MatricesIndicesKind
  27606. * - VertexBuffer.MatricesIndicesExtraKind
  27607. * - VertexBuffer.MatricesWeightsKind
  27608. * - VertexBuffer.MatricesWeightsExtraKind
  27609. *
  27610. * Returns the Mesh.
  27611. */
  27612. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  27613. /**
  27614. * Sets the mesh indices.
  27615. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  27616. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27617. * This method creates a new index buffer each call.
  27618. * Returns the Mesh.
  27619. */
  27620. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  27621. /**
  27622. * Boolean : True if the mesh owns the requested kind of data.
  27623. */
  27624. isVerticesDataPresent(kind: string): boolean;
  27625. /**
  27626. * Returns an array of indices (IndicesArray).
  27627. */
  27628. getIndices(): Nullable<IndicesArray>;
  27629. get _positions(): Nullable<Vector3[]>;
  27630. /**
  27631. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27632. * This means the mesh underlying bounding box and sphere are recomputed.
  27633. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27634. * @returns the current mesh
  27635. */
  27636. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  27637. /** @hidden */
  27638. _preActivate(): InstancedMesh;
  27639. /** @hidden */
  27640. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27641. /** @hidden */
  27642. _postActivate(): void;
  27643. getWorldMatrix(): Matrix;
  27644. get isAnInstance(): boolean;
  27645. /**
  27646. * Returns the current associated LOD AbstractMesh.
  27647. */
  27648. getLOD(camera: Camera): AbstractMesh;
  27649. /** @hidden */
  27650. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27651. /** @hidden */
  27652. _syncSubMeshes(): InstancedMesh;
  27653. /** @hidden */
  27654. _generatePointsArray(): boolean;
  27655. /** @hidden */
  27656. _updateBoundingInfo(): AbstractMesh;
  27657. /**
  27658. * Creates a new InstancedMesh from the current mesh.
  27659. * - name (string) : the cloned mesh name
  27660. * - newParent (optional Node) : the optional Node to parent the clone to.
  27661. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  27662. *
  27663. * Returns the clone.
  27664. */
  27665. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  27666. /**
  27667. * Disposes the InstancedMesh.
  27668. * Returns nothing.
  27669. */
  27670. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27671. }
  27672. interface Mesh {
  27673. /**
  27674. * Register a custom buffer that will be instanced
  27675. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27676. * @param kind defines the buffer kind
  27677. * @param stride defines the stride in floats
  27678. */
  27679. registerInstancedBuffer(kind: string, stride: number): void;
  27680. /**
  27681. * true to use the edge renderer for all instances of this mesh
  27682. */
  27683. edgesShareWithInstances: boolean;
  27684. /** @hidden */
  27685. _userInstancedBuffersStorage: {
  27686. data: {
  27687. [key: string]: Float32Array;
  27688. };
  27689. sizes: {
  27690. [key: string]: number;
  27691. };
  27692. vertexBuffers: {
  27693. [key: string]: Nullable<VertexBuffer>;
  27694. };
  27695. strides: {
  27696. [key: string]: number;
  27697. };
  27698. };
  27699. }
  27700. interface AbstractMesh {
  27701. /**
  27702. * Object used to store instanced buffers defined by user
  27703. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  27704. */
  27705. instancedBuffers: {
  27706. [key: string]: any;
  27707. };
  27708. }
  27709. }
  27710. declare module BABYLON {
  27711. /**
  27712. * Defines the options associated with the creation of a shader material.
  27713. */
  27714. export interface IShaderMaterialOptions {
  27715. /**
  27716. * Does the material work in alpha blend mode
  27717. */
  27718. needAlphaBlending: boolean;
  27719. /**
  27720. * Does the material work in alpha test mode
  27721. */
  27722. needAlphaTesting: boolean;
  27723. /**
  27724. * The list of attribute names used in the shader
  27725. */
  27726. attributes: string[];
  27727. /**
  27728. * The list of unifrom names used in the shader
  27729. */
  27730. uniforms: string[];
  27731. /**
  27732. * The list of UBO names used in the shader
  27733. */
  27734. uniformBuffers: string[];
  27735. /**
  27736. * The list of sampler names used in the shader
  27737. */
  27738. samplers: string[];
  27739. /**
  27740. * The list of defines used in the shader
  27741. */
  27742. defines: string[];
  27743. }
  27744. /**
  27745. * 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.
  27746. *
  27747. * This returned material effects how the mesh will look based on the code in the shaders.
  27748. *
  27749. * @see https://doc.babylonjs.com/how_to/shader_material
  27750. */
  27751. export class ShaderMaterial extends Material {
  27752. private _shaderPath;
  27753. private _options;
  27754. private _textures;
  27755. private _textureArrays;
  27756. private _floats;
  27757. private _ints;
  27758. private _floatsArrays;
  27759. private _colors3;
  27760. private _colors3Arrays;
  27761. private _colors4;
  27762. private _colors4Arrays;
  27763. private _vectors2;
  27764. private _vectors3;
  27765. private _vectors4;
  27766. private _matrices;
  27767. private _matrixArrays;
  27768. private _matrices3x3;
  27769. private _matrices2x2;
  27770. private _vectors2Arrays;
  27771. private _vectors3Arrays;
  27772. private _vectors4Arrays;
  27773. private _cachedWorldViewMatrix;
  27774. private _cachedWorldViewProjectionMatrix;
  27775. private _renderId;
  27776. private _multiview;
  27777. private _cachedDefines;
  27778. /** Define the Url to load snippets */
  27779. static SnippetUrl: string;
  27780. /** Snippet ID if the material was created from the snippet server */
  27781. snippetId: string;
  27782. /**
  27783. * Instantiate a new shader material.
  27784. * 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.
  27785. * This returned material effects how the mesh will look based on the code in the shaders.
  27786. * @see https://doc.babylonjs.com/how_to/shader_material
  27787. * @param name Define the name of the material in the scene
  27788. * @param scene Define the scene the material belongs to
  27789. * @param shaderPath Defines the route to the shader code in one of three ways:
  27790. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  27791. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  27792. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  27793. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  27794. * @param options Define the options used to create the shader
  27795. */
  27796. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  27797. /**
  27798. * Gets the shader path used to define the shader code
  27799. * It can be modified to trigger a new compilation
  27800. */
  27801. get shaderPath(): any;
  27802. /**
  27803. * Sets the shader path used to define the shader code
  27804. * It can be modified to trigger a new compilation
  27805. */
  27806. set shaderPath(shaderPath: any);
  27807. /**
  27808. * Gets the options used to compile the shader.
  27809. * They can be modified to trigger a new compilation
  27810. */
  27811. get options(): IShaderMaterialOptions;
  27812. /**
  27813. * Gets the current class name of the material e.g. "ShaderMaterial"
  27814. * Mainly use in serialization.
  27815. * @returns the class name
  27816. */
  27817. getClassName(): string;
  27818. /**
  27819. * Specifies if the material will require alpha blending
  27820. * @returns a boolean specifying if alpha blending is needed
  27821. */
  27822. needAlphaBlending(): boolean;
  27823. /**
  27824. * Specifies if this material should be rendered in alpha test mode
  27825. * @returns a boolean specifying if an alpha test is needed.
  27826. */
  27827. needAlphaTesting(): boolean;
  27828. private _checkUniform;
  27829. /**
  27830. * Set a texture in the shader.
  27831. * @param name Define the name of the uniform samplers as defined in the shader
  27832. * @param texture Define the texture to bind to this sampler
  27833. * @return the material itself allowing "fluent" like uniform updates
  27834. */
  27835. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  27836. /**
  27837. * Set a texture array in the shader.
  27838. * @param name Define the name of the uniform sampler array as defined in the shader
  27839. * @param textures Define the list of textures to bind to this sampler
  27840. * @return the material itself allowing "fluent" like uniform updates
  27841. */
  27842. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  27843. /**
  27844. * Set a float in the shader.
  27845. * @param name Define the name of the uniform as defined in the shader
  27846. * @param value Define the value to give to the uniform
  27847. * @return the material itself allowing "fluent" like uniform updates
  27848. */
  27849. setFloat(name: string, value: number): ShaderMaterial;
  27850. /**
  27851. * Set a int in the shader.
  27852. * @param name Define the name of the uniform as defined in the shader
  27853. * @param value Define the value to give to the uniform
  27854. * @return the material itself allowing "fluent" like uniform updates
  27855. */
  27856. setInt(name: string, value: number): ShaderMaterial;
  27857. /**
  27858. * Set an array of floats in the shader.
  27859. * @param name Define the name of the uniform as defined in the shader
  27860. * @param value Define the value to give to the uniform
  27861. * @return the material itself allowing "fluent" like uniform updates
  27862. */
  27863. setFloats(name: string, value: number[]): ShaderMaterial;
  27864. /**
  27865. * Set a vec3 in the shader from a Color3.
  27866. * @param name Define the name of the uniform as defined in the shader
  27867. * @param value Define the value to give to the uniform
  27868. * @return the material itself allowing "fluent" like uniform updates
  27869. */
  27870. setColor3(name: string, value: Color3): ShaderMaterial;
  27871. /**
  27872. * Set a vec3 array in the shader from a Color3 array.
  27873. * @param name Define the name of the uniform as defined in the shader
  27874. * @param value Define the value to give to the uniform
  27875. * @return the material itself allowing "fluent" like uniform updates
  27876. */
  27877. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  27878. /**
  27879. * Set a vec4 in the shader from a Color4.
  27880. * @param name Define the name of the uniform as defined in the shader
  27881. * @param value Define the value to give to the uniform
  27882. * @return the material itself allowing "fluent" like uniform updates
  27883. */
  27884. setColor4(name: string, value: Color4): ShaderMaterial;
  27885. /**
  27886. * Set a vec4 array in the shader from a Color4 array.
  27887. * @param name Define the name of the uniform as defined in the shader
  27888. * @param value Define the value to give to the uniform
  27889. * @return the material itself allowing "fluent" like uniform updates
  27890. */
  27891. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  27892. /**
  27893. * Set a vec2 in the shader from a Vector2.
  27894. * @param name Define the name of the uniform as defined in the shader
  27895. * @param value Define the value to give to the uniform
  27896. * @return the material itself allowing "fluent" like uniform updates
  27897. */
  27898. setVector2(name: string, value: Vector2): ShaderMaterial;
  27899. /**
  27900. * Set a vec3 in the shader from a Vector3.
  27901. * @param name Define the name of the uniform as defined in the shader
  27902. * @param value Define the value to give to the uniform
  27903. * @return the material itself allowing "fluent" like uniform updates
  27904. */
  27905. setVector3(name: string, value: Vector3): ShaderMaterial;
  27906. /**
  27907. * Set a vec4 in the shader from a Vector4.
  27908. * @param name Define the name of the uniform as defined in the shader
  27909. * @param value Define the value to give to the uniform
  27910. * @return the material itself allowing "fluent" like uniform updates
  27911. */
  27912. setVector4(name: string, value: Vector4): ShaderMaterial;
  27913. /**
  27914. * Set a mat4 in the shader from a Matrix.
  27915. * @param name Define the name of the uniform as defined in the shader
  27916. * @param value Define the value to give to the uniform
  27917. * @return the material itself allowing "fluent" like uniform updates
  27918. */
  27919. setMatrix(name: string, value: Matrix): ShaderMaterial;
  27920. /**
  27921. * Set a float32Array in the shader from a matrix array.
  27922. * @param name Define the name of the uniform as defined in the shader
  27923. * @param value Define the value to give to the uniform
  27924. * @return the material itself allowing "fluent" like uniform updates
  27925. */
  27926. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  27927. /**
  27928. * Set a mat3 in the shader from a Float32Array.
  27929. * @param name Define the name of the uniform as defined in the shader
  27930. * @param value Define the value to give to the uniform
  27931. * @return the material itself allowing "fluent" like uniform updates
  27932. */
  27933. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27934. /**
  27935. * Set a mat2 in the shader from a Float32Array.
  27936. * @param name Define the name of the uniform as defined in the shader
  27937. * @param value Define the value to give to the uniform
  27938. * @return the material itself allowing "fluent" like uniform updates
  27939. */
  27940. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  27941. /**
  27942. * Set a vec2 array in the shader from a number array.
  27943. * @param name Define the name of the uniform as defined in the shader
  27944. * @param value Define the value to give to the uniform
  27945. * @return the material itself allowing "fluent" like uniform updates
  27946. */
  27947. setArray2(name: string, value: number[]): ShaderMaterial;
  27948. /**
  27949. * Set a vec3 array in the shader from a number array.
  27950. * @param name Define the name of the uniform as defined in the shader
  27951. * @param value Define the value to give to the uniform
  27952. * @return the material itself allowing "fluent" like uniform updates
  27953. */
  27954. setArray3(name: string, value: number[]): ShaderMaterial;
  27955. /**
  27956. * Set a vec4 array in the shader from a number array.
  27957. * @param name Define the name of the uniform as defined in the shader
  27958. * @param value Define the value to give to the uniform
  27959. * @return the material itself allowing "fluent" like uniform updates
  27960. */
  27961. setArray4(name: string, value: number[]): ShaderMaterial;
  27962. private _checkCache;
  27963. /**
  27964. * Specifies that the submesh is ready to be used
  27965. * @param mesh defines the mesh to check
  27966. * @param subMesh defines which submesh to check
  27967. * @param useInstances specifies that instances should be used
  27968. * @returns a boolean indicating that the submesh is ready or not
  27969. */
  27970. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27971. /**
  27972. * Checks if the material is ready to render the requested mesh
  27973. * @param mesh Define the mesh to render
  27974. * @param useInstances Define whether or not the material is used with instances
  27975. * @returns true if ready, otherwise false
  27976. */
  27977. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27978. /**
  27979. * Binds the world matrix to the material
  27980. * @param world defines the world transformation matrix
  27981. * @param effectOverride - If provided, use this effect instead of internal effect
  27982. */
  27983. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  27984. /**
  27985. * Binds the submesh to this material by preparing the effect and shader to draw
  27986. * @param world defines the world transformation matrix
  27987. * @param mesh defines the mesh containing the submesh
  27988. * @param subMesh defines the submesh to bind the material to
  27989. */
  27990. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27991. /**
  27992. * Binds the material to the mesh
  27993. * @param world defines the world transformation matrix
  27994. * @param mesh defines the mesh to bind the material to
  27995. * @param effectOverride - If provided, use this effect instead of internal effect
  27996. */
  27997. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  27998. protected _afterBind(mesh?: Mesh): void;
  27999. /**
  28000. * Gets the active textures from the material
  28001. * @returns an array of textures
  28002. */
  28003. getActiveTextures(): BaseTexture[];
  28004. /**
  28005. * Specifies if the material uses a texture
  28006. * @param texture defines the texture to check against the material
  28007. * @returns a boolean specifying if the material uses the texture
  28008. */
  28009. hasTexture(texture: BaseTexture): boolean;
  28010. /**
  28011. * Makes a duplicate of the material, and gives it a new name
  28012. * @param name defines the new name for the duplicated material
  28013. * @returns the cloned material
  28014. */
  28015. clone(name: string): ShaderMaterial;
  28016. /**
  28017. * Disposes the material
  28018. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28019. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28020. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28021. */
  28022. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28023. /**
  28024. * Serializes this material in a JSON representation
  28025. * @returns the serialized material object
  28026. */
  28027. serialize(): any;
  28028. /**
  28029. * Creates a shader material from parsed shader material data
  28030. * @param source defines the JSON represnetation of the material
  28031. * @param scene defines the hosting scene
  28032. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28033. * @returns a new material
  28034. */
  28035. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28036. /**
  28037. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28038. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28039. * @param url defines the url to load from
  28040. * @param scene defines the hosting scene
  28041. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28042. * @returns a promise that will resolve to the new ShaderMaterial
  28043. */
  28044. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28045. /**
  28046. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28047. * @param snippetId defines the snippet to load
  28048. * @param scene defines the hosting scene
  28049. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28050. * @returns a promise that will resolve to the new ShaderMaterial
  28051. */
  28052. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28053. }
  28054. }
  28055. declare module BABYLON {
  28056. /** @hidden */
  28057. export var colorPixelShader: {
  28058. name: string;
  28059. shader: string;
  28060. };
  28061. }
  28062. declare module BABYLON {
  28063. /** @hidden */
  28064. export var colorVertexShader: {
  28065. name: string;
  28066. shader: string;
  28067. };
  28068. }
  28069. declare module BABYLON {
  28070. /**
  28071. * Line mesh
  28072. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28073. */
  28074. export class LinesMesh extends Mesh {
  28075. /**
  28076. * If vertex color should be applied to the mesh
  28077. */
  28078. readonly useVertexColor?: boolean | undefined;
  28079. /**
  28080. * If vertex alpha should be applied to the mesh
  28081. */
  28082. readonly useVertexAlpha?: boolean | undefined;
  28083. /**
  28084. * Color of the line (Default: White)
  28085. */
  28086. color: Color3;
  28087. /**
  28088. * Alpha of the line (Default: 1)
  28089. */
  28090. alpha: number;
  28091. /**
  28092. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28093. * This margin is expressed in world space coordinates, so its value may vary.
  28094. * Default value is 0.1
  28095. */
  28096. intersectionThreshold: number;
  28097. private _colorShader;
  28098. private color4;
  28099. /**
  28100. * Creates a new LinesMesh
  28101. * @param name defines the name
  28102. * @param scene defines the hosting scene
  28103. * @param parent defines the parent mesh if any
  28104. * @param source defines the optional source LinesMesh used to clone data from
  28105. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28106. * When false, achieved by calling a clone(), also passing False.
  28107. * This will make creation of children, recursive.
  28108. * @param useVertexColor defines if this LinesMesh supports vertex color
  28109. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28110. */
  28111. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28112. /**
  28113. * If vertex color should be applied to the mesh
  28114. */
  28115. useVertexColor?: boolean | undefined,
  28116. /**
  28117. * If vertex alpha should be applied to the mesh
  28118. */
  28119. useVertexAlpha?: boolean | undefined);
  28120. private _addClipPlaneDefine;
  28121. private _removeClipPlaneDefine;
  28122. isReady(): boolean;
  28123. /**
  28124. * Returns the string "LineMesh"
  28125. */
  28126. getClassName(): string;
  28127. /**
  28128. * @hidden
  28129. */
  28130. get material(): Material;
  28131. /**
  28132. * @hidden
  28133. */
  28134. set material(value: Material);
  28135. /**
  28136. * @hidden
  28137. */
  28138. get checkCollisions(): boolean;
  28139. set checkCollisions(value: boolean);
  28140. /** @hidden */
  28141. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28142. /** @hidden */
  28143. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28144. /**
  28145. * Disposes of the line mesh
  28146. * @param doNotRecurse If children should be disposed
  28147. */
  28148. dispose(doNotRecurse?: boolean): void;
  28149. /**
  28150. * Returns a new LineMesh object cloned from the current one.
  28151. */
  28152. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28153. /**
  28154. * Creates a new InstancedLinesMesh object from the mesh model.
  28155. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28156. * @param name defines the name of the new instance
  28157. * @returns a new InstancedLinesMesh
  28158. */
  28159. createInstance(name: string): InstancedLinesMesh;
  28160. }
  28161. /**
  28162. * Creates an instance based on a source LinesMesh
  28163. */
  28164. export class InstancedLinesMesh extends InstancedMesh {
  28165. /**
  28166. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28167. * This margin is expressed in world space coordinates, so its value may vary.
  28168. * Initilized with the intersectionThreshold value of the source LinesMesh
  28169. */
  28170. intersectionThreshold: number;
  28171. constructor(name: string, source: LinesMesh);
  28172. /**
  28173. * Returns the string "InstancedLinesMesh".
  28174. */
  28175. getClassName(): string;
  28176. }
  28177. }
  28178. declare module BABYLON {
  28179. /** @hidden */
  28180. export var linePixelShader: {
  28181. name: string;
  28182. shader: string;
  28183. };
  28184. }
  28185. declare module BABYLON {
  28186. /** @hidden */
  28187. export var lineVertexShader: {
  28188. name: string;
  28189. shader: string;
  28190. };
  28191. }
  28192. declare module BABYLON {
  28193. interface Scene {
  28194. /** @hidden */
  28195. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28196. }
  28197. interface AbstractMesh {
  28198. /**
  28199. * Gets the edgesRenderer associated with the mesh
  28200. */
  28201. edgesRenderer: Nullable<EdgesRenderer>;
  28202. }
  28203. interface LinesMesh {
  28204. /**
  28205. * Enables the edge rendering mode on the mesh.
  28206. * This mode makes the mesh edges visible
  28207. * @param epsilon defines the maximal distance between two angles to detect a face
  28208. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28209. * @returns the currentAbstractMesh
  28210. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28211. */
  28212. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28213. }
  28214. interface InstancedLinesMesh {
  28215. /**
  28216. * Enables the edge rendering mode on the mesh.
  28217. * This mode makes the mesh edges visible
  28218. * @param epsilon defines the maximal distance between two angles to detect a face
  28219. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28220. * @returns the current InstancedLinesMesh
  28221. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28222. */
  28223. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28224. }
  28225. /**
  28226. * Defines the minimum contract an Edges renderer should follow.
  28227. */
  28228. export interface IEdgesRenderer extends IDisposable {
  28229. /**
  28230. * Gets or sets a boolean indicating if the edgesRenderer is active
  28231. */
  28232. isEnabled: boolean;
  28233. /**
  28234. * Renders the edges of the attached mesh,
  28235. */
  28236. render(): void;
  28237. /**
  28238. * Checks wether or not the edges renderer is ready to render.
  28239. * @return true if ready, otherwise false.
  28240. */
  28241. isReady(): boolean;
  28242. /**
  28243. * List of instances to render in case the source mesh has instances
  28244. */
  28245. customInstances: SmartArray<Matrix>;
  28246. }
  28247. /**
  28248. * Defines the additional options of the edges renderer
  28249. */
  28250. export interface IEdgesRendererOptions {
  28251. /**
  28252. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28253. * If not defined, the default value is true
  28254. */
  28255. useAlternateEdgeFinder?: boolean;
  28256. /**
  28257. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28258. * If not defined, the default value is true.
  28259. * 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)
  28260. * This option is used only if useAlternateEdgeFinder = true
  28261. */
  28262. useFastVertexMerger?: boolean;
  28263. /**
  28264. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28265. * The default value is 1e-6
  28266. * This option is used only if useAlternateEdgeFinder = true
  28267. */
  28268. epsilonVertexMerge?: number;
  28269. /**
  28270. * 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
  28271. * 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.
  28272. * This option is used only if useAlternateEdgeFinder = true
  28273. */
  28274. applyTessellation?: boolean;
  28275. /**
  28276. * 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
  28277. * The default value is 1e-6
  28278. * This option is used only if useAlternateEdgeFinder = true
  28279. */
  28280. epsilonVertexAligned?: number;
  28281. }
  28282. /**
  28283. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28284. */
  28285. export class EdgesRenderer implements IEdgesRenderer {
  28286. /**
  28287. * Define the size of the edges with an orthographic camera
  28288. */
  28289. edgesWidthScalerForOrthographic: number;
  28290. /**
  28291. * Define the size of the edges with a perspective camera
  28292. */
  28293. edgesWidthScalerForPerspective: number;
  28294. protected _source: AbstractMesh;
  28295. protected _linesPositions: number[];
  28296. protected _linesNormals: number[];
  28297. protected _linesIndices: number[];
  28298. protected _epsilon: number;
  28299. protected _indicesCount: number;
  28300. protected _lineShader: ShaderMaterial;
  28301. protected _ib: DataBuffer;
  28302. protected _buffers: {
  28303. [key: string]: Nullable<VertexBuffer>;
  28304. };
  28305. protected _buffersForInstances: {
  28306. [key: string]: Nullable<VertexBuffer>;
  28307. };
  28308. protected _checkVerticesInsteadOfIndices: boolean;
  28309. protected _options: Nullable<IEdgesRendererOptions>;
  28310. private _meshRebuildObserver;
  28311. private _meshDisposeObserver;
  28312. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  28313. isEnabled: boolean;
  28314. /** Gets the vertices generated by the edge renderer */
  28315. get linesPositions(): Immutable<Array<number>>;
  28316. /** Gets the normals generated by the edge renderer */
  28317. get linesNormals(): Immutable<Array<number>>;
  28318. /** Gets the indices generated by the edge renderer */
  28319. get linesIndices(): Immutable<Array<number>>;
  28320. /**
  28321. * List of instances to render in case the source mesh has instances
  28322. */
  28323. customInstances: SmartArray<Matrix>;
  28324. private static GetShader;
  28325. /**
  28326. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  28327. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  28328. * @param source Mesh used to create edges
  28329. * @param epsilon sum of angles in adjacency to check for edge
  28330. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  28331. * @param generateEdgesLines - should generate Lines or only prepare resources.
  28332. * @param options The options to apply when generating the edges
  28333. */
  28334. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  28335. protected _prepareRessources(): void;
  28336. /** @hidden */
  28337. _rebuild(): void;
  28338. /**
  28339. * Releases the required resources for the edges renderer
  28340. */
  28341. dispose(): void;
  28342. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  28343. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  28344. /**
  28345. * Checks if the pair of p0 and p1 is en edge
  28346. * @param faceIndex
  28347. * @param edge
  28348. * @param faceNormals
  28349. * @param p0
  28350. * @param p1
  28351. * @private
  28352. */
  28353. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  28354. /**
  28355. * push line into the position, normal and index buffer
  28356. * @protected
  28357. */
  28358. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  28359. /**
  28360. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  28361. */
  28362. private _tessellateTriangle;
  28363. private _generateEdgesLinesAlternate;
  28364. /**
  28365. * Generates lines edges from adjacencjes
  28366. * @private
  28367. */
  28368. _generateEdgesLines(): void;
  28369. /**
  28370. * Checks wether or not the edges renderer is ready to render.
  28371. * @return true if ready, otherwise false.
  28372. */
  28373. isReady(): boolean;
  28374. /**
  28375. * Renders the edges of the attached mesh,
  28376. */
  28377. render(): void;
  28378. }
  28379. /**
  28380. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  28381. */
  28382. export class LineEdgesRenderer extends EdgesRenderer {
  28383. /**
  28384. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  28385. * @param source LineMesh used to generate edges
  28386. * @param epsilon not important (specified angle for edge detection)
  28387. * @param checkVerticesInsteadOfIndices not important for LineMesh
  28388. */
  28389. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  28390. /**
  28391. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  28392. */
  28393. _generateEdgesLines(): void;
  28394. }
  28395. }
  28396. declare module BABYLON {
  28397. /**
  28398. * This represents the object necessary to create a rendering group.
  28399. * This is exclusively used and created by the rendering manager.
  28400. * To modify the behavior, you use the available helpers in your scene or meshes.
  28401. * @hidden
  28402. */
  28403. export class RenderingGroup {
  28404. index: number;
  28405. private static _zeroVector;
  28406. private _scene;
  28407. private _opaqueSubMeshes;
  28408. private _transparentSubMeshes;
  28409. private _alphaTestSubMeshes;
  28410. private _depthOnlySubMeshes;
  28411. private _particleSystems;
  28412. private _spriteManagers;
  28413. private _opaqueSortCompareFn;
  28414. private _alphaTestSortCompareFn;
  28415. private _transparentSortCompareFn;
  28416. private _renderOpaque;
  28417. private _renderAlphaTest;
  28418. private _renderTransparent;
  28419. /** @hidden */
  28420. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  28421. onBeforeTransparentRendering: () => void;
  28422. /**
  28423. * Set the opaque sort comparison function.
  28424. * If null the sub meshes will be render in the order they were created
  28425. */
  28426. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28427. /**
  28428. * Set the alpha test sort comparison function.
  28429. * If null the sub meshes will be render in the order they were created
  28430. */
  28431. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28432. /**
  28433. * Set the transparent sort comparison function.
  28434. * If null the sub meshes will be render in the order they were created
  28435. */
  28436. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  28437. /**
  28438. * Creates a new rendering group.
  28439. * @param index The rendering group index
  28440. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  28441. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  28442. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  28443. */
  28444. 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>);
  28445. /**
  28446. * Render all the sub meshes contained in the group.
  28447. * @param customRenderFunction Used to override the default render behaviour of the group.
  28448. * @returns true if rendered some submeshes.
  28449. */
  28450. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  28451. /**
  28452. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  28453. * @param subMeshes The submeshes to render
  28454. */
  28455. private renderOpaqueSorted;
  28456. /**
  28457. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  28458. * @param subMeshes The submeshes to render
  28459. */
  28460. private renderAlphaTestSorted;
  28461. /**
  28462. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  28463. * @param subMeshes The submeshes to render
  28464. */
  28465. private renderTransparentSorted;
  28466. /**
  28467. * Renders the submeshes in a specified order.
  28468. * @param subMeshes The submeshes to sort before render
  28469. * @param sortCompareFn The comparison function use to sort
  28470. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  28471. * @param transparent Specifies to activate blending if true
  28472. */
  28473. private static renderSorted;
  28474. /**
  28475. * Renders the submeshes in the order they were dispatched (no sort applied).
  28476. * @param subMeshes The submeshes to render
  28477. */
  28478. private static renderUnsorted;
  28479. /**
  28480. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28481. * are rendered back to front if in the same alpha index.
  28482. *
  28483. * @param a The first submesh
  28484. * @param b The second submesh
  28485. * @returns The result of the comparison
  28486. */
  28487. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  28488. /**
  28489. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28490. * are rendered back to front.
  28491. *
  28492. * @param a The first submesh
  28493. * @param b The second submesh
  28494. * @returns The result of the comparison
  28495. */
  28496. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  28497. /**
  28498. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  28499. * are rendered front to back (prevent overdraw).
  28500. *
  28501. * @param a The first submesh
  28502. * @param b The second submesh
  28503. * @returns The result of the comparison
  28504. */
  28505. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  28506. /**
  28507. * Resets the different lists of submeshes to prepare a new frame.
  28508. */
  28509. prepare(): void;
  28510. dispose(): void;
  28511. /**
  28512. * Inserts the submesh in its correct queue depending on its material.
  28513. * @param subMesh The submesh to dispatch
  28514. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28515. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28516. */
  28517. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28518. dispatchSprites(spriteManager: ISpriteManager): void;
  28519. dispatchParticles(particleSystem: IParticleSystem): void;
  28520. private _renderParticles;
  28521. private _renderSprites;
  28522. }
  28523. }
  28524. declare module BABYLON {
  28525. /**
  28526. * Interface describing the different options available in the rendering manager
  28527. * regarding Auto Clear between groups.
  28528. */
  28529. export interface IRenderingManagerAutoClearSetup {
  28530. /**
  28531. * Defines whether or not autoclear is enable.
  28532. */
  28533. autoClear: boolean;
  28534. /**
  28535. * Defines whether or not to autoclear the depth buffer.
  28536. */
  28537. depth: boolean;
  28538. /**
  28539. * Defines whether or not to autoclear the stencil buffer.
  28540. */
  28541. stencil: boolean;
  28542. }
  28543. /**
  28544. * This class is used by the onRenderingGroupObservable
  28545. */
  28546. export class RenderingGroupInfo {
  28547. /**
  28548. * The Scene that being rendered
  28549. */
  28550. scene: Scene;
  28551. /**
  28552. * The camera currently used for the rendering pass
  28553. */
  28554. camera: Nullable<Camera>;
  28555. /**
  28556. * The ID of the renderingGroup being processed
  28557. */
  28558. renderingGroupId: number;
  28559. }
  28560. /**
  28561. * This is the manager responsible of all the rendering for meshes sprites and particles.
  28562. * It is enable to manage the different groups as well as the different necessary sort functions.
  28563. * This should not be used directly aside of the few static configurations
  28564. */
  28565. export class RenderingManager {
  28566. /**
  28567. * The max id used for rendering groups (not included)
  28568. */
  28569. static MAX_RENDERINGGROUPS: number;
  28570. /**
  28571. * The min id used for rendering groups (included)
  28572. */
  28573. static MIN_RENDERINGGROUPS: number;
  28574. /**
  28575. * Used to globally prevent autoclearing scenes.
  28576. */
  28577. static AUTOCLEAR: boolean;
  28578. /**
  28579. * @hidden
  28580. */
  28581. _useSceneAutoClearSetup: boolean;
  28582. private _scene;
  28583. private _renderingGroups;
  28584. private _depthStencilBufferAlreadyCleaned;
  28585. private _autoClearDepthStencil;
  28586. private _customOpaqueSortCompareFn;
  28587. private _customAlphaTestSortCompareFn;
  28588. private _customTransparentSortCompareFn;
  28589. private _renderingGroupInfo;
  28590. /**
  28591. * Instantiates a new rendering group for a particular scene
  28592. * @param scene Defines the scene the groups belongs to
  28593. */
  28594. constructor(scene: Scene);
  28595. private _clearDepthStencilBuffer;
  28596. /**
  28597. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  28598. * @hidden
  28599. */
  28600. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  28601. /**
  28602. * Resets the different information of the group to prepare a new frame
  28603. * @hidden
  28604. */
  28605. reset(): void;
  28606. /**
  28607. * Dispose and release the group and its associated resources.
  28608. * @hidden
  28609. */
  28610. dispose(): void;
  28611. /**
  28612. * Clear the info related to rendering groups preventing retention points during dispose.
  28613. */
  28614. freeRenderingGroups(): void;
  28615. private _prepareRenderingGroup;
  28616. /**
  28617. * Add a sprite manager to the rendering manager in order to render it this frame.
  28618. * @param spriteManager Define the sprite manager to render
  28619. */
  28620. dispatchSprites(spriteManager: ISpriteManager): void;
  28621. /**
  28622. * Add a particle system to the rendering manager in order to render it this frame.
  28623. * @param particleSystem Define the particle system to render
  28624. */
  28625. dispatchParticles(particleSystem: IParticleSystem): void;
  28626. /**
  28627. * Add a submesh to the manager in order to render it this frame
  28628. * @param subMesh The submesh to dispatch
  28629. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  28630. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  28631. */
  28632. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  28633. /**
  28634. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28635. * This allowed control for front to back rendering or reversly depending of the special needs.
  28636. *
  28637. * @param renderingGroupId The rendering group id corresponding to its index
  28638. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28639. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28640. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28641. */
  28642. 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;
  28643. /**
  28644. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28645. *
  28646. * @param renderingGroupId The rendering group id corresponding to its index
  28647. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28648. * @param depth Automatically clears depth between groups if true and autoClear is true.
  28649. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  28650. */
  28651. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  28652. /**
  28653. * Gets the current auto clear configuration for one rendering group of the rendering
  28654. * manager.
  28655. * @param index the rendering group index to get the information for
  28656. * @returns The auto clear setup for the requested rendering group
  28657. */
  28658. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  28659. }
  28660. }
  28661. declare module BABYLON {
  28662. /**
  28663. * Defines the options associated with the creation of a custom shader for a shadow generator.
  28664. */
  28665. export interface ICustomShaderOptions {
  28666. /**
  28667. * Gets or sets the custom shader name to use
  28668. */
  28669. shaderName: string;
  28670. /**
  28671. * The list of attribute names used in the shader
  28672. */
  28673. attributes?: string[];
  28674. /**
  28675. * The list of unifrom names used in the shader
  28676. */
  28677. uniforms?: string[];
  28678. /**
  28679. * The list of sampler names used in the shader
  28680. */
  28681. samplers?: string[];
  28682. /**
  28683. * The list of defines used in the shader
  28684. */
  28685. defines?: string[];
  28686. }
  28687. /**
  28688. * Interface to implement to create a shadow generator compatible with BJS.
  28689. */
  28690. export interface IShadowGenerator {
  28691. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28692. id: string;
  28693. /**
  28694. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  28695. * @returns The render target texture if present otherwise, null
  28696. */
  28697. getShadowMap(): Nullable<RenderTargetTexture>;
  28698. /**
  28699. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  28700. * @param subMesh The submesh we want to render in the shadow map
  28701. * @param useInstances Defines wether will draw in the map using instances
  28702. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  28703. * @returns true if ready otherwise, false
  28704. */
  28705. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  28706. /**
  28707. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  28708. * @param defines Defines of the material we want to update
  28709. * @param lightIndex Index of the light in the enabled light list of the material
  28710. */
  28711. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  28712. /**
  28713. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  28714. * defined in the generator but impacting the effect).
  28715. * It implies the unifroms available on the materials are the standard BJS ones.
  28716. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  28717. * @param effect The effect we are binfing the information for
  28718. */
  28719. bindShadowLight(lightIndex: string, effect: Effect): void;
  28720. /**
  28721. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  28722. * (eq to shadow prjection matrix * light transform matrix)
  28723. * @returns The transform matrix used to create the shadow map
  28724. */
  28725. getTransformMatrix(): Matrix;
  28726. /**
  28727. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  28728. * Cube and 2D textures for instance.
  28729. */
  28730. recreateShadowMap(): void;
  28731. /**
  28732. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28733. * @param onCompiled Callback triggered at the and of the effects compilation
  28734. * @param options Sets of optional options forcing the compilation with different modes
  28735. */
  28736. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  28737. useInstances: boolean;
  28738. }>): void;
  28739. /**
  28740. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  28741. * @param options Sets of optional options forcing the compilation with different modes
  28742. * @returns A promise that resolves when the compilation completes
  28743. */
  28744. forceCompilationAsync(options?: Partial<{
  28745. useInstances: boolean;
  28746. }>): Promise<void>;
  28747. /**
  28748. * Serializes the shadow generator setup to a json object.
  28749. * @returns The serialized JSON object
  28750. */
  28751. serialize(): any;
  28752. /**
  28753. * Disposes the Shadow map and related Textures and effects.
  28754. */
  28755. dispose(): void;
  28756. }
  28757. /**
  28758. * Default implementation IShadowGenerator.
  28759. * This is the main object responsible of generating shadows in the framework.
  28760. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  28761. */
  28762. export class ShadowGenerator implements IShadowGenerator {
  28763. /**
  28764. * Name of the shadow generator class
  28765. */
  28766. static CLASSNAME: string;
  28767. /**
  28768. * Shadow generator mode None: no filtering applied.
  28769. */
  28770. static readonly FILTER_NONE: number;
  28771. /**
  28772. * Shadow generator mode ESM: Exponential Shadow Mapping.
  28773. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28774. */
  28775. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  28776. /**
  28777. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  28778. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  28779. */
  28780. static readonly FILTER_POISSONSAMPLING: number;
  28781. /**
  28782. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  28783. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28784. */
  28785. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  28786. /**
  28787. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  28788. * edge artifacts on steep falloff.
  28789. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28790. */
  28791. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  28792. /**
  28793. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  28794. * edge artifacts on steep falloff.
  28795. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  28796. */
  28797. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  28798. /**
  28799. * Shadow generator mode PCF: Percentage Closer Filtering
  28800. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28801. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  28802. */
  28803. static readonly FILTER_PCF: number;
  28804. /**
  28805. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  28806. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  28807. * Contact Hardening
  28808. */
  28809. static readonly FILTER_PCSS: number;
  28810. /**
  28811. * Reserved for PCF and PCSS
  28812. * Highest Quality.
  28813. *
  28814. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  28815. *
  28816. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  28817. */
  28818. static readonly QUALITY_HIGH: number;
  28819. /**
  28820. * Reserved for PCF and PCSS
  28821. * Good tradeoff for quality/perf cross devices
  28822. *
  28823. * Execute PCF on a 3*3 kernel.
  28824. *
  28825. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  28826. */
  28827. static readonly QUALITY_MEDIUM: number;
  28828. /**
  28829. * Reserved for PCF and PCSS
  28830. * The lowest quality but the fastest.
  28831. *
  28832. * Execute PCF on a 1*1 kernel.
  28833. *
  28834. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  28835. */
  28836. static readonly QUALITY_LOW: number;
  28837. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  28838. id: string;
  28839. /** Gets or sets the custom shader name to use */
  28840. customShaderOptions: ICustomShaderOptions;
  28841. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  28842. customAllowRendering: (subMesh: SubMesh) => boolean;
  28843. /**
  28844. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  28845. */
  28846. onBeforeShadowMapRenderObservable: Observable<Effect>;
  28847. /**
  28848. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  28849. */
  28850. onAfterShadowMapRenderObservable: Observable<Effect>;
  28851. /**
  28852. * Observable triggered before a mesh is rendered in the shadow map.
  28853. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  28854. */
  28855. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  28856. /**
  28857. * Observable triggered after a mesh is rendered in the shadow map.
  28858. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  28859. */
  28860. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  28861. protected _bias: number;
  28862. /**
  28863. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  28864. */
  28865. get bias(): number;
  28866. /**
  28867. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  28868. */
  28869. set bias(bias: number);
  28870. protected _normalBias: number;
  28871. /**
  28872. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28873. */
  28874. get normalBias(): number;
  28875. /**
  28876. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  28877. */
  28878. set normalBias(normalBias: number);
  28879. protected _blurBoxOffset: number;
  28880. /**
  28881. * Gets the blur box offset: offset applied during the blur pass.
  28882. * Only useful if useKernelBlur = false
  28883. */
  28884. get blurBoxOffset(): number;
  28885. /**
  28886. * Sets the blur box offset: offset applied during the blur pass.
  28887. * Only useful if useKernelBlur = false
  28888. */
  28889. set blurBoxOffset(value: number);
  28890. protected _blurScale: number;
  28891. /**
  28892. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  28893. * 2 means half of the size.
  28894. */
  28895. get blurScale(): number;
  28896. /**
  28897. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  28898. * 2 means half of the size.
  28899. */
  28900. set blurScale(value: number);
  28901. protected _blurKernel: number;
  28902. /**
  28903. * Gets the blur kernel: kernel size of the blur pass.
  28904. * Only useful if useKernelBlur = true
  28905. */
  28906. get blurKernel(): number;
  28907. /**
  28908. * Sets the blur kernel: kernel size of the blur pass.
  28909. * Only useful if useKernelBlur = true
  28910. */
  28911. set blurKernel(value: number);
  28912. protected _useKernelBlur: boolean;
  28913. /**
  28914. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  28915. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28916. */
  28917. get useKernelBlur(): boolean;
  28918. /**
  28919. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  28920. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  28921. */
  28922. set useKernelBlur(value: boolean);
  28923. protected _depthScale: number;
  28924. /**
  28925. * Gets the depth scale used in ESM mode.
  28926. */
  28927. get depthScale(): number;
  28928. /**
  28929. * Sets the depth scale used in ESM mode.
  28930. * This can override the scale stored on the light.
  28931. */
  28932. set depthScale(value: number);
  28933. protected _validateFilter(filter: number): number;
  28934. protected _filter: number;
  28935. /**
  28936. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  28937. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28938. */
  28939. get filter(): number;
  28940. /**
  28941. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  28942. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  28943. */
  28944. set filter(value: number);
  28945. /**
  28946. * Gets if the current filter is set to Poisson Sampling.
  28947. */
  28948. get usePoissonSampling(): boolean;
  28949. /**
  28950. * Sets the current filter to Poisson Sampling.
  28951. */
  28952. set usePoissonSampling(value: boolean);
  28953. /**
  28954. * Gets if the current filter is set to ESM.
  28955. */
  28956. get useExponentialShadowMap(): boolean;
  28957. /**
  28958. * Sets the current filter is to ESM.
  28959. */
  28960. set useExponentialShadowMap(value: boolean);
  28961. /**
  28962. * Gets if the current filter is set to filtered ESM.
  28963. */
  28964. get useBlurExponentialShadowMap(): boolean;
  28965. /**
  28966. * Gets if the current filter is set to filtered ESM.
  28967. */
  28968. set useBlurExponentialShadowMap(value: boolean);
  28969. /**
  28970. * Gets if the current filter is set to "close ESM" (using the inverse of the
  28971. * exponential to prevent steep falloff artifacts).
  28972. */
  28973. get useCloseExponentialShadowMap(): boolean;
  28974. /**
  28975. * Sets the current filter to "close ESM" (using the inverse of the
  28976. * exponential to prevent steep falloff artifacts).
  28977. */
  28978. set useCloseExponentialShadowMap(value: boolean);
  28979. /**
  28980. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  28981. * exponential to prevent steep falloff artifacts).
  28982. */
  28983. get useBlurCloseExponentialShadowMap(): boolean;
  28984. /**
  28985. * Sets the current filter to filtered "close ESM" (using the inverse of the
  28986. * exponential to prevent steep falloff artifacts).
  28987. */
  28988. set useBlurCloseExponentialShadowMap(value: boolean);
  28989. /**
  28990. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  28991. */
  28992. get usePercentageCloserFiltering(): boolean;
  28993. /**
  28994. * Sets the current filter to "PCF" (percentage closer filtering).
  28995. */
  28996. set usePercentageCloserFiltering(value: boolean);
  28997. protected _filteringQuality: number;
  28998. /**
  28999. * Gets the PCF or PCSS Quality.
  29000. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29001. */
  29002. get filteringQuality(): number;
  29003. /**
  29004. * Sets the PCF or PCSS Quality.
  29005. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29006. */
  29007. set filteringQuality(filteringQuality: number);
  29008. /**
  29009. * Gets if the current filter is set to "PCSS" (contact hardening).
  29010. */
  29011. get useContactHardeningShadow(): boolean;
  29012. /**
  29013. * Sets the current filter to "PCSS" (contact hardening).
  29014. */
  29015. set useContactHardeningShadow(value: boolean);
  29016. protected _contactHardeningLightSizeUVRatio: number;
  29017. /**
  29018. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29019. * Using a ratio helps keeping shape stability independently of the map size.
  29020. *
  29021. * It does not account for the light projection as it was having too much
  29022. * instability during the light setup or during light position changes.
  29023. *
  29024. * Only valid if useContactHardeningShadow is true.
  29025. */
  29026. get contactHardeningLightSizeUVRatio(): number;
  29027. /**
  29028. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29029. * Using a ratio helps keeping shape stability independently of the map size.
  29030. *
  29031. * It does not account for the light projection as it was having too much
  29032. * instability during the light setup or during light position changes.
  29033. *
  29034. * Only valid if useContactHardeningShadow is true.
  29035. */
  29036. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29037. protected _darkness: number;
  29038. /** Gets or sets the actual darkness of a shadow */
  29039. get darkness(): number;
  29040. set darkness(value: number);
  29041. /**
  29042. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29043. * 0 means strongest and 1 would means no shadow.
  29044. * @returns the darkness.
  29045. */
  29046. getDarkness(): number;
  29047. /**
  29048. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29049. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29050. * @returns the shadow generator allowing fluent coding.
  29051. */
  29052. setDarkness(darkness: number): ShadowGenerator;
  29053. protected _transparencyShadow: boolean;
  29054. /** Gets or sets the ability to have transparent shadow */
  29055. get transparencyShadow(): boolean;
  29056. set transparencyShadow(value: boolean);
  29057. /**
  29058. * Sets the ability to have transparent shadow (boolean).
  29059. * @param transparent True if transparent else False
  29060. * @returns the shadow generator allowing fluent coding
  29061. */
  29062. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29063. /**
  29064. * Enables or disables shadows with varying strength based on the transparency
  29065. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29066. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29067. * mesh.visibility * alphaTexture.a
  29068. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29069. */
  29070. enableSoftTransparentShadow: boolean;
  29071. protected _shadowMap: Nullable<RenderTargetTexture>;
  29072. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29073. /**
  29074. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29075. * @returns The render target texture if present otherwise, null
  29076. */
  29077. getShadowMap(): Nullable<RenderTargetTexture>;
  29078. /**
  29079. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29080. * @returns The render target texture if the shadow map is present otherwise, null
  29081. */
  29082. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29083. /**
  29084. * Gets the class name of that object
  29085. * @returns "ShadowGenerator"
  29086. */
  29087. getClassName(): string;
  29088. /**
  29089. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29090. * @param mesh Mesh to add
  29091. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29092. * @returns the Shadow Generator itself
  29093. */
  29094. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29095. /**
  29096. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29097. * @param mesh Mesh to remove
  29098. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29099. * @returns the Shadow Generator itself
  29100. */
  29101. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29102. /**
  29103. * Controls the extent to which the shadows fade out at the edge of the frustum
  29104. */
  29105. frustumEdgeFalloff: number;
  29106. protected _light: IShadowLight;
  29107. /**
  29108. * Returns the associated light object.
  29109. * @returns the light generating the shadow
  29110. */
  29111. getLight(): IShadowLight;
  29112. /**
  29113. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29114. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29115. * It might on the other hand introduce peter panning.
  29116. */
  29117. forceBackFacesOnly: boolean;
  29118. protected _scene: Scene;
  29119. protected _lightDirection: Vector3;
  29120. protected _effect: Effect;
  29121. protected _viewMatrix: Matrix;
  29122. protected _projectionMatrix: Matrix;
  29123. protected _transformMatrix: Matrix;
  29124. protected _cachedPosition: Vector3;
  29125. protected _cachedDirection: Vector3;
  29126. protected _cachedDefines: string;
  29127. protected _currentRenderID: number;
  29128. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29129. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29130. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29131. protected _blurPostProcesses: PostProcess[];
  29132. protected _mapSize: number;
  29133. protected _currentFaceIndex: number;
  29134. protected _currentFaceIndexCache: number;
  29135. protected _textureType: number;
  29136. protected _defaultTextureMatrix: Matrix;
  29137. protected _storedUniqueId: Nullable<number>;
  29138. /** @hidden */
  29139. static _SceneComponentInitialization: (scene: Scene) => void;
  29140. /**
  29141. * Gets or sets the size of the texture what stores the shadows
  29142. */
  29143. get mapSize(): number;
  29144. set mapSize(size: number);
  29145. /**
  29146. * Creates a ShadowGenerator object.
  29147. * A ShadowGenerator is the required tool to use the shadows.
  29148. * Each light casting shadows needs to use its own ShadowGenerator.
  29149. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29150. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29151. * @param light The light object generating the shadows.
  29152. * @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.
  29153. */
  29154. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29155. protected _initializeGenerator(): void;
  29156. protected _createTargetRenderTexture(): void;
  29157. protected _initializeShadowMap(): void;
  29158. protected _initializeBlurRTTAndPostProcesses(): void;
  29159. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29160. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29161. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29162. protected _applyFilterValues(): void;
  29163. /**
  29164. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29165. * @param onCompiled Callback triggered at the and of the effects compilation
  29166. * @param options Sets of optional options forcing the compilation with different modes
  29167. */
  29168. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29169. useInstances: boolean;
  29170. }>): void;
  29171. /**
  29172. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29173. * @param options Sets of optional options forcing the compilation with different modes
  29174. * @returns A promise that resolves when the compilation completes
  29175. */
  29176. forceCompilationAsync(options?: Partial<{
  29177. useInstances: boolean;
  29178. }>): Promise<void>;
  29179. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29180. private _prepareShadowDefines;
  29181. /**
  29182. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29183. * @param subMesh The submesh we want to render in the shadow map
  29184. * @param useInstances Defines wether will draw in the map using instances
  29185. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29186. * @returns true if ready otherwise, false
  29187. */
  29188. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29189. /**
  29190. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29191. * @param defines Defines of the material we want to update
  29192. * @param lightIndex Index of the light in the enabled light list of the material
  29193. */
  29194. prepareDefines(defines: any, lightIndex: number): void;
  29195. /**
  29196. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29197. * defined in the generator but impacting the effect).
  29198. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29199. * @param effect The effect we are binfing the information for
  29200. */
  29201. bindShadowLight(lightIndex: string, effect: Effect): void;
  29202. /**
  29203. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29204. * (eq to shadow prjection matrix * light transform matrix)
  29205. * @returns The transform matrix used to create the shadow map
  29206. */
  29207. getTransformMatrix(): Matrix;
  29208. /**
  29209. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29210. * Cube and 2D textures for instance.
  29211. */
  29212. recreateShadowMap(): void;
  29213. protected _disposeBlurPostProcesses(): void;
  29214. protected _disposeRTTandPostProcesses(): void;
  29215. /**
  29216. * Disposes the ShadowGenerator.
  29217. * Returns nothing.
  29218. */
  29219. dispose(): void;
  29220. /**
  29221. * Serializes the shadow generator setup to a json object.
  29222. * @returns The serialized JSON object
  29223. */
  29224. serialize(): any;
  29225. /**
  29226. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29227. * @param parsedShadowGenerator The JSON object to parse
  29228. * @param scene The scene to create the shadow map for
  29229. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29230. * @returns The parsed shadow generator
  29231. */
  29232. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29233. }
  29234. }
  29235. declare module BABYLON {
  29236. /**
  29237. * Options to be used when creating a shadow depth material
  29238. */
  29239. export interface IIOptionShadowDepthMaterial {
  29240. /** Variables in the vertex shader code that need to have their names remapped.
  29241. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29242. * "var_name" should be either: worldPos or vNormalW
  29243. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29244. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29245. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29246. */
  29247. remappedVariables?: string[];
  29248. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29249. standalone?: boolean;
  29250. }
  29251. /**
  29252. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29253. */
  29254. export class ShadowDepthWrapper {
  29255. private _scene;
  29256. private _options?;
  29257. private _baseMaterial;
  29258. private _onEffectCreatedObserver;
  29259. private _subMeshToEffect;
  29260. private _subMeshToDepthEffect;
  29261. private _meshes;
  29262. /** @hidden */
  29263. _matriceNames: any;
  29264. /** Gets the standalone status of the wrapper */
  29265. get standalone(): boolean;
  29266. /** Gets the base material the wrapper is built upon */
  29267. get baseMaterial(): Material;
  29268. /**
  29269. * Instantiate a new shadow depth wrapper.
  29270. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29271. * generate the shadow depth map. For more information, please refer to the documentation:
  29272. * https://doc.babylonjs.com/babylon101/shadows
  29273. * @param baseMaterial Material to wrap
  29274. * @param scene Define the scene the material belongs to
  29275. * @param options Options used to create the wrapper
  29276. */
  29277. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29278. /**
  29279. * Gets the effect to use to generate the depth map
  29280. * @param subMesh subMesh to get the effect for
  29281. * @param shadowGenerator shadow generator to get the effect for
  29282. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29283. */
  29284. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29285. /**
  29286. * Specifies that the submesh is ready to be used for depth rendering
  29287. * @param subMesh submesh to check
  29288. * @param defines the list of defines to take into account when checking the effect
  29289. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29290. * @param useInstances specifies that instances should be used
  29291. * @returns a boolean indicating that the submesh is ready or not
  29292. */
  29293. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29294. /**
  29295. * Disposes the resources
  29296. */
  29297. dispose(): void;
  29298. private _makeEffect;
  29299. }
  29300. }
  29301. declare module BABYLON {
  29302. /**
  29303. * Options for compiling materials.
  29304. */
  29305. export interface IMaterialCompilationOptions {
  29306. /**
  29307. * Defines whether clip planes are enabled.
  29308. */
  29309. clipPlane: boolean;
  29310. /**
  29311. * Defines whether instances are enabled.
  29312. */
  29313. useInstances: boolean;
  29314. }
  29315. /**
  29316. * Options passed when calling customShaderNameResolve
  29317. */
  29318. export interface ICustomShaderNameResolveOptions {
  29319. /**
  29320. * 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
  29321. */
  29322. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  29323. }
  29324. /**
  29325. * Base class for the main features of a material in Babylon.js
  29326. */
  29327. export class Material implements IAnimatable {
  29328. /**
  29329. * Returns the triangle fill mode
  29330. */
  29331. static readonly TriangleFillMode: number;
  29332. /**
  29333. * Returns the wireframe mode
  29334. */
  29335. static readonly WireFrameFillMode: number;
  29336. /**
  29337. * Returns the point fill mode
  29338. */
  29339. static readonly PointFillMode: number;
  29340. /**
  29341. * Returns the point list draw mode
  29342. */
  29343. static readonly PointListDrawMode: number;
  29344. /**
  29345. * Returns the line list draw mode
  29346. */
  29347. static readonly LineListDrawMode: number;
  29348. /**
  29349. * Returns the line loop draw mode
  29350. */
  29351. static readonly LineLoopDrawMode: number;
  29352. /**
  29353. * Returns the line strip draw mode
  29354. */
  29355. static readonly LineStripDrawMode: number;
  29356. /**
  29357. * Returns the triangle strip draw mode
  29358. */
  29359. static readonly TriangleStripDrawMode: number;
  29360. /**
  29361. * Returns the triangle fan draw mode
  29362. */
  29363. static readonly TriangleFanDrawMode: number;
  29364. /**
  29365. * Stores the clock-wise side orientation
  29366. */
  29367. static readonly ClockWiseSideOrientation: number;
  29368. /**
  29369. * Stores the counter clock-wise side orientation
  29370. */
  29371. static readonly CounterClockWiseSideOrientation: number;
  29372. /**
  29373. * The dirty texture flag value
  29374. */
  29375. static readonly TextureDirtyFlag: number;
  29376. /**
  29377. * The dirty light flag value
  29378. */
  29379. static readonly LightDirtyFlag: number;
  29380. /**
  29381. * The dirty fresnel flag value
  29382. */
  29383. static readonly FresnelDirtyFlag: number;
  29384. /**
  29385. * The dirty attribute flag value
  29386. */
  29387. static readonly AttributesDirtyFlag: number;
  29388. /**
  29389. * The dirty misc flag value
  29390. */
  29391. static readonly MiscDirtyFlag: number;
  29392. /**
  29393. * The dirty prepass flag value
  29394. */
  29395. static readonly PrePassDirtyFlag: number;
  29396. /**
  29397. * The all dirty flag value
  29398. */
  29399. static readonly AllDirtyFlag: number;
  29400. /**
  29401. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  29402. */
  29403. static readonly MATERIAL_OPAQUE: number;
  29404. /**
  29405. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  29406. */
  29407. static readonly MATERIAL_ALPHATEST: number;
  29408. /**
  29409. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29410. */
  29411. static readonly MATERIAL_ALPHABLEND: number;
  29412. /**
  29413. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  29414. * They are also discarded below the alpha cutoff threshold to improve performances.
  29415. */
  29416. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  29417. /**
  29418. * The Whiteout method is used to blend normals.
  29419. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29420. */
  29421. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  29422. /**
  29423. * The Reoriented Normal Mapping method is used to blend normals.
  29424. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  29425. */
  29426. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  29427. /**
  29428. * Custom callback helping to override the default shader used in the material.
  29429. */
  29430. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  29431. /**
  29432. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  29433. */
  29434. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  29435. /**
  29436. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  29437. * This means that the material can keep using a previous shader while a new one is being compiled.
  29438. * This is mostly used when shader parallel compilation is supported (true by default)
  29439. */
  29440. allowShaderHotSwapping: boolean;
  29441. /**
  29442. * The ID of the material
  29443. */
  29444. id: string;
  29445. /**
  29446. * Gets or sets the unique id of the material
  29447. */
  29448. uniqueId: number;
  29449. /**
  29450. * The name of the material
  29451. */
  29452. name: string;
  29453. /**
  29454. * Gets or sets user defined metadata
  29455. */
  29456. metadata: any;
  29457. /**
  29458. * For internal use only. Please do not use.
  29459. */
  29460. reservedDataStore: any;
  29461. /**
  29462. * Specifies if the ready state should be checked on each call
  29463. */
  29464. checkReadyOnEveryCall: boolean;
  29465. /**
  29466. * Specifies if the ready state should be checked once
  29467. */
  29468. checkReadyOnlyOnce: boolean;
  29469. /**
  29470. * The state of the material
  29471. */
  29472. state: string;
  29473. /**
  29474. * If the material can be rendered to several textures with MRT extension
  29475. */
  29476. get canRenderToMRT(): boolean;
  29477. /**
  29478. * The alpha value of the material
  29479. */
  29480. protected _alpha: number;
  29481. /**
  29482. * List of inspectable custom properties (used by the Inspector)
  29483. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29484. */
  29485. inspectableCustomProperties: IInspectable[];
  29486. /**
  29487. * Sets the alpha value of the material
  29488. */
  29489. set alpha(value: number);
  29490. /**
  29491. * Gets the alpha value of the material
  29492. */
  29493. get alpha(): number;
  29494. /**
  29495. * Specifies if back face culling is enabled
  29496. */
  29497. protected _backFaceCulling: boolean;
  29498. /**
  29499. * Sets the back-face culling state
  29500. */
  29501. set backFaceCulling(value: boolean);
  29502. /**
  29503. * Gets the back-face culling state
  29504. */
  29505. get backFaceCulling(): boolean;
  29506. /**
  29507. * Stores the value for side orientation
  29508. */
  29509. sideOrientation: number;
  29510. /**
  29511. * Callback triggered when the material is compiled
  29512. */
  29513. onCompiled: Nullable<(effect: Effect) => void>;
  29514. /**
  29515. * Callback triggered when an error occurs
  29516. */
  29517. onError: Nullable<(effect: Effect, errors: string) => void>;
  29518. /**
  29519. * Callback triggered to get the render target textures
  29520. */
  29521. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  29522. /**
  29523. * Gets a boolean indicating that current material needs to register RTT
  29524. */
  29525. get hasRenderTargetTextures(): boolean;
  29526. /**
  29527. * Specifies if the material should be serialized
  29528. */
  29529. doNotSerialize: boolean;
  29530. /**
  29531. * @hidden
  29532. */
  29533. _storeEffectOnSubMeshes: boolean;
  29534. /**
  29535. * Stores the animations for the material
  29536. */
  29537. animations: Nullable<Array<Animation>>;
  29538. /**
  29539. * An event triggered when the material is disposed
  29540. */
  29541. onDisposeObservable: Observable<Material>;
  29542. /**
  29543. * An observer which watches for dispose events
  29544. */
  29545. private _onDisposeObserver;
  29546. private _onUnBindObservable;
  29547. /**
  29548. * Called during a dispose event
  29549. */
  29550. set onDispose(callback: () => void);
  29551. private _onBindObservable;
  29552. /**
  29553. * An event triggered when the material is bound
  29554. */
  29555. get onBindObservable(): Observable<AbstractMesh>;
  29556. /**
  29557. * An observer which watches for bind events
  29558. */
  29559. private _onBindObserver;
  29560. /**
  29561. * Called during a bind event
  29562. */
  29563. set onBind(callback: (Mesh: AbstractMesh) => void);
  29564. /**
  29565. * An event triggered when the material is unbound
  29566. */
  29567. get onUnBindObservable(): Observable<Material>;
  29568. protected _onEffectCreatedObservable: Nullable<Observable<{
  29569. effect: Effect;
  29570. subMesh: Nullable<SubMesh>;
  29571. }>>;
  29572. /**
  29573. * An event triggered when the effect is (re)created
  29574. */
  29575. get onEffectCreatedObservable(): Observable<{
  29576. effect: Effect;
  29577. subMesh: Nullable<SubMesh>;
  29578. }>;
  29579. /**
  29580. * Stores the value of the alpha mode
  29581. */
  29582. private _alphaMode;
  29583. /**
  29584. * Sets the value of the alpha mode.
  29585. *
  29586. * | Value | Type | Description |
  29587. * | --- | --- | --- |
  29588. * | 0 | ALPHA_DISABLE | |
  29589. * | 1 | ALPHA_ADD | |
  29590. * | 2 | ALPHA_COMBINE | |
  29591. * | 3 | ALPHA_SUBTRACT | |
  29592. * | 4 | ALPHA_MULTIPLY | |
  29593. * | 5 | ALPHA_MAXIMIZED | |
  29594. * | 6 | ALPHA_ONEONE | |
  29595. * | 7 | ALPHA_PREMULTIPLIED | |
  29596. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29597. * | 9 | ALPHA_INTERPOLATE | |
  29598. * | 10 | ALPHA_SCREENMODE | |
  29599. *
  29600. */
  29601. set alphaMode(value: number);
  29602. /**
  29603. * Gets the value of the alpha mode
  29604. */
  29605. get alphaMode(): number;
  29606. /**
  29607. * Stores the state of the need depth pre-pass value
  29608. */
  29609. private _needDepthPrePass;
  29610. /**
  29611. * Sets the need depth pre-pass value
  29612. */
  29613. set needDepthPrePass(value: boolean);
  29614. /**
  29615. * Gets the depth pre-pass value
  29616. */
  29617. get needDepthPrePass(): boolean;
  29618. /**
  29619. * Specifies if depth writing should be disabled
  29620. */
  29621. disableDepthWrite: boolean;
  29622. /**
  29623. * Specifies if color writing should be disabled
  29624. */
  29625. disableColorWrite: boolean;
  29626. /**
  29627. * Specifies if depth writing should be forced
  29628. */
  29629. forceDepthWrite: boolean;
  29630. /**
  29631. * Specifies the depth function that should be used. 0 means the default engine function
  29632. */
  29633. depthFunction: number;
  29634. /**
  29635. * Specifies if there should be a separate pass for culling
  29636. */
  29637. separateCullingPass: boolean;
  29638. /**
  29639. * Stores the state specifing if fog should be enabled
  29640. */
  29641. private _fogEnabled;
  29642. /**
  29643. * Sets the state for enabling fog
  29644. */
  29645. set fogEnabled(value: boolean);
  29646. /**
  29647. * Gets the value of the fog enabled state
  29648. */
  29649. get fogEnabled(): boolean;
  29650. /**
  29651. * Stores the size of points
  29652. */
  29653. pointSize: number;
  29654. /**
  29655. * Stores the z offset value
  29656. */
  29657. zOffset: number;
  29658. get wireframe(): boolean;
  29659. /**
  29660. * Sets the state of wireframe mode
  29661. */
  29662. set wireframe(value: boolean);
  29663. /**
  29664. * Gets the value specifying if point clouds are enabled
  29665. */
  29666. get pointsCloud(): boolean;
  29667. /**
  29668. * Sets the state of point cloud mode
  29669. */
  29670. set pointsCloud(value: boolean);
  29671. /**
  29672. * Gets the material fill mode
  29673. */
  29674. get fillMode(): number;
  29675. /**
  29676. * Sets the material fill mode
  29677. */
  29678. set fillMode(value: number);
  29679. /**
  29680. * @hidden
  29681. * Stores the effects for the material
  29682. */
  29683. _effect: Nullable<Effect>;
  29684. /**
  29685. * Specifies if uniform buffers should be used
  29686. */
  29687. private _useUBO;
  29688. /**
  29689. * Stores a reference to the scene
  29690. */
  29691. private _scene;
  29692. /**
  29693. * Stores the fill mode state
  29694. */
  29695. private _fillMode;
  29696. /**
  29697. * Specifies if the depth write state should be cached
  29698. */
  29699. private _cachedDepthWriteState;
  29700. /**
  29701. * Specifies if the color write state should be cached
  29702. */
  29703. private _cachedColorWriteState;
  29704. /**
  29705. * Specifies if the depth function state should be cached
  29706. */
  29707. private _cachedDepthFunctionState;
  29708. /**
  29709. * Stores the uniform buffer
  29710. */
  29711. protected _uniformBuffer: UniformBuffer;
  29712. /** @hidden */
  29713. _indexInSceneMaterialArray: number;
  29714. /** @hidden */
  29715. meshMap: Nullable<{
  29716. [id: string]: AbstractMesh | undefined;
  29717. }>;
  29718. /**
  29719. * Creates a material instance
  29720. * @param name defines the name of the material
  29721. * @param scene defines the scene to reference
  29722. * @param doNotAdd specifies if the material should be added to the scene
  29723. */
  29724. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29725. /**
  29726. * Returns a string representation of the current material
  29727. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29728. * @returns a string with material information
  29729. */
  29730. toString(fullDetails?: boolean): string;
  29731. /**
  29732. * Gets the class name of the material
  29733. * @returns a string with the class name of the material
  29734. */
  29735. getClassName(): string;
  29736. /**
  29737. * Specifies if updates for the material been locked
  29738. */
  29739. get isFrozen(): boolean;
  29740. /**
  29741. * Locks updates for the material
  29742. */
  29743. freeze(): void;
  29744. /**
  29745. * Unlocks updates for the material
  29746. */
  29747. unfreeze(): void;
  29748. /**
  29749. * Specifies if the material is ready to be used
  29750. * @param mesh defines the mesh to check
  29751. * @param useInstances specifies if instances should be used
  29752. * @returns a boolean indicating if the material is ready to be used
  29753. */
  29754. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29755. /**
  29756. * Specifies that the submesh is ready to be used
  29757. * @param mesh defines the mesh to check
  29758. * @param subMesh defines which submesh to check
  29759. * @param useInstances specifies that instances should be used
  29760. * @returns a boolean indicating that the submesh is ready or not
  29761. */
  29762. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29763. /**
  29764. * Returns the material effect
  29765. * @returns the effect associated with the material
  29766. */
  29767. getEffect(): Nullable<Effect>;
  29768. /**
  29769. * Returns the current scene
  29770. * @returns a Scene
  29771. */
  29772. getScene(): Scene;
  29773. /**
  29774. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29775. */
  29776. protected _forceAlphaTest: boolean;
  29777. /**
  29778. * The transparency mode of the material.
  29779. */
  29780. protected _transparencyMode: Nullable<number>;
  29781. /**
  29782. * Gets the current transparency mode.
  29783. */
  29784. get transparencyMode(): Nullable<number>;
  29785. /**
  29786. * Sets the transparency mode of the material.
  29787. *
  29788. * | Value | Type | Description |
  29789. * | ----- | ----------------------------------- | ----------- |
  29790. * | 0 | OPAQUE | |
  29791. * | 1 | ALPHATEST | |
  29792. * | 2 | ALPHABLEND | |
  29793. * | 3 | ALPHATESTANDBLEND | |
  29794. *
  29795. */
  29796. set transparencyMode(value: Nullable<number>);
  29797. /**
  29798. * Returns true if alpha blending should be disabled.
  29799. */
  29800. protected get _disableAlphaBlending(): boolean;
  29801. /**
  29802. * Specifies whether or not this material should be rendered in alpha blend mode.
  29803. * @returns a boolean specifying if alpha blending is needed
  29804. */
  29805. needAlphaBlending(): boolean;
  29806. /**
  29807. * Specifies if the mesh will require alpha blending
  29808. * @param mesh defines the mesh to check
  29809. * @returns a boolean specifying if alpha blending is needed for the mesh
  29810. */
  29811. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29812. /**
  29813. * Specifies whether or not this material should be rendered in alpha test mode.
  29814. * @returns a boolean specifying if an alpha test is needed.
  29815. */
  29816. needAlphaTesting(): boolean;
  29817. /**
  29818. * Specifies if material alpha testing should be turned on for the mesh
  29819. * @param mesh defines the mesh to check
  29820. */
  29821. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29822. /**
  29823. * Gets the texture used for the alpha test
  29824. * @returns the texture to use for alpha testing
  29825. */
  29826. getAlphaTestTexture(): Nullable<BaseTexture>;
  29827. /**
  29828. * Marks the material to indicate that it needs to be re-calculated
  29829. */
  29830. markDirty(): void;
  29831. /** @hidden */
  29832. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29833. /**
  29834. * Binds the material to the mesh
  29835. * @param world defines the world transformation matrix
  29836. * @param mesh defines the mesh to bind the material to
  29837. */
  29838. bind(world: Matrix, mesh?: Mesh): void;
  29839. /**
  29840. * Binds the submesh to the material
  29841. * @param world defines the world transformation matrix
  29842. * @param mesh defines the mesh containing the submesh
  29843. * @param subMesh defines the submesh to bind the material to
  29844. */
  29845. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29846. /**
  29847. * Binds the world matrix to the material
  29848. * @param world defines the world transformation matrix
  29849. */
  29850. bindOnlyWorldMatrix(world: Matrix): void;
  29851. /**
  29852. * Binds the scene's uniform buffer to the effect.
  29853. * @param effect defines the effect to bind to the scene uniform buffer
  29854. * @param sceneUbo defines the uniform buffer storing scene data
  29855. */
  29856. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29857. /**
  29858. * Binds the view matrix to the effect
  29859. * @param effect defines the effect to bind the view matrix to
  29860. */
  29861. bindView(effect: Effect): void;
  29862. /**
  29863. * Binds the view projection matrix to the effect
  29864. * @param effect defines the effect to bind the view projection matrix to
  29865. */
  29866. bindViewProjection(effect: Effect): void;
  29867. /**
  29868. * Processes to execute after binding the material to a mesh
  29869. * @param mesh defines the rendered mesh
  29870. */
  29871. protected _afterBind(mesh?: Mesh): void;
  29872. /**
  29873. * Unbinds the material from the mesh
  29874. */
  29875. unbind(): void;
  29876. /**
  29877. * Gets the active textures from the material
  29878. * @returns an array of textures
  29879. */
  29880. getActiveTextures(): BaseTexture[];
  29881. /**
  29882. * Specifies if the material uses a texture
  29883. * @param texture defines the texture to check against the material
  29884. * @returns a boolean specifying if the material uses the texture
  29885. */
  29886. hasTexture(texture: BaseTexture): boolean;
  29887. /**
  29888. * Makes a duplicate of the material, and gives it a new name
  29889. * @param name defines the new name for the duplicated material
  29890. * @returns the cloned material
  29891. */
  29892. clone(name: string): Nullable<Material>;
  29893. /**
  29894. * Gets the meshes bound to the material
  29895. * @returns an array of meshes bound to the material
  29896. */
  29897. getBindedMeshes(): AbstractMesh[];
  29898. /**
  29899. * Force shader compilation
  29900. * @param mesh defines the mesh associated with this material
  29901. * @param onCompiled defines a function to execute once the material is compiled
  29902. * @param options defines the options to configure the compilation
  29903. * @param onError defines a function to execute if the material fails compiling
  29904. */
  29905. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29906. /**
  29907. * Force shader compilation
  29908. * @param mesh defines the mesh that will use this material
  29909. * @param options defines additional options for compiling the shaders
  29910. * @returns a promise that resolves when the compilation completes
  29911. */
  29912. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29913. private static readonly _AllDirtyCallBack;
  29914. private static readonly _ImageProcessingDirtyCallBack;
  29915. private static readonly _TextureDirtyCallBack;
  29916. private static readonly _FresnelDirtyCallBack;
  29917. private static readonly _MiscDirtyCallBack;
  29918. private static readonly _PrePassDirtyCallBack;
  29919. private static readonly _LightsDirtyCallBack;
  29920. private static readonly _AttributeDirtyCallBack;
  29921. private static _FresnelAndMiscDirtyCallBack;
  29922. private static _TextureAndMiscDirtyCallBack;
  29923. private static readonly _DirtyCallbackArray;
  29924. private static readonly _RunDirtyCallBacks;
  29925. /**
  29926. * Marks a define in the material to indicate that it needs to be re-computed
  29927. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29928. */
  29929. markAsDirty(flag: number): void;
  29930. /**
  29931. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29932. * @param func defines a function which checks material defines against the submeshes
  29933. */
  29934. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29935. /**
  29936. * Indicates that the scene should check if the rendering now needs a prepass
  29937. */
  29938. protected _markScenePrePassDirty(): void;
  29939. /**
  29940. * Indicates that we need to re-calculated for all submeshes
  29941. */
  29942. protected _markAllSubMeshesAsAllDirty(): void;
  29943. /**
  29944. * Indicates that image processing needs to be re-calculated for all submeshes
  29945. */
  29946. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29947. /**
  29948. * Indicates that textures need to be re-calculated for all submeshes
  29949. */
  29950. protected _markAllSubMeshesAsTexturesDirty(): void;
  29951. /**
  29952. * Indicates that fresnel needs to be re-calculated for all submeshes
  29953. */
  29954. protected _markAllSubMeshesAsFresnelDirty(): void;
  29955. /**
  29956. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29957. */
  29958. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29959. /**
  29960. * Indicates that lights need to be re-calculated for all submeshes
  29961. */
  29962. protected _markAllSubMeshesAsLightsDirty(): void;
  29963. /**
  29964. * Indicates that attributes need to be re-calculated for all submeshes
  29965. */
  29966. protected _markAllSubMeshesAsAttributesDirty(): void;
  29967. /**
  29968. * Indicates that misc needs to be re-calculated for all submeshes
  29969. */
  29970. protected _markAllSubMeshesAsMiscDirty(): void;
  29971. /**
  29972. * Indicates that prepass needs to be re-calculated for all submeshes
  29973. */
  29974. protected _markAllSubMeshesAsPrePassDirty(): void;
  29975. /**
  29976. * Indicates that textures and misc need to be re-calculated for all submeshes
  29977. */
  29978. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29979. /**
  29980. * Sets the required values to the prepass renderer.
  29981. * @param prePassRenderer defines the prepass renderer to setup.
  29982. * @returns true if the pre pass is needed.
  29983. */
  29984. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29985. /**
  29986. * Disposes the material
  29987. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29988. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29989. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29990. */
  29991. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29992. /** @hidden */
  29993. private releaseVertexArrayObject;
  29994. /**
  29995. * Serializes this material
  29996. * @returns the serialized material object
  29997. */
  29998. serialize(): any;
  29999. /**
  30000. * Creates a material from parsed material data
  30001. * @param parsedMaterial defines parsed material data
  30002. * @param scene defines the hosting scene
  30003. * @param rootUrl defines the root URL to use to load textures
  30004. * @returns a new material
  30005. */
  30006. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30007. }
  30008. }
  30009. declare module BABYLON {
  30010. /**
  30011. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30012. * separate meshes. This can be use to improve performances.
  30013. * @see https://doc.babylonjs.com/how_to/multi_materials
  30014. */
  30015. export class MultiMaterial extends Material {
  30016. private _subMaterials;
  30017. /**
  30018. * Gets or Sets the list of Materials used within the multi material.
  30019. * They need to be ordered according to the submeshes order in the associated mesh
  30020. */
  30021. get subMaterials(): Nullable<Material>[];
  30022. set subMaterials(value: Nullable<Material>[]);
  30023. /**
  30024. * Function used to align with Node.getChildren()
  30025. * @returns the list of Materials used within the multi material
  30026. */
  30027. getChildren(): Nullable<Material>[];
  30028. /**
  30029. * Instantiates a new Multi Material
  30030. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30031. * separate meshes. This can be use to improve performances.
  30032. * @see https://doc.babylonjs.com/how_to/multi_materials
  30033. * @param name Define the name in the scene
  30034. * @param scene Define the scene the material belongs to
  30035. */
  30036. constructor(name: string, scene: Scene);
  30037. private _hookArray;
  30038. /**
  30039. * Get one of the submaterial by its index in the submaterials array
  30040. * @param index The index to look the sub material at
  30041. * @returns The Material if the index has been defined
  30042. */
  30043. getSubMaterial(index: number): Nullable<Material>;
  30044. /**
  30045. * Get the list of active textures for the whole sub materials list.
  30046. * @returns All the textures that will be used during the rendering
  30047. */
  30048. getActiveTextures(): BaseTexture[];
  30049. /**
  30050. * Specifies if any sub-materials of this multi-material use a given texture.
  30051. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30052. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30053. */
  30054. hasTexture(texture: BaseTexture): boolean;
  30055. /**
  30056. * Gets the current class name of the material e.g. "MultiMaterial"
  30057. * Mainly use in serialization.
  30058. * @returns the class name
  30059. */
  30060. getClassName(): string;
  30061. /**
  30062. * Checks if the material is ready to render the requested sub mesh
  30063. * @param mesh Define the mesh the submesh belongs to
  30064. * @param subMesh Define the sub mesh to look readyness for
  30065. * @param useInstances Define whether or not the material is used with instances
  30066. * @returns true if ready, otherwise false
  30067. */
  30068. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30069. /**
  30070. * Clones the current material and its related sub materials
  30071. * @param name Define the name of the newly cloned material
  30072. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30073. * @returns the cloned material
  30074. */
  30075. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30076. /**
  30077. * Serializes the materials into a JSON representation.
  30078. * @returns the JSON representation
  30079. */
  30080. serialize(): any;
  30081. /**
  30082. * Dispose the material and release its associated resources
  30083. * @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)
  30084. * @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)
  30085. * @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)
  30086. */
  30087. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30088. /**
  30089. * Creates a MultiMaterial from parsed MultiMaterial data.
  30090. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30091. * @param scene defines the hosting scene
  30092. * @returns a new MultiMaterial
  30093. */
  30094. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30095. }
  30096. }
  30097. declare module BABYLON {
  30098. /**
  30099. * Defines a subdivision inside a mesh
  30100. */
  30101. export class SubMesh implements ICullable {
  30102. /** the material index to use */
  30103. materialIndex: number;
  30104. /** vertex index start */
  30105. verticesStart: number;
  30106. /** vertices count */
  30107. verticesCount: number;
  30108. /** index start */
  30109. indexStart: number;
  30110. /** indices count */
  30111. indexCount: number;
  30112. /** @hidden */
  30113. _materialDefines: Nullable<MaterialDefines>;
  30114. /** @hidden */
  30115. _materialEffect: Nullable<Effect>;
  30116. /** @hidden */
  30117. _effectOverride: Nullable<Effect>;
  30118. /**
  30119. * Gets material defines used by the effect associated to the sub mesh
  30120. */
  30121. get materialDefines(): Nullable<MaterialDefines>;
  30122. /**
  30123. * Sets material defines used by the effect associated to the sub mesh
  30124. */
  30125. set materialDefines(defines: Nullable<MaterialDefines>);
  30126. /**
  30127. * Gets associated effect
  30128. */
  30129. get effect(): Nullable<Effect>;
  30130. /**
  30131. * Sets associated effect (effect used to render this submesh)
  30132. * @param effect defines the effect to associate with
  30133. * @param defines defines the set of defines used to compile this effect
  30134. */
  30135. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30136. /** @hidden */
  30137. _linesIndexCount: number;
  30138. private _mesh;
  30139. private _renderingMesh;
  30140. private _boundingInfo;
  30141. private _linesIndexBuffer;
  30142. /** @hidden */
  30143. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30144. /** @hidden */
  30145. _trianglePlanes: Plane[];
  30146. /** @hidden */
  30147. _lastColliderTransformMatrix: Nullable<Matrix>;
  30148. /** @hidden */
  30149. _renderId: number;
  30150. /** @hidden */
  30151. _alphaIndex: number;
  30152. /** @hidden */
  30153. _distanceToCamera: number;
  30154. /** @hidden */
  30155. _id: number;
  30156. private _currentMaterial;
  30157. /**
  30158. * Add a new submesh to a mesh
  30159. * @param materialIndex defines the material index to use
  30160. * @param verticesStart defines vertex index start
  30161. * @param verticesCount defines vertices count
  30162. * @param indexStart defines index start
  30163. * @param indexCount defines indices count
  30164. * @param mesh defines the parent mesh
  30165. * @param renderingMesh defines an optional rendering mesh
  30166. * @param createBoundingBox defines if bounding box should be created for this submesh
  30167. * @returns the new submesh
  30168. */
  30169. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30170. /**
  30171. * Creates a new submesh
  30172. * @param materialIndex defines the material index to use
  30173. * @param verticesStart defines vertex index start
  30174. * @param verticesCount defines vertices count
  30175. * @param indexStart defines index start
  30176. * @param indexCount defines indices count
  30177. * @param mesh defines the parent mesh
  30178. * @param renderingMesh defines an optional rendering mesh
  30179. * @param createBoundingBox defines if bounding box should be created for this submesh
  30180. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30181. */
  30182. constructor(
  30183. /** the material index to use */
  30184. materialIndex: number,
  30185. /** vertex index start */
  30186. verticesStart: number,
  30187. /** vertices count */
  30188. verticesCount: number,
  30189. /** index start */
  30190. indexStart: number,
  30191. /** indices count */
  30192. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30193. /**
  30194. * Returns true if this submesh covers the entire parent mesh
  30195. * @ignorenaming
  30196. */
  30197. get IsGlobal(): boolean;
  30198. /**
  30199. * Returns the submesh BoudingInfo object
  30200. * @returns current bounding info (or mesh's one if the submesh is global)
  30201. */
  30202. getBoundingInfo(): BoundingInfo;
  30203. /**
  30204. * Sets the submesh BoundingInfo
  30205. * @param boundingInfo defines the new bounding info to use
  30206. * @returns the SubMesh
  30207. */
  30208. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30209. /**
  30210. * Returns the mesh of the current submesh
  30211. * @return the parent mesh
  30212. */
  30213. getMesh(): AbstractMesh;
  30214. /**
  30215. * Returns the rendering mesh of the submesh
  30216. * @returns the rendering mesh (could be different from parent mesh)
  30217. */
  30218. getRenderingMesh(): Mesh;
  30219. /**
  30220. * Returns the replacement mesh of the submesh
  30221. * @returns the replacement mesh (could be different from parent mesh)
  30222. */
  30223. getReplacementMesh(): Nullable<AbstractMesh>;
  30224. /**
  30225. * Returns the effective mesh of the submesh
  30226. * @returns the effective mesh (could be different from parent mesh)
  30227. */
  30228. getEffectiveMesh(): AbstractMesh;
  30229. /**
  30230. * Returns the submesh material
  30231. * @returns null or the current material
  30232. */
  30233. getMaterial(): Nullable<Material>;
  30234. private _IsMultiMaterial;
  30235. /**
  30236. * Sets a new updated BoundingInfo object to the submesh
  30237. * @param data defines an optional position array to use to determine the bounding info
  30238. * @returns the SubMesh
  30239. */
  30240. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30241. /** @hidden */
  30242. _checkCollision(collider: Collider): boolean;
  30243. /**
  30244. * Updates the submesh BoundingInfo
  30245. * @param world defines the world matrix to use to update the bounding info
  30246. * @returns the submesh
  30247. */
  30248. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30249. /**
  30250. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30251. * @param frustumPlanes defines the frustum planes
  30252. * @returns true if the submesh is intersecting with the frustum
  30253. */
  30254. isInFrustum(frustumPlanes: Plane[]): boolean;
  30255. /**
  30256. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30257. * @param frustumPlanes defines the frustum planes
  30258. * @returns true if the submesh is inside the frustum
  30259. */
  30260. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30261. /**
  30262. * Renders the submesh
  30263. * @param enableAlphaMode defines if alpha needs to be used
  30264. * @returns the submesh
  30265. */
  30266. render(enableAlphaMode: boolean): SubMesh;
  30267. /**
  30268. * @hidden
  30269. */
  30270. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30271. /**
  30272. * Checks if the submesh intersects with a ray
  30273. * @param ray defines the ray to test
  30274. * @returns true is the passed ray intersects the submesh bounding box
  30275. */
  30276. canIntersects(ray: Ray): boolean;
  30277. /**
  30278. * Intersects current submesh with a ray
  30279. * @param ray defines the ray to test
  30280. * @param positions defines mesh's positions array
  30281. * @param indices defines mesh's indices array
  30282. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30283. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30284. * @returns intersection info or null if no intersection
  30285. */
  30286. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30287. /** @hidden */
  30288. private _intersectLines;
  30289. /** @hidden */
  30290. private _intersectUnIndexedLines;
  30291. /** @hidden */
  30292. private _intersectTriangles;
  30293. /** @hidden */
  30294. private _intersectUnIndexedTriangles;
  30295. /** @hidden */
  30296. _rebuild(): void;
  30297. /**
  30298. * Creates a new submesh from the passed mesh
  30299. * @param newMesh defines the new hosting mesh
  30300. * @param newRenderingMesh defines an optional rendering mesh
  30301. * @returns the new submesh
  30302. */
  30303. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  30304. /**
  30305. * Release associated resources
  30306. */
  30307. dispose(): void;
  30308. /**
  30309. * Gets the class name
  30310. * @returns the string "SubMesh".
  30311. */
  30312. getClassName(): string;
  30313. /**
  30314. * Creates a new submesh from indices data
  30315. * @param materialIndex the index of the main mesh material
  30316. * @param startIndex the index where to start the copy in the mesh indices array
  30317. * @param indexCount the number of indices to copy then from the startIndex
  30318. * @param mesh the main mesh to create the submesh from
  30319. * @param renderingMesh the optional rendering mesh
  30320. * @returns a new submesh
  30321. */
  30322. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  30323. }
  30324. }
  30325. declare module BABYLON {
  30326. /**
  30327. * Class used to represent data loading progression
  30328. */
  30329. export class SceneLoaderFlags {
  30330. private static _ForceFullSceneLoadingForIncremental;
  30331. private static _ShowLoadingScreen;
  30332. private static _CleanBoneMatrixWeights;
  30333. private static _loggingLevel;
  30334. /**
  30335. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  30336. */
  30337. static get ForceFullSceneLoadingForIncremental(): boolean;
  30338. static set ForceFullSceneLoadingForIncremental(value: boolean);
  30339. /**
  30340. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  30341. */
  30342. static get ShowLoadingScreen(): boolean;
  30343. static set ShowLoadingScreen(value: boolean);
  30344. /**
  30345. * Defines the current logging level (while loading the scene)
  30346. * @ignorenaming
  30347. */
  30348. static get loggingLevel(): number;
  30349. static set loggingLevel(value: number);
  30350. /**
  30351. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  30352. */
  30353. static get CleanBoneMatrixWeights(): boolean;
  30354. static set CleanBoneMatrixWeights(value: boolean);
  30355. }
  30356. }
  30357. declare module BABYLON {
  30358. /**
  30359. * Class used to store geometry data (vertex buffers + index buffer)
  30360. */
  30361. export class Geometry implements IGetSetVerticesData {
  30362. /**
  30363. * Gets or sets the ID of the geometry
  30364. */
  30365. id: string;
  30366. /**
  30367. * Gets or sets the unique ID of the geometry
  30368. */
  30369. uniqueId: number;
  30370. /**
  30371. * Gets the delay loading state of the geometry (none by default which means not delayed)
  30372. */
  30373. delayLoadState: number;
  30374. /**
  30375. * Gets the file containing the data to load when running in delay load state
  30376. */
  30377. delayLoadingFile: Nullable<string>;
  30378. /**
  30379. * Callback called when the geometry is updated
  30380. */
  30381. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  30382. private _scene;
  30383. private _engine;
  30384. private _meshes;
  30385. private _totalVertices;
  30386. /** @hidden */
  30387. _indices: IndicesArray;
  30388. /** @hidden */
  30389. _vertexBuffers: {
  30390. [key: string]: VertexBuffer;
  30391. };
  30392. private _isDisposed;
  30393. private _extend;
  30394. private _boundingBias;
  30395. /** @hidden */
  30396. _delayInfo: Array<string>;
  30397. private _indexBuffer;
  30398. private _indexBufferIsUpdatable;
  30399. /** @hidden */
  30400. _boundingInfo: Nullable<BoundingInfo>;
  30401. /** @hidden */
  30402. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  30403. /** @hidden */
  30404. _softwareSkinningFrameId: number;
  30405. private _vertexArrayObjects;
  30406. private _updatable;
  30407. /** @hidden */
  30408. _positions: Nullable<Vector3[]>;
  30409. private _positionsCache;
  30410. /**
  30411. * 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
  30412. */
  30413. get boundingBias(): Vector2;
  30414. /**
  30415. * 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
  30416. */
  30417. set boundingBias(value: Vector2);
  30418. /**
  30419. * Static function used to attach a new empty geometry to a mesh
  30420. * @param mesh defines the mesh to attach the geometry to
  30421. * @returns the new Geometry
  30422. */
  30423. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  30424. /** Get the list of meshes using this geometry */
  30425. get meshes(): Mesh[];
  30426. /**
  30427. * 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
  30428. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  30429. */
  30430. useBoundingInfoFromGeometry: boolean;
  30431. /**
  30432. * Creates a new geometry
  30433. * @param id defines the unique ID
  30434. * @param scene defines the hosting scene
  30435. * @param vertexData defines the VertexData used to get geometry data
  30436. * @param updatable defines if geometry must be updatable (false by default)
  30437. * @param mesh defines the mesh that will be associated with the geometry
  30438. */
  30439. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  30440. /**
  30441. * Gets the current extend of the geometry
  30442. */
  30443. get extend(): {
  30444. minimum: Vector3;
  30445. maximum: Vector3;
  30446. };
  30447. /**
  30448. * Gets the hosting scene
  30449. * @returns the hosting Scene
  30450. */
  30451. getScene(): Scene;
  30452. /**
  30453. * Gets the hosting engine
  30454. * @returns the hosting Engine
  30455. */
  30456. getEngine(): Engine;
  30457. /**
  30458. * Defines if the geometry is ready to use
  30459. * @returns true if the geometry is ready to be used
  30460. */
  30461. isReady(): boolean;
  30462. /**
  30463. * Gets a value indicating that the geometry should not be serialized
  30464. */
  30465. get doNotSerialize(): boolean;
  30466. /** @hidden */
  30467. _rebuild(): void;
  30468. /**
  30469. * Affects all geometry data in one call
  30470. * @param vertexData defines the geometry data
  30471. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  30472. */
  30473. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  30474. /**
  30475. * Set specific vertex data
  30476. * @param kind defines the data kind (Position, normal, etc...)
  30477. * @param data defines the vertex data to use
  30478. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30479. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30480. */
  30481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  30482. /**
  30483. * Removes a specific vertex data
  30484. * @param kind defines the data kind (Position, normal, etc...)
  30485. */
  30486. removeVerticesData(kind: string): void;
  30487. /**
  30488. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  30489. * @param buffer defines the vertex buffer to use
  30490. * @param totalVertices defines the total number of vertices for position kind (could be null)
  30491. */
  30492. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  30493. /**
  30494. * Update a specific vertex buffer
  30495. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  30496. * It will do nothing if the buffer is not updatable
  30497. * @param kind defines the data kind (Position, normal, etc...)
  30498. * @param data defines the data to use
  30499. * @param offset defines the offset in the target buffer where to store the data
  30500. * @param useBytes set to true if the offset is in bytes
  30501. */
  30502. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  30503. /**
  30504. * Update a specific vertex buffer
  30505. * This function will create a new buffer if the current one is not updatable
  30506. * @param kind defines the data kind (Position, normal, etc...)
  30507. * @param data defines the data to use
  30508. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  30509. */
  30510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  30511. private _updateBoundingInfo;
  30512. /** @hidden */
  30513. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  30514. /**
  30515. * Gets total number of vertices
  30516. * @returns the total number of vertices
  30517. */
  30518. getTotalVertices(): number;
  30519. /**
  30520. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30521. * @param kind defines the data kind (Position, normal, etc...)
  30522. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30523. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30524. * @returns a float array containing vertex data
  30525. */
  30526. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30527. /**
  30528. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  30529. * @param kind defines the data kind (Position, normal, etc...)
  30530. * @returns true if the vertex buffer with the specified kind is updatable
  30531. */
  30532. isVertexBufferUpdatable(kind: string): boolean;
  30533. /**
  30534. * Gets a specific vertex buffer
  30535. * @param kind defines the data kind (Position, normal, etc...)
  30536. * @returns a VertexBuffer
  30537. */
  30538. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  30539. /**
  30540. * Returns all vertex buffers
  30541. * @return an object holding all vertex buffers indexed by kind
  30542. */
  30543. getVertexBuffers(): Nullable<{
  30544. [key: string]: VertexBuffer;
  30545. }>;
  30546. /**
  30547. * Gets a boolean indicating if specific vertex buffer is present
  30548. * @param kind defines the data kind (Position, normal, etc...)
  30549. * @returns true if data is present
  30550. */
  30551. isVerticesDataPresent(kind: string): boolean;
  30552. /**
  30553. * Gets a list of all attached data kinds (Position, normal, etc...)
  30554. * @returns a list of string containing all kinds
  30555. */
  30556. getVerticesDataKinds(): string[];
  30557. /**
  30558. * Update index buffer
  30559. * @param indices defines the indices to store in the index buffer
  30560. * @param offset defines the offset in the target buffer where to store the data
  30561. * @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)
  30562. */
  30563. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  30564. /**
  30565. * Creates a new index buffer
  30566. * @param indices defines the indices to store in the index buffer
  30567. * @param totalVertices defines the total number of vertices (could be null)
  30568. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30569. */
  30570. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30571. /**
  30572. * Return the total number of indices
  30573. * @returns the total number of indices
  30574. */
  30575. getTotalIndices(): number;
  30576. /**
  30577. * Gets the index buffer array
  30578. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30579. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30580. * @returns the index buffer array
  30581. */
  30582. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30583. /**
  30584. * Gets the index buffer
  30585. * @return the index buffer
  30586. */
  30587. getIndexBuffer(): Nullable<DataBuffer>;
  30588. /** @hidden */
  30589. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30590. /**
  30591. * Release the associated resources for a specific mesh
  30592. * @param mesh defines the source mesh
  30593. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30594. */
  30595. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30596. /**
  30597. * Apply current geometry to a given mesh
  30598. * @param mesh defines the mesh to apply geometry to
  30599. */
  30600. applyToMesh(mesh: Mesh): void;
  30601. private _updateExtend;
  30602. private _applyToMesh;
  30603. private notifyUpdate;
  30604. /**
  30605. * Load the geometry if it was flagged as delay loaded
  30606. * @param scene defines the hosting scene
  30607. * @param onLoaded defines a callback called when the geometry is loaded
  30608. */
  30609. load(scene: Scene, onLoaded?: () => void): void;
  30610. private _queueLoad;
  30611. /**
  30612. * Invert the geometry to move from a right handed system to a left handed one.
  30613. */
  30614. toLeftHanded(): void;
  30615. /** @hidden */
  30616. _resetPointsArrayCache(): void;
  30617. /** @hidden */
  30618. _generatePointsArray(): boolean;
  30619. /**
  30620. * Gets a value indicating if the geometry is disposed
  30621. * @returns true if the geometry was disposed
  30622. */
  30623. isDisposed(): boolean;
  30624. private _disposeVertexArrayObjects;
  30625. /**
  30626. * Free all associated resources
  30627. */
  30628. dispose(): void;
  30629. /**
  30630. * Clone the current geometry into a new geometry
  30631. * @param id defines the unique ID of the new geometry
  30632. * @returns a new geometry object
  30633. */
  30634. copy(id: string): Geometry;
  30635. /**
  30636. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30637. * @return a JSON representation of the current geometry data (without the vertices data)
  30638. */
  30639. serialize(): any;
  30640. private toNumberArray;
  30641. /**
  30642. * Serialize all vertices data into a JSON oject
  30643. * @returns a JSON representation of the current geometry data
  30644. */
  30645. serializeVerticeData(): any;
  30646. /**
  30647. * Extracts a clone of a mesh geometry
  30648. * @param mesh defines the source mesh
  30649. * @param id defines the unique ID of the new geometry object
  30650. * @returns the new geometry object
  30651. */
  30652. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30653. /**
  30654. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30655. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30656. * Be aware Math.random() could cause collisions, but:
  30657. * "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"
  30658. * @returns a string containing a new GUID
  30659. */
  30660. static RandomId(): string;
  30661. /** @hidden */
  30662. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30663. private static _CleanMatricesWeights;
  30664. /**
  30665. * Create a new geometry from persisted data (Using .babylon file format)
  30666. * @param parsedVertexData defines the persisted data
  30667. * @param scene defines the hosting scene
  30668. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30669. * @returns the new geometry object
  30670. */
  30671. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30672. }
  30673. }
  30674. declare module BABYLON {
  30675. /**
  30676. * Defines a target to use with MorphTargetManager
  30677. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30678. */
  30679. export class MorphTarget implements IAnimatable {
  30680. /** defines the name of the target */
  30681. name: string;
  30682. /**
  30683. * Gets or sets the list of animations
  30684. */
  30685. animations: Animation[];
  30686. private _scene;
  30687. private _positions;
  30688. private _normals;
  30689. private _tangents;
  30690. private _uvs;
  30691. private _influence;
  30692. private _uniqueId;
  30693. /**
  30694. * Observable raised when the influence changes
  30695. */
  30696. onInfluenceChanged: Observable<boolean>;
  30697. /** @hidden */
  30698. _onDataLayoutChanged: Observable<void>;
  30699. /**
  30700. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30701. */
  30702. get influence(): number;
  30703. set influence(influence: number);
  30704. /**
  30705. * Gets or sets the id of the morph Target
  30706. */
  30707. id: string;
  30708. private _animationPropertiesOverride;
  30709. /**
  30710. * Gets or sets the animation properties override
  30711. */
  30712. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30713. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30714. /**
  30715. * Creates a new MorphTarget
  30716. * @param name defines the name of the target
  30717. * @param influence defines the influence to use
  30718. * @param scene defines the scene the morphtarget belongs to
  30719. */
  30720. constructor(
  30721. /** defines the name of the target */
  30722. name: string, influence?: number, scene?: Nullable<Scene>);
  30723. /**
  30724. * Gets the unique ID of this manager
  30725. */
  30726. get uniqueId(): number;
  30727. /**
  30728. * Gets a boolean defining if the target contains position data
  30729. */
  30730. get hasPositions(): boolean;
  30731. /**
  30732. * Gets a boolean defining if the target contains normal data
  30733. */
  30734. get hasNormals(): boolean;
  30735. /**
  30736. * Gets a boolean defining if the target contains tangent data
  30737. */
  30738. get hasTangents(): boolean;
  30739. /**
  30740. * Gets a boolean defining if the target contains texture coordinates data
  30741. */
  30742. get hasUVs(): boolean;
  30743. /**
  30744. * Affects position data to this target
  30745. * @param data defines the position data to use
  30746. */
  30747. setPositions(data: Nullable<FloatArray>): void;
  30748. /**
  30749. * Gets the position data stored in this target
  30750. * @returns a FloatArray containing the position data (or null if not present)
  30751. */
  30752. getPositions(): Nullable<FloatArray>;
  30753. /**
  30754. * Affects normal data to this target
  30755. * @param data defines the normal data to use
  30756. */
  30757. setNormals(data: Nullable<FloatArray>): void;
  30758. /**
  30759. * Gets the normal data stored in this target
  30760. * @returns a FloatArray containing the normal data (or null if not present)
  30761. */
  30762. getNormals(): Nullable<FloatArray>;
  30763. /**
  30764. * Affects tangent data to this target
  30765. * @param data defines the tangent data to use
  30766. */
  30767. setTangents(data: Nullable<FloatArray>): void;
  30768. /**
  30769. * Gets the tangent data stored in this target
  30770. * @returns a FloatArray containing the tangent data (or null if not present)
  30771. */
  30772. getTangents(): Nullable<FloatArray>;
  30773. /**
  30774. * Affects texture coordinates data to this target
  30775. * @param data defines the texture coordinates data to use
  30776. */
  30777. setUVs(data: Nullable<FloatArray>): void;
  30778. /**
  30779. * Gets the texture coordinates data stored in this target
  30780. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30781. */
  30782. getUVs(): Nullable<FloatArray>;
  30783. /**
  30784. * Clone the current target
  30785. * @returns a new MorphTarget
  30786. */
  30787. clone(): MorphTarget;
  30788. /**
  30789. * Serializes the current target into a Serialization object
  30790. * @returns the serialized object
  30791. */
  30792. serialize(): any;
  30793. /**
  30794. * Returns the string "MorphTarget"
  30795. * @returns "MorphTarget"
  30796. */
  30797. getClassName(): string;
  30798. /**
  30799. * Creates a new target from serialized data
  30800. * @param serializationObject defines the serialized data to use
  30801. * @returns a new MorphTarget
  30802. */
  30803. static Parse(serializationObject: any): MorphTarget;
  30804. /**
  30805. * Creates a MorphTarget from mesh data
  30806. * @param mesh defines the source mesh
  30807. * @param name defines the name to use for the new target
  30808. * @param influence defines the influence to attach to the target
  30809. * @returns a new MorphTarget
  30810. */
  30811. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30812. }
  30813. }
  30814. declare module BABYLON {
  30815. /**
  30816. * This class is used to deform meshes using morphing between different targets
  30817. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30818. */
  30819. export class MorphTargetManager {
  30820. private _targets;
  30821. private _targetInfluenceChangedObservers;
  30822. private _targetDataLayoutChangedObservers;
  30823. private _activeTargets;
  30824. private _scene;
  30825. private _influences;
  30826. private _supportsNormals;
  30827. private _supportsTangents;
  30828. private _supportsUVs;
  30829. private _vertexCount;
  30830. private _uniqueId;
  30831. private _tempInfluences;
  30832. /**
  30833. * Gets or sets a boolean indicating if normals must be morphed
  30834. */
  30835. enableNormalMorphing: boolean;
  30836. /**
  30837. * Gets or sets a boolean indicating if tangents must be morphed
  30838. */
  30839. enableTangentMorphing: boolean;
  30840. /**
  30841. * Gets or sets a boolean indicating if UV must be morphed
  30842. */
  30843. enableUVMorphing: boolean;
  30844. /**
  30845. * Creates a new MorphTargetManager
  30846. * @param scene defines the current scene
  30847. */
  30848. constructor(scene?: Nullable<Scene>);
  30849. /**
  30850. * Gets the unique ID of this manager
  30851. */
  30852. get uniqueId(): number;
  30853. /**
  30854. * Gets the number of vertices handled by this manager
  30855. */
  30856. get vertexCount(): number;
  30857. /**
  30858. * Gets a boolean indicating if this manager supports morphing of normals
  30859. */
  30860. get supportsNormals(): boolean;
  30861. /**
  30862. * Gets a boolean indicating if this manager supports morphing of tangents
  30863. */
  30864. get supportsTangents(): boolean;
  30865. /**
  30866. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30867. */
  30868. get supportsUVs(): boolean;
  30869. /**
  30870. * Gets the number of targets stored in this manager
  30871. */
  30872. get numTargets(): number;
  30873. /**
  30874. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30875. */
  30876. get numInfluencers(): number;
  30877. /**
  30878. * Gets the list of influences (one per target)
  30879. */
  30880. get influences(): Float32Array;
  30881. /**
  30882. * Gets the active target at specified index. An active target is a target with an influence > 0
  30883. * @param index defines the index to check
  30884. * @returns the requested target
  30885. */
  30886. getActiveTarget(index: number): MorphTarget;
  30887. /**
  30888. * Gets the target at specified index
  30889. * @param index defines the index to check
  30890. * @returns the requested target
  30891. */
  30892. getTarget(index: number): MorphTarget;
  30893. /**
  30894. * Add a new target to this manager
  30895. * @param target defines the target to add
  30896. */
  30897. addTarget(target: MorphTarget): void;
  30898. /**
  30899. * Removes a target from the manager
  30900. * @param target defines the target to remove
  30901. */
  30902. removeTarget(target: MorphTarget): void;
  30903. /**
  30904. * Clone the current manager
  30905. * @returns a new MorphTargetManager
  30906. */
  30907. clone(): MorphTargetManager;
  30908. /**
  30909. * Serializes the current manager into a Serialization object
  30910. * @returns the serialized object
  30911. */
  30912. serialize(): any;
  30913. private _syncActiveTargets;
  30914. /**
  30915. * Syncrhonize the targets with all the meshes using this morph target manager
  30916. */
  30917. synchronize(): void;
  30918. /**
  30919. * Creates a new MorphTargetManager from serialized data
  30920. * @param serializationObject defines the serialized data
  30921. * @param scene defines the hosting scene
  30922. * @returns the new MorphTargetManager
  30923. */
  30924. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  30925. }
  30926. }
  30927. declare module BABYLON {
  30928. /**
  30929. * Class used to represent a specific level of detail of a mesh
  30930. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  30931. */
  30932. export class MeshLODLevel {
  30933. /** Defines the distance where this level should start being displayed */
  30934. distance: number;
  30935. /** Defines the mesh to use to render this level */
  30936. mesh: Nullable<Mesh>;
  30937. /**
  30938. * Creates a new LOD level
  30939. * @param distance defines the distance where this level should star being displayed
  30940. * @param mesh defines the mesh to use to render this level
  30941. */
  30942. constructor(
  30943. /** Defines the distance where this level should start being displayed */
  30944. distance: number,
  30945. /** Defines the mesh to use to render this level */
  30946. mesh: Nullable<Mesh>);
  30947. }
  30948. }
  30949. declare module BABYLON {
  30950. /**
  30951. * Helper class used to generate a canvas to manipulate images
  30952. */
  30953. export class CanvasGenerator {
  30954. /**
  30955. * Create a new canvas (or offscreen canvas depending on the context)
  30956. * @param width defines the expected width
  30957. * @param height defines the expected height
  30958. * @return a new canvas or offscreen canvas
  30959. */
  30960. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  30961. }
  30962. }
  30963. declare module BABYLON {
  30964. /**
  30965. * Mesh representing the gorund
  30966. */
  30967. export class GroundMesh extends Mesh {
  30968. /** If octree should be generated */
  30969. generateOctree: boolean;
  30970. private _heightQuads;
  30971. /** @hidden */
  30972. _subdivisionsX: number;
  30973. /** @hidden */
  30974. _subdivisionsY: number;
  30975. /** @hidden */
  30976. _width: number;
  30977. /** @hidden */
  30978. _height: number;
  30979. /** @hidden */
  30980. _minX: number;
  30981. /** @hidden */
  30982. _maxX: number;
  30983. /** @hidden */
  30984. _minZ: number;
  30985. /** @hidden */
  30986. _maxZ: number;
  30987. constructor(name: string, scene: Scene);
  30988. /**
  30989. * "GroundMesh"
  30990. * @returns "GroundMesh"
  30991. */
  30992. getClassName(): string;
  30993. /**
  30994. * The minimum of x and y subdivisions
  30995. */
  30996. get subdivisions(): number;
  30997. /**
  30998. * X subdivisions
  30999. */
  31000. get subdivisionsX(): number;
  31001. /**
  31002. * Y subdivisions
  31003. */
  31004. get subdivisionsY(): number;
  31005. /**
  31006. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31007. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31008. * @param chunksCount the number of subdivisions for x and y
  31009. * @param octreeBlocksSize (Default: 32)
  31010. */
  31011. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31012. /**
  31013. * Returns a height (y) value in the Worl system :
  31014. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31015. * @param x x coordinate
  31016. * @param z z coordinate
  31017. * @returns the ground y position if (x, z) are outside the ground surface.
  31018. */
  31019. getHeightAtCoordinates(x: number, z: number): number;
  31020. /**
  31021. * Returns a normalized vector (Vector3) orthogonal to the ground
  31022. * at the ground coordinates (x, z) expressed in the World system.
  31023. * @param x x coordinate
  31024. * @param z z coordinate
  31025. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31026. */
  31027. getNormalAtCoordinates(x: number, z: number): Vector3;
  31028. /**
  31029. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31030. * at the ground coordinates (x, z) expressed in the World system.
  31031. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31032. * @param x x coordinate
  31033. * @param z z coordinate
  31034. * @param ref vector to store the result
  31035. * @returns the GroundMesh.
  31036. */
  31037. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31038. /**
  31039. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31040. * if the ground has been updated.
  31041. * This can be used in the render loop.
  31042. * @returns the GroundMesh.
  31043. */
  31044. updateCoordinateHeights(): GroundMesh;
  31045. private _getFacetAt;
  31046. private _initHeightQuads;
  31047. private _computeHeightQuads;
  31048. /**
  31049. * Serializes this ground mesh
  31050. * @param serializationObject object to write serialization to
  31051. */
  31052. serialize(serializationObject: any): void;
  31053. /**
  31054. * Parses a serialized ground mesh
  31055. * @param parsedMesh the serialized mesh
  31056. * @param scene the scene to create the ground mesh in
  31057. * @returns the created ground mesh
  31058. */
  31059. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31060. }
  31061. }
  31062. declare module BABYLON {
  31063. /**
  31064. * Interface for Physics-Joint data
  31065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31066. */
  31067. export interface PhysicsJointData {
  31068. /**
  31069. * The main pivot of the joint
  31070. */
  31071. mainPivot?: Vector3;
  31072. /**
  31073. * The connected pivot of the joint
  31074. */
  31075. connectedPivot?: Vector3;
  31076. /**
  31077. * The main axis of the joint
  31078. */
  31079. mainAxis?: Vector3;
  31080. /**
  31081. * The connected axis of the joint
  31082. */
  31083. connectedAxis?: Vector3;
  31084. /**
  31085. * The collision of the joint
  31086. */
  31087. collision?: boolean;
  31088. /**
  31089. * Native Oimo/Cannon/Energy data
  31090. */
  31091. nativeParams?: any;
  31092. }
  31093. /**
  31094. * This is a holder class for the physics joint created by the physics plugin
  31095. * It holds a set of functions to control the underlying joint
  31096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31097. */
  31098. export class PhysicsJoint {
  31099. /**
  31100. * The type of the physics joint
  31101. */
  31102. type: number;
  31103. /**
  31104. * The data for the physics joint
  31105. */
  31106. jointData: PhysicsJointData;
  31107. private _physicsJoint;
  31108. protected _physicsPlugin: IPhysicsEnginePlugin;
  31109. /**
  31110. * Initializes the physics joint
  31111. * @param type The type of the physics joint
  31112. * @param jointData The data for the physics joint
  31113. */
  31114. constructor(
  31115. /**
  31116. * The type of the physics joint
  31117. */
  31118. type: number,
  31119. /**
  31120. * The data for the physics joint
  31121. */
  31122. jointData: PhysicsJointData);
  31123. /**
  31124. * Gets the physics joint
  31125. */
  31126. get physicsJoint(): any;
  31127. /**
  31128. * Sets the physics joint
  31129. */
  31130. set physicsJoint(newJoint: any);
  31131. /**
  31132. * Sets the physics plugin
  31133. */
  31134. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31135. /**
  31136. * Execute a function that is physics-plugin specific.
  31137. * @param {Function} func the function that will be executed.
  31138. * It accepts two parameters: the physics world and the physics joint
  31139. */
  31140. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31141. /**
  31142. * Distance-Joint type
  31143. */
  31144. static DistanceJoint: number;
  31145. /**
  31146. * Hinge-Joint type
  31147. */
  31148. static HingeJoint: number;
  31149. /**
  31150. * Ball-and-Socket joint type
  31151. */
  31152. static BallAndSocketJoint: number;
  31153. /**
  31154. * Wheel-Joint type
  31155. */
  31156. static WheelJoint: number;
  31157. /**
  31158. * Slider-Joint type
  31159. */
  31160. static SliderJoint: number;
  31161. /**
  31162. * Prismatic-Joint type
  31163. */
  31164. static PrismaticJoint: number;
  31165. /**
  31166. * Universal-Joint type
  31167. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31168. */
  31169. static UniversalJoint: number;
  31170. /**
  31171. * Hinge-Joint 2 type
  31172. */
  31173. static Hinge2Joint: number;
  31174. /**
  31175. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31176. */
  31177. static PointToPointJoint: number;
  31178. /**
  31179. * Spring-Joint type
  31180. */
  31181. static SpringJoint: number;
  31182. /**
  31183. * Lock-Joint type
  31184. */
  31185. static LockJoint: number;
  31186. }
  31187. /**
  31188. * A class representing a physics distance joint
  31189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31190. */
  31191. export class DistanceJoint extends PhysicsJoint {
  31192. /**
  31193. *
  31194. * @param jointData The data for the Distance-Joint
  31195. */
  31196. constructor(jointData: DistanceJointData);
  31197. /**
  31198. * Update the predefined distance.
  31199. * @param maxDistance The maximum preferred distance
  31200. * @param minDistance The minimum preferred distance
  31201. */
  31202. updateDistance(maxDistance: number, minDistance?: number): void;
  31203. }
  31204. /**
  31205. * Represents a Motor-Enabled Joint
  31206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31207. */
  31208. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31209. /**
  31210. * Initializes the Motor-Enabled Joint
  31211. * @param type The type of the joint
  31212. * @param jointData The physica joint data for the joint
  31213. */
  31214. constructor(type: number, jointData: PhysicsJointData);
  31215. /**
  31216. * Set the motor values.
  31217. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31218. * @param force the force to apply
  31219. * @param maxForce max force for this motor.
  31220. */
  31221. setMotor(force?: number, maxForce?: number): void;
  31222. /**
  31223. * Set the motor's limits.
  31224. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31225. * @param upperLimit The upper limit of the motor
  31226. * @param lowerLimit The lower limit of the motor
  31227. */
  31228. setLimit(upperLimit: number, lowerLimit?: number): void;
  31229. }
  31230. /**
  31231. * This class represents a single physics Hinge-Joint
  31232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31233. */
  31234. export class HingeJoint extends MotorEnabledJoint {
  31235. /**
  31236. * Initializes the Hinge-Joint
  31237. * @param jointData The joint data for the Hinge-Joint
  31238. */
  31239. constructor(jointData: PhysicsJointData);
  31240. /**
  31241. * Set the motor values.
  31242. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31243. * @param {number} force the force to apply
  31244. * @param {number} maxForce max force for this motor.
  31245. */
  31246. setMotor(force?: number, maxForce?: number): void;
  31247. /**
  31248. * Set the motor's limits.
  31249. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31250. * @param upperLimit The upper limit of the motor
  31251. * @param lowerLimit The lower limit of the motor
  31252. */
  31253. setLimit(upperLimit: number, lowerLimit?: number): void;
  31254. }
  31255. /**
  31256. * This class represents a dual hinge physics joint (same as wheel joint)
  31257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31258. */
  31259. export class Hinge2Joint extends MotorEnabledJoint {
  31260. /**
  31261. * Initializes the Hinge2-Joint
  31262. * @param jointData The joint data for the Hinge2-Joint
  31263. */
  31264. constructor(jointData: PhysicsJointData);
  31265. /**
  31266. * Set the motor values.
  31267. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31268. * @param {number} targetSpeed the speed the motor is to reach
  31269. * @param {number} maxForce max force for this motor.
  31270. * @param {motorIndex} the motor's index, 0 or 1.
  31271. */
  31272. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31273. /**
  31274. * Set the motor limits.
  31275. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31276. * @param {number} upperLimit the upper limit
  31277. * @param {number} lowerLimit lower limit
  31278. * @param {motorIndex} the motor's index, 0 or 1.
  31279. */
  31280. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31281. }
  31282. /**
  31283. * Interface for a motor enabled joint
  31284. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31285. */
  31286. export interface IMotorEnabledJoint {
  31287. /**
  31288. * Physics joint
  31289. */
  31290. physicsJoint: any;
  31291. /**
  31292. * Sets the motor of the motor-enabled joint
  31293. * @param force The force of the motor
  31294. * @param maxForce The maximum force of the motor
  31295. * @param motorIndex The index of the motor
  31296. */
  31297. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31298. /**
  31299. * Sets the limit of the motor
  31300. * @param upperLimit The upper limit of the motor
  31301. * @param lowerLimit The lower limit of the motor
  31302. * @param motorIndex The index of the motor
  31303. */
  31304. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31305. }
  31306. /**
  31307. * Joint data for a Distance-Joint
  31308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31309. */
  31310. export interface DistanceJointData extends PhysicsJointData {
  31311. /**
  31312. * Max distance the 2 joint objects can be apart
  31313. */
  31314. maxDistance: number;
  31315. }
  31316. /**
  31317. * Joint data from a spring joint
  31318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31319. */
  31320. export interface SpringJointData extends PhysicsJointData {
  31321. /**
  31322. * Length of the spring
  31323. */
  31324. length: number;
  31325. /**
  31326. * Stiffness of the spring
  31327. */
  31328. stiffness: number;
  31329. /**
  31330. * Damping of the spring
  31331. */
  31332. damping: number;
  31333. /** this callback will be called when applying the force to the impostors. */
  31334. forceApplicationCallback: () => void;
  31335. }
  31336. }
  31337. declare module BABYLON {
  31338. /**
  31339. * Holds the data for the raycast result
  31340. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31341. */
  31342. export class PhysicsRaycastResult {
  31343. private _hasHit;
  31344. private _hitDistance;
  31345. private _hitNormalWorld;
  31346. private _hitPointWorld;
  31347. private _rayFromWorld;
  31348. private _rayToWorld;
  31349. /**
  31350. * Gets if there was a hit
  31351. */
  31352. get hasHit(): boolean;
  31353. /**
  31354. * Gets the distance from the hit
  31355. */
  31356. get hitDistance(): number;
  31357. /**
  31358. * Gets the hit normal/direction in the world
  31359. */
  31360. get hitNormalWorld(): Vector3;
  31361. /**
  31362. * Gets the hit point in the world
  31363. */
  31364. get hitPointWorld(): Vector3;
  31365. /**
  31366. * Gets the ray "start point" of the ray in the world
  31367. */
  31368. get rayFromWorld(): Vector3;
  31369. /**
  31370. * Gets the ray "end point" of the ray in the world
  31371. */
  31372. get rayToWorld(): Vector3;
  31373. /**
  31374. * Sets the hit data (normal & point in world space)
  31375. * @param hitNormalWorld defines the normal in world space
  31376. * @param hitPointWorld defines the point in world space
  31377. */
  31378. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31379. /**
  31380. * Sets the distance from the start point to the hit point
  31381. * @param distance
  31382. */
  31383. setHitDistance(distance: number): void;
  31384. /**
  31385. * Calculates the distance manually
  31386. */
  31387. calculateHitDistance(): void;
  31388. /**
  31389. * Resets all the values to default
  31390. * @param from The from point on world space
  31391. * @param to The to point on world space
  31392. */
  31393. reset(from?: Vector3, to?: Vector3): void;
  31394. }
  31395. /**
  31396. * Interface for the size containing width and height
  31397. */
  31398. interface IXYZ {
  31399. /**
  31400. * X
  31401. */
  31402. x: number;
  31403. /**
  31404. * Y
  31405. */
  31406. y: number;
  31407. /**
  31408. * Z
  31409. */
  31410. z: number;
  31411. }
  31412. }
  31413. declare module BABYLON {
  31414. /**
  31415. * Interface used to describe a physics joint
  31416. */
  31417. export interface PhysicsImpostorJoint {
  31418. /** Defines the main impostor to which the joint is linked */
  31419. mainImpostor: PhysicsImpostor;
  31420. /** Defines the impostor that is connected to the main impostor using this joint */
  31421. connectedImpostor: PhysicsImpostor;
  31422. /** Defines the joint itself */
  31423. joint: PhysicsJoint;
  31424. }
  31425. /** @hidden */
  31426. export interface IPhysicsEnginePlugin {
  31427. world: any;
  31428. name: string;
  31429. setGravity(gravity: Vector3): void;
  31430. setTimeStep(timeStep: number): void;
  31431. getTimeStep(): number;
  31432. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31433. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31434. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31435. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31436. removePhysicsBody(impostor: PhysicsImpostor): void;
  31437. generateJoint(joint: PhysicsImpostorJoint): void;
  31438. removeJoint(joint: PhysicsImpostorJoint): void;
  31439. isSupported(): boolean;
  31440. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31441. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31442. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31443. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31444. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31445. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31446. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31447. getBodyMass(impostor: PhysicsImpostor): number;
  31448. getBodyFriction(impostor: PhysicsImpostor): number;
  31449. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31450. getBodyRestitution(impostor: PhysicsImpostor): number;
  31451. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31452. getBodyPressure?(impostor: PhysicsImpostor): number;
  31453. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31454. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31455. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31456. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31457. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31458. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31459. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31460. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31461. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31462. sleepBody(impostor: PhysicsImpostor): void;
  31463. wakeUpBody(impostor: PhysicsImpostor): void;
  31464. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31465. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31466. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31467. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31468. getRadius(impostor: PhysicsImpostor): number;
  31469. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31470. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31471. dispose(): void;
  31472. }
  31473. /**
  31474. * Interface used to define a physics engine
  31475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31476. */
  31477. export interface IPhysicsEngine {
  31478. /**
  31479. * Gets the gravity vector used by the simulation
  31480. */
  31481. gravity: Vector3;
  31482. /**
  31483. * Sets the gravity vector used by the simulation
  31484. * @param gravity defines the gravity vector to use
  31485. */
  31486. setGravity(gravity: Vector3): void;
  31487. /**
  31488. * Set the time step of the physics engine.
  31489. * Default is 1/60.
  31490. * To slow it down, enter 1/600 for example.
  31491. * To speed it up, 1/30
  31492. * @param newTimeStep the new timestep to apply to this world.
  31493. */
  31494. setTimeStep(newTimeStep: number): void;
  31495. /**
  31496. * Get the time step of the physics engine.
  31497. * @returns the current time step
  31498. */
  31499. getTimeStep(): number;
  31500. /**
  31501. * Set the sub time step of the physics engine.
  31502. * Default is 0 meaning there is no sub steps
  31503. * To increase physics resolution precision, set a small value (like 1 ms)
  31504. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31505. */
  31506. setSubTimeStep(subTimeStep: number): void;
  31507. /**
  31508. * Get the sub time step of the physics engine.
  31509. * @returns the current sub time step
  31510. */
  31511. getSubTimeStep(): number;
  31512. /**
  31513. * Release all resources
  31514. */
  31515. dispose(): void;
  31516. /**
  31517. * Gets the name of the current physics plugin
  31518. * @returns the name of the plugin
  31519. */
  31520. getPhysicsPluginName(): string;
  31521. /**
  31522. * Adding a new impostor for the impostor tracking.
  31523. * This will be done by the impostor itself.
  31524. * @param impostor the impostor to add
  31525. */
  31526. addImpostor(impostor: PhysicsImpostor): void;
  31527. /**
  31528. * Remove an impostor from the engine.
  31529. * This impostor and its mesh will not longer be updated by the physics engine.
  31530. * @param impostor the impostor to remove
  31531. */
  31532. removeImpostor(impostor: PhysicsImpostor): void;
  31533. /**
  31534. * Add a joint to the physics engine
  31535. * @param mainImpostor defines the main impostor to which the joint is added.
  31536. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31537. * @param joint defines the joint that will connect both impostors.
  31538. */
  31539. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31540. /**
  31541. * Removes a joint from the simulation
  31542. * @param mainImpostor defines the impostor used with the joint
  31543. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31544. * @param joint defines the joint to remove
  31545. */
  31546. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31547. /**
  31548. * Gets the current plugin used to run the simulation
  31549. * @returns current plugin
  31550. */
  31551. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31552. /**
  31553. * Gets the list of physic impostors
  31554. * @returns an array of PhysicsImpostor
  31555. */
  31556. getImpostors(): Array<PhysicsImpostor>;
  31557. /**
  31558. * Gets the impostor for a physics enabled object
  31559. * @param object defines the object impersonated by the impostor
  31560. * @returns the PhysicsImpostor or null if not found
  31561. */
  31562. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31563. /**
  31564. * Gets the impostor for a physics body object
  31565. * @param body defines physics body used by the impostor
  31566. * @returns the PhysicsImpostor or null if not found
  31567. */
  31568. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31569. /**
  31570. * Does a raycast in the physics world
  31571. * @param from when should the ray start?
  31572. * @param to when should the ray end?
  31573. * @returns PhysicsRaycastResult
  31574. */
  31575. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31576. /**
  31577. * Called by the scene. No need to call it.
  31578. * @param delta defines the timespam between frames
  31579. */
  31580. _step(delta: number): void;
  31581. }
  31582. }
  31583. declare module BABYLON {
  31584. /**
  31585. * The interface for the physics imposter parameters
  31586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31587. */
  31588. export interface PhysicsImpostorParameters {
  31589. /**
  31590. * The mass of the physics imposter
  31591. */
  31592. mass: number;
  31593. /**
  31594. * The friction of the physics imposter
  31595. */
  31596. friction?: number;
  31597. /**
  31598. * The coefficient of restitution of the physics imposter
  31599. */
  31600. restitution?: number;
  31601. /**
  31602. * The native options of the physics imposter
  31603. */
  31604. nativeOptions?: any;
  31605. /**
  31606. * Specifies if the parent should be ignored
  31607. */
  31608. ignoreParent?: boolean;
  31609. /**
  31610. * Specifies if bi-directional transformations should be disabled
  31611. */
  31612. disableBidirectionalTransformation?: boolean;
  31613. /**
  31614. * The pressure inside the physics imposter, soft object only
  31615. */
  31616. pressure?: number;
  31617. /**
  31618. * The stiffness the physics imposter, soft object only
  31619. */
  31620. stiffness?: number;
  31621. /**
  31622. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31623. */
  31624. velocityIterations?: number;
  31625. /**
  31626. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31627. */
  31628. positionIterations?: number;
  31629. /**
  31630. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31631. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31632. * Add to fix multiple points
  31633. */
  31634. fixedPoints?: number;
  31635. /**
  31636. * The collision margin around a soft object
  31637. */
  31638. margin?: number;
  31639. /**
  31640. * The collision margin around a soft object
  31641. */
  31642. damping?: number;
  31643. /**
  31644. * The path for a rope based on an extrusion
  31645. */
  31646. path?: any;
  31647. /**
  31648. * The shape of an extrusion used for a rope based on an extrusion
  31649. */
  31650. shape?: any;
  31651. }
  31652. /**
  31653. * Interface for a physics-enabled object
  31654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31655. */
  31656. export interface IPhysicsEnabledObject {
  31657. /**
  31658. * The position of the physics-enabled object
  31659. */
  31660. position: Vector3;
  31661. /**
  31662. * The rotation of the physics-enabled object
  31663. */
  31664. rotationQuaternion: Nullable<Quaternion>;
  31665. /**
  31666. * The scale of the physics-enabled object
  31667. */
  31668. scaling: Vector3;
  31669. /**
  31670. * The rotation of the physics-enabled object
  31671. */
  31672. rotation?: Vector3;
  31673. /**
  31674. * The parent of the physics-enabled object
  31675. */
  31676. parent?: any;
  31677. /**
  31678. * The bounding info of the physics-enabled object
  31679. * @returns The bounding info of the physics-enabled object
  31680. */
  31681. getBoundingInfo(): BoundingInfo;
  31682. /**
  31683. * Computes the world matrix
  31684. * @param force Specifies if the world matrix should be computed by force
  31685. * @returns A world matrix
  31686. */
  31687. computeWorldMatrix(force: boolean): Matrix;
  31688. /**
  31689. * Gets the world matrix
  31690. * @returns A world matrix
  31691. */
  31692. getWorldMatrix?(): Matrix;
  31693. /**
  31694. * Gets the child meshes
  31695. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31696. * @returns An array of abstract meshes
  31697. */
  31698. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31699. /**
  31700. * Gets the vertex data
  31701. * @param kind The type of vertex data
  31702. * @returns A nullable array of numbers, or a float32 array
  31703. */
  31704. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31705. /**
  31706. * Gets the indices from the mesh
  31707. * @returns A nullable array of index arrays
  31708. */
  31709. getIndices?(): Nullable<IndicesArray>;
  31710. /**
  31711. * Gets the scene from the mesh
  31712. * @returns the indices array or null
  31713. */
  31714. getScene?(): Scene;
  31715. /**
  31716. * Gets the absolute position from the mesh
  31717. * @returns the absolute position
  31718. */
  31719. getAbsolutePosition(): Vector3;
  31720. /**
  31721. * Gets the absolute pivot point from the mesh
  31722. * @returns the absolute pivot point
  31723. */
  31724. getAbsolutePivotPoint(): Vector3;
  31725. /**
  31726. * Rotates the mesh
  31727. * @param axis The axis of rotation
  31728. * @param amount The amount of rotation
  31729. * @param space The space of the rotation
  31730. * @returns The rotation transform node
  31731. */
  31732. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31733. /**
  31734. * Translates the mesh
  31735. * @param axis The axis of translation
  31736. * @param distance The distance of translation
  31737. * @param space The space of the translation
  31738. * @returns The transform node
  31739. */
  31740. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31741. /**
  31742. * Sets the absolute position of the mesh
  31743. * @param absolutePosition The absolute position of the mesh
  31744. * @returns The transform node
  31745. */
  31746. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31747. /**
  31748. * Gets the class name of the mesh
  31749. * @returns The class name
  31750. */
  31751. getClassName(): string;
  31752. }
  31753. /**
  31754. * Represents a physics imposter
  31755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31756. */
  31757. export class PhysicsImpostor {
  31758. /**
  31759. * The physics-enabled object used as the physics imposter
  31760. */
  31761. object: IPhysicsEnabledObject;
  31762. /**
  31763. * The type of the physics imposter
  31764. */
  31765. type: number;
  31766. private _options;
  31767. private _scene?;
  31768. /**
  31769. * The default object size of the imposter
  31770. */
  31771. static DEFAULT_OBJECT_SIZE: Vector3;
  31772. /**
  31773. * The identity quaternion of the imposter
  31774. */
  31775. static IDENTITY_QUATERNION: Quaternion;
  31776. /** @hidden */
  31777. _pluginData: any;
  31778. private _physicsEngine;
  31779. private _physicsBody;
  31780. private _bodyUpdateRequired;
  31781. private _onBeforePhysicsStepCallbacks;
  31782. private _onAfterPhysicsStepCallbacks;
  31783. /** @hidden */
  31784. _onPhysicsCollideCallbacks: Array<{
  31785. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  31786. otherImpostors: Array<PhysicsImpostor>;
  31787. }>;
  31788. private _deltaPosition;
  31789. private _deltaRotation;
  31790. private _deltaRotationConjugated;
  31791. /** @hidden */
  31792. _isFromLine: boolean;
  31793. private _parent;
  31794. private _isDisposed;
  31795. private static _tmpVecs;
  31796. private static _tmpQuat;
  31797. /**
  31798. * Specifies if the physics imposter is disposed
  31799. */
  31800. get isDisposed(): boolean;
  31801. /**
  31802. * Gets the mass of the physics imposter
  31803. */
  31804. get mass(): number;
  31805. set mass(value: number);
  31806. /**
  31807. * Gets the coefficient of friction
  31808. */
  31809. get friction(): number;
  31810. /**
  31811. * Sets the coefficient of friction
  31812. */
  31813. set friction(value: number);
  31814. /**
  31815. * Gets the coefficient of restitution
  31816. */
  31817. get restitution(): number;
  31818. /**
  31819. * Sets the coefficient of restitution
  31820. */
  31821. set restitution(value: number);
  31822. /**
  31823. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31824. */
  31825. get pressure(): number;
  31826. /**
  31827. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31828. */
  31829. set pressure(value: number);
  31830. /**
  31831. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31832. */
  31833. get stiffness(): number;
  31834. /**
  31835. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31836. */
  31837. set stiffness(value: number);
  31838. /**
  31839. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31840. */
  31841. get velocityIterations(): number;
  31842. /**
  31843. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31844. */
  31845. set velocityIterations(value: number);
  31846. /**
  31847. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31848. */
  31849. get positionIterations(): number;
  31850. /**
  31851. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31852. */
  31853. set positionIterations(value: number);
  31854. /**
  31855. * The unique id of the physics imposter
  31856. * set by the physics engine when adding this impostor to the array
  31857. */
  31858. uniqueId: number;
  31859. /**
  31860. * @hidden
  31861. */
  31862. soft: boolean;
  31863. /**
  31864. * @hidden
  31865. */
  31866. segments: number;
  31867. private _joints;
  31868. /**
  31869. * Initializes the physics imposter
  31870. * @param object The physics-enabled object used as the physics imposter
  31871. * @param type The type of the physics imposter
  31872. * @param _options The options for the physics imposter
  31873. * @param _scene The Babylon scene
  31874. */
  31875. constructor(
  31876. /**
  31877. * The physics-enabled object used as the physics imposter
  31878. */
  31879. object: IPhysicsEnabledObject,
  31880. /**
  31881. * The type of the physics imposter
  31882. */
  31883. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31884. /**
  31885. * This function will completly initialize this impostor.
  31886. * It will create a new body - but only if this mesh has no parent.
  31887. * If it has, this impostor will not be used other than to define the impostor
  31888. * of the child mesh.
  31889. * @hidden
  31890. */
  31891. _init(): void;
  31892. private _getPhysicsParent;
  31893. /**
  31894. * Should a new body be generated.
  31895. * @returns boolean specifying if body initialization is required
  31896. */
  31897. isBodyInitRequired(): boolean;
  31898. /**
  31899. * Sets the updated scaling
  31900. * @param updated Specifies if the scaling is updated
  31901. */
  31902. setScalingUpdated(): void;
  31903. /**
  31904. * Force a regeneration of this or the parent's impostor's body.
  31905. * Use under cautious - This will remove all joints already implemented.
  31906. */
  31907. forceUpdate(): void;
  31908. /**
  31909. * Gets the body that holds this impostor. Either its own, or its parent.
  31910. */
  31911. get physicsBody(): any;
  31912. /**
  31913. * Get the parent of the physics imposter
  31914. * @returns Physics imposter or null
  31915. */
  31916. get parent(): Nullable<PhysicsImpostor>;
  31917. /**
  31918. * Sets the parent of the physics imposter
  31919. */
  31920. set parent(value: Nullable<PhysicsImpostor>);
  31921. /**
  31922. * Set the physics body. Used mainly by the physics engine/plugin
  31923. */
  31924. set physicsBody(physicsBody: any);
  31925. /**
  31926. * Resets the update flags
  31927. */
  31928. resetUpdateFlags(): void;
  31929. /**
  31930. * Gets the object extend size
  31931. * @returns the object extend size
  31932. */
  31933. getObjectExtendSize(): Vector3;
  31934. /**
  31935. * Gets the object center
  31936. * @returns The object center
  31937. */
  31938. getObjectCenter(): Vector3;
  31939. /**
  31940. * Get a specific parameter from the options parameters
  31941. * @param paramName The object parameter name
  31942. * @returns The object parameter
  31943. */
  31944. getParam(paramName: string): any;
  31945. /**
  31946. * Sets a specific parameter in the options given to the physics plugin
  31947. * @param paramName The parameter name
  31948. * @param value The value of the parameter
  31949. */
  31950. setParam(paramName: string, value: number): void;
  31951. /**
  31952. * Specifically change the body's mass option. Won't recreate the physics body object
  31953. * @param mass The mass of the physics imposter
  31954. */
  31955. setMass(mass: number): void;
  31956. /**
  31957. * Gets the linear velocity
  31958. * @returns linear velocity or null
  31959. */
  31960. getLinearVelocity(): Nullable<Vector3>;
  31961. /**
  31962. * Sets the linear velocity
  31963. * @param velocity linear velocity or null
  31964. */
  31965. setLinearVelocity(velocity: Nullable<Vector3>): void;
  31966. /**
  31967. * Gets the angular velocity
  31968. * @returns angular velocity or null
  31969. */
  31970. getAngularVelocity(): Nullable<Vector3>;
  31971. /**
  31972. * Sets the angular velocity
  31973. * @param velocity The velocity or null
  31974. */
  31975. setAngularVelocity(velocity: Nullable<Vector3>): void;
  31976. /**
  31977. * Execute a function with the physics plugin native code
  31978. * Provide a function the will have two variables - the world object and the physics body object
  31979. * @param func The function to execute with the physics plugin native code
  31980. */
  31981. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  31982. /**
  31983. * Register a function that will be executed before the physics world is stepping forward
  31984. * @param func The function to execute before the physics world is stepped forward
  31985. */
  31986. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31987. /**
  31988. * Unregister a function that will be executed before the physics world is stepping forward
  31989. * @param func The function to execute before the physics world is stepped forward
  31990. */
  31991. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31992. /**
  31993. * Register a function that will be executed after the physics step
  31994. * @param func The function to execute after physics step
  31995. */
  31996. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  31997. /**
  31998. * Unregisters a function that will be executed after the physics step
  31999. * @param func The function to execute after physics step
  32000. */
  32001. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32002. /**
  32003. * register a function that will be executed when this impostor collides against a different body
  32004. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32005. * @param func Callback that is executed on collision
  32006. */
  32007. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32008. /**
  32009. * Unregisters the physics imposter on contact
  32010. * @param collideAgainst The physics object to collide against
  32011. * @param func Callback to execute on collision
  32012. */
  32013. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32014. private _tmpQuat;
  32015. private _tmpQuat2;
  32016. /**
  32017. * Get the parent rotation
  32018. * @returns The parent rotation
  32019. */
  32020. getParentsRotation(): Quaternion;
  32021. /**
  32022. * this function is executed by the physics engine.
  32023. */
  32024. beforeStep: () => void;
  32025. /**
  32026. * this function is executed by the physics engine
  32027. */
  32028. afterStep: () => void;
  32029. /**
  32030. * Legacy collision detection event support
  32031. */
  32032. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32033. /**
  32034. * event and body object due to cannon's event-based architecture.
  32035. */
  32036. onCollide: (e: {
  32037. body: any;
  32038. point: Nullable<Vector3>;
  32039. }) => void;
  32040. /**
  32041. * Apply a force
  32042. * @param force The force to apply
  32043. * @param contactPoint The contact point for the force
  32044. * @returns The physics imposter
  32045. */
  32046. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32047. /**
  32048. * Apply an impulse
  32049. * @param force The impulse force
  32050. * @param contactPoint The contact point for the impulse force
  32051. * @returns The physics imposter
  32052. */
  32053. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32054. /**
  32055. * A help function to create a joint
  32056. * @param otherImpostor A physics imposter used to create a joint
  32057. * @param jointType The type of joint
  32058. * @param jointData The data for the joint
  32059. * @returns The physics imposter
  32060. */
  32061. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32062. /**
  32063. * Add a joint to this impostor with a different impostor
  32064. * @param otherImpostor A physics imposter used to add a joint
  32065. * @param joint The joint to add
  32066. * @returns The physics imposter
  32067. */
  32068. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32069. /**
  32070. * Add an anchor to a cloth impostor
  32071. * @param otherImpostor rigid impostor to anchor to
  32072. * @param width ratio across width from 0 to 1
  32073. * @param height ratio up height from 0 to 1
  32074. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32075. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32076. * @returns impostor the soft imposter
  32077. */
  32078. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32079. /**
  32080. * Add a hook to a rope impostor
  32081. * @param otherImpostor rigid impostor to anchor to
  32082. * @param length ratio across rope from 0 to 1
  32083. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32084. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32085. * @returns impostor the rope imposter
  32086. */
  32087. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32088. /**
  32089. * Will keep this body still, in a sleep mode.
  32090. * @returns the physics imposter
  32091. */
  32092. sleep(): PhysicsImpostor;
  32093. /**
  32094. * Wake the body up.
  32095. * @returns The physics imposter
  32096. */
  32097. wakeUp(): PhysicsImpostor;
  32098. /**
  32099. * Clones the physics imposter
  32100. * @param newObject The physics imposter clones to this physics-enabled object
  32101. * @returns A nullable physics imposter
  32102. */
  32103. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32104. /**
  32105. * Disposes the physics imposter
  32106. */
  32107. dispose(): void;
  32108. /**
  32109. * Sets the delta position
  32110. * @param position The delta position amount
  32111. */
  32112. setDeltaPosition(position: Vector3): void;
  32113. /**
  32114. * Sets the delta rotation
  32115. * @param rotation The delta rotation amount
  32116. */
  32117. setDeltaRotation(rotation: Quaternion): void;
  32118. /**
  32119. * Gets the box size of the physics imposter and stores the result in the input parameter
  32120. * @param result Stores the box size
  32121. * @returns The physics imposter
  32122. */
  32123. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32124. /**
  32125. * Gets the radius of the physics imposter
  32126. * @returns Radius of the physics imposter
  32127. */
  32128. getRadius(): number;
  32129. /**
  32130. * Sync a bone with this impostor
  32131. * @param bone The bone to sync to the impostor.
  32132. * @param boneMesh The mesh that the bone is influencing.
  32133. * @param jointPivot The pivot of the joint / bone in local space.
  32134. * @param distToJoint Optional distance from the impostor to the joint.
  32135. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32136. */
  32137. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32138. /**
  32139. * Sync impostor to a bone
  32140. * @param bone The bone that the impostor will be synced to.
  32141. * @param boneMesh The mesh that the bone is influencing.
  32142. * @param jointPivot The pivot of the joint / bone in local space.
  32143. * @param distToJoint Optional distance from the impostor to the joint.
  32144. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32145. * @param boneAxis Optional vector3 axis the bone is aligned with
  32146. */
  32147. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32148. /**
  32149. * No-Imposter type
  32150. */
  32151. static NoImpostor: number;
  32152. /**
  32153. * Sphere-Imposter type
  32154. */
  32155. static SphereImpostor: number;
  32156. /**
  32157. * Box-Imposter type
  32158. */
  32159. static BoxImpostor: number;
  32160. /**
  32161. * Plane-Imposter type
  32162. */
  32163. static PlaneImpostor: number;
  32164. /**
  32165. * Mesh-imposter type
  32166. */
  32167. static MeshImpostor: number;
  32168. /**
  32169. * Capsule-Impostor type (Ammo.js plugin only)
  32170. */
  32171. static CapsuleImpostor: number;
  32172. /**
  32173. * Cylinder-Imposter type
  32174. */
  32175. static CylinderImpostor: number;
  32176. /**
  32177. * Particle-Imposter type
  32178. */
  32179. static ParticleImpostor: number;
  32180. /**
  32181. * Heightmap-Imposter type
  32182. */
  32183. static HeightmapImpostor: number;
  32184. /**
  32185. * ConvexHull-Impostor type (Ammo.js plugin only)
  32186. */
  32187. static ConvexHullImpostor: number;
  32188. /**
  32189. * Custom-Imposter type (Ammo.js plugin only)
  32190. */
  32191. static CustomImpostor: number;
  32192. /**
  32193. * Rope-Imposter type
  32194. */
  32195. static RopeImpostor: number;
  32196. /**
  32197. * Cloth-Imposter type
  32198. */
  32199. static ClothImpostor: number;
  32200. /**
  32201. * Softbody-Imposter type
  32202. */
  32203. static SoftbodyImpostor: number;
  32204. }
  32205. }
  32206. declare module BABYLON {
  32207. /**
  32208. * @hidden
  32209. **/
  32210. export class _CreationDataStorage {
  32211. closePath?: boolean;
  32212. closeArray?: boolean;
  32213. idx: number[];
  32214. dashSize: number;
  32215. gapSize: number;
  32216. path3D: Path3D;
  32217. pathArray: Vector3[][];
  32218. arc: number;
  32219. radius: number;
  32220. cap: number;
  32221. tessellation: number;
  32222. }
  32223. /**
  32224. * @hidden
  32225. **/
  32226. class _InstanceDataStorage {
  32227. visibleInstances: any;
  32228. batchCache: _InstancesBatch;
  32229. instancesBufferSize: number;
  32230. instancesBuffer: Nullable<Buffer>;
  32231. instancesData: Float32Array;
  32232. overridenInstanceCount: number;
  32233. isFrozen: boolean;
  32234. previousBatch: Nullable<_InstancesBatch>;
  32235. hardwareInstancedRendering: boolean;
  32236. sideOrientation: number;
  32237. manualUpdate: boolean;
  32238. previousRenderId: number;
  32239. }
  32240. /**
  32241. * @hidden
  32242. **/
  32243. export class _InstancesBatch {
  32244. mustReturn: boolean;
  32245. visibleInstances: Nullable<InstancedMesh[]>[];
  32246. renderSelf: boolean[];
  32247. hardwareInstancedRendering: boolean[];
  32248. }
  32249. /**
  32250. * @hidden
  32251. **/
  32252. class _ThinInstanceDataStorage {
  32253. instancesCount: number;
  32254. matrixBuffer: Nullable<Buffer>;
  32255. matrixBufferSize: number;
  32256. matrixData: Nullable<Float32Array>;
  32257. boundingVectors: Array<Vector3>;
  32258. worldMatrices: Nullable<Matrix[]>;
  32259. }
  32260. /**
  32261. * Class used to represent renderable models
  32262. */
  32263. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32264. /**
  32265. * Mesh side orientation : usually the external or front surface
  32266. */
  32267. static readonly FRONTSIDE: number;
  32268. /**
  32269. * Mesh side orientation : usually the internal or back surface
  32270. */
  32271. static readonly BACKSIDE: number;
  32272. /**
  32273. * Mesh side orientation : both internal and external or front and back surfaces
  32274. */
  32275. static readonly DOUBLESIDE: number;
  32276. /**
  32277. * Mesh side orientation : by default, `FRONTSIDE`
  32278. */
  32279. static readonly DEFAULTSIDE: number;
  32280. /**
  32281. * Mesh cap setting : no cap
  32282. */
  32283. static readonly NO_CAP: number;
  32284. /**
  32285. * Mesh cap setting : one cap at the beginning of the mesh
  32286. */
  32287. static readonly CAP_START: number;
  32288. /**
  32289. * Mesh cap setting : one cap at the end of the mesh
  32290. */
  32291. static readonly CAP_END: number;
  32292. /**
  32293. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32294. */
  32295. static readonly CAP_ALL: number;
  32296. /**
  32297. * Mesh pattern setting : no flip or rotate
  32298. */
  32299. static readonly NO_FLIP: number;
  32300. /**
  32301. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32302. */
  32303. static readonly FLIP_TILE: number;
  32304. /**
  32305. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32306. */
  32307. static readonly ROTATE_TILE: number;
  32308. /**
  32309. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32310. */
  32311. static readonly FLIP_ROW: number;
  32312. /**
  32313. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32314. */
  32315. static readonly ROTATE_ROW: number;
  32316. /**
  32317. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32318. */
  32319. static readonly FLIP_N_ROTATE_TILE: number;
  32320. /**
  32321. * Mesh pattern setting : rotate pattern and rotate
  32322. */
  32323. static readonly FLIP_N_ROTATE_ROW: number;
  32324. /**
  32325. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32326. */
  32327. static readonly CENTER: number;
  32328. /**
  32329. * Mesh tile positioning : part tiles on left
  32330. */
  32331. static readonly LEFT: number;
  32332. /**
  32333. * Mesh tile positioning : part tiles on right
  32334. */
  32335. static readonly RIGHT: number;
  32336. /**
  32337. * Mesh tile positioning : part tiles on top
  32338. */
  32339. static readonly TOP: number;
  32340. /**
  32341. * Mesh tile positioning : part tiles on bottom
  32342. */
  32343. static readonly BOTTOM: number;
  32344. /**
  32345. * Gets the default side orientation.
  32346. * @param orientation the orientation to value to attempt to get
  32347. * @returns the default orientation
  32348. * @hidden
  32349. */
  32350. static _GetDefaultSideOrientation(orientation?: number): number;
  32351. private _internalMeshDataInfo;
  32352. get computeBonesUsingShaders(): boolean;
  32353. set computeBonesUsingShaders(value: boolean);
  32354. /**
  32355. * An event triggered before rendering the mesh
  32356. */
  32357. get onBeforeRenderObservable(): Observable<Mesh>;
  32358. /**
  32359. * An event triggered before binding the mesh
  32360. */
  32361. get onBeforeBindObservable(): Observable<Mesh>;
  32362. /**
  32363. * An event triggered after rendering the mesh
  32364. */
  32365. get onAfterRenderObservable(): Observable<Mesh>;
  32366. /**
  32367. * An event triggered before drawing the mesh
  32368. */
  32369. get onBeforeDrawObservable(): Observable<Mesh>;
  32370. private _onBeforeDrawObserver;
  32371. /**
  32372. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32373. */
  32374. set onBeforeDraw(callback: () => void);
  32375. get hasInstances(): boolean;
  32376. get hasThinInstances(): boolean;
  32377. /**
  32378. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32379. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32380. */
  32381. delayLoadState: number;
  32382. /**
  32383. * Gets the list of instances created from this mesh
  32384. * it is not supposed to be modified manually.
  32385. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32386. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32387. */
  32388. instances: InstancedMesh[];
  32389. /**
  32390. * Gets the file containing delay loading data for this mesh
  32391. */
  32392. delayLoadingFile: string;
  32393. /** @hidden */
  32394. _binaryInfo: any;
  32395. /**
  32396. * User defined function used to change how LOD level selection is done
  32397. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32398. */
  32399. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32400. /**
  32401. * Gets or sets the morph target manager
  32402. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32403. */
  32404. get morphTargetManager(): Nullable<MorphTargetManager>;
  32405. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32406. /** @hidden */
  32407. _creationDataStorage: Nullable<_CreationDataStorage>;
  32408. /** @hidden */
  32409. _geometry: Nullable<Geometry>;
  32410. /** @hidden */
  32411. _delayInfo: Array<string>;
  32412. /** @hidden */
  32413. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32414. /** @hidden */
  32415. _instanceDataStorage: _InstanceDataStorage;
  32416. /** @hidden */
  32417. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32418. private _effectiveMaterial;
  32419. /** @hidden */
  32420. _shouldGenerateFlatShading: boolean;
  32421. /** @hidden */
  32422. _originalBuilderSideOrientation: number;
  32423. /**
  32424. * Use this property to change the original side orientation defined at construction time
  32425. */
  32426. overrideMaterialSideOrientation: Nullable<number>;
  32427. /**
  32428. * Gets the source mesh (the one used to clone this one from)
  32429. */
  32430. get source(): Nullable<Mesh>;
  32431. /**
  32432. * Gets the list of clones of this mesh
  32433. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32434. * Note that useClonedMeshMap=true is the default setting
  32435. */
  32436. get cloneMeshMap(): Nullable<{
  32437. [id: string]: Mesh | undefined;
  32438. }>;
  32439. /**
  32440. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32441. */
  32442. get isUnIndexed(): boolean;
  32443. set isUnIndexed(value: boolean);
  32444. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32445. get worldMatrixInstancedBuffer(): Float32Array;
  32446. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32447. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32448. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32449. /**
  32450. * @constructor
  32451. * @param name The value used by scene.getMeshByName() to do a lookup.
  32452. * @param scene The scene to add this mesh to.
  32453. * @param parent The parent of this mesh, if it has one
  32454. * @param source An optional Mesh from which geometry is shared, cloned.
  32455. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32456. * When false, achieved by calling a clone(), also passing False.
  32457. * This will make creation of children, recursive.
  32458. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32459. */
  32460. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32461. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32462. doNotInstantiate: boolean;
  32463. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32464. /**
  32465. * Gets the class name
  32466. * @returns the string "Mesh".
  32467. */
  32468. getClassName(): string;
  32469. /** @hidden */
  32470. get _isMesh(): boolean;
  32471. /**
  32472. * Returns a description of this mesh
  32473. * @param fullDetails define if full details about this mesh must be used
  32474. * @returns a descriptive string representing this mesh
  32475. */
  32476. toString(fullDetails?: boolean): string;
  32477. /** @hidden */
  32478. _unBindEffect(): void;
  32479. /**
  32480. * Gets a boolean indicating if this mesh has LOD
  32481. */
  32482. get hasLODLevels(): boolean;
  32483. /**
  32484. * Gets the list of MeshLODLevel associated with the current mesh
  32485. * @returns an array of MeshLODLevel
  32486. */
  32487. getLODLevels(): MeshLODLevel[];
  32488. private _sortLODLevels;
  32489. /**
  32490. * Add a mesh as LOD level triggered at the given distance.
  32491. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32492. * @param distance The distance from the center of the object to show this level
  32493. * @param mesh The mesh to be added as LOD level (can be null)
  32494. * @return This mesh (for chaining)
  32495. */
  32496. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32497. /**
  32498. * Returns the LOD level mesh at the passed distance or null if not found.
  32499. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32500. * @param distance The distance from the center of the object to show this level
  32501. * @returns a Mesh or `null`
  32502. */
  32503. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32504. /**
  32505. * Remove a mesh from the LOD array
  32506. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32507. * @param mesh defines the mesh to be removed
  32508. * @return This mesh (for chaining)
  32509. */
  32510. removeLODLevel(mesh: Mesh): Mesh;
  32511. /**
  32512. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32513. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32514. * @param camera defines the camera to use to compute distance
  32515. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32516. * @return This mesh (for chaining)
  32517. */
  32518. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32519. /**
  32520. * Gets the mesh internal Geometry object
  32521. */
  32522. get geometry(): Nullable<Geometry>;
  32523. /**
  32524. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32525. * @returns the total number of vertices
  32526. */
  32527. getTotalVertices(): number;
  32528. /**
  32529. * Returns the content of an associated vertex buffer
  32530. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32531. * - VertexBuffer.PositionKind
  32532. * - VertexBuffer.UVKind
  32533. * - VertexBuffer.UV2Kind
  32534. * - VertexBuffer.UV3Kind
  32535. * - VertexBuffer.UV4Kind
  32536. * - VertexBuffer.UV5Kind
  32537. * - VertexBuffer.UV6Kind
  32538. * - VertexBuffer.ColorKind
  32539. * - VertexBuffer.MatricesIndicesKind
  32540. * - VertexBuffer.MatricesIndicesExtraKind
  32541. * - VertexBuffer.MatricesWeightsKind
  32542. * - VertexBuffer.MatricesWeightsExtraKind
  32543. * @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
  32544. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32545. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32546. */
  32547. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32548. /**
  32549. * Returns the mesh VertexBuffer object from the requested `kind`
  32550. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32551. * - VertexBuffer.PositionKind
  32552. * - VertexBuffer.NormalKind
  32553. * - VertexBuffer.UVKind
  32554. * - VertexBuffer.UV2Kind
  32555. * - VertexBuffer.UV3Kind
  32556. * - VertexBuffer.UV4Kind
  32557. * - VertexBuffer.UV5Kind
  32558. * - VertexBuffer.UV6Kind
  32559. * - VertexBuffer.ColorKind
  32560. * - VertexBuffer.MatricesIndicesKind
  32561. * - VertexBuffer.MatricesIndicesExtraKind
  32562. * - VertexBuffer.MatricesWeightsKind
  32563. * - VertexBuffer.MatricesWeightsExtraKind
  32564. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32565. */
  32566. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32567. /**
  32568. * Tests if a specific vertex buffer is associated with this mesh
  32569. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32570. * - VertexBuffer.PositionKind
  32571. * - VertexBuffer.NormalKind
  32572. * - VertexBuffer.UVKind
  32573. * - VertexBuffer.UV2Kind
  32574. * - VertexBuffer.UV3Kind
  32575. * - VertexBuffer.UV4Kind
  32576. * - VertexBuffer.UV5Kind
  32577. * - VertexBuffer.UV6Kind
  32578. * - VertexBuffer.ColorKind
  32579. * - VertexBuffer.MatricesIndicesKind
  32580. * - VertexBuffer.MatricesIndicesExtraKind
  32581. * - VertexBuffer.MatricesWeightsKind
  32582. * - VertexBuffer.MatricesWeightsExtraKind
  32583. * @returns a boolean
  32584. */
  32585. isVerticesDataPresent(kind: string): boolean;
  32586. /**
  32587. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32588. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32589. * - VertexBuffer.PositionKind
  32590. * - VertexBuffer.UVKind
  32591. * - VertexBuffer.UV2Kind
  32592. * - VertexBuffer.UV3Kind
  32593. * - VertexBuffer.UV4Kind
  32594. * - VertexBuffer.UV5Kind
  32595. * - VertexBuffer.UV6Kind
  32596. * - VertexBuffer.ColorKind
  32597. * - VertexBuffer.MatricesIndicesKind
  32598. * - VertexBuffer.MatricesIndicesExtraKind
  32599. * - VertexBuffer.MatricesWeightsKind
  32600. * - VertexBuffer.MatricesWeightsExtraKind
  32601. * @returns a boolean
  32602. */
  32603. isVertexBufferUpdatable(kind: string): boolean;
  32604. /**
  32605. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32606. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32607. * - VertexBuffer.PositionKind
  32608. * - VertexBuffer.NormalKind
  32609. * - VertexBuffer.UVKind
  32610. * - VertexBuffer.UV2Kind
  32611. * - VertexBuffer.UV3Kind
  32612. * - VertexBuffer.UV4Kind
  32613. * - VertexBuffer.UV5Kind
  32614. * - VertexBuffer.UV6Kind
  32615. * - VertexBuffer.ColorKind
  32616. * - VertexBuffer.MatricesIndicesKind
  32617. * - VertexBuffer.MatricesIndicesExtraKind
  32618. * - VertexBuffer.MatricesWeightsKind
  32619. * - VertexBuffer.MatricesWeightsExtraKind
  32620. * @returns an array of strings
  32621. */
  32622. getVerticesDataKinds(): string[];
  32623. /**
  32624. * Returns a positive integer : the total number of indices in this mesh geometry.
  32625. * @returns the numner of indices or zero if the mesh has no geometry.
  32626. */
  32627. getTotalIndices(): number;
  32628. /**
  32629. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32630. * @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.
  32631. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32632. * @returns the indices array or an empty array if the mesh has no geometry
  32633. */
  32634. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32635. get isBlocked(): boolean;
  32636. /**
  32637. * Determine if the current mesh is ready to be rendered
  32638. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32639. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32640. * @returns true if all associated assets are ready (material, textures, shaders)
  32641. */
  32642. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32643. /**
  32644. * 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.
  32645. */
  32646. get areNormalsFrozen(): boolean;
  32647. /**
  32648. * 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.
  32649. * @returns the current mesh
  32650. */
  32651. freezeNormals(): Mesh;
  32652. /**
  32653. * 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
  32654. * @returns the current mesh
  32655. */
  32656. unfreezeNormals(): Mesh;
  32657. /**
  32658. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32659. */
  32660. set overridenInstanceCount(count: number);
  32661. /** @hidden */
  32662. _preActivate(): Mesh;
  32663. /** @hidden */
  32664. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32665. /** @hidden */
  32666. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32667. protected _afterComputeWorldMatrix(): void;
  32668. /** @hidden */
  32669. _postActivate(): void;
  32670. /**
  32671. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32672. * This means the mesh underlying bounding box and sphere are recomputed.
  32673. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32674. * @returns the current mesh
  32675. */
  32676. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32677. /** @hidden */
  32678. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32679. /**
  32680. * This function will subdivide the mesh into multiple submeshes
  32681. * @param count defines the expected number of submeshes
  32682. */
  32683. subdivide(count: number): void;
  32684. /**
  32685. * Copy a FloatArray into a specific associated vertex buffer
  32686. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32687. * - VertexBuffer.PositionKind
  32688. * - VertexBuffer.UVKind
  32689. * - VertexBuffer.UV2Kind
  32690. * - VertexBuffer.UV3Kind
  32691. * - VertexBuffer.UV4Kind
  32692. * - VertexBuffer.UV5Kind
  32693. * - VertexBuffer.UV6Kind
  32694. * - VertexBuffer.ColorKind
  32695. * - VertexBuffer.MatricesIndicesKind
  32696. * - VertexBuffer.MatricesIndicesExtraKind
  32697. * - VertexBuffer.MatricesWeightsKind
  32698. * - VertexBuffer.MatricesWeightsExtraKind
  32699. * @param data defines the data source
  32700. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32701. * @param stride defines the data stride size (can be null)
  32702. * @returns the current mesh
  32703. */
  32704. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32705. /**
  32706. * Delete a vertex buffer associated with this mesh
  32707. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32708. * - VertexBuffer.PositionKind
  32709. * - VertexBuffer.UVKind
  32710. * - VertexBuffer.UV2Kind
  32711. * - VertexBuffer.UV3Kind
  32712. * - VertexBuffer.UV4Kind
  32713. * - VertexBuffer.UV5Kind
  32714. * - VertexBuffer.UV6Kind
  32715. * - VertexBuffer.ColorKind
  32716. * - VertexBuffer.MatricesIndicesKind
  32717. * - VertexBuffer.MatricesIndicesExtraKind
  32718. * - VertexBuffer.MatricesWeightsKind
  32719. * - VertexBuffer.MatricesWeightsExtraKind
  32720. */
  32721. removeVerticesData(kind: string): void;
  32722. /**
  32723. * Flags an associated vertex buffer as updatable
  32724. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32725. * - VertexBuffer.PositionKind
  32726. * - VertexBuffer.UVKind
  32727. * - VertexBuffer.UV2Kind
  32728. * - VertexBuffer.UV3Kind
  32729. * - VertexBuffer.UV4Kind
  32730. * - VertexBuffer.UV5Kind
  32731. * - VertexBuffer.UV6Kind
  32732. * - VertexBuffer.ColorKind
  32733. * - VertexBuffer.MatricesIndicesKind
  32734. * - VertexBuffer.MatricesIndicesExtraKind
  32735. * - VertexBuffer.MatricesWeightsKind
  32736. * - VertexBuffer.MatricesWeightsExtraKind
  32737. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32738. */
  32739. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32740. /**
  32741. * Sets the mesh global Vertex Buffer
  32742. * @param buffer defines the buffer to use
  32743. * @returns the current mesh
  32744. */
  32745. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32746. /**
  32747. * Update a specific associated vertex buffer
  32748. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32749. * - VertexBuffer.PositionKind
  32750. * - VertexBuffer.UVKind
  32751. * - VertexBuffer.UV2Kind
  32752. * - VertexBuffer.UV3Kind
  32753. * - VertexBuffer.UV4Kind
  32754. * - VertexBuffer.UV5Kind
  32755. * - VertexBuffer.UV6Kind
  32756. * - VertexBuffer.ColorKind
  32757. * - VertexBuffer.MatricesIndicesKind
  32758. * - VertexBuffer.MatricesIndicesExtraKind
  32759. * - VertexBuffer.MatricesWeightsKind
  32760. * - VertexBuffer.MatricesWeightsExtraKind
  32761. * @param data defines the data source
  32762. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32763. * @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)
  32764. * @returns the current mesh
  32765. */
  32766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32767. /**
  32768. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32769. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32770. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32771. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32772. * @returns the current mesh
  32773. */
  32774. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32775. /**
  32776. * Creates a un-shared specific occurence of the geometry for the mesh.
  32777. * @returns the current mesh
  32778. */
  32779. makeGeometryUnique(): Mesh;
  32780. /**
  32781. * Set the index buffer of this mesh
  32782. * @param indices defines the source data
  32783. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32784. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32785. * @returns the current mesh
  32786. */
  32787. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32788. /**
  32789. * Update the current index buffer
  32790. * @param indices defines the source data
  32791. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32792. * @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)
  32793. * @returns the current mesh
  32794. */
  32795. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32796. /**
  32797. * Invert the geometry to move from a right handed system to a left handed one.
  32798. * @returns the current mesh
  32799. */
  32800. toLeftHanded(): Mesh;
  32801. /** @hidden */
  32802. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32803. /** @hidden */
  32804. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32805. /**
  32806. * Registers for this mesh a javascript function called just before the rendering process
  32807. * @param func defines the function to call before rendering this mesh
  32808. * @returns the current mesh
  32809. */
  32810. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32811. /**
  32812. * Disposes a previously registered javascript function called before the rendering
  32813. * @param func defines the function to remove
  32814. * @returns the current mesh
  32815. */
  32816. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32817. /**
  32818. * Registers for this mesh a javascript function called just after the rendering is complete
  32819. * @param func defines the function to call after rendering this mesh
  32820. * @returns the current mesh
  32821. */
  32822. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32823. /**
  32824. * Disposes a previously registered javascript function called after the rendering.
  32825. * @param func defines the function to remove
  32826. * @returns the current mesh
  32827. */
  32828. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32829. /** @hidden */
  32830. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32831. /** @hidden */
  32832. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32833. /** @hidden */
  32834. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32835. /** @hidden */
  32836. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32837. /** @hidden */
  32838. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32839. /** @hidden */
  32840. _rebuild(): void;
  32841. /** @hidden */
  32842. _freeze(): void;
  32843. /** @hidden */
  32844. _unFreeze(): void;
  32845. /**
  32846. * 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
  32847. * @param subMesh defines the subMesh to render
  32848. * @param enableAlphaMode defines if alpha mode can be changed
  32849. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32850. * @returns the current mesh
  32851. */
  32852. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32853. private _onBeforeDraw;
  32854. /**
  32855. * Renormalize the mesh and patch it up if there are no weights
  32856. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32857. * However in the case of zero weights then we set just a single influence to 1.
  32858. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32859. */
  32860. cleanMatrixWeights(): void;
  32861. private normalizeSkinFourWeights;
  32862. private normalizeSkinWeightsAndExtra;
  32863. /**
  32864. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32865. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32866. * the user know there was an issue with importing the mesh
  32867. * @returns a validation object with skinned, valid and report string
  32868. */
  32869. validateSkinning(): {
  32870. skinned: boolean;
  32871. valid: boolean;
  32872. report: string;
  32873. };
  32874. /** @hidden */
  32875. _checkDelayState(): Mesh;
  32876. private _queueLoad;
  32877. /**
  32878. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32879. * A mesh is in the frustum if its bounding box intersects the frustum
  32880. * @param frustumPlanes defines the frustum to test
  32881. * @returns true if the mesh is in the frustum planes
  32882. */
  32883. isInFrustum(frustumPlanes: Plane[]): boolean;
  32884. /**
  32885. * Sets the mesh material by the material or multiMaterial `id` property
  32886. * @param id is a string identifying the material or the multiMaterial
  32887. * @returns the current mesh
  32888. */
  32889. setMaterialByID(id: string): Mesh;
  32890. /**
  32891. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32892. * @returns an array of IAnimatable
  32893. */
  32894. getAnimatables(): IAnimatable[];
  32895. /**
  32896. * Modifies the mesh geometry according to the passed transformation matrix.
  32897. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  32898. * The mesh normals are modified using the same transformation.
  32899. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32900. * @param transform defines the transform matrix to use
  32901. * @see https://doc.babylonjs.com/resources/baking_transformations
  32902. * @returns the current mesh
  32903. */
  32904. bakeTransformIntoVertices(transform: Matrix): Mesh;
  32905. /**
  32906. * Modifies the mesh geometry according to its own current World Matrix.
  32907. * The mesh World Matrix is then reset.
  32908. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  32909. * Note that, under the hood, this method sets a new VertexBuffer each call.
  32910. * @see https://doc.babylonjs.com/resources/baking_transformations
  32911. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  32912. * @returns the current mesh
  32913. */
  32914. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  32915. /** @hidden */
  32916. get _positions(): Nullable<Vector3[]>;
  32917. /** @hidden */
  32918. _resetPointsArrayCache(): Mesh;
  32919. /** @hidden */
  32920. _generatePointsArray(): boolean;
  32921. /**
  32922. * Returns a new Mesh object generated from the current mesh properties.
  32923. * This method must not get confused with createInstance()
  32924. * @param name is a string, the name given to the new mesh
  32925. * @param newParent can be any Node object (default `null`)
  32926. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  32927. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  32928. * @returns a new mesh
  32929. */
  32930. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  32931. /**
  32932. * Releases resources associated with this mesh.
  32933. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32934. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32935. */
  32936. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32937. /** @hidden */
  32938. _disposeInstanceSpecificData(): void;
  32939. /** @hidden */
  32940. _disposeThinInstanceSpecificData(): void;
  32941. /**
  32942. * Modifies the mesh geometry according to a displacement map.
  32943. * 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.
  32944. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32945. * @param url is a string, the URL from the image file is to be downloaded.
  32946. * @param minHeight is the lower limit of the displacement.
  32947. * @param maxHeight is the upper limit of the displacement.
  32948. * @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.
  32949. * @param uvOffset is an optional vector2 used to offset UV.
  32950. * @param uvScale is an optional vector2 used to scale UV.
  32951. * @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.
  32952. * @returns the Mesh.
  32953. */
  32954. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32955. /**
  32956. * Modifies the mesh geometry according to a displacementMap buffer.
  32957. * 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.
  32958. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  32959. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  32960. * @param heightMapWidth is the width of the buffer image.
  32961. * @param heightMapHeight is the height of the buffer image.
  32962. * @param minHeight is the lower limit of the displacement.
  32963. * @param maxHeight is the upper limit of the displacement.
  32964. * @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.
  32965. * @param uvOffset is an optional vector2 used to offset UV.
  32966. * @param uvScale is an optional vector2 used to scale UV.
  32967. * @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.
  32968. * @returns the Mesh.
  32969. */
  32970. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  32971. /**
  32972. * Modify the mesh to get a flat shading rendering.
  32973. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  32974. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  32975. * @returns current mesh
  32976. */
  32977. convertToFlatShadedMesh(): Mesh;
  32978. /**
  32979. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  32980. * In other words, more vertices, no more indices and a single bigger VBO.
  32981. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  32982. * @returns current mesh
  32983. */
  32984. convertToUnIndexedMesh(): Mesh;
  32985. /**
  32986. * Inverses facet orientations.
  32987. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32988. * @param flipNormals will also inverts the normals
  32989. * @returns current mesh
  32990. */
  32991. flipFaces(flipNormals?: boolean): Mesh;
  32992. /**
  32993. * Increase the number of facets and hence vertices in a mesh
  32994. * Vertex normals are interpolated from existing vertex normals
  32995. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  32996. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  32997. */
  32998. increaseVertices(numberPerEdge: number): void;
  32999. /**
  33000. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33001. * This will undo any application of covertToFlatShadedMesh
  33002. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33003. */
  33004. forceSharedVertices(): void;
  33005. /** @hidden */
  33006. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33007. /** @hidden */
  33008. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33009. /**
  33010. * Creates a new InstancedMesh object from the mesh model.
  33011. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33012. * @param name defines the name of the new instance
  33013. * @returns a new InstancedMesh
  33014. */
  33015. createInstance(name: string): InstancedMesh;
  33016. /**
  33017. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33018. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33019. * @returns the current mesh
  33020. */
  33021. synchronizeInstances(): Mesh;
  33022. /**
  33023. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33024. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33025. * This should be used together with the simplification to avoid disappearing triangles.
  33026. * @param successCallback an optional success callback to be called after the optimization finished.
  33027. * @returns the current mesh
  33028. */
  33029. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33030. /**
  33031. * Serialize current mesh
  33032. * @param serializationObject defines the object which will receive the serialization data
  33033. */
  33034. serialize(serializationObject: any): void;
  33035. /** @hidden */
  33036. _syncGeometryWithMorphTargetManager(): void;
  33037. /** @hidden */
  33038. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33039. /**
  33040. * Returns a new Mesh object parsed from the source provided.
  33041. * @param parsedMesh is the source
  33042. * @param scene defines the hosting scene
  33043. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33044. * @returns a new Mesh
  33045. */
  33046. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33047. /**
  33048. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33049. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33050. * @param name defines the name of the mesh to create
  33051. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33052. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33053. * @param closePath creates a seam between the first and the last points of each path of the path array
  33054. * @param offset is taken in account only if the `pathArray` is containing a single path
  33055. * @param scene defines the hosting scene
  33056. * @param updatable defines if the mesh must be flagged as updatable
  33057. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33058. * @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)
  33059. * @returns a new Mesh
  33060. */
  33061. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33062. /**
  33063. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33064. * @param name defines the name of the mesh to create
  33065. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33066. * @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
  33067. * @param scene defines the hosting scene
  33068. * @param updatable defines if the mesh must be flagged as updatable
  33069. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33070. * @returns a new Mesh
  33071. */
  33072. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33073. /**
  33074. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33075. * @param name defines the name of the mesh to create
  33076. * @param size sets the size (float) of each box side (default 1)
  33077. * @param scene defines the hosting scene
  33078. * @param updatable defines if the mesh must be flagged as updatable
  33079. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33080. * @returns a new Mesh
  33081. */
  33082. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33083. /**
  33084. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33085. * @param name defines the name of the mesh to create
  33086. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33087. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33088. * @param scene defines the hosting scene
  33089. * @param updatable defines if the mesh must be flagged as updatable
  33090. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33091. * @returns a new Mesh
  33092. */
  33093. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33094. /**
  33095. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33096. * @param name defines the name of the mesh to create
  33097. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33098. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33099. * @param scene defines the hosting scene
  33100. * @returns a new Mesh
  33101. */
  33102. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33103. /**
  33104. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33105. * @param name defines the name of the mesh to create
  33106. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33107. * @param diameterTop set the top cap diameter (floats, default 1)
  33108. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33109. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33110. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33111. * @param scene defines the hosting scene
  33112. * @param updatable defines if the mesh must be flagged as updatable
  33113. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33114. * @returns a new Mesh
  33115. */
  33116. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33117. /**
  33118. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33119. * @param name defines the name of the mesh to create
  33120. * @param diameter sets the diameter size (float) of the torus (default 1)
  33121. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33122. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33123. * @param scene defines the hosting scene
  33124. * @param updatable defines if the mesh must be flagged as updatable
  33125. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33126. * @returns a new Mesh
  33127. */
  33128. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33129. /**
  33130. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33131. * @param name defines the name of the mesh to create
  33132. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33133. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33134. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33135. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33136. * @param p the number of windings on X axis (positive integers, default 2)
  33137. * @param q the number of windings on Y axis (positive integers, default 3)
  33138. * @param scene defines the hosting scene
  33139. * @param updatable defines if the mesh must be flagged as updatable
  33140. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33141. * @returns a new Mesh
  33142. */
  33143. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33144. /**
  33145. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33146. * @param name defines the name of the mesh to create
  33147. * @param points is an array successive Vector3
  33148. * @param scene defines the hosting scene
  33149. * @param updatable defines if the mesh must be flagged as updatable
  33150. * @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).
  33151. * @returns a new Mesh
  33152. */
  33153. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33154. /**
  33155. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33156. * @param name defines the name of the mesh to create
  33157. * @param points is an array successive Vector3
  33158. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33159. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33160. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33161. * @param scene defines the hosting scene
  33162. * @param updatable defines if the mesh must be flagged as updatable
  33163. * @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)
  33164. * @returns a new Mesh
  33165. */
  33166. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33167. /**
  33168. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33169. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33170. * 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.
  33171. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33172. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33173. * Remember you can only change the shape positions, not their number when updating a polygon.
  33174. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33175. * @param name defines the name of the mesh to create
  33176. * @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
  33177. * @param scene defines the hosting scene
  33178. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33179. * @param updatable defines if the mesh must be flagged as updatable
  33180. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33181. * @param earcutInjection can be used to inject your own earcut reference
  33182. * @returns a new Mesh
  33183. */
  33184. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33185. /**
  33186. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33188. * @param name defines the name of the mesh to create
  33189. * @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
  33190. * @param depth defines the height of extrusion
  33191. * @param scene defines the hosting scene
  33192. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33193. * @param updatable defines if the mesh must be flagged as updatable
  33194. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33195. * @param earcutInjection can be used to inject your own earcut reference
  33196. * @returns a new Mesh
  33197. */
  33198. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33199. /**
  33200. * Creates an extruded shape mesh.
  33201. * 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
  33202. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33203. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33204. * @param name defines the name of the mesh to create
  33205. * @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
  33206. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33207. * @param scale is the value to scale the shape
  33208. * @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
  33209. * @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
  33210. * @param scene defines the hosting scene
  33211. * @param updatable defines if the mesh must be flagged as updatable
  33212. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33213. * @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)
  33214. * @returns a new Mesh
  33215. */
  33216. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33217. /**
  33218. * Creates an custom extruded shape mesh.
  33219. * The custom extrusion is a parametric shape.
  33220. * It has no predefined shape. Its final shape will depend on the input parameters.
  33221. * Please consider using the same method from the MeshBuilder class instead
  33222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33223. * @param name defines the name of the mesh to create
  33224. * @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
  33225. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33226. * @param scaleFunction is a custom Javascript function called on each path point
  33227. * @param rotationFunction is a custom Javascript function called on each path point
  33228. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33229. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33230. * @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
  33231. * @param scene defines the hosting scene
  33232. * @param updatable defines if the mesh must be flagged as updatable
  33233. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33234. * @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)
  33235. * @returns a new Mesh
  33236. */
  33237. 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;
  33238. /**
  33239. * Creates lathe mesh.
  33240. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33241. * Please consider using the same method from the MeshBuilder class instead
  33242. * @param name defines the name of the mesh to create
  33243. * @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
  33244. * @param radius is the radius value of the lathe
  33245. * @param tessellation is the side number of the lathe.
  33246. * @param scene defines the hosting scene
  33247. * @param updatable defines if the mesh must be flagged as updatable
  33248. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33249. * @returns a new Mesh
  33250. */
  33251. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33252. /**
  33253. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33254. * @param name defines the name of the mesh to create
  33255. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33256. * @param scene defines the hosting scene
  33257. * @param updatable defines if the mesh must be flagged as updatable
  33258. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33259. * @returns a new Mesh
  33260. */
  33261. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33262. /**
  33263. * Creates a ground mesh.
  33264. * Please consider using the same method from the MeshBuilder class instead
  33265. * @param name defines the name of the mesh to create
  33266. * @param width set the width of the ground
  33267. * @param height set the height of the ground
  33268. * @param subdivisions sets the number of subdivisions per side
  33269. * @param scene defines the hosting scene
  33270. * @param updatable defines if the mesh must be flagged as updatable
  33271. * @returns a new Mesh
  33272. */
  33273. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33274. /**
  33275. * Creates a tiled ground mesh.
  33276. * Please consider using the same method from the MeshBuilder class instead
  33277. * @param name defines the name of the mesh to create
  33278. * @param xmin set the ground minimum X coordinate
  33279. * @param zmin set the ground minimum Y coordinate
  33280. * @param xmax set the ground maximum X coordinate
  33281. * @param zmax set the ground maximum Z coordinate
  33282. * @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
  33283. * @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
  33284. * @param scene defines the hosting scene
  33285. * @param updatable defines if the mesh must be flagged as updatable
  33286. * @returns a new Mesh
  33287. */
  33288. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33289. w: number;
  33290. h: number;
  33291. }, precision: {
  33292. w: number;
  33293. h: number;
  33294. }, scene: Scene, updatable?: boolean): Mesh;
  33295. /**
  33296. * Creates a ground mesh from a height map.
  33297. * Please consider using the same method from the MeshBuilder class instead
  33298. * @see https://doc.babylonjs.com/babylon101/height_map
  33299. * @param name defines the name of the mesh to create
  33300. * @param url sets the URL of the height map image resource
  33301. * @param width set the ground width size
  33302. * @param height set the ground height size
  33303. * @param subdivisions sets the number of subdivision per side
  33304. * @param minHeight is the minimum altitude on the ground
  33305. * @param maxHeight is the maximum altitude on the ground
  33306. * @param scene defines the hosting scene
  33307. * @param updatable defines if the mesh must be flagged as updatable
  33308. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33309. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33310. * @returns a new Mesh
  33311. */
  33312. 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;
  33313. /**
  33314. * Creates a tube mesh.
  33315. * The tube is a parametric shape.
  33316. * It has no predefined shape. Its final shape will depend on the input parameters.
  33317. * Please consider using the same method from the MeshBuilder class instead
  33318. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33319. * @param name defines the name of the mesh to create
  33320. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33321. * @param radius sets the tube radius size
  33322. * @param tessellation is the number of sides on the tubular surface
  33323. * @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
  33324. * @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
  33325. * @param scene defines the hosting scene
  33326. * @param updatable defines if the mesh must be flagged as updatable
  33327. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33328. * @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)
  33329. * @returns a new Mesh
  33330. */
  33331. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33332. (i: number, distance: number): number;
  33333. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33334. /**
  33335. * Creates a polyhedron mesh.
  33336. * Please consider using the same method from the MeshBuilder class instead.
  33337. * * 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
  33338. * * The parameter `size` (positive float, default 1) sets the polygon size
  33339. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33340. * * 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`
  33341. * * 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
  33342. * * 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)`)
  33343. * * 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
  33344. * * 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
  33345. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33346. * * 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
  33347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33348. * @param name defines the name of the mesh to create
  33349. * @param options defines the options used to create the mesh
  33350. * @param scene defines the hosting scene
  33351. * @returns a new Mesh
  33352. */
  33353. static CreatePolyhedron(name: string, options: {
  33354. type?: number;
  33355. size?: number;
  33356. sizeX?: number;
  33357. sizeY?: number;
  33358. sizeZ?: number;
  33359. custom?: any;
  33360. faceUV?: Vector4[];
  33361. faceColors?: Color4[];
  33362. updatable?: boolean;
  33363. sideOrientation?: number;
  33364. }, scene: Scene): Mesh;
  33365. /**
  33366. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33367. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33368. * * 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`)
  33369. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33370. * * 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
  33371. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33372. * * 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
  33373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33374. * @param name defines the name of the mesh
  33375. * @param options defines the options used to create the mesh
  33376. * @param scene defines the hosting scene
  33377. * @returns a new Mesh
  33378. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33379. */
  33380. static CreateIcoSphere(name: string, options: {
  33381. radius?: number;
  33382. flat?: boolean;
  33383. subdivisions?: number;
  33384. sideOrientation?: number;
  33385. updatable?: boolean;
  33386. }, scene: Scene): Mesh;
  33387. /**
  33388. * Creates a decal mesh.
  33389. * Please consider using the same method from the MeshBuilder class instead.
  33390. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33391. * @param name defines the name of the mesh
  33392. * @param sourceMesh defines the mesh receiving the decal
  33393. * @param position sets the position of the decal in world coordinates
  33394. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33395. * @param size sets the decal scaling
  33396. * @param angle sets the angle to rotate the decal
  33397. * @returns a new Mesh
  33398. */
  33399. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33400. /** Creates a Capsule Mesh
  33401. * @param name defines the name of the mesh.
  33402. * @param options the constructors options used to shape the mesh.
  33403. * @param scene defines the scene the mesh is scoped to.
  33404. * @returns the capsule mesh
  33405. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33406. */
  33407. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33408. /**
  33409. * Prepare internal position array for software CPU skinning
  33410. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33411. */
  33412. setPositionsForCPUSkinning(): Float32Array;
  33413. /**
  33414. * Prepare internal normal array for software CPU skinning
  33415. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33416. */
  33417. setNormalsForCPUSkinning(): Float32Array;
  33418. /**
  33419. * Updates the vertex buffer by applying transformation from the bones
  33420. * @param skeleton defines the skeleton to apply to current mesh
  33421. * @returns the current mesh
  33422. */
  33423. applySkeleton(skeleton: Skeleton): Mesh;
  33424. /**
  33425. * 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
  33426. * @param meshes defines the list of meshes to scan
  33427. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33428. */
  33429. static MinMax(meshes: AbstractMesh[]): {
  33430. min: Vector3;
  33431. max: Vector3;
  33432. };
  33433. /**
  33434. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33435. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33436. * @returns a vector3
  33437. */
  33438. static Center(meshesOrMinMaxVector: {
  33439. min: Vector3;
  33440. max: Vector3;
  33441. } | AbstractMesh[]): Vector3;
  33442. /**
  33443. * Merge the array of meshes into a single mesh for performance reasons.
  33444. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33445. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33446. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33447. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33448. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33449. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33450. * @returns a new mesh
  33451. */
  33452. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33453. /** @hidden */
  33454. addInstance(instance: InstancedMesh): void;
  33455. /** @hidden */
  33456. removeInstance(instance: InstancedMesh): void;
  33457. }
  33458. }
  33459. declare module BABYLON {
  33460. /**
  33461. * The options Interface for creating a Capsule Mesh
  33462. */
  33463. export interface ICreateCapsuleOptions {
  33464. /** The Orientation of the capsule. Default : Vector3.Up() */
  33465. orientation?: Vector3;
  33466. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  33467. subdivisions: number;
  33468. /** Number of cylindrical segments on the capsule. */
  33469. tessellation: number;
  33470. /** Height or Length of the capsule. */
  33471. height: number;
  33472. /** Radius of the capsule. */
  33473. radius: number;
  33474. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  33475. capSubdivisions: number;
  33476. /** Overwrite for the top radius. */
  33477. radiusTop?: number;
  33478. /** Overwrite for the bottom radius. */
  33479. radiusBottom?: number;
  33480. /** Overwrite for the top capSubdivisions. */
  33481. topCapSubdivisions?: number;
  33482. /** Overwrite for the bottom capSubdivisions. */
  33483. bottomCapSubdivisions?: number;
  33484. }
  33485. /**
  33486. * Class containing static functions to help procedurally build meshes
  33487. */
  33488. export class CapsuleBuilder {
  33489. /**
  33490. * Creates a capsule or a pill mesh
  33491. * @param name defines the name of the mesh
  33492. * @param options The constructors options.
  33493. * @param scene The scene the mesh is scoped to.
  33494. * @returns Capsule Mesh
  33495. */
  33496. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  33497. }
  33498. }
  33499. declare module BABYLON {
  33500. /**
  33501. * Define an interface for all classes that will get and set the data on vertices
  33502. */
  33503. export interface IGetSetVerticesData {
  33504. /**
  33505. * Gets a boolean indicating if specific vertex data is present
  33506. * @param kind defines the vertex data kind to use
  33507. * @returns true is data kind is present
  33508. */
  33509. isVerticesDataPresent(kind: string): boolean;
  33510. /**
  33511. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  33512. * @param kind defines the data kind (Position, normal, etc...)
  33513. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  33514. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33515. * @returns a float array containing vertex data
  33516. */
  33517. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33518. /**
  33519. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33520. * @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.
  33521. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33522. * @returns the indices array or an empty array if the mesh has no geometry
  33523. */
  33524. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33525. /**
  33526. * Set specific vertex data
  33527. * @param kind defines the data kind (Position, normal, etc...)
  33528. * @param data defines the vertex data to use
  33529. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  33530. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  33531. */
  33532. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  33533. /**
  33534. * Update a specific associated vertex buffer
  33535. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33536. * - VertexBuffer.PositionKind
  33537. * - VertexBuffer.UVKind
  33538. * - VertexBuffer.UV2Kind
  33539. * - VertexBuffer.UV3Kind
  33540. * - VertexBuffer.UV4Kind
  33541. * - VertexBuffer.UV5Kind
  33542. * - VertexBuffer.UV6Kind
  33543. * - VertexBuffer.ColorKind
  33544. * - VertexBuffer.MatricesIndicesKind
  33545. * - VertexBuffer.MatricesIndicesExtraKind
  33546. * - VertexBuffer.MatricesWeightsKind
  33547. * - VertexBuffer.MatricesWeightsExtraKind
  33548. * @param data defines the data source
  33549. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33550. * @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)
  33551. */
  33552. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  33553. /**
  33554. * Creates a new index buffer
  33555. * @param indices defines the indices to store in the index buffer
  33556. * @param totalVertices defines the total number of vertices (could be null)
  33557. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  33558. */
  33559. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  33560. }
  33561. /**
  33562. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  33563. */
  33564. export class VertexData {
  33565. /**
  33566. * Mesh side orientation : usually the external or front surface
  33567. */
  33568. static readonly FRONTSIDE: number;
  33569. /**
  33570. * Mesh side orientation : usually the internal or back surface
  33571. */
  33572. static readonly BACKSIDE: number;
  33573. /**
  33574. * Mesh side orientation : both internal and external or front and back surfaces
  33575. */
  33576. static readonly DOUBLESIDE: number;
  33577. /**
  33578. * Mesh side orientation : by default, `FRONTSIDE`
  33579. */
  33580. static readonly DEFAULTSIDE: number;
  33581. /**
  33582. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  33583. */
  33584. positions: Nullable<FloatArray>;
  33585. /**
  33586. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  33587. */
  33588. normals: Nullable<FloatArray>;
  33589. /**
  33590. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  33591. */
  33592. tangents: Nullable<FloatArray>;
  33593. /**
  33594. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33595. */
  33596. uvs: Nullable<FloatArray>;
  33597. /**
  33598. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33599. */
  33600. uvs2: Nullable<FloatArray>;
  33601. /**
  33602. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33603. */
  33604. uvs3: Nullable<FloatArray>;
  33605. /**
  33606. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33607. */
  33608. uvs4: Nullable<FloatArray>;
  33609. /**
  33610. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33611. */
  33612. uvs5: Nullable<FloatArray>;
  33613. /**
  33614. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  33615. */
  33616. uvs6: Nullable<FloatArray>;
  33617. /**
  33618. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  33619. */
  33620. colors: Nullable<FloatArray>;
  33621. /**
  33622. * 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).
  33623. */
  33624. matricesIndices: Nullable<FloatArray>;
  33625. /**
  33626. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  33627. */
  33628. matricesWeights: Nullable<FloatArray>;
  33629. /**
  33630. * An array extending the number of possible indices
  33631. */
  33632. matricesIndicesExtra: Nullable<FloatArray>;
  33633. /**
  33634. * An array extending the number of possible weights when the number of indices is extended
  33635. */
  33636. matricesWeightsExtra: Nullable<FloatArray>;
  33637. /**
  33638. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  33639. */
  33640. indices: Nullable<IndicesArray>;
  33641. /**
  33642. * Uses the passed data array to set the set the values for the specified kind of data
  33643. * @param data a linear array of floating numbers
  33644. * @param kind the type of data that is being set, eg positions, colors etc
  33645. */
  33646. set(data: FloatArray, kind: string): void;
  33647. /**
  33648. * Associates the vertexData to the passed Mesh.
  33649. * Sets it as updatable or not (default `false`)
  33650. * @param mesh the mesh the vertexData is applied to
  33651. * @param updatable when used and having the value true allows new data to update the vertexData
  33652. * @returns the VertexData
  33653. */
  33654. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  33655. /**
  33656. * Associates the vertexData to the passed Geometry.
  33657. * Sets it as updatable or not (default `false`)
  33658. * @param geometry the geometry the vertexData is applied to
  33659. * @param updatable when used and having the value true allows new data to update the vertexData
  33660. * @returns VertexData
  33661. */
  33662. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  33663. /**
  33664. * Updates the associated mesh
  33665. * @param mesh the mesh to be updated
  33666. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33667. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  33668. * @returns VertexData
  33669. */
  33670. updateMesh(mesh: Mesh): VertexData;
  33671. /**
  33672. * Updates the associated geometry
  33673. * @param geometry the geometry to be updated
  33674. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  33675. * @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
  33676. * @returns VertexData.
  33677. */
  33678. updateGeometry(geometry: Geometry): VertexData;
  33679. private _applyTo;
  33680. private _update;
  33681. /**
  33682. * Transforms each position and each normal of the vertexData according to the passed Matrix
  33683. * @param matrix the transforming matrix
  33684. * @returns the VertexData
  33685. */
  33686. transform(matrix: Matrix): VertexData;
  33687. /**
  33688. * Merges the passed VertexData into the current one
  33689. * @param other the VertexData to be merged into the current one
  33690. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  33691. * @returns the modified VertexData
  33692. */
  33693. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  33694. private _mergeElement;
  33695. private _validate;
  33696. /**
  33697. * Serializes the VertexData
  33698. * @returns a serialized object
  33699. */
  33700. serialize(): any;
  33701. /**
  33702. * Extracts the vertexData from a mesh
  33703. * @param mesh the mesh from which to extract the VertexData
  33704. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  33705. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33706. * @returns the object VertexData associated to the passed mesh
  33707. */
  33708. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33709. /**
  33710. * Extracts the vertexData from the geometry
  33711. * @param geometry the geometry from which to extract the VertexData
  33712. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  33713. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  33714. * @returns the object VertexData associated to the passed mesh
  33715. */
  33716. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  33717. private static _ExtractFrom;
  33718. /**
  33719. * Creates the VertexData for a Ribbon
  33720. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  33721. * * pathArray array of paths, each of which an array of successive Vector3
  33722. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  33723. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  33724. * * 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
  33725. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33726. * * 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)
  33727. * * 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)
  33728. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  33729. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  33730. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  33731. * @returns the VertexData of the ribbon
  33732. */
  33733. static CreateRibbon(options: {
  33734. pathArray: Vector3[][];
  33735. closeArray?: boolean;
  33736. closePath?: boolean;
  33737. offset?: number;
  33738. sideOrientation?: number;
  33739. frontUVs?: Vector4;
  33740. backUVs?: Vector4;
  33741. invertUV?: boolean;
  33742. uvs?: Vector2[];
  33743. colors?: Color4[];
  33744. }): VertexData;
  33745. /**
  33746. * Creates the VertexData for a box
  33747. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33748. * * size sets the width, height and depth of the box to the value of size, optional default 1
  33749. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  33750. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  33751. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  33752. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33753. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33754. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33755. * * 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)
  33756. * * 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)
  33757. * @returns the VertexData of the box
  33758. */
  33759. static CreateBox(options: {
  33760. size?: number;
  33761. width?: number;
  33762. height?: number;
  33763. depth?: number;
  33764. faceUV?: Vector4[];
  33765. faceColors?: Color4[];
  33766. sideOrientation?: number;
  33767. frontUVs?: Vector4;
  33768. backUVs?: Vector4;
  33769. }): VertexData;
  33770. /**
  33771. * Creates the VertexData for a tiled box
  33772. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33773. * * faceTiles sets the pattern, tile size and number of tiles for a face
  33774. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  33775. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  33776. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33777. * @returns the VertexData of the box
  33778. */
  33779. static CreateTiledBox(options: {
  33780. pattern?: number;
  33781. width?: number;
  33782. height?: number;
  33783. depth?: number;
  33784. tileSize?: number;
  33785. tileWidth?: number;
  33786. tileHeight?: number;
  33787. alignHorizontal?: number;
  33788. alignVertical?: number;
  33789. faceUV?: Vector4[];
  33790. faceColors?: Color4[];
  33791. sideOrientation?: number;
  33792. }): VertexData;
  33793. /**
  33794. * Creates the VertexData for a tiled plane
  33795. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33796. * * pattern a limited pattern arrangement depending on the number
  33797. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  33798. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  33799. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  33800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33801. * * 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)
  33802. * * 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)
  33803. * @returns the VertexData of the tiled plane
  33804. */
  33805. static CreateTiledPlane(options: {
  33806. pattern?: number;
  33807. tileSize?: number;
  33808. tileWidth?: number;
  33809. tileHeight?: number;
  33810. size?: number;
  33811. width?: number;
  33812. height?: number;
  33813. alignHorizontal?: number;
  33814. alignVertical?: number;
  33815. sideOrientation?: number;
  33816. frontUVs?: Vector4;
  33817. backUVs?: Vector4;
  33818. }): VertexData;
  33819. /**
  33820. * Creates the VertexData for an ellipsoid, defaults to a sphere
  33821. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33822. * * segments sets the number of horizontal strips optional, default 32
  33823. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  33824. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  33825. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  33826. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  33827. * * 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
  33828. * * 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
  33829. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33830. * * 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)
  33831. * * 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)
  33832. * @returns the VertexData of the ellipsoid
  33833. */
  33834. static CreateSphere(options: {
  33835. segments?: number;
  33836. diameter?: number;
  33837. diameterX?: number;
  33838. diameterY?: number;
  33839. diameterZ?: number;
  33840. arc?: number;
  33841. slice?: number;
  33842. sideOrientation?: number;
  33843. frontUVs?: Vector4;
  33844. backUVs?: Vector4;
  33845. }): VertexData;
  33846. /**
  33847. * Creates the VertexData for a cylinder, cone or prism
  33848. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33849. * * height sets the height (y direction) of the cylinder, optional, default 2
  33850. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  33851. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  33852. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  33853. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33854. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  33855. * * 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
  33856. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  33857. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  33858. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  33859. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  33860. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33861. * * 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)
  33862. * * 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)
  33863. * @returns the VertexData of the cylinder, cone or prism
  33864. */
  33865. static CreateCylinder(options: {
  33866. height?: number;
  33867. diameterTop?: number;
  33868. diameterBottom?: number;
  33869. diameter?: number;
  33870. tessellation?: number;
  33871. subdivisions?: number;
  33872. arc?: number;
  33873. faceColors?: Color4[];
  33874. faceUV?: Vector4[];
  33875. hasRings?: boolean;
  33876. enclose?: boolean;
  33877. sideOrientation?: number;
  33878. frontUVs?: Vector4;
  33879. backUVs?: Vector4;
  33880. }): VertexData;
  33881. /**
  33882. * Creates the VertexData for a torus
  33883. * @param options an object used to set the following optional parameters for the box, required but can be empty
  33884. * * diameter the diameter of the torus, optional default 1
  33885. * * thickness the diameter of the tube forming the torus, optional default 0.5
  33886. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  33887. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33888. * * 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)
  33889. * * 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)
  33890. * @returns the VertexData of the torus
  33891. */
  33892. static CreateTorus(options: {
  33893. diameter?: number;
  33894. thickness?: number;
  33895. tessellation?: number;
  33896. sideOrientation?: number;
  33897. frontUVs?: Vector4;
  33898. backUVs?: Vector4;
  33899. }): VertexData;
  33900. /**
  33901. * Creates the VertexData of the LineSystem
  33902. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  33903. * - lines an array of lines, each line being an array of successive Vector3
  33904. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  33905. * @returns the VertexData of the LineSystem
  33906. */
  33907. static CreateLineSystem(options: {
  33908. lines: Vector3[][];
  33909. colors?: Nullable<Color4[][]>;
  33910. }): VertexData;
  33911. /**
  33912. * Create the VertexData for a DashedLines
  33913. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  33914. * - points an array successive Vector3
  33915. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  33916. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  33917. * - dashNb the intended total number of dashes, optional, default 200
  33918. * @returns the VertexData for the DashedLines
  33919. */
  33920. static CreateDashedLines(options: {
  33921. points: Vector3[];
  33922. dashSize?: number;
  33923. gapSize?: number;
  33924. dashNb?: number;
  33925. }): VertexData;
  33926. /**
  33927. * Creates the VertexData for a Ground
  33928. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33929. * - width the width (x direction) of the ground, optional, default 1
  33930. * - height the height (z direction) of the ground, optional, default 1
  33931. * - subdivisions the number of subdivisions per side, optional, default 1
  33932. * @returns the VertexData of the Ground
  33933. */
  33934. static CreateGround(options: {
  33935. width?: number;
  33936. height?: number;
  33937. subdivisions?: number;
  33938. subdivisionsX?: number;
  33939. subdivisionsY?: number;
  33940. }): VertexData;
  33941. /**
  33942. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  33943. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  33944. * * xmin the ground minimum X coordinate, optional, default -1
  33945. * * zmin the ground minimum Z coordinate, optional, default -1
  33946. * * xmax the ground maximum X coordinate, optional, default 1
  33947. * * zmax the ground maximum Z coordinate, optional, default 1
  33948. * * 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}
  33949. * * 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}
  33950. * @returns the VertexData of the TiledGround
  33951. */
  33952. static CreateTiledGround(options: {
  33953. xmin: number;
  33954. zmin: number;
  33955. xmax: number;
  33956. zmax: number;
  33957. subdivisions?: {
  33958. w: number;
  33959. h: number;
  33960. };
  33961. precision?: {
  33962. w: number;
  33963. h: number;
  33964. };
  33965. }): VertexData;
  33966. /**
  33967. * Creates the VertexData of the Ground designed from a heightmap
  33968. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  33969. * * width the width (x direction) of the ground
  33970. * * height the height (z direction) of the ground
  33971. * * subdivisions the number of subdivisions per side
  33972. * * minHeight the minimum altitude on the ground, optional, default 0
  33973. * * maxHeight the maximum altitude on the ground, optional default 1
  33974. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  33975. * * buffer the array holding the image color data
  33976. * * bufferWidth the width of image
  33977. * * bufferHeight the height of image
  33978. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  33979. * @returns the VertexData of the Ground designed from a heightmap
  33980. */
  33981. static CreateGroundFromHeightMap(options: {
  33982. width: number;
  33983. height: number;
  33984. subdivisions: number;
  33985. minHeight: number;
  33986. maxHeight: number;
  33987. colorFilter: Color3;
  33988. buffer: Uint8Array;
  33989. bufferWidth: number;
  33990. bufferHeight: number;
  33991. alphaFilter: number;
  33992. }): VertexData;
  33993. /**
  33994. * Creates the VertexData for a Plane
  33995. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  33996. * * size sets the width and height of the plane to the value of size, optional default 1
  33997. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  33998. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  33999. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34000. * * 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)
  34001. * * 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)
  34002. * @returns the VertexData of the box
  34003. */
  34004. static CreatePlane(options: {
  34005. size?: number;
  34006. width?: number;
  34007. height?: number;
  34008. sideOrientation?: number;
  34009. frontUVs?: Vector4;
  34010. backUVs?: Vector4;
  34011. }): VertexData;
  34012. /**
  34013. * Creates the VertexData of the Disc or regular Polygon
  34014. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34015. * * radius the radius of the disc, optional default 0.5
  34016. * * tessellation the number of polygon sides, optional, default 64
  34017. * * 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
  34018. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34019. * * 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)
  34020. * * 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)
  34021. * @returns the VertexData of the box
  34022. */
  34023. static CreateDisc(options: {
  34024. radius?: number;
  34025. tessellation?: number;
  34026. arc?: number;
  34027. sideOrientation?: number;
  34028. frontUVs?: Vector4;
  34029. backUVs?: Vector4;
  34030. }): VertexData;
  34031. /**
  34032. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34033. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34034. * @param polygon a mesh built from polygonTriangulation.build()
  34035. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34036. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34037. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34038. * @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)
  34039. * @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)
  34040. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34041. * @returns the VertexData of the Polygon
  34042. */
  34043. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34044. /**
  34045. * Creates the VertexData of the IcoSphere
  34046. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34047. * * radius the radius of the IcoSphere, optional default 1
  34048. * * radiusX allows stretching in the x direction, optional, default radius
  34049. * * radiusY allows stretching in the y direction, optional, default radius
  34050. * * radiusZ allows stretching in the z direction, optional, default radius
  34051. * * flat when true creates a flat shaded mesh, optional, default true
  34052. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34053. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34054. * * 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)
  34055. * * 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)
  34056. * @returns the VertexData of the IcoSphere
  34057. */
  34058. static CreateIcoSphere(options: {
  34059. radius?: number;
  34060. radiusX?: number;
  34061. radiusY?: number;
  34062. radiusZ?: number;
  34063. flat?: boolean;
  34064. subdivisions?: number;
  34065. sideOrientation?: number;
  34066. frontUVs?: Vector4;
  34067. backUVs?: Vector4;
  34068. }): VertexData;
  34069. /**
  34070. * Creates the VertexData for a Polyhedron
  34071. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34072. * * type provided types are:
  34073. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34074. * * 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)
  34075. * * size the size of the IcoSphere, optional default 1
  34076. * * sizeX allows stretching in the x direction, optional, default size
  34077. * * sizeY allows stretching in the y direction, optional, default size
  34078. * * sizeZ allows stretching in the z direction, optional, default size
  34079. * * 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
  34080. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34081. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34082. * * flat when true creates a flat shaded mesh, optional, default true
  34083. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34084. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34085. * * 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)
  34086. * * 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)
  34087. * @returns the VertexData of the Polyhedron
  34088. */
  34089. static CreatePolyhedron(options: {
  34090. type?: number;
  34091. size?: number;
  34092. sizeX?: number;
  34093. sizeY?: number;
  34094. sizeZ?: number;
  34095. custom?: any;
  34096. faceUV?: Vector4[];
  34097. faceColors?: Color4[];
  34098. flat?: boolean;
  34099. sideOrientation?: number;
  34100. frontUVs?: Vector4;
  34101. backUVs?: Vector4;
  34102. }): VertexData;
  34103. /**
  34104. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34105. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34106. * @returns the VertexData of the Capsule
  34107. */
  34108. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34109. /**
  34110. * Creates the VertexData for a TorusKnot
  34111. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34112. * * radius the radius of the torus knot, optional, default 2
  34113. * * tube the thickness of the tube, optional, default 0.5
  34114. * * radialSegments the number of sides on each tube segments, optional, default 32
  34115. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34116. * * p the number of windings around the z axis, optional, default 2
  34117. * * q the number of windings around the x axis, optional, default 3
  34118. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34119. * * 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)
  34120. * * 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)
  34121. * @returns the VertexData of the Torus Knot
  34122. */
  34123. static CreateTorusKnot(options: {
  34124. radius?: number;
  34125. tube?: number;
  34126. radialSegments?: number;
  34127. tubularSegments?: number;
  34128. p?: number;
  34129. q?: number;
  34130. sideOrientation?: number;
  34131. frontUVs?: Vector4;
  34132. backUVs?: Vector4;
  34133. }): VertexData;
  34134. /**
  34135. * Compute normals for given positions and indices
  34136. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34137. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34138. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34139. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34140. * * facetNormals : optional array of facet normals (vector3)
  34141. * * facetPositions : optional array of facet positions (vector3)
  34142. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34143. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34144. * * bInfo : optional bounding info, required for facetPartitioning computation
  34145. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34146. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34147. * * useRightHandedSystem: optional boolean to for right handed system computation
  34148. * * depthSort : optional boolean to enable the facet depth sort computation
  34149. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34150. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34151. */
  34152. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34153. facetNormals?: any;
  34154. facetPositions?: any;
  34155. facetPartitioning?: any;
  34156. ratio?: number;
  34157. bInfo?: any;
  34158. bbSize?: Vector3;
  34159. subDiv?: any;
  34160. useRightHandedSystem?: boolean;
  34161. depthSort?: boolean;
  34162. distanceTo?: Vector3;
  34163. depthSortedFacets?: any;
  34164. }): void;
  34165. /** @hidden */
  34166. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34167. /**
  34168. * Applies VertexData created from the imported parameters to the geometry
  34169. * @param parsedVertexData the parsed data from an imported file
  34170. * @param geometry the geometry to apply the VertexData to
  34171. */
  34172. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34173. }
  34174. }
  34175. declare module BABYLON {
  34176. /**
  34177. * Class containing static functions to help procedurally build meshes
  34178. */
  34179. export class DiscBuilder {
  34180. /**
  34181. * Creates a plane polygonal mesh. By default, this is a disc
  34182. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34183. * * 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
  34184. * * 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
  34185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34186. * * 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
  34187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34188. * @param name defines the name of the mesh
  34189. * @param options defines the options used to create the mesh
  34190. * @param scene defines the hosting scene
  34191. * @returns the plane polygonal mesh
  34192. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34193. */
  34194. static CreateDisc(name: string, options: {
  34195. radius?: number;
  34196. tessellation?: number;
  34197. arc?: number;
  34198. updatable?: boolean;
  34199. sideOrientation?: number;
  34200. frontUVs?: Vector4;
  34201. backUVs?: Vector4;
  34202. }, scene?: Nullable<Scene>): Mesh;
  34203. }
  34204. }
  34205. declare module BABYLON {
  34206. /**
  34207. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34208. *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.
  34209. * The SPS is also a particle system. It provides some methods to manage the particles.
  34210. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34211. *
  34212. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34213. */
  34214. export class SolidParticleSystem implements IDisposable {
  34215. /**
  34216. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34217. * Example : var p = SPS.particles[i];
  34218. */
  34219. particles: SolidParticle[];
  34220. /**
  34221. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34222. */
  34223. nbParticles: number;
  34224. /**
  34225. * If the particles must ever face the camera (default false). Useful for planar particles.
  34226. */
  34227. billboard: boolean;
  34228. /**
  34229. * Recompute normals when adding a shape
  34230. */
  34231. recomputeNormals: boolean;
  34232. /**
  34233. * This a counter ofr your own usage. It's not set by any SPS functions.
  34234. */
  34235. counter: number;
  34236. /**
  34237. * The SPS name. This name is also given to the underlying mesh.
  34238. */
  34239. name: string;
  34240. /**
  34241. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34242. */
  34243. mesh: Mesh;
  34244. /**
  34245. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34246. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34247. */
  34248. vars: any;
  34249. /**
  34250. * This array is populated when the SPS is set as 'pickable'.
  34251. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34252. * Each element of this array is an object `{idx: int, faceId: int}`.
  34253. * `idx` is the picked particle index in the `SPS.particles` array
  34254. * `faceId` is the picked face index counted within this particle.
  34255. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34256. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34257. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34258. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34259. */
  34260. pickedParticles: {
  34261. idx: number;
  34262. faceId: number;
  34263. }[];
  34264. /**
  34265. * This array is populated when the SPS is set as 'pickable'
  34266. * Each key of this array is a submesh index.
  34267. * Each element of this array is a second array defined like this :
  34268. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34269. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34270. * `idx` is the picked particle index in the `SPS.particles` array
  34271. * `faceId` is the picked face index counted within this particle.
  34272. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34273. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34274. */
  34275. pickedBySubMesh: {
  34276. idx: number;
  34277. faceId: number;
  34278. }[][];
  34279. /**
  34280. * This array is populated when `enableDepthSort` is set to true.
  34281. * Each element of this array is an instance of the class DepthSortedParticle.
  34282. */
  34283. depthSortedParticles: DepthSortedParticle[];
  34284. /**
  34285. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34286. * @hidden
  34287. */
  34288. _bSphereOnly: boolean;
  34289. /**
  34290. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34291. * @hidden
  34292. */
  34293. _bSphereRadiusFactor: number;
  34294. private _scene;
  34295. private _positions;
  34296. private _indices;
  34297. private _normals;
  34298. private _colors;
  34299. private _uvs;
  34300. private _indices32;
  34301. private _positions32;
  34302. private _normals32;
  34303. private _fixedNormal32;
  34304. private _colors32;
  34305. private _uvs32;
  34306. private _index;
  34307. private _updatable;
  34308. private _pickable;
  34309. private _isVisibilityBoxLocked;
  34310. private _alwaysVisible;
  34311. private _depthSort;
  34312. private _expandable;
  34313. private _shapeCounter;
  34314. private _copy;
  34315. private _color;
  34316. private _computeParticleColor;
  34317. private _computeParticleTexture;
  34318. private _computeParticleRotation;
  34319. private _computeParticleVertex;
  34320. private _computeBoundingBox;
  34321. private _depthSortParticles;
  34322. private _camera;
  34323. private _mustUnrotateFixedNormals;
  34324. private _particlesIntersect;
  34325. private _needs32Bits;
  34326. private _isNotBuilt;
  34327. private _lastParticleId;
  34328. private _idxOfId;
  34329. private _multimaterialEnabled;
  34330. private _useModelMaterial;
  34331. private _indicesByMaterial;
  34332. private _materialIndexes;
  34333. private _depthSortFunction;
  34334. private _materialSortFunction;
  34335. private _materials;
  34336. private _multimaterial;
  34337. private _materialIndexesById;
  34338. private _defaultMaterial;
  34339. private _autoUpdateSubMeshes;
  34340. private _tmpVertex;
  34341. /**
  34342. * Creates a SPS (Solid Particle System) object.
  34343. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34344. * @param scene (Scene) is the scene in which the SPS is added.
  34345. * @param options defines the options of the sps e.g.
  34346. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34347. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34348. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34349. * * 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.
  34350. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34351. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34352. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34353. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34354. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34355. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34356. */
  34357. constructor(name: string, scene: Scene, options?: {
  34358. updatable?: boolean;
  34359. isPickable?: boolean;
  34360. enableDepthSort?: boolean;
  34361. particleIntersection?: boolean;
  34362. boundingSphereOnly?: boolean;
  34363. bSphereRadiusFactor?: number;
  34364. expandable?: boolean;
  34365. useModelMaterial?: boolean;
  34366. enableMultiMaterial?: boolean;
  34367. });
  34368. /**
  34369. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34370. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34371. * @returns the created mesh
  34372. */
  34373. buildMesh(): Mesh;
  34374. /**
  34375. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34376. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34377. * Thus the particles generated from `digest()` have their property `position` set yet.
  34378. * @param mesh ( Mesh ) is the mesh to be digested
  34379. * @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
  34380. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34381. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34382. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34383. * @returns the current SPS
  34384. */
  34385. digest(mesh: Mesh, options?: {
  34386. facetNb?: number;
  34387. number?: number;
  34388. delta?: number;
  34389. storage?: [];
  34390. }): SolidParticleSystem;
  34391. /**
  34392. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34393. * @hidden
  34394. */
  34395. private _unrotateFixedNormals;
  34396. /**
  34397. * Resets the temporary working copy particle
  34398. * @hidden
  34399. */
  34400. private _resetCopy;
  34401. /**
  34402. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34403. * @param p the current index in the positions array to be updated
  34404. * @param ind the current index in the indices array
  34405. * @param shape a Vector3 array, the shape geometry
  34406. * @param positions the positions array to be updated
  34407. * @param meshInd the shape indices array
  34408. * @param indices the indices array to be updated
  34409. * @param meshUV the shape uv array
  34410. * @param uvs the uv array to be updated
  34411. * @param meshCol the shape color array
  34412. * @param colors the color array to be updated
  34413. * @param meshNor the shape normals array
  34414. * @param normals the normals array to be updated
  34415. * @param idx the particle index
  34416. * @param idxInShape the particle index in its shape
  34417. * @param options the addShape() method passed options
  34418. * @model the particle model
  34419. * @hidden
  34420. */
  34421. private _meshBuilder;
  34422. /**
  34423. * Returns a shape Vector3 array from positions float array
  34424. * @param positions float array
  34425. * @returns a vector3 array
  34426. * @hidden
  34427. */
  34428. private _posToShape;
  34429. /**
  34430. * Returns a shapeUV array from a float uvs (array deep copy)
  34431. * @param uvs as a float array
  34432. * @returns a shapeUV array
  34433. * @hidden
  34434. */
  34435. private _uvsToShapeUV;
  34436. /**
  34437. * Adds a new particle object in the particles array
  34438. * @param idx particle index in particles array
  34439. * @param id particle id
  34440. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34441. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34442. * @param model particle ModelShape object
  34443. * @param shapeId model shape identifier
  34444. * @param idxInShape index of the particle in the current model
  34445. * @param bInfo model bounding info object
  34446. * @param storage target storage array, if any
  34447. * @hidden
  34448. */
  34449. private _addParticle;
  34450. /**
  34451. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34452. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34453. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34454. * @param nb (positive integer) the number of particles to be created from this model
  34455. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34456. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34457. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34458. * @returns the number of shapes in the system
  34459. */
  34460. addShape(mesh: Mesh, nb: number, options?: {
  34461. positionFunction?: any;
  34462. vertexFunction?: any;
  34463. storage?: [];
  34464. }): number;
  34465. /**
  34466. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34467. * @hidden
  34468. */
  34469. private _rebuildParticle;
  34470. /**
  34471. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34472. * @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.
  34473. * @returns the SPS.
  34474. */
  34475. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34476. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34477. * Returns an array with the removed particles.
  34478. * 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.
  34479. * The SPS can't be empty so at least one particle needs to remain in place.
  34480. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34481. * @param start index of the first particle to remove
  34482. * @param end index of the last particle to remove (included)
  34483. * @returns an array populated with the removed particles
  34484. */
  34485. removeParticles(start: number, end: number): SolidParticle[];
  34486. /**
  34487. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34488. * @param solidParticleArray an array populated with Solid Particles objects
  34489. * @returns the SPS
  34490. */
  34491. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34492. /**
  34493. * Creates a new particle and modifies the SPS mesh geometry :
  34494. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34495. * - calls _addParticle() to populate the particle array
  34496. * factorized code from addShape() and insertParticlesFromArray()
  34497. * @param idx particle index in the particles array
  34498. * @param i particle index in its shape
  34499. * @param modelShape particle ModelShape object
  34500. * @param shape shape vertex array
  34501. * @param meshInd shape indices array
  34502. * @param meshUV shape uv array
  34503. * @param meshCol shape color array
  34504. * @param meshNor shape normals array
  34505. * @param bbInfo shape bounding info
  34506. * @param storage target particle storage
  34507. * @options addShape() passed options
  34508. * @hidden
  34509. */
  34510. private _insertNewParticle;
  34511. /**
  34512. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34513. * This method calls `updateParticle()` for each particle of the SPS.
  34514. * For an animated SPS, it is usually called within the render loop.
  34515. * 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.
  34516. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34517. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34518. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34519. * @returns the SPS.
  34520. */
  34521. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34522. /**
  34523. * Disposes the SPS.
  34524. */
  34525. dispose(): void;
  34526. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34527. * idx is the particle index in the SPS
  34528. * faceId is the picked face index counted within this particle.
  34529. * Returns null if the pickInfo can't identify a picked particle.
  34530. * @param pickingInfo (PickingInfo object)
  34531. * @returns {idx: number, faceId: number} or null
  34532. */
  34533. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34534. idx: number;
  34535. faceId: number;
  34536. }>;
  34537. /**
  34538. * Returns a SolidParticle object from its identifier : particle.id
  34539. * @param id (integer) the particle Id
  34540. * @returns the searched particle or null if not found in the SPS.
  34541. */
  34542. getParticleById(id: number): Nullable<SolidParticle>;
  34543. /**
  34544. * Returns a new array populated with the particles having the passed shapeId.
  34545. * @param shapeId (integer) the shape identifier
  34546. * @returns a new solid particle array
  34547. */
  34548. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34549. /**
  34550. * Populates the passed array "ref" with the particles having the passed shapeId.
  34551. * @param shapeId the shape identifier
  34552. * @returns the SPS
  34553. * @param ref
  34554. */
  34555. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34556. /**
  34557. * Computes the required SubMeshes according the materials assigned to the particles.
  34558. * @returns the solid particle system.
  34559. * Does nothing if called before the SPS mesh is built.
  34560. */
  34561. computeSubMeshes(): SolidParticleSystem;
  34562. /**
  34563. * Sorts the solid particles by material when MultiMaterial is enabled.
  34564. * Updates the indices32 array.
  34565. * Updates the indicesByMaterial array.
  34566. * Updates the mesh indices array.
  34567. * @returns the SPS
  34568. * @hidden
  34569. */
  34570. private _sortParticlesByMaterial;
  34571. /**
  34572. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34573. * @hidden
  34574. */
  34575. private _setMaterialIndexesById;
  34576. /**
  34577. * Returns an array with unique values of Materials from the passed array
  34578. * @param array the material array to be checked and filtered
  34579. * @hidden
  34580. */
  34581. private _filterUniqueMaterialId;
  34582. /**
  34583. * Sets a new Standard Material as _defaultMaterial if not already set.
  34584. * @hidden
  34585. */
  34586. private _setDefaultMaterial;
  34587. /**
  34588. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34589. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34590. * @returns the SPS.
  34591. */
  34592. refreshVisibleSize(): SolidParticleSystem;
  34593. /**
  34594. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34595. * @param size the size (float) of the visibility box
  34596. * note : this doesn't lock the SPS mesh bounding box.
  34597. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34598. */
  34599. setVisibilityBox(size: number): void;
  34600. /**
  34601. * Gets whether the SPS as always visible or not
  34602. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34603. */
  34604. get isAlwaysVisible(): boolean;
  34605. /**
  34606. * Sets the SPS as always visible or not
  34607. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34608. */
  34609. set isAlwaysVisible(val: boolean);
  34610. /**
  34611. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34612. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34613. */
  34614. set isVisibilityBoxLocked(val: boolean);
  34615. /**
  34616. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34617. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34618. */
  34619. get isVisibilityBoxLocked(): boolean;
  34620. /**
  34621. * Tells to `setParticles()` to compute the particle rotations or not.
  34622. * Default value : true. The SPS is faster when it's set to false.
  34623. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34624. */
  34625. set computeParticleRotation(val: boolean);
  34626. /**
  34627. * Tells to `setParticles()` to compute the particle colors or not.
  34628. * Default value : true. The SPS is faster when it's set to false.
  34629. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34630. */
  34631. set computeParticleColor(val: boolean);
  34632. set computeParticleTexture(val: boolean);
  34633. /**
  34634. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34635. * Default value : false. The SPS is faster when it's set to false.
  34636. * Note : the particle custom vertex positions aren't stored values.
  34637. */
  34638. set computeParticleVertex(val: boolean);
  34639. /**
  34640. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34641. */
  34642. set computeBoundingBox(val: boolean);
  34643. /**
  34644. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34645. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34646. * Default : `true`
  34647. */
  34648. set depthSortParticles(val: boolean);
  34649. /**
  34650. * Gets if `setParticles()` computes the particle rotations or not.
  34651. * Default value : true. The SPS is faster when it's set to false.
  34652. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34653. */
  34654. get computeParticleRotation(): boolean;
  34655. /**
  34656. * Gets if `setParticles()` computes the particle colors or not.
  34657. * Default value : true. The SPS is faster when it's set to false.
  34658. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34659. */
  34660. get computeParticleColor(): boolean;
  34661. /**
  34662. * Gets if `setParticles()` computes the particle textures or not.
  34663. * Default value : true. The SPS is faster when it's set to false.
  34664. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34665. */
  34666. get computeParticleTexture(): boolean;
  34667. /**
  34668. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34669. * Default value : false. The SPS is faster when it's set to false.
  34670. * Note : the particle custom vertex positions aren't stored values.
  34671. */
  34672. get computeParticleVertex(): boolean;
  34673. /**
  34674. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34675. */
  34676. get computeBoundingBox(): boolean;
  34677. /**
  34678. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34679. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34680. * Default : `true`
  34681. */
  34682. get depthSortParticles(): boolean;
  34683. /**
  34684. * Gets if the SPS is created as expandable at construction time.
  34685. * Default : `false`
  34686. */
  34687. get expandable(): boolean;
  34688. /**
  34689. * Gets if the SPS supports the Multi Materials
  34690. */
  34691. get multimaterialEnabled(): boolean;
  34692. /**
  34693. * Gets if the SPS uses the model materials for its own multimaterial.
  34694. */
  34695. get useModelMaterial(): boolean;
  34696. /**
  34697. * The SPS used material array.
  34698. */
  34699. get materials(): Material[];
  34700. /**
  34701. * Sets the SPS MultiMaterial from the passed materials.
  34702. * Note : the passed array is internally copied and not used then by reference.
  34703. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34704. */
  34705. setMultiMaterial(materials: Material[]): void;
  34706. /**
  34707. * The SPS computed multimaterial object
  34708. */
  34709. get multimaterial(): MultiMaterial;
  34710. set multimaterial(mm: MultiMaterial);
  34711. /**
  34712. * If the subMeshes must be updated on the next call to setParticles()
  34713. */
  34714. get autoUpdateSubMeshes(): boolean;
  34715. set autoUpdateSubMeshes(val: boolean);
  34716. /**
  34717. * This function does nothing. It may be overwritten to set all the particle first values.
  34718. * The SPS doesn't call this function, you may have to call it by your own.
  34719. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34720. */
  34721. initParticles(): void;
  34722. /**
  34723. * This function does nothing. It may be overwritten to recycle a particle.
  34724. * The SPS doesn't call this function, you may have to call it by your own.
  34725. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34726. * @param particle The particle to recycle
  34727. * @returns the recycled particle
  34728. */
  34729. recycleParticle(particle: SolidParticle): SolidParticle;
  34730. /**
  34731. * Updates a particle : this function should be overwritten by the user.
  34732. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34733. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34734. * @example : just set a particle position or velocity and recycle conditions
  34735. * @param particle The particle to update
  34736. * @returns the updated particle
  34737. */
  34738. updateParticle(particle: SolidParticle): SolidParticle;
  34739. /**
  34740. * Updates a vertex of a particle : it can be overwritten by the user.
  34741. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34742. * @param particle the current particle
  34743. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34744. * @param pt the index of the current vertex in the particle shape
  34745. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34746. * @example : just set a vertex particle position or color
  34747. * @returns the sps
  34748. */
  34749. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34750. /**
  34751. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34752. * This does nothing and may be overwritten by the user.
  34753. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34754. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34755. * @param update the boolean update value actually passed to setParticles()
  34756. */
  34757. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34758. /**
  34759. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34760. * This will be passed three parameters.
  34761. * This does nothing and may be overwritten by the user.
  34762. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34763. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34764. * @param update the boolean update value actually passed to setParticles()
  34765. */
  34766. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34767. }
  34768. }
  34769. declare module BABYLON {
  34770. /**
  34771. * Represents one particle of a solid particle system.
  34772. */
  34773. export class SolidParticle {
  34774. /**
  34775. * particle global index
  34776. */
  34777. idx: number;
  34778. /**
  34779. * particle identifier
  34780. */
  34781. id: number;
  34782. /**
  34783. * The color of the particle
  34784. */
  34785. color: Nullable<Color4>;
  34786. /**
  34787. * The world space position of the particle.
  34788. */
  34789. position: Vector3;
  34790. /**
  34791. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34792. */
  34793. rotation: Vector3;
  34794. /**
  34795. * The world space rotation quaternion of the particle.
  34796. */
  34797. rotationQuaternion: Nullable<Quaternion>;
  34798. /**
  34799. * The scaling of the particle.
  34800. */
  34801. scaling: Vector3;
  34802. /**
  34803. * The uvs of the particle.
  34804. */
  34805. uvs: Vector4;
  34806. /**
  34807. * The current speed of the particle.
  34808. */
  34809. velocity: Vector3;
  34810. /**
  34811. * The pivot point in the particle local space.
  34812. */
  34813. pivot: Vector3;
  34814. /**
  34815. * Must the particle be translated from its pivot point in its local space ?
  34816. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34817. * Default : false
  34818. */
  34819. translateFromPivot: boolean;
  34820. /**
  34821. * Is the particle active or not ?
  34822. */
  34823. alive: boolean;
  34824. /**
  34825. * Is the particle visible or not ?
  34826. */
  34827. isVisible: boolean;
  34828. /**
  34829. * Index of this particle in the global "positions" array (Internal use)
  34830. * @hidden
  34831. */
  34832. _pos: number;
  34833. /**
  34834. * @hidden Index of this particle in the global "indices" array (Internal use)
  34835. */
  34836. _ind: number;
  34837. /**
  34838. * @hidden ModelShape of this particle (Internal use)
  34839. */
  34840. _model: ModelShape;
  34841. /**
  34842. * ModelShape id of this particle
  34843. */
  34844. shapeId: number;
  34845. /**
  34846. * Index of the particle in its shape id
  34847. */
  34848. idxInShape: number;
  34849. /**
  34850. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34851. */
  34852. _modelBoundingInfo: BoundingInfo;
  34853. /**
  34854. * @hidden Particle BoundingInfo object (Internal use)
  34855. */
  34856. _boundingInfo: BoundingInfo;
  34857. /**
  34858. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34859. */
  34860. _sps: SolidParticleSystem;
  34861. /**
  34862. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34863. */
  34864. _stillInvisible: boolean;
  34865. /**
  34866. * @hidden Last computed particle rotation matrix
  34867. */
  34868. _rotationMatrix: number[];
  34869. /**
  34870. * Parent particle Id, if any.
  34871. * Default null.
  34872. */
  34873. parentId: Nullable<number>;
  34874. /**
  34875. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34876. */
  34877. materialIndex: Nullable<number>;
  34878. /**
  34879. * Custom object or properties.
  34880. */
  34881. props: Nullable<any>;
  34882. /**
  34883. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34884. * The possible values are :
  34885. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34886. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34887. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34888. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34889. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34890. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34891. * */
  34892. cullingStrategy: number;
  34893. /**
  34894. * @hidden Internal global position in the SPS.
  34895. */
  34896. _globalPosition: Vector3;
  34897. /**
  34898. * Creates a Solid Particle object.
  34899. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34900. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34901. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34902. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34903. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34904. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34905. * @param shapeId (integer) is the model shape identifier in the SPS.
  34906. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34907. * @param sps defines the sps it is associated to
  34908. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34909. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34910. */
  34911. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34912. /**
  34913. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34914. * @param target the particle target
  34915. * @returns the current particle
  34916. */
  34917. copyToRef(target: SolidParticle): SolidParticle;
  34918. /**
  34919. * Legacy support, changed scale to scaling
  34920. */
  34921. get scale(): Vector3;
  34922. /**
  34923. * Legacy support, changed scale to scaling
  34924. */
  34925. set scale(scale: Vector3);
  34926. /**
  34927. * Legacy support, changed quaternion to rotationQuaternion
  34928. */
  34929. get quaternion(): Nullable<Quaternion>;
  34930. /**
  34931. * Legacy support, changed quaternion to rotationQuaternion
  34932. */
  34933. set quaternion(q: Nullable<Quaternion>);
  34934. /**
  34935. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34936. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34937. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34938. * @returns true if it intersects
  34939. */
  34940. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34941. /**
  34942. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34943. * A particle is in the frustum if its bounding box intersects the frustum
  34944. * @param frustumPlanes defines the frustum to test
  34945. * @returns true if the particle is in the frustum planes
  34946. */
  34947. isInFrustum(frustumPlanes: Plane[]): boolean;
  34948. /**
  34949. * get the rotation matrix of the particle
  34950. * @hidden
  34951. */
  34952. getRotationMatrix(m: Matrix): void;
  34953. }
  34954. /**
  34955. * Represents the shape of the model used by one particle of a solid particle system.
  34956. * SPS internal tool, don't use it manually.
  34957. */
  34958. export class ModelShape {
  34959. /**
  34960. * The shape id
  34961. * @hidden
  34962. */
  34963. shapeID: number;
  34964. /**
  34965. * flat array of model positions (internal use)
  34966. * @hidden
  34967. */
  34968. _shape: Vector3[];
  34969. /**
  34970. * flat array of model UVs (internal use)
  34971. * @hidden
  34972. */
  34973. _shapeUV: number[];
  34974. /**
  34975. * color array of the model
  34976. * @hidden
  34977. */
  34978. _shapeColors: number[];
  34979. /**
  34980. * indices array of the model
  34981. * @hidden
  34982. */
  34983. _indices: number[];
  34984. /**
  34985. * normals array of the model
  34986. * @hidden
  34987. */
  34988. _normals: number[];
  34989. /**
  34990. * length of the shape in the model indices array (internal use)
  34991. * @hidden
  34992. */
  34993. _indicesLength: number;
  34994. /**
  34995. * Custom position function (internal use)
  34996. * @hidden
  34997. */
  34998. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34999. /**
  35000. * Custom vertex function (internal use)
  35001. * @hidden
  35002. */
  35003. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35004. /**
  35005. * Model material (internal use)
  35006. * @hidden
  35007. */
  35008. _material: Nullable<Material>;
  35009. /**
  35010. * 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.
  35011. * SPS internal tool, don't use it manually.
  35012. * @hidden
  35013. */
  35014. 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>);
  35015. }
  35016. /**
  35017. * Represents a Depth Sorted Particle in the solid particle system.
  35018. * @hidden
  35019. */
  35020. export class DepthSortedParticle {
  35021. /**
  35022. * Particle index
  35023. */
  35024. idx: number;
  35025. /**
  35026. * Index of the particle in the "indices" array
  35027. */
  35028. ind: number;
  35029. /**
  35030. * Length of the particle shape in the "indices" array
  35031. */
  35032. indicesLength: number;
  35033. /**
  35034. * Squared distance from the particle to the camera
  35035. */
  35036. sqDistance: number;
  35037. /**
  35038. * Material index when used with MultiMaterials
  35039. */
  35040. materialIndex: number;
  35041. /**
  35042. * Creates a new sorted particle
  35043. * @param materialIndex
  35044. */
  35045. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35046. }
  35047. /**
  35048. * Represents a solid particle vertex
  35049. */
  35050. export class SolidParticleVertex {
  35051. /**
  35052. * Vertex position
  35053. */
  35054. position: Vector3;
  35055. /**
  35056. * Vertex color
  35057. */
  35058. color: Color4;
  35059. /**
  35060. * Vertex UV
  35061. */
  35062. uv: Vector2;
  35063. /**
  35064. * Creates a new solid particle vertex
  35065. */
  35066. constructor();
  35067. /** Vertex x coordinate */
  35068. get x(): number;
  35069. set x(val: number);
  35070. /** Vertex y coordinate */
  35071. get y(): number;
  35072. set y(val: number);
  35073. /** Vertex z coordinate */
  35074. get z(): number;
  35075. set z(val: number);
  35076. }
  35077. }
  35078. declare module BABYLON {
  35079. /**
  35080. * @hidden
  35081. */
  35082. export class _MeshCollisionData {
  35083. _checkCollisions: boolean;
  35084. _collisionMask: number;
  35085. _collisionGroup: number;
  35086. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35087. _collider: Nullable<Collider>;
  35088. _oldPositionForCollisions: Vector3;
  35089. _diffPositionForCollisions: Vector3;
  35090. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35091. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35092. _collisionResponse: boolean;
  35093. }
  35094. }
  35095. declare module BABYLON {
  35096. /** @hidden */
  35097. class _FacetDataStorage {
  35098. facetPositions: Vector3[];
  35099. facetNormals: Vector3[];
  35100. facetPartitioning: number[][];
  35101. facetNb: number;
  35102. partitioningSubdivisions: number;
  35103. partitioningBBoxRatio: number;
  35104. facetDataEnabled: boolean;
  35105. facetParameters: any;
  35106. bbSize: Vector3;
  35107. subDiv: {
  35108. max: number;
  35109. X: number;
  35110. Y: number;
  35111. Z: number;
  35112. };
  35113. facetDepthSort: boolean;
  35114. facetDepthSortEnabled: boolean;
  35115. depthSortedIndices: IndicesArray;
  35116. depthSortedFacets: {
  35117. ind: number;
  35118. sqDistance: number;
  35119. }[];
  35120. facetDepthSortFunction: (f1: {
  35121. ind: number;
  35122. sqDistance: number;
  35123. }, f2: {
  35124. ind: number;
  35125. sqDistance: number;
  35126. }) => number;
  35127. facetDepthSortFrom: Vector3;
  35128. facetDepthSortOrigin: Vector3;
  35129. invertedMatrix: Matrix;
  35130. }
  35131. /**
  35132. * @hidden
  35133. **/
  35134. class _InternalAbstractMeshDataInfo {
  35135. _hasVertexAlpha: boolean;
  35136. _useVertexColors: boolean;
  35137. _numBoneInfluencers: number;
  35138. _applyFog: boolean;
  35139. _receiveShadows: boolean;
  35140. _facetData: _FacetDataStorage;
  35141. _visibility: number;
  35142. _skeleton: Nullable<Skeleton>;
  35143. _layerMask: number;
  35144. _computeBonesUsingShaders: boolean;
  35145. _isActive: boolean;
  35146. _onlyForInstances: boolean;
  35147. _isActiveIntermediate: boolean;
  35148. _onlyForInstancesIntermediate: boolean;
  35149. _actAsRegularMesh: boolean;
  35150. _currentLOD: Nullable<AbstractMesh>;
  35151. _currentLODIsUpToDate: boolean;
  35152. }
  35153. /**
  35154. * Class used to store all common mesh properties
  35155. */
  35156. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35157. /** No occlusion */
  35158. static OCCLUSION_TYPE_NONE: number;
  35159. /** Occlusion set to optimisitic */
  35160. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35161. /** Occlusion set to strict */
  35162. static OCCLUSION_TYPE_STRICT: number;
  35163. /** Use an accurante occlusion algorithm */
  35164. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35165. /** Use a conservative occlusion algorithm */
  35166. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35167. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35168. * Test order :
  35169. * Is the bounding sphere outside the frustum ?
  35170. * If not, are the bounding box vertices outside the frustum ?
  35171. * It not, then the cullable object is in the frustum.
  35172. */
  35173. static readonly CULLINGSTRATEGY_STANDARD: number;
  35174. /** Culling strategy : Bounding Sphere Only.
  35175. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35176. * It's also less accurate than the standard because some not visible objects can still be selected.
  35177. * Test : is the bounding sphere outside the frustum ?
  35178. * If not, then the cullable object is in the frustum.
  35179. */
  35180. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35181. /** Culling strategy : Optimistic Inclusion.
  35182. * This in an inclusion test first, then the standard exclusion test.
  35183. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35184. * 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.
  35185. * Anyway, it's as accurate as the standard strategy.
  35186. * Test :
  35187. * Is the cullable object bounding sphere center in the frustum ?
  35188. * If not, apply the default culling strategy.
  35189. */
  35190. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35191. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35192. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35193. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35194. * 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.
  35195. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35196. * Test :
  35197. * Is the cullable object bounding sphere center in the frustum ?
  35198. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35199. */
  35200. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35201. /**
  35202. * No billboard
  35203. */
  35204. static get BILLBOARDMODE_NONE(): number;
  35205. /** Billboard on X axis */
  35206. static get BILLBOARDMODE_X(): number;
  35207. /** Billboard on Y axis */
  35208. static get BILLBOARDMODE_Y(): number;
  35209. /** Billboard on Z axis */
  35210. static get BILLBOARDMODE_Z(): number;
  35211. /** Billboard on all axes */
  35212. static get BILLBOARDMODE_ALL(): number;
  35213. /** Billboard on using position instead of orientation */
  35214. static get BILLBOARDMODE_USE_POSITION(): number;
  35215. /** @hidden */
  35216. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35217. /**
  35218. * The culling strategy to use to check whether the mesh must be rendered or not.
  35219. * This value can be changed at any time and will be used on the next render mesh selection.
  35220. * The possible values are :
  35221. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35222. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35223. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35224. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35225. * Please read each static variable documentation to get details about the culling process.
  35226. * */
  35227. cullingStrategy: number;
  35228. /**
  35229. * Gets the number of facets in the mesh
  35230. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35231. */
  35232. get facetNb(): number;
  35233. /**
  35234. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35235. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35236. */
  35237. get partitioningSubdivisions(): number;
  35238. set partitioningSubdivisions(nb: number);
  35239. /**
  35240. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35241. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35242. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35243. */
  35244. get partitioningBBoxRatio(): number;
  35245. set partitioningBBoxRatio(ratio: number);
  35246. /**
  35247. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35248. * Works only for updatable meshes.
  35249. * Doesn't work with multi-materials
  35250. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35251. */
  35252. get mustDepthSortFacets(): boolean;
  35253. set mustDepthSortFacets(sort: boolean);
  35254. /**
  35255. * The location (Vector3) where the facet depth sort must be computed from.
  35256. * By default, the active camera position.
  35257. * Used only when facet depth sort is enabled
  35258. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35259. */
  35260. get facetDepthSortFrom(): Vector3;
  35261. set facetDepthSortFrom(location: Vector3);
  35262. /**
  35263. * gets a boolean indicating if facetData is enabled
  35264. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35265. */
  35266. get isFacetDataEnabled(): boolean;
  35267. /** @hidden */
  35268. _updateNonUniformScalingState(value: boolean): boolean;
  35269. /**
  35270. * An event triggered when this mesh collides with another one
  35271. */
  35272. onCollideObservable: Observable<AbstractMesh>;
  35273. /** Set a function to call when this mesh collides with another one */
  35274. set onCollide(callback: () => void);
  35275. /**
  35276. * An event triggered when the collision's position changes
  35277. */
  35278. onCollisionPositionChangeObservable: Observable<Vector3>;
  35279. /** Set a function to call when the collision's position changes */
  35280. set onCollisionPositionChange(callback: () => void);
  35281. /**
  35282. * An event triggered when material is changed
  35283. */
  35284. onMaterialChangedObservable: Observable<AbstractMesh>;
  35285. /**
  35286. * Gets or sets the orientation for POV movement & rotation
  35287. */
  35288. definedFacingForward: boolean;
  35289. /** @hidden */
  35290. _occlusionQuery: Nullable<WebGLQuery>;
  35291. /** @hidden */
  35292. _renderingGroup: Nullable<RenderingGroup>;
  35293. /**
  35294. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35295. */
  35296. get visibility(): number;
  35297. /**
  35298. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35299. */
  35300. set visibility(value: number);
  35301. /** Gets or sets the alpha index used to sort transparent meshes
  35302. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35303. */
  35304. alphaIndex: number;
  35305. /**
  35306. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35307. */
  35308. isVisible: boolean;
  35309. /**
  35310. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35311. */
  35312. isPickable: boolean;
  35313. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35314. showSubMeshesBoundingBox: boolean;
  35315. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35316. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35317. */
  35318. isBlocker: boolean;
  35319. /**
  35320. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35321. */
  35322. enablePointerMoveEvents: boolean;
  35323. private _renderingGroupId;
  35324. /**
  35325. * Specifies the rendering group id for this mesh (0 by default)
  35326. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35327. */
  35328. get renderingGroupId(): number;
  35329. set renderingGroupId(value: number);
  35330. private _material;
  35331. /** Gets or sets current material */
  35332. get material(): Nullable<Material>;
  35333. set material(value: Nullable<Material>);
  35334. /**
  35335. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35336. * @see https://doc.babylonjs.com/babylon101/shadows
  35337. */
  35338. get receiveShadows(): boolean;
  35339. set receiveShadows(value: boolean);
  35340. /** Defines color to use when rendering outline */
  35341. outlineColor: Color3;
  35342. /** Define width to use when rendering outline */
  35343. outlineWidth: number;
  35344. /** Defines color to use when rendering overlay */
  35345. overlayColor: Color3;
  35346. /** Defines alpha to use when rendering overlay */
  35347. overlayAlpha: number;
  35348. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35349. get hasVertexAlpha(): boolean;
  35350. set hasVertexAlpha(value: boolean);
  35351. /** 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) */
  35352. get useVertexColors(): boolean;
  35353. set useVertexColors(value: boolean);
  35354. /**
  35355. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35356. */
  35357. get computeBonesUsingShaders(): boolean;
  35358. set computeBonesUsingShaders(value: boolean);
  35359. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35360. get numBoneInfluencers(): number;
  35361. set numBoneInfluencers(value: number);
  35362. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35363. get applyFog(): boolean;
  35364. set applyFog(value: boolean);
  35365. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35366. useOctreeForRenderingSelection: boolean;
  35367. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35368. useOctreeForPicking: boolean;
  35369. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35370. useOctreeForCollisions: boolean;
  35371. /**
  35372. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35373. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35374. */
  35375. get layerMask(): number;
  35376. set layerMask(value: number);
  35377. /**
  35378. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35379. */
  35380. alwaysSelectAsActiveMesh: boolean;
  35381. /**
  35382. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35383. */
  35384. doNotSyncBoundingInfo: boolean;
  35385. /**
  35386. * Gets or sets the current action manager
  35387. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35388. */
  35389. actionManager: Nullable<AbstractActionManager>;
  35390. private _meshCollisionData;
  35391. /**
  35392. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35393. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35394. */
  35395. ellipsoid: Vector3;
  35396. /**
  35397. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35398. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35399. */
  35400. ellipsoidOffset: Vector3;
  35401. /**
  35402. * Gets or sets a collision mask used to mask collisions (default is -1).
  35403. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35404. */
  35405. get collisionMask(): number;
  35406. set collisionMask(mask: number);
  35407. /**
  35408. * Gets or sets a collision response flag (default is true).
  35409. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35410. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35411. * to respond to the collision.
  35412. */
  35413. get collisionResponse(): boolean;
  35414. set collisionResponse(response: boolean);
  35415. /**
  35416. * Gets or sets the current collision group mask (-1 by default).
  35417. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35418. */
  35419. get collisionGroup(): number;
  35420. set collisionGroup(mask: number);
  35421. /**
  35422. * Gets or sets current surrounding meshes (null by default).
  35423. *
  35424. * By default collision detection is tested against every mesh in the scene.
  35425. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35426. * meshes will be tested for the collision.
  35427. *
  35428. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35429. */
  35430. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35431. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35432. /**
  35433. * Defines edge width used when edgesRenderer is enabled
  35434. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35435. */
  35436. edgesWidth: number;
  35437. /**
  35438. * Defines edge color used when edgesRenderer is enabled
  35439. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35440. */
  35441. edgesColor: Color4;
  35442. /** @hidden */
  35443. _edgesRenderer: Nullable<IEdgesRenderer>;
  35444. /** @hidden */
  35445. _masterMesh: Nullable<AbstractMesh>;
  35446. /** @hidden */
  35447. _boundingInfo: Nullable<BoundingInfo>;
  35448. /** @hidden */
  35449. _renderId: number;
  35450. /**
  35451. * Gets or sets the list of subMeshes
  35452. * @see https://doc.babylonjs.com/how_to/multi_materials
  35453. */
  35454. subMeshes: SubMesh[];
  35455. /** @hidden */
  35456. _intersectionsInProgress: AbstractMesh[];
  35457. /** @hidden */
  35458. _unIndexed: boolean;
  35459. /** @hidden */
  35460. _lightSources: Light[];
  35461. /** Gets the list of lights affecting that mesh */
  35462. get lightSources(): Light[];
  35463. /** @hidden */
  35464. get _positions(): Nullable<Vector3[]>;
  35465. /** @hidden */
  35466. _waitingData: {
  35467. lods: Nullable<any>;
  35468. actions: Nullable<any>;
  35469. freezeWorldMatrix: Nullable<boolean>;
  35470. };
  35471. /** @hidden */
  35472. _bonesTransformMatrices: Nullable<Float32Array>;
  35473. /** @hidden */
  35474. _transformMatrixTexture: Nullable<RawTexture>;
  35475. /**
  35476. * Gets or sets a skeleton to apply skining transformations
  35477. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35478. */
  35479. set skeleton(value: Nullable<Skeleton>);
  35480. get skeleton(): Nullable<Skeleton>;
  35481. /**
  35482. * An event triggered when the mesh is rebuilt.
  35483. */
  35484. onRebuildObservable: Observable<AbstractMesh>;
  35485. /**
  35486. * Creates a new AbstractMesh
  35487. * @param name defines the name of the mesh
  35488. * @param scene defines the hosting scene
  35489. */
  35490. constructor(name: string, scene?: Nullable<Scene>);
  35491. /**
  35492. * Returns the string "AbstractMesh"
  35493. * @returns "AbstractMesh"
  35494. */
  35495. getClassName(): string;
  35496. /**
  35497. * Gets a string representation of the current mesh
  35498. * @param fullDetails defines a boolean indicating if full details must be included
  35499. * @returns a string representation of the current mesh
  35500. */
  35501. toString(fullDetails?: boolean): string;
  35502. /**
  35503. * @hidden
  35504. */
  35505. protected _getEffectiveParent(): Nullable<Node>;
  35506. /** @hidden */
  35507. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35508. /** @hidden */
  35509. _rebuild(): void;
  35510. /** @hidden */
  35511. _resyncLightSources(): void;
  35512. /** @hidden */
  35513. _resyncLightSource(light: Light): void;
  35514. /** @hidden */
  35515. _unBindEffect(): void;
  35516. /** @hidden */
  35517. _removeLightSource(light: Light, dispose: boolean): void;
  35518. private _markSubMeshesAsDirty;
  35519. /** @hidden */
  35520. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35521. /** @hidden */
  35522. _markSubMeshesAsAttributesDirty(): void;
  35523. /** @hidden */
  35524. _markSubMeshesAsMiscDirty(): void;
  35525. /**
  35526. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35527. */
  35528. get scaling(): Vector3;
  35529. set scaling(newScaling: Vector3);
  35530. /**
  35531. * Returns true if the mesh is blocked. Implemented by child classes
  35532. */
  35533. get isBlocked(): boolean;
  35534. /**
  35535. * Returns the mesh itself by default. Implemented by child classes
  35536. * @param camera defines the camera to use to pick the right LOD level
  35537. * @returns the currentAbstractMesh
  35538. */
  35539. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35540. /**
  35541. * Returns 0 by default. Implemented by child classes
  35542. * @returns an integer
  35543. */
  35544. getTotalVertices(): number;
  35545. /**
  35546. * Returns a positive integer : the total number of indices in this mesh geometry.
  35547. * @returns the numner of indices or zero if the mesh has no geometry.
  35548. */
  35549. getTotalIndices(): number;
  35550. /**
  35551. * Returns null by default. Implemented by child classes
  35552. * @returns null
  35553. */
  35554. getIndices(): Nullable<IndicesArray>;
  35555. /**
  35556. * Returns the array of the requested vertex data kind. Implemented by child classes
  35557. * @param kind defines the vertex data kind to use
  35558. * @returns null
  35559. */
  35560. getVerticesData(kind: string): Nullable<FloatArray>;
  35561. /**
  35562. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35563. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35564. * Note that a new underlying VertexBuffer object is created each call.
  35565. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35566. * @param kind defines vertex data kind:
  35567. * * VertexBuffer.PositionKind
  35568. * * VertexBuffer.UVKind
  35569. * * VertexBuffer.UV2Kind
  35570. * * VertexBuffer.UV3Kind
  35571. * * VertexBuffer.UV4Kind
  35572. * * VertexBuffer.UV5Kind
  35573. * * VertexBuffer.UV6Kind
  35574. * * VertexBuffer.ColorKind
  35575. * * VertexBuffer.MatricesIndicesKind
  35576. * * VertexBuffer.MatricesIndicesExtraKind
  35577. * * VertexBuffer.MatricesWeightsKind
  35578. * * VertexBuffer.MatricesWeightsExtraKind
  35579. * @param data defines the data source
  35580. * @param updatable defines if the data must be flagged as updatable (or static)
  35581. * @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
  35582. * @returns the current mesh
  35583. */
  35584. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35585. /**
  35586. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35587. * If the mesh has no geometry, it is simply returned as it is.
  35588. * @param kind defines vertex data kind:
  35589. * * VertexBuffer.PositionKind
  35590. * * VertexBuffer.UVKind
  35591. * * VertexBuffer.UV2Kind
  35592. * * VertexBuffer.UV3Kind
  35593. * * VertexBuffer.UV4Kind
  35594. * * VertexBuffer.UV5Kind
  35595. * * VertexBuffer.UV6Kind
  35596. * * VertexBuffer.ColorKind
  35597. * * VertexBuffer.MatricesIndicesKind
  35598. * * VertexBuffer.MatricesIndicesExtraKind
  35599. * * VertexBuffer.MatricesWeightsKind
  35600. * * VertexBuffer.MatricesWeightsExtraKind
  35601. * @param data defines the data source
  35602. * @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
  35603. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35604. * @returns the current mesh
  35605. */
  35606. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35607. /**
  35608. * Sets the mesh indices,
  35609. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35610. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35611. * @param totalVertices Defines the total number of vertices
  35612. * @returns the current mesh
  35613. */
  35614. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35615. /**
  35616. * Gets a boolean indicating if specific vertex data is present
  35617. * @param kind defines the vertex data kind to use
  35618. * @returns true is data kind is present
  35619. */
  35620. isVerticesDataPresent(kind: string): boolean;
  35621. /**
  35622. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35623. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35624. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35625. * @returns a BoundingInfo
  35626. */
  35627. getBoundingInfo(): BoundingInfo;
  35628. /**
  35629. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35630. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35631. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35632. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35633. * @returns the current mesh
  35634. */
  35635. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35636. /**
  35637. * Overwrite the current bounding info
  35638. * @param boundingInfo defines the new bounding info
  35639. * @returns the current mesh
  35640. */
  35641. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35642. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35643. get useBones(): boolean;
  35644. /** @hidden */
  35645. _preActivate(): void;
  35646. /** @hidden */
  35647. _preActivateForIntermediateRendering(renderId: number): void;
  35648. /** @hidden */
  35649. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35650. /** @hidden */
  35651. _postActivate(): void;
  35652. /** @hidden */
  35653. _freeze(): void;
  35654. /** @hidden */
  35655. _unFreeze(): void;
  35656. /**
  35657. * Gets the current world matrix
  35658. * @returns a Matrix
  35659. */
  35660. getWorldMatrix(): Matrix;
  35661. /** @hidden */
  35662. _getWorldMatrixDeterminant(): number;
  35663. /**
  35664. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35665. */
  35666. get isAnInstance(): boolean;
  35667. /**
  35668. * Gets a boolean indicating if this mesh has instances
  35669. */
  35670. get hasInstances(): boolean;
  35671. /**
  35672. * Gets a boolean indicating if this mesh has thin instances
  35673. */
  35674. get hasThinInstances(): boolean;
  35675. /**
  35676. * Perform relative position change from the point of view of behind the front of the mesh.
  35677. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35678. * Supports definition of mesh facing forward or backward
  35679. * @param amountRight defines the distance on the right axis
  35680. * @param amountUp defines the distance on the up axis
  35681. * @param amountForward defines the distance on the forward axis
  35682. * @returns the current mesh
  35683. */
  35684. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35685. /**
  35686. * Calculate relative position change from the point of view of behind the front of the mesh.
  35687. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35688. * Supports definition of mesh facing forward or backward
  35689. * @param amountRight defines the distance on the right axis
  35690. * @param amountUp defines the distance on the up axis
  35691. * @param amountForward defines the distance on the forward axis
  35692. * @returns the new displacement vector
  35693. */
  35694. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35695. /**
  35696. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35697. * Supports definition of mesh facing forward or backward
  35698. * @param flipBack defines the flip
  35699. * @param twirlClockwise defines the twirl
  35700. * @param tiltRight defines the tilt
  35701. * @returns the current mesh
  35702. */
  35703. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35704. /**
  35705. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35706. * Supports definition of mesh facing forward or backward.
  35707. * @param flipBack defines the flip
  35708. * @param twirlClockwise defines the twirl
  35709. * @param tiltRight defines the tilt
  35710. * @returns the new rotation vector
  35711. */
  35712. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35713. /**
  35714. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35715. * This means the mesh underlying bounding box and sphere are recomputed.
  35716. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35717. * @returns the current mesh
  35718. */
  35719. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35720. /** @hidden */
  35721. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35722. /** @hidden */
  35723. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35724. /** @hidden */
  35725. _updateBoundingInfo(): AbstractMesh;
  35726. /** @hidden */
  35727. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35728. /** @hidden */
  35729. protected _afterComputeWorldMatrix(): void;
  35730. /** @hidden */
  35731. get _effectiveMesh(): AbstractMesh;
  35732. /**
  35733. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35734. * A mesh is in the frustum if its bounding box intersects the frustum
  35735. * @param frustumPlanes defines the frustum to test
  35736. * @returns true if the mesh is in the frustum planes
  35737. */
  35738. isInFrustum(frustumPlanes: Plane[]): boolean;
  35739. /**
  35740. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35741. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35742. * @param frustumPlanes defines the frustum to test
  35743. * @returns true if the mesh is completely in the frustum planes
  35744. */
  35745. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35746. /**
  35747. * True if the mesh intersects another mesh or a SolidParticle object
  35748. * @param mesh defines a target mesh or SolidParticle to test
  35749. * @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)
  35750. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35751. * @returns true if there is an intersection
  35752. */
  35753. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35754. /**
  35755. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35756. * @param point defines the point to test
  35757. * @returns true if there is an intersection
  35758. */
  35759. intersectsPoint(point: Vector3): boolean;
  35760. /**
  35761. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35762. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35763. */
  35764. get checkCollisions(): boolean;
  35765. set checkCollisions(collisionEnabled: boolean);
  35766. /**
  35767. * Gets Collider object used to compute collisions (not physics)
  35768. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35769. */
  35770. get collider(): Nullable<Collider>;
  35771. /**
  35772. * Move the mesh using collision engine
  35773. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35774. * @param displacement defines the requested displacement vector
  35775. * @returns the current mesh
  35776. */
  35777. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35778. private _onCollisionPositionChange;
  35779. /** @hidden */
  35780. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35781. /** @hidden */
  35782. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35783. /** @hidden */
  35784. _checkCollision(collider: Collider): AbstractMesh;
  35785. /** @hidden */
  35786. _generatePointsArray(): boolean;
  35787. /**
  35788. * Checks if the passed Ray intersects with the mesh
  35789. * @param ray defines the ray to use
  35790. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35791. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35792. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35793. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35794. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  35795. * @returns the picking info
  35796. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35797. */
  35798. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  35799. /**
  35800. * Clones the current mesh
  35801. * @param name defines the mesh name
  35802. * @param newParent defines the new mesh parent
  35803. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35804. * @returns the new mesh
  35805. */
  35806. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35807. /**
  35808. * Disposes all the submeshes of the current meshnp
  35809. * @returns the current mesh
  35810. */
  35811. releaseSubMeshes(): AbstractMesh;
  35812. /**
  35813. * Releases resources associated with this abstract mesh.
  35814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35816. */
  35817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35818. /**
  35819. * Adds the passed mesh as a child to the current mesh
  35820. * @param mesh defines the child mesh
  35821. * @returns the current mesh
  35822. */
  35823. addChild(mesh: AbstractMesh): AbstractMesh;
  35824. /**
  35825. * Removes the passed mesh from the current mesh children list
  35826. * @param mesh defines the child mesh
  35827. * @returns the current mesh
  35828. */
  35829. removeChild(mesh: AbstractMesh): AbstractMesh;
  35830. /** @hidden */
  35831. private _initFacetData;
  35832. /**
  35833. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35834. * This method can be called within the render loop.
  35835. * 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
  35836. * @returns the current mesh
  35837. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35838. */
  35839. updateFacetData(): AbstractMesh;
  35840. /**
  35841. * Returns the facetLocalNormals array.
  35842. * The normals are expressed in the mesh local spac
  35843. * @returns an array of Vector3
  35844. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35845. */
  35846. getFacetLocalNormals(): Vector3[];
  35847. /**
  35848. * Returns the facetLocalPositions array.
  35849. * The facet positions are expressed in the mesh local space
  35850. * @returns an array of Vector3
  35851. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35852. */
  35853. getFacetLocalPositions(): Vector3[];
  35854. /**
  35855. * Returns the facetLocalPartioning array
  35856. * @returns an array of array of numbers
  35857. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35858. */
  35859. getFacetLocalPartitioning(): number[][];
  35860. /**
  35861. * Returns the i-th facet position in the world system.
  35862. * This method allocates a new Vector3 per call
  35863. * @param i defines the facet index
  35864. * @returns a new Vector3
  35865. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35866. */
  35867. getFacetPosition(i: number): Vector3;
  35868. /**
  35869. * Sets the reference Vector3 with the i-th facet position in the world system
  35870. * @param i defines the facet index
  35871. * @param ref defines the target vector
  35872. * @returns the current mesh
  35873. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35874. */
  35875. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35876. /**
  35877. * Returns the i-th facet normal in the world system.
  35878. * This method allocates a new Vector3 per call
  35879. * @param i defines the facet index
  35880. * @returns a new Vector3
  35881. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35882. */
  35883. getFacetNormal(i: number): Vector3;
  35884. /**
  35885. * Sets the reference Vector3 with the i-th facet normal in the world system
  35886. * @param i defines the facet index
  35887. * @param ref defines the target vector
  35888. * @returns the current mesh
  35889. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35890. */
  35891. getFacetNormalToRef(i: number, ref: Vector3): this;
  35892. /**
  35893. * 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)
  35894. * @param x defines x coordinate
  35895. * @param y defines y coordinate
  35896. * @param z defines z coordinate
  35897. * @returns the array of facet indexes
  35898. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35899. */
  35900. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35901. /**
  35902. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35903. * @param projected sets as the (x,y,z) world projection on the facet
  35904. * @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
  35905. * @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
  35906. * @param x defines x coordinate
  35907. * @param y defines y coordinate
  35908. * @param z defines z coordinate
  35909. * @returns the face index if found (or null instead)
  35910. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35911. */
  35912. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35913. /**
  35914. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35915. * @param projected sets as the (x,y,z) local projection on the facet
  35916. * @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
  35917. * @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
  35918. * @param x defines x coordinate
  35919. * @param y defines y coordinate
  35920. * @param z defines z coordinate
  35921. * @returns the face index if found (or null instead)
  35922. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35923. */
  35924. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35925. /**
  35926. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35927. * @returns the parameters
  35928. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35929. */
  35930. getFacetDataParameters(): any;
  35931. /**
  35932. * Disables the feature FacetData and frees the related memory
  35933. * @returns the current mesh
  35934. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35935. */
  35936. disableFacetData(): AbstractMesh;
  35937. /**
  35938. * Updates the AbstractMesh indices array
  35939. * @param indices defines the data source
  35940. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35941. * @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)
  35942. * @returns the current mesh
  35943. */
  35944. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35945. /**
  35946. * Creates new normals data for the mesh
  35947. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35948. * @returns the current mesh
  35949. */
  35950. createNormals(updatable: boolean): AbstractMesh;
  35951. /**
  35952. * Align the mesh with a normal
  35953. * @param normal defines the normal to use
  35954. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35955. * @returns the current mesh
  35956. */
  35957. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35958. /** @hidden */
  35959. _checkOcclusionQuery(): boolean;
  35960. /**
  35961. * Disables the mesh edge rendering mode
  35962. * @returns the currentAbstractMesh
  35963. */
  35964. disableEdgesRendering(): AbstractMesh;
  35965. /**
  35966. * Enables the edge rendering mode on the mesh.
  35967. * This mode makes the mesh edges visible
  35968. * @param epsilon defines the maximal distance between two angles to detect a face
  35969. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35970. * @param options options to the edge renderer
  35971. * @returns the currentAbstractMesh
  35972. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35973. */
  35974. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  35975. /**
  35976. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35977. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35978. */
  35979. getConnectedParticleSystems(): IParticleSystem[];
  35980. }
  35981. }
  35982. declare module BABYLON {
  35983. /**
  35984. * Interface used to define ActionEvent
  35985. */
  35986. export interface IActionEvent {
  35987. /** The mesh or sprite that triggered the action */
  35988. source: any;
  35989. /** The X mouse cursor position at the time of the event */
  35990. pointerX: number;
  35991. /** The Y mouse cursor position at the time of the event */
  35992. pointerY: number;
  35993. /** The mesh that is currently pointed at (can be null) */
  35994. meshUnderPointer: Nullable<AbstractMesh>;
  35995. /** the original (browser) event that triggered the ActionEvent */
  35996. sourceEvent?: any;
  35997. /** additional data for the event */
  35998. additionalData?: any;
  35999. }
  36000. /**
  36001. * ActionEvent is the event being sent when an action is triggered.
  36002. */
  36003. export class ActionEvent implements IActionEvent {
  36004. /** The mesh or sprite that triggered the action */
  36005. source: any;
  36006. /** The X mouse cursor position at the time of the event */
  36007. pointerX: number;
  36008. /** The Y mouse cursor position at the time of the event */
  36009. pointerY: number;
  36010. /** The mesh that is currently pointed at (can be null) */
  36011. meshUnderPointer: Nullable<AbstractMesh>;
  36012. /** the original (browser) event that triggered the ActionEvent */
  36013. sourceEvent?: any;
  36014. /** additional data for the event */
  36015. additionalData?: any;
  36016. /**
  36017. * Creates a new ActionEvent
  36018. * @param source The mesh or sprite that triggered the action
  36019. * @param pointerX The X mouse cursor position at the time of the event
  36020. * @param pointerY The Y mouse cursor position at the time of the event
  36021. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36022. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36023. * @param additionalData additional data for the event
  36024. */
  36025. constructor(
  36026. /** The mesh or sprite that triggered the action */
  36027. source: any,
  36028. /** The X mouse cursor position at the time of the event */
  36029. pointerX: number,
  36030. /** The Y mouse cursor position at the time of the event */
  36031. pointerY: number,
  36032. /** The mesh that is currently pointed at (can be null) */
  36033. meshUnderPointer: Nullable<AbstractMesh>,
  36034. /** the original (browser) event that triggered the ActionEvent */
  36035. sourceEvent?: any,
  36036. /** additional data for the event */
  36037. additionalData?: any);
  36038. /**
  36039. * Helper function to auto-create an ActionEvent from a source mesh.
  36040. * @param source The source mesh that triggered the event
  36041. * @param evt The original (browser) event
  36042. * @param additionalData additional data for the event
  36043. * @returns the new ActionEvent
  36044. */
  36045. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36046. /**
  36047. * Helper function to auto-create an ActionEvent from a source sprite
  36048. * @param source The source sprite that triggered the event
  36049. * @param scene Scene associated with the sprite
  36050. * @param evt The original (browser) event
  36051. * @param additionalData additional data for the event
  36052. * @returns the new ActionEvent
  36053. */
  36054. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36055. /**
  36056. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36057. * @param scene the scene where the event occurred
  36058. * @param evt The original (browser) event
  36059. * @returns the new ActionEvent
  36060. */
  36061. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36062. /**
  36063. * Helper function to auto-create an ActionEvent from a primitive
  36064. * @param prim defines the target primitive
  36065. * @param pointerPos defines the pointer position
  36066. * @param evt The original (browser) event
  36067. * @param additionalData additional data for the event
  36068. * @returns the new ActionEvent
  36069. */
  36070. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36071. }
  36072. }
  36073. declare module BABYLON {
  36074. /**
  36075. * Abstract class used to decouple action Manager from scene and meshes.
  36076. * Do not instantiate.
  36077. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36078. */
  36079. export abstract class AbstractActionManager implements IDisposable {
  36080. /** Gets the list of active triggers */
  36081. static Triggers: {
  36082. [key: string]: number;
  36083. };
  36084. /** Gets the cursor to use when hovering items */
  36085. hoverCursor: string;
  36086. /** Gets the list of actions */
  36087. actions: IAction[];
  36088. /**
  36089. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36090. */
  36091. isRecursive: boolean;
  36092. /**
  36093. * Releases all associated resources
  36094. */
  36095. abstract dispose(): void;
  36096. /**
  36097. * Does this action manager has pointer triggers
  36098. */
  36099. abstract get hasPointerTriggers(): boolean;
  36100. /**
  36101. * Does this action manager has pick triggers
  36102. */
  36103. abstract get hasPickTriggers(): boolean;
  36104. /**
  36105. * Process a specific trigger
  36106. * @param trigger defines the trigger to process
  36107. * @param evt defines the event details to be processed
  36108. */
  36109. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36110. /**
  36111. * Does this action manager handles actions of any of the given triggers
  36112. * @param triggers defines the triggers to be tested
  36113. * @return a boolean indicating whether one (or more) of the triggers is handled
  36114. */
  36115. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36116. /**
  36117. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36118. * speed.
  36119. * @param triggerA defines the trigger to be tested
  36120. * @param triggerB defines the trigger to be tested
  36121. * @return a boolean indicating whether one (or more) of the triggers is handled
  36122. */
  36123. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36124. /**
  36125. * Does this action manager handles actions of a given trigger
  36126. * @param trigger defines the trigger to be tested
  36127. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36128. * @return whether the trigger is handled
  36129. */
  36130. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36131. /**
  36132. * Serialize this manager to a JSON object
  36133. * @param name defines the property name to store this manager
  36134. * @returns a JSON representation of this manager
  36135. */
  36136. abstract serialize(name: string): any;
  36137. /**
  36138. * Registers an action to this action manager
  36139. * @param action defines the action to be registered
  36140. * @return the action amended (prepared) after registration
  36141. */
  36142. abstract registerAction(action: IAction): Nullable<IAction>;
  36143. /**
  36144. * Unregisters an action to this action manager
  36145. * @param action defines the action to be unregistered
  36146. * @return a boolean indicating whether the action has been unregistered
  36147. */
  36148. abstract unregisterAction(action: IAction): Boolean;
  36149. /**
  36150. * Does exist one action manager with at least one trigger
  36151. **/
  36152. static get HasTriggers(): boolean;
  36153. /**
  36154. * Does exist one action manager with at least one pick trigger
  36155. **/
  36156. static get HasPickTriggers(): boolean;
  36157. /**
  36158. * Does exist one action manager that handles actions of a given trigger
  36159. * @param trigger defines the trigger to be tested
  36160. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36161. **/
  36162. static HasSpecificTrigger(trigger: number): boolean;
  36163. }
  36164. }
  36165. declare module BABYLON {
  36166. /**
  36167. * Defines how a node can be built from a string name.
  36168. */
  36169. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36170. /**
  36171. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36172. */
  36173. export class Node implements IBehaviorAware<Node> {
  36174. /** @hidden */
  36175. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36176. private static _NodeConstructors;
  36177. /**
  36178. * Add a new node constructor
  36179. * @param type defines the type name of the node to construct
  36180. * @param constructorFunc defines the constructor function
  36181. */
  36182. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36183. /**
  36184. * Returns a node constructor based on type name
  36185. * @param type defines the type name
  36186. * @param name defines the new node name
  36187. * @param scene defines the hosting scene
  36188. * @param options defines optional options to transmit to constructors
  36189. * @returns the new constructor or null
  36190. */
  36191. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36192. /**
  36193. * Gets or sets the name of the node
  36194. */
  36195. name: string;
  36196. /**
  36197. * Gets or sets the id of the node
  36198. */
  36199. id: string;
  36200. /**
  36201. * Gets or sets the unique id of the node
  36202. */
  36203. uniqueId: number;
  36204. /**
  36205. * Gets or sets a string used to store user defined state for the node
  36206. */
  36207. state: string;
  36208. /**
  36209. * Gets or sets an object used to store user defined information for the node
  36210. */
  36211. metadata: any;
  36212. /**
  36213. * For internal use only. Please do not use.
  36214. */
  36215. reservedDataStore: any;
  36216. /**
  36217. * List of inspectable custom properties (used by the Inspector)
  36218. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36219. */
  36220. inspectableCustomProperties: IInspectable[];
  36221. private _doNotSerialize;
  36222. /**
  36223. * Gets or sets a boolean used to define if the node must be serialized
  36224. */
  36225. get doNotSerialize(): boolean;
  36226. set doNotSerialize(value: boolean);
  36227. /** @hidden */
  36228. _isDisposed: boolean;
  36229. /**
  36230. * Gets a list of Animations associated with the node
  36231. */
  36232. animations: Animation[];
  36233. protected _ranges: {
  36234. [name: string]: Nullable<AnimationRange>;
  36235. };
  36236. /**
  36237. * Callback raised when the node is ready to be used
  36238. */
  36239. onReady: Nullable<(node: Node) => void>;
  36240. private _isEnabled;
  36241. private _isParentEnabled;
  36242. private _isReady;
  36243. /** @hidden */
  36244. _currentRenderId: number;
  36245. private _parentUpdateId;
  36246. /** @hidden */
  36247. _childUpdateId: number;
  36248. /** @hidden */
  36249. _waitingParentId: Nullable<string>;
  36250. /** @hidden */
  36251. _scene: Scene;
  36252. /** @hidden */
  36253. _cache: any;
  36254. private _parentNode;
  36255. private _children;
  36256. /** @hidden */
  36257. _worldMatrix: Matrix;
  36258. /** @hidden */
  36259. _worldMatrixDeterminant: number;
  36260. /** @hidden */
  36261. _worldMatrixDeterminantIsDirty: boolean;
  36262. /** @hidden */
  36263. private _sceneRootNodesIndex;
  36264. /**
  36265. * Gets a boolean indicating if the node has been disposed
  36266. * @returns true if the node was disposed
  36267. */
  36268. isDisposed(): boolean;
  36269. /**
  36270. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36271. * @see https://doc.babylonjs.com/how_to/parenting
  36272. */
  36273. set parent(parent: Nullable<Node>);
  36274. get parent(): Nullable<Node>;
  36275. /** @hidden */
  36276. _addToSceneRootNodes(): void;
  36277. /** @hidden */
  36278. _removeFromSceneRootNodes(): void;
  36279. private _animationPropertiesOverride;
  36280. /**
  36281. * Gets or sets the animation properties override
  36282. */
  36283. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36284. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36285. /**
  36286. * Gets a string identifying the name of the class
  36287. * @returns "Node" string
  36288. */
  36289. getClassName(): string;
  36290. /** @hidden */
  36291. readonly _isNode: boolean;
  36292. /**
  36293. * An event triggered when the mesh is disposed
  36294. */
  36295. onDisposeObservable: Observable<Node>;
  36296. private _onDisposeObserver;
  36297. /**
  36298. * Sets a callback that will be raised when the node will be disposed
  36299. */
  36300. set onDispose(callback: () => void);
  36301. /**
  36302. * Creates a new Node
  36303. * @param name the name and id to be given to this node
  36304. * @param scene the scene this node will be added to
  36305. */
  36306. constructor(name: string, scene?: Nullable<Scene>);
  36307. /**
  36308. * Gets the scene of the node
  36309. * @returns a scene
  36310. */
  36311. getScene(): Scene;
  36312. /**
  36313. * Gets the engine of the node
  36314. * @returns a Engine
  36315. */
  36316. getEngine(): Engine;
  36317. private _behaviors;
  36318. /**
  36319. * Attach a behavior to the node
  36320. * @see https://doc.babylonjs.com/features/behaviour
  36321. * @param behavior defines the behavior to attach
  36322. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36323. * @returns the current Node
  36324. */
  36325. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36326. /**
  36327. * Remove an attached behavior
  36328. * @see https://doc.babylonjs.com/features/behaviour
  36329. * @param behavior defines the behavior to attach
  36330. * @returns the current Node
  36331. */
  36332. removeBehavior(behavior: Behavior<Node>): Node;
  36333. /**
  36334. * Gets the list of attached behaviors
  36335. * @see https://doc.babylonjs.com/features/behaviour
  36336. */
  36337. get behaviors(): Behavior<Node>[];
  36338. /**
  36339. * Gets an attached behavior by name
  36340. * @param name defines the name of the behavior to look for
  36341. * @see https://doc.babylonjs.com/features/behaviour
  36342. * @returns null if behavior was not found else the requested behavior
  36343. */
  36344. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36345. /**
  36346. * Returns the latest update of the World matrix
  36347. * @returns a Matrix
  36348. */
  36349. getWorldMatrix(): Matrix;
  36350. /** @hidden */
  36351. _getWorldMatrixDeterminant(): number;
  36352. /**
  36353. * Returns directly the latest state of the mesh World matrix.
  36354. * A Matrix is returned.
  36355. */
  36356. get worldMatrixFromCache(): Matrix;
  36357. /** @hidden */
  36358. _initCache(): void;
  36359. /** @hidden */
  36360. updateCache(force?: boolean): void;
  36361. /** @hidden */
  36362. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36363. /** @hidden */
  36364. _updateCache(ignoreParentClass?: boolean): void;
  36365. /** @hidden */
  36366. _isSynchronized(): boolean;
  36367. /** @hidden */
  36368. _markSyncedWithParent(): void;
  36369. /** @hidden */
  36370. isSynchronizedWithParent(): boolean;
  36371. /** @hidden */
  36372. isSynchronized(): boolean;
  36373. /**
  36374. * Is this node ready to be used/rendered
  36375. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36376. * @return true if the node is ready
  36377. */
  36378. isReady(completeCheck?: boolean): boolean;
  36379. /**
  36380. * Is this node enabled?
  36381. * 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
  36382. * @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
  36383. * @return whether this node (and its parent) is enabled
  36384. */
  36385. isEnabled(checkAncestors?: boolean): boolean;
  36386. /** @hidden */
  36387. protected _syncParentEnabledState(): void;
  36388. /**
  36389. * Set the enabled state of this node
  36390. * @param value defines the new enabled state
  36391. */
  36392. setEnabled(value: boolean): void;
  36393. /**
  36394. * Is this node a descendant of the given node?
  36395. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36396. * @param ancestor defines the parent node to inspect
  36397. * @returns a boolean indicating if this node is a descendant of the given node
  36398. */
  36399. isDescendantOf(ancestor: Node): boolean;
  36400. /** @hidden */
  36401. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36402. /**
  36403. * Will return all nodes that have this node as ascendant
  36404. * @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
  36405. * @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
  36406. * @return all children nodes of all types
  36407. */
  36408. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36409. /**
  36410. * Get all child-meshes of this node
  36411. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  36412. * @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
  36413. * @returns an array of AbstractMesh
  36414. */
  36415. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36416. /**
  36417. * Get all direct children of this node
  36418. * @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
  36419. * @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)
  36420. * @returns an array of Node
  36421. */
  36422. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36423. /** @hidden */
  36424. _setReady(state: boolean): void;
  36425. /**
  36426. * Get an animation by name
  36427. * @param name defines the name of the animation to look for
  36428. * @returns null if not found else the requested animation
  36429. */
  36430. getAnimationByName(name: string): Nullable<Animation>;
  36431. /**
  36432. * Creates an animation range for this node
  36433. * @param name defines the name of the range
  36434. * @param from defines the starting key
  36435. * @param to defines the end key
  36436. */
  36437. createAnimationRange(name: string, from: number, to: number): void;
  36438. /**
  36439. * Delete a specific animation range
  36440. * @param name defines the name of the range to delete
  36441. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36442. */
  36443. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36444. /**
  36445. * Get an animation range by name
  36446. * @param name defines the name of the animation range to look for
  36447. * @returns null if not found else the requested animation range
  36448. */
  36449. getAnimationRange(name: string): Nullable<AnimationRange>;
  36450. /**
  36451. * Gets the list of all animation ranges defined on this node
  36452. * @returns an array
  36453. */
  36454. getAnimationRanges(): Nullable<AnimationRange>[];
  36455. /**
  36456. * Will start the animation sequence
  36457. * @param name defines the range frames for animation sequence
  36458. * @param loop defines if the animation should loop (false by default)
  36459. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36460. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36461. * @returns the object created for this animation. If range does not exist, it will return null
  36462. */
  36463. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36464. /**
  36465. * Serialize animation ranges into a JSON compatible object
  36466. * @returns serialization object
  36467. */
  36468. serializeAnimationRanges(): any;
  36469. /**
  36470. * Computes the world matrix of the node
  36471. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36472. * @returns the world matrix
  36473. */
  36474. computeWorldMatrix(force?: boolean): Matrix;
  36475. /**
  36476. * Releases resources associated with this node.
  36477. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36478. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36479. */
  36480. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36481. /**
  36482. * Parse animation range data from a serialization object and store them into a given node
  36483. * @param node defines where to store the animation ranges
  36484. * @param parsedNode defines the serialization object to read data from
  36485. * @param scene defines the hosting scene
  36486. */
  36487. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36488. /**
  36489. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36490. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36491. * @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
  36492. * @returns the new bounding vectors
  36493. */
  36494. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36495. min: Vector3;
  36496. max: Vector3;
  36497. };
  36498. }
  36499. }
  36500. declare module BABYLON {
  36501. /**
  36502. * @hidden
  36503. */
  36504. export class _IAnimationState {
  36505. key: number;
  36506. repeatCount: number;
  36507. workValue?: any;
  36508. loopMode?: number;
  36509. offsetValue?: any;
  36510. highLimitValue?: any;
  36511. }
  36512. /**
  36513. * Class used to store any kind of animation
  36514. */
  36515. export class Animation {
  36516. /**Name of the animation */
  36517. name: string;
  36518. /**Property to animate */
  36519. targetProperty: string;
  36520. /**The frames per second of the animation */
  36521. framePerSecond: number;
  36522. /**The data type of the animation */
  36523. dataType: number;
  36524. /**The loop mode of the animation */
  36525. loopMode?: number | undefined;
  36526. /**Specifies if blending should be enabled */
  36527. enableBlending?: boolean | undefined;
  36528. /**
  36529. * Use matrix interpolation instead of using direct key value when animating matrices
  36530. */
  36531. static AllowMatricesInterpolation: boolean;
  36532. /**
  36533. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36534. */
  36535. static AllowMatrixDecomposeForInterpolation: boolean;
  36536. /** Define the Url to load snippets */
  36537. static SnippetUrl: string;
  36538. /** Snippet ID if the animation was created from the snippet server */
  36539. snippetId: string;
  36540. /**
  36541. * Stores the key frames of the animation
  36542. */
  36543. private _keys;
  36544. /**
  36545. * Stores the easing function of the animation
  36546. */
  36547. private _easingFunction;
  36548. /**
  36549. * @hidden Internal use only
  36550. */
  36551. _runtimeAnimations: RuntimeAnimation[];
  36552. /**
  36553. * The set of event that will be linked to this animation
  36554. */
  36555. private _events;
  36556. /**
  36557. * Stores an array of target property paths
  36558. */
  36559. targetPropertyPath: string[];
  36560. /**
  36561. * Stores the blending speed of the animation
  36562. */
  36563. blendingSpeed: number;
  36564. /**
  36565. * Stores the animation ranges for the animation
  36566. */
  36567. private _ranges;
  36568. /**
  36569. * @hidden Internal use
  36570. */
  36571. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36572. /**
  36573. * Sets up an animation
  36574. * @param property The property to animate
  36575. * @param animationType The animation type to apply
  36576. * @param framePerSecond The frames per second of the animation
  36577. * @param easingFunction The easing function used in the animation
  36578. * @returns The created animation
  36579. */
  36580. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36581. /**
  36582. * Create and start an animation on a node
  36583. * @param name defines the name of the global animation that will be run on all nodes
  36584. * @param node defines the root node where the animation will take place
  36585. * @param targetProperty defines property to animate
  36586. * @param framePerSecond defines the number of frame per second yo use
  36587. * @param totalFrame defines the number of frames in total
  36588. * @param from defines the initial value
  36589. * @param to defines the final value
  36590. * @param loopMode defines which loop mode you want to use (off by default)
  36591. * @param easingFunction defines the easing function to use (linear by default)
  36592. * @param onAnimationEnd defines the callback to call when animation end
  36593. * @returns the animatable created for this animation
  36594. */
  36595. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36596. /**
  36597. * Create and start an animation on a node and its descendants
  36598. * @param name defines the name of the global animation that will be run on all nodes
  36599. * @param node defines the root node where the animation will take place
  36600. * @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
  36601. * @param targetProperty defines property to animate
  36602. * @param framePerSecond defines the number of frame per second to use
  36603. * @param totalFrame defines the number of frames in total
  36604. * @param from defines the initial value
  36605. * @param to defines the final value
  36606. * @param loopMode defines which loop mode you want to use (off by default)
  36607. * @param easingFunction defines the easing function to use (linear by default)
  36608. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36609. * @returns the list of animatables created for all nodes
  36610. * @example https://www.babylonjs-playground.com/#MH0VLI
  36611. */
  36612. 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[]>;
  36613. /**
  36614. * Creates a new animation, merges it with the existing animations and starts it
  36615. * @param name Name of the animation
  36616. * @param node Node which contains the scene that begins the animations
  36617. * @param targetProperty Specifies which property to animate
  36618. * @param framePerSecond The frames per second of the animation
  36619. * @param totalFrame The total number of frames
  36620. * @param from The frame at the beginning of the animation
  36621. * @param to The frame at the end of the animation
  36622. * @param loopMode Specifies the loop mode of the animation
  36623. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36624. * @param onAnimationEnd Callback to run once the animation is complete
  36625. * @returns Nullable animation
  36626. */
  36627. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36628. /**
  36629. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36630. * @param sourceAnimation defines the Animation containing keyframes to convert
  36631. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36632. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36633. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36634. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36635. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36636. */
  36637. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36638. /**
  36639. * Transition property of an host to the target Value
  36640. * @param property The property to transition
  36641. * @param targetValue The target Value of the property
  36642. * @param host The object where the property to animate belongs
  36643. * @param scene Scene used to run the animation
  36644. * @param frameRate Framerate (in frame/s) to use
  36645. * @param transition The transition type we want to use
  36646. * @param duration The duration of the animation, in milliseconds
  36647. * @param onAnimationEnd Callback trigger at the end of the animation
  36648. * @returns Nullable animation
  36649. */
  36650. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36651. /**
  36652. * Return the array of runtime animations currently using this animation
  36653. */
  36654. get runtimeAnimations(): RuntimeAnimation[];
  36655. /**
  36656. * Specifies if any of the runtime animations are currently running
  36657. */
  36658. get hasRunningRuntimeAnimations(): boolean;
  36659. /**
  36660. * Initializes the animation
  36661. * @param name Name of the animation
  36662. * @param targetProperty Property to animate
  36663. * @param framePerSecond The frames per second of the animation
  36664. * @param dataType The data type of the animation
  36665. * @param loopMode The loop mode of the animation
  36666. * @param enableBlending Specifies if blending should be enabled
  36667. */
  36668. constructor(
  36669. /**Name of the animation */
  36670. name: string,
  36671. /**Property to animate */
  36672. targetProperty: string,
  36673. /**The frames per second of the animation */
  36674. framePerSecond: number,
  36675. /**The data type of the animation */
  36676. dataType: number,
  36677. /**The loop mode of the animation */
  36678. loopMode?: number | undefined,
  36679. /**Specifies if blending should be enabled */
  36680. enableBlending?: boolean | undefined);
  36681. /**
  36682. * Converts the animation to a string
  36683. * @param fullDetails support for multiple levels of logging within scene loading
  36684. * @returns String form of the animation
  36685. */
  36686. toString(fullDetails?: boolean): string;
  36687. /**
  36688. * Add an event to this animation
  36689. * @param event Event to add
  36690. */
  36691. addEvent(event: AnimationEvent): void;
  36692. /**
  36693. * Remove all events found at the given frame
  36694. * @param frame The frame to remove events from
  36695. */
  36696. removeEvents(frame: number): void;
  36697. /**
  36698. * Retrieves all the events from the animation
  36699. * @returns Events from the animation
  36700. */
  36701. getEvents(): AnimationEvent[];
  36702. /**
  36703. * Creates an animation range
  36704. * @param name Name of the animation range
  36705. * @param from Starting frame of the animation range
  36706. * @param to Ending frame of the animation
  36707. */
  36708. createRange(name: string, from: number, to: number): void;
  36709. /**
  36710. * Deletes an animation range by name
  36711. * @param name Name of the animation range to delete
  36712. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36713. */
  36714. deleteRange(name: string, deleteFrames?: boolean): void;
  36715. /**
  36716. * Gets the animation range by name, or null if not defined
  36717. * @param name Name of the animation range
  36718. * @returns Nullable animation range
  36719. */
  36720. getRange(name: string): Nullable<AnimationRange>;
  36721. /**
  36722. * Gets the key frames from the animation
  36723. * @returns The key frames of the animation
  36724. */
  36725. getKeys(): Array<IAnimationKey>;
  36726. /**
  36727. * Gets the highest frame rate of the animation
  36728. * @returns Highest frame rate of the animation
  36729. */
  36730. getHighestFrame(): number;
  36731. /**
  36732. * Gets the easing function of the animation
  36733. * @returns Easing function of the animation
  36734. */
  36735. getEasingFunction(): IEasingFunction;
  36736. /**
  36737. * Sets the easing function of the animation
  36738. * @param easingFunction A custom mathematical formula for animation
  36739. */
  36740. setEasingFunction(easingFunction: EasingFunction): void;
  36741. /**
  36742. * Interpolates a scalar linearly
  36743. * @param startValue Start value of the animation curve
  36744. * @param endValue End value of the animation curve
  36745. * @param gradient Scalar amount to interpolate
  36746. * @returns Interpolated scalar value
  36747. */
  36748. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36749. /**
  36750. * Interpolates a scalar cubically
  36751. * @param startValue Start value of the animation curve
  36752. * @param outTangent End tangent of the animation
  36753. * @param endValue End value of the animation curve
  36754. * @param inTangent Start tangent of the animation curve
  36755. * @param gradient Scalar amount to interpolate
  36756. * @returns Interpolated scalar value
  36757. */
  36758. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36759. /**
  36760. * Interpolates a quaternion using a spherical linear interpolation
  36761. * @param startValue Start value of the animation curve
  36762. * @param endValue End value of the animation curve
  36763. * @param gradient Scalar amount to interpolate
  36764. * @returns Interpolated quaternion value
  36765. */
  36766. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36767. /**
  36768. * Interpolates a quaternion cubically
  36769. * @param startValue Start value of the animation curve
  36770. * @param outTangent End tangent of the animation curve
  36771. * @param endValue End value of the animation curve
  36772. * @param inTangent Start tangent of the animation curve
  36773. * @param gradient Scalar amount to interpolate
  36774. * @returns Interpolated quaternion value
  36775. */
  36776. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36777. /**
  36778. * Interpolates a Vector3 linearl
  36779. * @param startValue Start value of the animation curve
  36780. * @param endValue End value of the animation curve
  36781. * @param gradient Scalar amount to interpolate
  36782. * @returns Interpolated scalar value
  36783. */
  36784. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36785. /**
  36786. * Interpolates a Vector3 cubically
  36787. * @param startValue Start value of the animation curve
  36788. * @param outTangent End tangent of the animation
  36789. * @param endValue End value of the animation curve
  36790. * @param inTangent Start tangent of the animation curve
  36791. * @param gradient Scalar amount to interpolate
  36792. * @returns InterpolatedVector3 value
  36793. */
  36794. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36795. /**
  36796. * Interpolates a Vector2 linearly
  36797. * @param startValue Start value of the animation curve
  36798. * @param endValue End value of the animation curve
  36799. * @param gradient Scalar amount to interpolate
  36800. * @returns Interpolated Vector2 value
  36801. */
  36802. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36803. /**
  36804. * Interpolates a Vector2 cubically
  36805. * @param startValue Start value of the animation curve
  36806. * @param outTangent End tangent of the animation
  36807. * @param endValue End value of the animation curve
  36808. * @param inTangent Start tangent of the animation curve
  36809. * @param gradient Scalar amount to interpolate
  36810. * @returns Interpolated Vector2 value
  36811. */
  36812. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36813. /**
  36814. * Interpolates a size linearly
  36815. * @param startValue Start value of the animation curve
  36816. * @param endValue End value of the animation curve
  36817. * @param gradient Scalar amount to interpolate
  36818. * @returns Interpolated Size value
  36819. */
  36820. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36821. /**
  36822. * Interpolates a Color3 linearly
  36823. * @param startValue Start value of the animation curve
  36824. * @param endValue End value of the animation curve
  36825. * @param gradient Scalar amount to interpolate
  36826. * @returns Interpolated Color3 value
  36827. */
  36828. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36829. /**
  36830. * Interpolates a Color4 linearly
  36831. * @param startValue Start value of the animation curve
  36832. * @param endValue End value of the animation curve
  36833. * @param gradient Scalar amount to interpolate
  36834. * @returns Interpolated Color3 value
  36835. */
  36836. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36837. /**
  36838. * @hidden Internal use only
  36839. */
  36840. _getKeyValue(value: any): any;
  36841. /**
  36842. * @hidden Internal use only
  36843. */
  36844. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36845. /**
  36846. * Defines the function to use to interpolate matrices
  36847. * @param startValue defines the start matrix
  36848. * @param endValue defines the end matrix
  36849. * @param gradient defines the gradient between both matrices
  36850. * @param result defines an optional target matrix where to store the interpolation
  36851. * @returns the interpolated matrix
  36852. */
  36853. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36854. /**
  36855. * Makes a copy of the animation
  36856. * @returns Cloned animation
  36857. */
  36858. clone(): Animation;
  36859. /**
  36860. * Sets the key frames of the animation
  36861. * @param values The animation key frames to set
  36862. */
  36863. setKeys(values: Array<IAnimationKey>): void;
  36864. /**
  36865. * Serializes the animation to an object
  36866. * @returns Serialized object
  36867. */
  36868. serialize(): any;
  36869. /**
  36870. * Float animation type
  36871. */
  36872. static readonly ANIMATIONTYPE_FLOAT: number;
  36873. /**
  36874. * Vector3 animation type
  36875. */
  36876. static readonly ANIMATIONTYPE_VECTOR3: number;
  36877. /**
  36878. * Quaternion animation type
  36879. */
  36880. static readonly ANIMATIONTYPE_QUATERNION: number;
  36881. /**
  36882. * Matrix animation type
  36883. */
  36884. static readonly ANIMATIONTYPE_MATRIX: number;
  36885. /**
  36886. * Color3 animation type
  36887. */
  36888. static readonly ANIMATIONTYPE_COLOR3: number;
  36889. /**
  36890. * Color3 animation type
  36891. */
  36892. static readonly ANIMATIONTYPE_COLOR4: number;
  36893. /**
  36894. * Vector2 animation type
  36895. */
  36896. static readonly ANIMATIONTYPE_VECTOR2: number;
  36897. /**
  36898. * Size animation type
  36899. */
  36900. static readonly ANIMATIONTYPE_SIZE: number;
  36901. /**
  36902. * Relative Loop Mode
  36903. */
  36904. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36905. /**
  36906. * Cycle Loop Mode
  36907. */
  36908. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36909. /**
  36910. * Constant Loop Mode
  36911. */
  36912. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36913. /** @hidden */
  36914. static _UniversalLerp(left: any, right: any, amount: number): any;
  36915. /**
  36916. * Parses an animation object and creates an animation
  36917. * @param parsedAnimation Parsed animation object
  36918. * @returns Animation object
  36919. */
  36920. static Parse(parsedAnimation: any): Animation;
  36921. /**
  36922. * Appends the serialized animations from the source animations
  36923. * @param source Source containing the animations
  36924. * @param destination Target to store the animations
  36925. */
  36926. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36927. /**
  36928. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36929. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36930. * @param url defines the url to load from
  36931. * @returns a promise that will resolve to the new animation or an array of animations
  36932. */
  36933. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36934. /**
  36935. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36936. * @param snippetId defines the snippet to load
  36937. * @returns a promise that will resolve to the new animation or a new array of animations
  36938. */
  36939. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36940. }
  36941. }
  36942. declare module BABYLON {
  36943. /**
  36944. * Interface containing an array of animations
  36945. */
  36946. export interface IAnimatable {
  36947. /**
  36948. * Array of animations
  36949. */
  36950. animations: Nullable<Array<Animation>>;
  36951. }
  36952. }
  36953. declare module BABYLON {
  36954. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36955. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36956. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36957. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36958. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36959. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36960. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36961. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36962. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36963. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36964. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36965. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36966. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36967. /**
  36968. * Decorator used to define property that can be serialized as reference to a camera
  36969. * @param sourceName defines the name of the property to decorate
  36970. */
  36971. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36972. /**
  36973. * Class used to help serialization objects
  36974. */
  36975. export class SerializationHelper {
  36976. /** @hidden */
  36977. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36978. /** @hidden */
  36979. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36980. /** @hidden */
  36981. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36982. /** @hidden */
  36983. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36984. /**
  36985. * Appends the serialized animations from the source animations
  36986. * @param source Source containing the animations
  36987. * @param destination Target to store the animations
  36988. */
  36989. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36990. /**
  36991. * Static function used to serialized a specific entity
  36992. * @param entity defines the entity to serialize
  36993. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36994. * @returns a JSON compatible object representing the serialization of the entity
  36995. */
  36996. static Serialize<T>(entity: T, serializationObject?: any): any;
  36997. /**
  36998. * Creates a new entity from a serialization data object
  36999. * @param creationFunction defines a function used to instanciated the new entity
  37000. * @param source defines the source serialization data
  37001. * @param scene defines the hosting scene
  37002. * @param rootUrl defines the root url for resources
  37003. * @returns a new entity
  37004. */
  37005. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37006. /**
  37007. * Clones an object
  37008. * @param creationFunction defines the function used to instanciate the new object
  37009. * @param source defines the source object
  37010. * @returns the cloned object
  37011. */
  37012. static Clone<T>(creationFunction: () => T, source: T): T;
  37013. /**
  37014. * Instanciates a new object based on a source one (some data will be shared between both object)
  37015. * @param creationFunction defines the function used to instanciate the new object
  37016. * @param source defines the source object
  37017. * @returns the new object
  37018. */
  37019. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37020. }
  37021. }
  37022. declare module BABYLON {
  37023. /**
  37024. * This is the base class of all the camera used in the application.
  37025. * @see https://doc.babylonjs.com/features/cameras
  37026. */
  37027. export class Camera extends Node {
  37028. /** @hidden */
  37029. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37030. /**
  37031. * This is the default projection mode used by the cameras.
  37032. * It helps recreating a feeling of perspective and better appreciate depth.
  37033. * This is the best way to simulate real life cameras.
  37034. */
  37035. static readonly PERSPECTIVE_CAMERA: number;
  37036. /**
  37037. * This helps creating camera with an orthographic mode.
  37038. * 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.
  37039. */
  37040. static readonly ORTHOGRAPHIC_CAMERA: number;
  37041. /**
  37042. * This is the default FOV mode for perspective cameras.
  37043. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37044. */
  37045. static readonly FOVMODE_VERTICAL_FIXED: number;
  37046. /**
  37047. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37048. */
  37049. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37050. /**
  37051. * This specifies ther is no need for a camera rig.
  37052. * Basically only one eye is rendered corresponding to the camera.
  37053. */
  37054. static readonly RIG_MODE_NONE: number;
  37055. /**
  37056. * Simulates a camera Rig with one blue eye and one red eye.
  37057. * This can be use with 3d blue and red glasses.
  37058. */
  37059. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37060. /**
  37061. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37062. */
  37063. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37064. /**
  37065. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37066. */
  37067. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37068. /**
  37069. * Defines that both eyes of the camera will be rendered over under each other.
  37070. */
  37071. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37072. /**
  37073. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37074. */
  37075. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37076. /**
  37077. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37078. */
  37079. static readonly RIG_MODE_VR: number;
  37080. /**
  37081. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37082. */
  37083. static readonly RIG_MODE_WEBVR: number;
  37084. /**
  37085. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37086. */
  37087. static readonly RIG_MODE_CUSTOM: number;
  37088. /**
  37089. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37090. */
  37091. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37092. /**
  37093. * Define the input manager associated with the camera.
  37094. */
  37095. inputs: CameraInputsManager<Camera>;
  37096. /** @hidden */
  37097. _position: Vector3;
  37098. /**
  37099. * Define the current local position of the camera in the scene
  37100. */
  37101. get position(): Vector3;
  37102. set position(newPosition: Vector3);
  37103. protected _upVector: Vector3;
  37104. /**
  37105. * The vector the camera should consider as up.
  37106. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37107. */
  37108. set upVector(vec: Vector3);
  37109. get upVector(): Vector3;
  37110. /**
  37111. * Define the current limit on the left side for an orthographic camera
  37112. * In scene unit
  37113. */
  37114. orthoLeft: Nullable<number>;
  37115. /**
  37116. * Define the current limit on the right side for an orthographic camera
  37117. * In scene unit
  37118. */
  37119. orthoRight: Nullable<number>;
  37120. /**
  37121. * Define the current limit on the bottom side for an orthographic camera
  37122. * In scene unit
  37123. */
  37124. orthoBottom: Nullable<number>;
  37125. /**
  37126. * Define the current limit on the top side for an orthographic camera
  37127. * In scene unit
  37128. */
  37129. orthoTop: Nullable<number>;
  37130. /**
  37131. * Field Of View is set in Radians. (default is 0.8)
  37132. */
  37133. fov: number;
  37134. /**
  37135. * Define the minimum distance the camera can see from.
  37136. * This is important to note that the depth buffer are not infinite and the closer it starts
  37137. * the more your scene might encounter depth fighting issue.
  37138. */
  37139. minZ: number;
  37140. /**
  37141. * Define the maximum distance the camera can see to.
  37142. * This is important to note that the depth buffer are not infinite and the further it end
  37143. * the more your scene might encounter depth fighting issue.
  37144. */
  37145. maxZ: number;
  37146. /**
  37147. * Define the default inertia of the camera.
  37148. * This helps giving a smooth feeling to the camera movement.
  37149. */
  37150. inertia: number;
  37151. /**
  37152. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37153. */
  37154. mode: number;
  37155. /**
  37156. * Define whether the camera is intermediate.
  37157. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37158. */
  37159. isIntermediate: boolean;
  37160. /**
  37161. * Define the viewport of the camera.
  37162. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37163. */
  37164. viewport: Viewport;
  37165. /**
  37166. * Restricts the camera to viewing objects with the same layerMask.
  37167. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37168. */
  37169. layerMask: number;
  37170. /**
  37171. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37172. */
  37173. fovMode: number;
  37174. /**
  37175. * Rig mode of the camera.
  37176. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37177. * This is normally controlled byt the camera themselves as internal use.
  37178. */
  37179. cameraRigMode: number;
  37180. /**
  37181. * Defines the distance between both "eyes" in case of a RIG
  37182. */
  37183. interaxialDistance: number;
  37184. /**
  37185. * Defines if stereoscopic rendering is done side by side or over under.
  37186. */
  37187. isStereoscopicSideBySide: boolean;
  37188. /**
  37189. * 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
  37190. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37191. * else in the scene. (Eg. security camera)
  37192. *
  37193. * 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)
  37194. */
  37195. customRenderTargets: RenderTargetTexture[];
  37196. /**
  37197. * When set, the camera will render to this render target instead of the default canvas
  37198. *
  37199. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37200. */
  37201. outputRenderTarget: Nullable<RenderTargetTexture>;
  37202. /**
  37203. * Observable triggered when the camera view matrix has changed.
  37204. */
  37205. onViewMatrixChangedObservable: Observable<Camera>;
  37206. /**
  37207. * Observable triggered when the camera Projection matrix has changed.
  37208. */
  37209. onProjectionMatrixChangedObservable: Observable<Camera>;
  37210. /**
  37211. * Observable triggered when the inputs have been processed.
  37212. */
  37213. onAfterCheckInputsObservable: Observable<Camera>;
  37214. /**
  37215. * Observable triggered when reset has been called and applied to the camera.
  37216. */
  37217. onRestoreStateObservable: Observable<Camera>;
  37218. /**
  37219. * Is this camera a part of a rig system?
  37220. */
  37221. isRigCamera: boolean;
  37222. /**
  37223. * If isRigCamera set to true this will be set with the parent camera.
  37224. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37225. */
  37226. rigParent?: Camera;
  37227. /** @hidden */
  37228. _cameraRigParams: any;
  37229. /** @hidden */
  37230. _rigCameras: Camera[];
  37231. /** @hidden */
  37232. _rigPostProcess: Nullable<PostProcess>;
  37233. protected _webvrViewMatrix: Matrix;
  37234. /** @hidden */
  37235. _skipRendering: boolean;
  37236. /** @hidden */
  37237. _projectionMatrix: Matrix;
  37238. /** @hidden */
  37239. _postProcesses: Nullable<PostProcess>[];
  37240. /** @hidden */
  37241. _activeMeshes: SmartArray<AbstractMesh>;
  37242. protected _globalPosition: Vector3;
  37243. /** @hidden */
  37244. _computedViewMatrix: Matrix;
  37245. private _doNotComputeProjectionMatrix;
  37246. private _transformMatrix;
  37247. private _frustumPlanes;
  37248. private _refreshFrustumPlanes;
  37249. private _storedFov;
  37250. private _stateStored;
  37251. /**
  37252. * Instantiates a new camera object.
  37253. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37254. * @see https://doc.babylonjs.com/features/cameras
  37255. * @param name Defines the name of the camera in the scene
  37256. * @param position Defines the position of the camera
  37257. * @param scene Defines the scene the camera belongs too
  37258. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37259. */
  37260. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37261. /**
  37262. * Store current camera state (fov, position, etc..)
  37263. * @returns the camera
  37264. */
  37265. storeState(): Camera;
  37266. /**
  37267. * Restores the camera state values if it has been stored. You must call storeState() first
  37268. */
  37269. protected _restoreStateValues(): boolean;
  37270. /**
  37271. * Restored camera state. You must call storeState() first.
  37272. * @returns true if restored and false otherwise
  37273. */
  37274. restoreState(): boolean;
  37275. /**
  37276. * Gets the class name of the camera.
  37277. * @returns the class name
  37278. */
  37279. getClassName(): string;
  37280. /** @hidden */
  37281. readonly _isCamera: boolean;
  37282. /**
  37283. * Gets a string representation of the camera useful for debug purpose.
  37284. * @param fullDetails Defines that a more verboe level of logging is required
  37285. * @returns the string representation
  37286. */
  37287. toString(fullDetails?: boolean): string;
  37288. /**
  37289. * Gets the current world space position of the camera.
  37290. */
  37291. get globalPosition(): Vector3;
  37292. /**
  37293. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  37294. * @returns the active meshe list
  37295. */
  37296. getActiveMeshes(): SmartArray<AbstractMesh>;
  37297. /**
  37298. * Check whether a mesh is part of the current active mesh list of the camera
  37299. * @param mesh Defines the mesh to check
  37300. * @returns true if active, false otherwise
  37301. */
  37302. isActiveMesh(mesh: Mesh): boolean;
  37303. /**
  37304. * Is this camera ready to be used/rendered
  37305. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  37306. * @return true if the camera is ready
  37307. */
  37308. isReady(completeCheck?: boolean): boolean;
  37309. /** @hidden */
  37310. _initCache(): void;
  37311. /** @hidden */
  37312. _updateCache(ignoreParentClass?: boolean): void;
  37313. /** @hidden */
  37314. _isSynchronized(): boolean;
  37315. /** @hidden */
  37316. _isSynchronizedViewMatrix(): boolean;
  37317. /** @hidden */
  37318. _isSynchronizedProjectionMatrix(): boolean;
  37319. /**
  37320. * Attach the input controls to a specific dom element to get the input from.
  37321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37322. */
  37323. attachControl(noPreventDefault?: boolean): void;
  37324. /**
  37325. * Attach the input controls to a specific dom element to get the input from.
  37326. * @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
  37327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37328. * BACK COMPAT SIGNATURE ONLY.
  37329. */
  37330. attachControl(ignored: any, noPreventDefault?: boolean): void;
  37331. /**
  37332. * Detach the current controls from the specified dom element.
  37333. */
  37334. detachControl(): void;
  37335. /**
  37336. * Detach the current controls from the specified dom element.
  37337. * @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
  37338. */
  37339. detachControl(ignored: any): void;
  37340. /**
  37341. * Update the camera state according to the different inputs gathered during the frame.
  37342. */
  37343. update(): void;
  37344. /** @hidden */
  37345. _checkInputs(): void;
  37346. /** @hidden */
  37347. get rigCameras(): Camera[];
  37348. /**
  37349. * Gets the post process used by the rig cameras
  37350. */
  37351. get rigPostProcess(): Nullable<PostProcess>;
  37352. /**
  37353. * Internal, gets the first post proces.
  37354. * @returns the first post process to be run on this camera.
  37355. */
  37356. _getFirstPostProcess(): Nullable<PostProcess>;
  37357. private _cascadePostProcessesToRigCams;
  37358. /**
  37359. * Attach a post process to the camera.
  37360. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37361. * @param postProcess The post process to attach to the camera
  37362. * @param insertAt The position of the post process in case several of them are in use in the scene
  37363. * @returns the position the post process has been inserted at
  37364. */
  37365. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  37366. /**
  37367. * Detach a post process to the camera.
  37368. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  37369. * @param postProcess The post process to detach from the camera
  37370. */
  37371. detachPostProcess(postProcess: PostProcess): void;
  37372. /**
  37373. * Gets the current world matrix of the camera
  37374. */
  37375. getWorldMatrix(): Matrix;
  37376. /** @hidden */
  37377. _getViewMatrix(): Matrix;
  37378. /**
  37379. * Gets the current view matrix of the camera.
  37380. * @param force forces the camera to recompute the matrix without looking at the cached state
  37381. * @returns the view matrix
  37382. */
  37383. getViewMatrix(force?: boolean): Matrix;
  37384. /**
  37385. * Freeze the projection matrix.
  37386. * It will prevent the cache check of the camera projection compute and can speed up perf
  37387. * if no parameter of the camera are meant to change
  37388. * @param projection Defines manually a projection if necessary
  37389. */
  37390. freezeProjectionMatrix(projection?: Matrix): void;
  37391. /**
  37392. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  37393. */
  37394. unfreezeProjectionMatrix(): void;
  37395. /**
  37396. * Gets the current projection matrix of the camera.
  37397. * @param force forces the camera to recompute the matrix without looking at the cached state
  37398. * @returns the projection matrix
  37399. */
  37400. getProjectionMatrix(force?: boolean): Matrix;
  37401. /**
  37402. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  37403. * @returns a Matrix
  37404. */
  37405. getTransformationMatrix(): Matrix;
  37406. private _updateFrustumPlanes;
  37407. /**
  37408. * Checks if a cullable object (mesh...) is in the camera frustum
  37409. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  37410. * @param target The object to check
  37411. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  37412. * @returns true if the object is in frustum otherwise false
  37413. */
  37414. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  37415. /**
  37416. * Checks if a cullable object (mesh...) is in the camera frustum
  37417. * Unlike isInFrustum this cheks the full bounding box
  37418. * @param target The object to check
  37419. * @returns true if the object is in frustum otherwise false
  37420. */
  37421. isCompletelyInFrustum(target: ICullable): boolean;
  37422. /**
  37423. * Gets a ray in the forward direction from the camera.
  37424. * @param length Defines the length of the ray to create
  37425. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37426. * @param origin Defines the start point of the ray which defaults to the camera position
  37427. * @returns the forward ray
  37428. */
  37429. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37430. /**
  37431. * Gets a ray in the forward direction from the camera.
  37432. * @param refRay the ray to (re)use when setting the values
  37433. * @param length Defines the length of the ray to create
  37434. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  37435. * @param origin Defines the start point of the ray which defaults to the camera position
  37436. * @returns the forward ray
  37437. */
  37438. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  37439. /**
  37440. * Releases resources associated with this node.
  37441. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37442. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37443. */
  37444. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37445. /** @hidden */
  37446. _isLeftCamera: boolean;
  37447. /**
  37448. * Gets the left camera of a rig setup in case of Rigged Camera
  37449. */
  37450. get isLeftCamera(): boolean;
  37451. /** @hidden */
  37452. _isRightCamera: boolean;
  37453. /**
  37454. * Gets the right camera of a rig setup in case of Rigged Camera
  37455. */
  37456. get isRightCamera(): boolean;
  37457. /**
  37458. * Gets the left camera of a rig setup in case of Rigged Camera
  37459. */
  37460. get leftCamera(): Nullable<FreeCamera>;
  37461. /**
  37462. * Gets the right camera of a rig setup in case of Rigged Camera
  37463. */
  37464. get rightCamera(): Nullable<FreeCamera>;
  37465. /**
  37466. * Gets the left camera target of a rig setup in case of Rigged Camera
  37467. * @returns the target position
  37468. */
  37469. getLeftTarget(): Nullable<Vector3>;
  37470. /**
  37471. * Gets the right camera target of a rig setup in case of Rigged Camera
  37472. * @returns the target position
  37473. */
  37474. getRightTarget(): Nullable<Vector3>;
  37475. /**
  37476. * @hidden
  37477. */
  37478. setCameraRigMode(mode: number, rigParams: any): void;
  37479. /** @hidden */
  37480. static _setStereoscopicRigMode(camera: Camera): void;
  37481. /** @hidden */
  37482. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  37483. /** @hidden */
  37484. static _setVRRigMode(camera: Camera, rigParams: any): void;
  37485. /** @hidden */
  37486. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  37487. /** @hidden */
  37488. _getVRProjectionMatrix(): Matrix;
  37489. protected _updateCameraRotationMatrix(): void;
  37490. protected _updateWebVRCameraRotationMatrix(): void;
  37491. /**
  37492. * This function MUST be overwritten by the different WebVR cameras available.
  37493. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37494. * @hidden
  37495. */
  37496. _getWebVRProjectionMatrix(): Matrix;
  37497. /**
  37498. * This function MUST be overwritten by the different WebVR cameras available.
  37499. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  37500. * @hidden
  37501. */
  37502. _getWebVRViewMatrix(): Matrix;
  37503. /** @hidden */
  37504. setCameraRigParameter(name: string, value: any): void;
  37505. /**
  37506. * needs to be overridden by children so sub has required properties to be copied
  37507. * @hidden
  37508. */
  37509. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  37510. /**
  37511. * May need to be overridden by children
  37512. * @hidden
  37513. */
  37514. _updateRigCameras(): void;
  37515. /** @hidden */
  37516. _setupInputs(): void;
  37517. /**
  37518. * Serialiaze the camera setup to a json represention
  37519. * @returns the JSON representation
  37520. */
  37521. serialize(): any;
  37522. /**
  37523. * Clones the current camera.
  37524. * @param name The cloned camera name
  37525. * @returns the cloned camera
  37526. */
  37527. clone(name: string): Camera;
  37528. /**
  37529. * Gets the direction of the camera relative to a given local axis.
  37530. * @param localAxis Defines the reference axis to provide a relative direction.
  37531. * @return the direction
  37532. */
  37533. getDirection(localAxis: Vector3): Vector3;
  37534. /**
  37535. * Returns the current camera absolute rotation
  37536. */
  37537. get absoluteRotation(): Quaternion;
  37538. /**
  37539. * Gets the direction of the camera relative to a given local axis into a passed vector.
  37540. * @param localAxis Defines the reference axis to provide a relative direction.
  37541. * @param result Defines the vector to store the result in
  37542. */
  37543. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  37544. /**
  37545. * Gets a camera constructor for a given camera type
  37546. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  37547. * @param name The name of the camera the result will be able to instantiate
  37548. * @param scene The scene the result will construct the camera in
  37549. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  37550. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  37551. * @returns a factory method to construc the camera
  37552. */
  37553. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  37554. /**
  37555. * Compute the world matrix of the camera.
  37556. * @returns the camera world matrix
  37557. */
  37558. computeWorldMatrix(): Matrix;
  37559. /**
  37560. * Parse a JSON and creates the camera from the parsed information
  37561. * @param parsedCamera The JSON to parse
  37562. * @param scene The scene to instantiate the camera in
  37563. * @returns the newly constructed camera
  37564. */
  37565. static Parse(parsedCamera: any, scene: Scene): Camera;
  37566. }
  37567. }
  37568. declare module BABYLON {
  37569. /**
  37570. * PostProcessManager is used to manage one or more post processes or post process pipelines
  37571. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  37572. */
  37573. export class PostProcessManager {
  37574. private _scene;
  37575. private _indexBuffer;
  37576. private _vertexBuffers;
  37577. /**
  37578. * Creates a new instance PostProcess
  37579. * @param scene The scene that the post process is associated with.
  37580. */
  37581. constructor(scene: Scene);
  37582. private _prepareBuffers;
  37583. private _buildIndexBuffer;
  37584. /**
  37585. * Rebuilds the vertex buffers of the manager.
  37586. * @hidden
  37587. */
  37588. _rebuild(): void;
  37589. /**
  37590. * Prepares a frame to be run through a post process.
  37591. * @param sourceTexture The input texture to the post procesess. (default: null)
  37592. * @param postProcesses An array of post processes to be run. (default: null)
  37593. * @returns True if the post processes were able to be run.
  37594. * @hidden
  37595. */
  37596. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  37597. /**
  37598. * Manually render a set of post processes to a texture.
  37599. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  37600. * @param postProcesses An array of post processes to be run.
  37601. * @param targetTexture The target texture to render to.
  37602. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  37603. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  37604. * @param lodLevel defines which lod of the texture to render to
  37605. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  37606. */
  37607. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  37608. /**
  37609. * Finalize the result of the output of the postprocesses.
  37610. * @param doNotPresent If true the result will not be displayed to the screen.
  37611. * @param targetTexture The target texture to render to.
  37612. * @param faceIndex The index of the face to bind the target texture to.
  37613. * @param postProcesses The array of post processes to render.
  37614. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  37615. * @hidden
  37616. */
  37617. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  37618. /**
  37619. * Disposes of the post process manager.
  37620. */
  37621. dispose(): void;
  37622. }
  37623. }
  37624. declare module BABYLON {
  37625. /**
  37626. * This Helps creating a texture that will be created from a camera in your scene.
  37627. * It is basically a dynamic texture that could be used to create special effects for instance.
  37628. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  37629. */
  37630. export class RenderTargetTexture extends Texture {
  37631. /**
  37632. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  37633. */
  37634. static readonly REFRESHRATE_RENDER_ONCE: number;
  37635. /**
  37636. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  37637. */
  37638. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  37639. /**
  37640. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  37641. * the central point of your effect and can save a lot of performances.
  37642. */
  37643. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  37644. /**
  37645. * Use this predicate to dynamically define the list of mesh you want to render.
  37646. * If set, the renderList property will be overwritten.
  37647. */
  37648. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  37649. private _renderList;
  37650. /**
  37651. * Use this list to define the list of mesh you want to render.
  37652. */
  37653. get renderList(): Nullable<Array<AbstractMesh>>;
  37654. set renderList(value: Nullable<Array<AbstractMesh>>);
  37655. /**
  37656. * Use this function to overload the renderList array at rendering time.
  37657. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  37658. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  37659. * the cube (if the RTT is a cube, else layerOrFace=0).
  37660. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  37661. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  37662. * hold dummy elements!
  37663. */
  37664. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  37665. private _hookArray;
  37666. /**
  37667. * Define if particles should be rendered in your texture.
  37668. */
  37669. renderParticles: boolean;
  37670. /**
  37671. * Define if sprites should be rendered in your texture.
  37672. */
  37673. renderSprites: boolean;
  37674. /**
  37675. * Define the camera used to render the texture.
  37676. */
  37677. activeCamera: Nullable<Camera>;
  37678. /**
  37679. * Override the mesh isReady function with your own one.
  37680. */
  37681. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  37682. /**
  37683. * Override the render function of the texture with your own one.
  37684. */
  37685. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  37686. /**
  37687. * Define if camera post processes should be use while rendering the texture.
  37688. */
  37689. useCameraPostProcesses: boolean;
  37690. /**
  37691. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  37692. */
  37693. ignoreCameraViewport: boolean;
  37694. private _postProcessManager;
  37695. private _postProcesses;
  37696. private _resizeObserver;
  37697. /**
  37698. * An event triggered when the texture is unbind.
  37699. */
  37700. onBeforeBindObservable: Observable<RenderTargetTexture>;
  37701. /**
  37702. * An event triggered when the texture is unbind.
  37703. */
  37704. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  37705. private _onAfterUnbindObserver;
  37706. /**
  37707. * Set a after unbind callback in the texture.
  37708. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  37709. */
  37710. set onAfterUnbind(callback: () => void);
  37711. /**
  37712. * An event triggered before rendering the texture
  37713. */
  37714. onBeforeRenderObservable: Observable<number>;
  37715. private _onBeforeRenderObserver;
  37716. /**
  37717. * Set a before render callback in the texture.
  37718. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  37719. */
  37720. set onBeforeRender(callback: (faceIndex: number) => void);
  37721. /**
  37722. * An event triggered after rendering the texture
  37723. */
  37724. onAfterRenderObservable: Observable<number>;
  37725. private _onAfterRenderObserver;
  37726. /**
  37727. * Set a after render callback in the texture.
  37728. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  37729. */
  37730. set onAfterRender(callback: (faceIndex: number) => void);
  37731. /**
  37732. * An event triggered after the texture clear
  37733. */
  37734. onClearObservable: Observable<Engine>;
  37735. private _onClearObserver;
  37736. /**
  37737. * Set a clear callback in the texture.
  37738. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  37739. */
  37740. set onClear(callback: (Engine: Engine) => void);
  37741. /**
  37742. * An event triggered when the texture is resized.
  37743. */
  37744. onResizeObservable: Observable<RenderTargetTexture>;
  37745. /**
  37746. * Define the clear color of the Render Target if it should be different from the scene.
  37747. */
  37748. clearColor: Color4;
  37749. protected _size: number | {
  37750. width: number;
  37751. height: number;
  37752. layers?: number;
  37753. };
  37754. protected _initialSizeParameter: number | {
  37755. width: number;
  37756. height: number;
  37757. } | {
  37758. ratio: number;
  37759. };
  37760. protected _sizeRatio: Nullable<number>;
  37761. /** @hidden */
  37762. _generateMipMaps: boolean;
  37763. protected _renderingManager: RenderingManager;
  37764. /** @hidden */
  37765. _waitingRenderList?: string[];
  37766. protected _doNotChangeAspectRatio: boolean;
  37767. protected _currentRefreshId: number;
  37768. protected _refreshRate: number;
  37769. protected _textureMatrix: Matrix;
  37770. protected _samples: number;
  37771. protected _renderTargetOptions: RenderTargetCreationOptions;
  37772. /**
  37773. * Gets render target creation options that were used.
  37774. */
  37775. get renderTargetOptions(): RenderTargetCreationOptions;
  37776. protected _onRatioRescale(): void;
  37777. /**
  37778. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  37779. * It must define where the camera used to render the texture is set
  37780. */
  37781. boundingBoxPosition: Vector3;
  37782. private _boundingBoxSize;
  37783. /**
  37784. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  37785. * When defined, the cubemap will switch to local mode
  37786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  37787. * @example https://www.babylonjs-playground.com/#RNASML
  37788. */
  37789. set boundingBoxSize(value: Vector3);
  37790. get boundingBoxSize(): Vector3;
  37791. /**
  37792. * In case the RTT has been created with a depth texture, get the associated
  37793. * depth texture.
  37794. * Otherwise, return null.
  37795. */
  37796. get depthStencilTexture(): Nullable<InternalTexture>;
  37797. /**
  37798. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  37799. * or used a shadow, depth texture...
  37800. * @param name The friendly name of the texture
  37801. * @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)
  37802. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  37803. * @param generateMipMaps True if mip maps need to be generated after render.
  37804. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  37805. * @param type The type of the buffer in the RTT (int, half float, float...)
  37806. * @param isCube True if a cube texture needs to be created
  37807. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  37808. * @param generateDepthBuffer True to generate a depth buffer
  37809. * @param generateStencilBuffer True to generate a stencil buffer
  37810. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  37811. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  37812. * @param delayAllocation if the texture allocation should be delayed (default: false)
  37813. */
  37814. constructor(name: string, size: number | {
  37815. width: number;
  37816. height: number;
  37817. layers?: number;
  37818. } | {
  37819. ratio: number;
  37820. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  37821. /**
  37822. * Creates a depth stencil texture.
  37823. * This is only available in WebGL 2 or with the depth texture extension available.
  37824. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  37825. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  37826. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  37827. */
  37828. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  37829. private _processSizeParameter;
  37830. /**
  37831. * Define the number of samples to use in case of MSAA.
  37832. * It defaults to one meaning no MSAA has been enabled.
  37833. */
  37834. get samples(): number;
  37835. set samples(value: number);
  37836. /**
  37837. * Resets the refresh counter of the texture and start bak from scratch.
  37838. * Could be useful to regenerate the texture if it is setup to render only once.
  37839. */
  37840. resetRefreshCounter(): void;
  37841. /**
  37842. * Define the refresh rate of the texture or the rendering frequency.
  37843. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  37844. */
  37845. get refreshRate(): number;
  37846. set refreshRate(value: number);
  37847. /**
  37848. * Adds a post process to the render target rendering passes.
  37849. * @param postProcess define the post process to add
  37850. */
  37851. addPostProcess(postProcess: PostProcess): void;
  37852. /**
  37853. * Clear all the post processes attached to the render target
  37854. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  37855. */
  37856. clearPostProcesses(dispose?: boolean): void;
  37857. /**
  37858. * Remove one of the post process from the list of attached post processes to the texture
  37859. * @param postProcess define the post process to remove from the list
  37860. */
  37861. removePostProcess(postProcess: PostProcess): void;
  37862. /** @hidden */
  37863. _shouldRender(): boolean;
  37864. /**
  37865. * Gets the actual render size of the texture.
  37866. * @returns the width of the render size
  37867. */
  37868. getRenderSize(): number;
  37869. /**
  37870. * Gets the actual render width of the texture.
  37871. * @returns the width of the render size
  37872. */
  37873. getRenderWidth(): number;
  37874. /**
  37875. * Gets the actual render height of the texture.
  37876. * @returns the height of the render size
  37877. */
  37878. getRenderHeight(): number;
  37879. /**
  37880. * Gets the actual number of layers of the texture.
  37881. * @returns the number of layers
  37882. */
  37883. getRenderLayers(): number;
  37884. /**
  37885. * Get if the texture can be rescaled or not.
  37886. */
  37887. get canRescale(): boolean;
  37888. /**
  37889. * Resize the texture using a ratio.
  37890. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  37891. */
  37892. scale(ratio: number): void;
  37893. /**
  37894. * Get the texture reflection matrix used to rotate/transform the reflection.
  37895. * @returns the reflection matrix
  37896. */
  37897. getReflectionTextureMatrix(): Matrix;
  37898. /**
  37899. * Resize the texture to a new desired size.
  37900. * Be carrefull as it will recreate all the data in the new texture.
  37901. * @param size Define the new size. It can be:
  37902. * - a number for squared texture,
  37903. * - an object containing { width: number, height: number }
  37904. * - or an object containing a ratio { ratio: number }
  37905. */
  37906. resize(size: number | {
  37907. width: number;
  37908. height: number;
  37909. } | {
  37910. ratio: number;
  37911. }): void;
  37912. private _defaultRenderListPrepared;
  37913. /**
  37914. * Renders all the objects from the render list into the texture.
  37915. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  37916. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  37917. */
  37918. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  37919. private _bestReflectionRenderTargetDimension;
  37920. private _prepareRenderingManager;
  37921. /**
  37922. * @hidden
  37923. * @param faceIndex face index to bind to if this is a cubetexture
  37924. * @param layer defines the index of the texture to bind in the array
  37925. */
  37926. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  37927. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  37928. private renderToTarget;
  37929. /**
  37930. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37931. * This allowed control for front to back rendering or reversly depending of the special needs.
  37932. *
  37933. * @param renderingGroupId The rendering group id corresponding to its index
  37934. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37935. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37936. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37937. */
  37938. 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;
  37939. /**
  37940. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37941. *
  37942. * @param renderingGroupId The rendering group id corresponding to its index
  37943. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37944. */
  37945. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  37946. /**
  37947. * Clones the texture.
  37948. * @returns the cloned texture
  37949. */
  37950. clone(): RenderTargetTexture;
  37951. /**
  37952. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  37953. * @returns The JSON representation of the texture
  37954. */
  37955. serialize(): any;
  37956. /**
  37957. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  37958. */
  37959. disposeFramebufferObjects(): void;
  37960. /**
  37961. * Dispose the texture and release its associated resources.
  37962. */
  37963. dispose(): void;
  37964. /** @hidden */
  37965. _rebuild(): void;
  37966. /**
  37967. * Clear the info related to rendering groups preventing retention point in material dispose.
  37968. */
  37969. freeRenderingGroups(): void;
  37970. /**
  37971. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  37972. * @returns the view count
  37973. */
  37974. getViewCount(): number;
  37975. }
  37976. }
  37977. declare module BABYLON {
  37978. /**
  37979. * Options to be used when creating an effect.
  37980. */
  37981. export interface IEffectCreationOptions {
  37982. /**
  37983. * Atrributes that will be used in the shader.
  37984. */
  37985. attributes: string[];
  37986. /**
  37987. * Uniform varible names that will be set in the shader.
  37988. */
  37989. uniformsNames: string[];
  37990. /**
  37991. * Uniform buffer variable names that will be set in the shader.
  37992. */
  37993. uniformBuffersNames: string[];
  37994. /**
  37995. * Sampler texture variable names that will be set in the shader.
  37996. */
  37997. samplers: string[];
  37998. /**
  37999. * Define statements that will be set in the shader.
  38000. */
  38001. defines: any;
  38002. /**
  38003. * Possible fallbacks for this effect to improve performance when needed.
  38004. */
  38005. fallbacks: Nullable<IEffectFallbacks>;
  38006. /**
  38007. * Callback that will be called when the shader is compiled.
  38008. */
  38009. onCompiled: Nullable<(effect: Effect) => void>;
  38010. /**
  38011. * Callback that will be called if an error occurs during shader compilation.
  38012. */
  38013. onError: Nullable<(effect: Effect, errors: string) => void>;
  38014. /**
  38015. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38016. */
  38017. indexParameters?: any;
  38018. /**
  38019. * Max number of lights that can be used in the shader.
  38020. */
  38021. maxSimultaneousLights?: number;
  38022. /**
  38023. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38024. */
  38025. transformFeedbackVaryings?: Nullable<string[]>;
  38026. /**
  38027. * 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
  38028. */
  38029. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38030. /**
  38031. * Is this effect rendering to several color attachments ?
  38032. */
  38033. multiTarget?: boolean;
  38034. }
  38035. /**
  38036. * Effect containing vertex and fragment shader that can be executed on an object.
  38037. */
  38038. export class Effect implements IDisposable {
  38039. /**
  38040. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38041. */
  38042. static ShadersRepository: string;
  38043. /**
  38044. * Enable logging of the shader code when a compilation error occurs
  38045. */
  38046. static LogShaderCodeOnCompilationError: boolean;
  38047. /**
  38048. * Name of the effect.
  38049. */
  38050. name: any;
  38051. /**
  38052. * String container all the define statements that should be set on the shader.
  38053. */
  38054. defines: string;
  38055. /**
  38056. * Callback that will be called when the shader is compiled.
  38057. */
  38058. onCompiled: Nullable<(effect: Effect) => void>;
  38059. /**
  38060. * Callback that will be called if an error occurs during shader compilation.
  38061. */
  38062. onError: Nullable<(effect: Effect, errors: string) => void>;
  38063. /**
  38064. * Callback that will be called when effect is bound.
  38065. */
  38066. onBind: Nullable<(effect: Effect) => void>;
  38067. /**
  38068. * Unique ID of the effect.
  38069. */
  38070. uniqueId: number;
  38071. /**
  38072. * Observable that will be called when the shader is compiled.
  38073. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38074. */
  38075. onCompileObservable: Observable<Effect>;
  38076. /**
  38077. * Observable that will be called if an error occurs during shader compilation.
  38078. */
  38079. onErrorObservable: Observable<Effect>;
  38080. /** @hidden */
  38081. _onBindObservable: Nullable<Observable<Effect>>;
  38082. /**
  38083. * @hidden
  38084. * Specifies if the effect was previously ready
  38085. */
  38086. _wasPreviouslyReady: boolean;
  38087. /**
  38088. * Observable that will be called when effect is bound.
  38089. */
  38090. get onBindObservable(): Observable<Effect>;
  38091. /** @hidden */
  38092. _bonesComputationForcedToCPU: boolean;
  38093. /** @hidden */
  38094. _multiTarget: boolean;
  38095. private static _uniqueIdSeed;
  38096. private _engine;
  38097. private _uniformBuffersNames;
  38098. private _uniformBuffersNamesList;
  38099. private _uniformsNames;
  38100. private _samplerList;
  38101. private _samplers;
  38102. private _isReady;
  38103. private _compilationError;
  38104. private _allFallbacksProcessed;
  38105. private _attributesNames;
  38106. private _attributes;
  38107. private _attributeLocationByName;
  38108. private _uniforms;
  38109. /**
  38110. * Key for the effect.
  38111. * @hidden
  38112. */
  38113. _key: string;
  38114. private _indexParameters;
  38115. private _fallbacks;
  38116. private _vertexSourceCode;
  38117. private _fragmentSourceCode;
  38118. private _vertexSourceCodeOverride;
  38119. private _fragmentSourceCodeOverride;
  38120. private _transformFeedbackVaryings;
  38121. private _rawVertexSourceCode;
  38122. private _rawFragmentSourceCode;
  38123. /**
  38124. * Compiled shader to webGL program.
  38125. * @hidden
  38126. */
  38127. _pipelineContext: Nullable<IPipelineContext>;
  38128. private _valueCache;
  38129. private static _baseCache;
  38130. /**
  38131. * Instantiates an effect.
  38132. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38133. * @param baseName Name of the effect.
  38134. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38135. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38136. * @param samplers List of sampler variables that will be passed to the shader.
  38137. * @param engine Engine to be used to render the effect
  38138. * @param defines Define statements to be added to the shader.
  38139. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38140. * @param onCompiled Callback that will be called when the shader is compiled.
  38141. * @param onError Callback that will be called if an error occurs during shader compilation.
  38142. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38143. */
  38144. 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);
  38145. private _useFinalCode;
  38146. /**
  38147. * Unique key for this effect
  38148. */
  38149. get key(): string;
  38150. /**
  38151. * If the effect has been compiled and prepared.
  38152. * @returns if the effect is compiled and prepared.
  38153. */
  38154. isReady(): boolean;
  38155. private _isReadyInternal;
  38156. /**
  38157. * The engine the effect was initialized with.
  38158. * @returns the engine.
  38159. */
  38160. getEngine(): Engine;
  38161. /**
  38162. * The pipeline context for this effect
  38163. * @returns the associated pipeline context
  38164. */
  38165. getPipelineContext(): Nullable<IPipelineContext>;
  38166. /**
  38167. * The set of names of attribute variables for the shader.
  38168. * @returns An array of attribute names.
  38169. */
  38170. getAttributesNames(): string[];
  38171. /**
  38172. * Returns the attribute at the given index.
  38173. * @param index The index of the attribute.
  38174. * @returns The location of the attribute.
  38175. */
  38176. getAttributeLocation(index: number): number;
  38177. /**
  38178. * Returns the attribute based on the name of the variable.
  38179. * @param name of the attribute to look up.
  38180. * @returns the attribute location.
  38181. */
  38182. getAttributeLocationByName(name: string): number;
  38183. /**
  38184. * The number of attributes.
  38185. * @returns the numnber of attributes.
  38186. */
  38187. getAttributesCount(): number;
  38188. /**
  38189. * Gets the index of a uniform variable.
  38190. * @param uniformName of the uniform to look up.
  38191. * @returns the index.
  38192. */
  38193. getUniformIndex(uniformName: string): number;
  38194. /**
  38195. * Returns the attribute based on the name of the variable.
  38196. * @param uniformName of the uniform to look up.
  38197. * @returns the location of the uniform.
  38198. */
  38199. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38200. /**
  38201. * Returns an array of sampler variable names
  38202. * @returns The array of sampler variable names.
  38203. */
  38204. getSamplers(): string[];
  38205. /**
  38206. * Returns an array of uniform variable names
  38207. * @returns The array of uniform variable names.
  38208. */
  38209. getUniformNames(): string[];
  38210. /**
  38211. * Returns an array of uniform buffer variable names
  38212. * @returns The array of uniform buffer variable names.
  38213. */
  38214. getUniformBuffersNames(): string[];
  38215. /**
  38216. * Returns the index parameters used to create the effect
  38217. * @returns The index parameters object
  38218. */
  38219. getIndexParameters(): any;
  38220. /**
  38221. * The error from the last compilation.
  38222. * @returns the error string.
  38223. */
  38224. getCompilationError(): string;
  38225. /**
  38226. * Gets a boolean indicating that all fallbacks were used during compilation
  38227. * @returns true if all fallbacks were used
  38228. */
  38229. allFallbacksProcessed(): boolean;
  38230. /**
  38231. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38232. * @param func The callback to be used.
  38233. */
  38234. executeWhenCompiled(func: (effect: Effect) => void): void;
  38235. private _checkIsReady;
  38236. private _loadShader;
  38237. /**
  38238. * Gets the vertex shader source code of this effect
  38239. */
  38240. get vertexSourceCode(): string;
  38241. /**
  38242. * Gets the fragment shader source code of this effect
  38243. */
  38244. get fragmentSourceCode(): string;
  38245. /**
  38246. * Gets the vertex shader source code before it has been processed by the preprocessor
  38247. */
  38248. get rawVertexSourceCode(): string;
  38249. /**
  38250. * Gets the fragment shader source code before it has been processed by the preprocessor
  38251. */
  38252. get rawFragmentSourceCode(): string;
  38253. /**
  38254. * Recompiles the webGL program
  38255. * @param vertexSourceCode The source code for the vertex shader.
  38256. * @param fragmentSourceCode The source code for the fragment shader.
  38257. * @param onCompiled Callback called when completed.
  38258. * @param onError Callback called on error.
  38259. * @hidden
  38260. */
  38261. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  38262. /**
  38263. * Prepares the effect
  38264. * @hidden
  38265. */
  38266. _prepareEffect(): void;
  38267. private _getShaderCodeAndErrorLine;
  38268. private _processCompilationErrors;
  38269. /**
  38270. * Checks if the effect is supported. (Must be called after compilation)
  38271. */
  38272. get isSupported(): boolean;
  38273. /**
  38274. * Binds a texture to the engine to be used as output of the shader.
  38275. * @param channel Name of the output variable.
  38276. * @param texture Texture to bind.
  38277. * @hidden
  38278. */
  38279. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  38280. /**
  38281. * Sets a texture on the engine to be used in the shader.
  38282. * @param channel Name of the sampler variable.
  38283. * @param texture Texture to set.
  38284. */
  38285. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  38286. /**
  38287. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  38288. * @param channel Name of the sampler variable.
  38289. * @param texture Texture to set.
  38290. */
  38291. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  38292. /**
  38293. * Sets an array of textures on the engine to be used in the shader.
  38294. * @param channel Name of the variable.
  38295. * @param textures Textures to set.
  38296. */
  38297. setTextureArray(channel: string, textures: ThinTexture[]): void;
  38298. /**
  38299. * 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)
  38300. * @param channel Name of the sampler variable.
  38301. * @param postProcess Post process to get the input texture from.
  38302. */
  38303. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  38304. /**
  38305. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  38306. * 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)
  38307. * @param channel Name of the sampler variable.
  38308. * @param postProcess Post process to get the output texture from.
  38309. */
  38310. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  38311. /** @hidden */
  38312. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  38313. /** @hidden */
  38314. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  38315. /** @hidden */
  38316. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  38317. /** @hidden */
  38318. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  38319. /**
  38320. * Binds a buffer to a uniform.
  38321. * @param buffer Buffer to bind.
  38322. * @param name Name of the uniform variable to bind to.
  38323. */
  38324. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  38325. /**
  38326. * Binds block to a uniform.
  38327. * @param blockName Name of the block to bind.
  38328. * @param index Index to bind.
  38329. */
  38330. bindUniformBlock(blockName: string, index: number): void;
  38331. /**
  38332. * Sets an interger value on a uniform variable.
  38333. * @param uniformName Name of the variable.
  38334. * @param value Value to be set.
  38335. * @returns this effect.
  38336. */
  38337. setInt(uniformName: string, value: number): Effect;
  38338. /**
  38339. * Sets an int array on a uniform variable.
  38340. * @param uniformName Name of the variable.
  38341. * @param array array to be set.
  38342. * @returns this effect.
  38343. */
  38344. setIntArray(uniformName: string, array: Int32Array): Effect;
  38345. /**
  38346. * 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)
  38347. * @param uniformName Name of the variable.
  38348. * @param array array to be set.
  38349. * @returns this effect.
  38350. */
  38351. setIntArray2(uniformName: string, array: Int32Array): Effect;
  38352. /**
  38353. * 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)
  38354. * @param uniformName Name of the variable.
  38355. * @param array array to be set.
  38356. * @returns this effect.
  38357. */
  38358. setIntArray3(uniformName: string, array: Int32Array): Effect;
  38359. /**
  38360. * 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)
  38361. * @param uniformName Name of the variable.
  38362. * @param array array to be set.
  38363. * @returns this effect.
  38364. */
  38365. setIntArray4(uniformName: string, array: Int32Array): Effect;
  38366. /**
  38367. * Sets an float array on a uniform variable.
  38368. * @param uniformName Name of the variable.
  38369. * @param array array to be set.
  38370. * @returns this effect.
  38371. */
  38372. setFloatArray(uniformName: string, array: Float32Array): Effect;
  38373. /**
  38374. * 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)
  38375. * @param uniformName Name of the variable.
  38376. * @param array array to be set.
  38377. * @returns this effect.
  38378. */
  38379. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  38380. /**
  38381. * 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)
  38382. * @param uniformName Name of the variable.
  38383. * @param array array to be set.
  38384. * @returns this effect.
  38385. */
  38386. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  38387. /**
  38388. * 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)
  38389. * @param uniformName Name of the variable.
  38390. * @param array array to be set.
  38391. * @returns this effect.
  38392. */
  38393. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  38394. /**
  38395. * Sets an array on a uniform variable.
  38396. * @param uniformName Name of the variable.
  38397. * @param array array to be set.
  38398. * @returns this effect.
  38399. */
  38400. setArray(uniformName: string, array: number[]): Effect;
  38401. /**
  38402. * 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)
  38403. * @param uniformName Name of the variable.
  38404. * @param array array to be set.
  38405. * @returns this effect.
  38406. */
  38407. setArray2(uniformName: string, array: number[]): Effect;
  38408. /**
  38409. * 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)
  38410. * @param uniformName Name of the variable.
  38411. * @param array array to be set.
  38412. * @returns this effect.
  38413. */
  38414. setArray3(uniformName: string, array: number[]): Effect;
  38415. /**
  38416. * 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)
  38417. * @param uniformName Name of the variable.
  38418. * @param array array to be set.
  38419. * @returns this effect.
  38420. */
  38421. setArray4(uniformName: string, array: number[]): Effect;
  38422. /**
  38423. * Sets matrices on a uniform variable.
  38424. * @param uniformName Name of the variable.
  38425. * @param matrices matrices to be set.
  38426. * @returns this effect.
  38427. */
  38428. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  38429. /**
  38430. * Sets matrix on a uniform variable.
  38431. * @param uniformName Name of the variable.
  38432. * @param matrix matrix to be set.
  38433. * @returns this effect.
  38434. */
  38435. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  38436. /**
  38437. * 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)
  38438. * @param uniformName Name of the variable.
  38439. * @param matrix matrix to be set.
  38440. * @returns this effect.
  38441. */
  38442. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38443. /**
  38444. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  38445. * @param uniformName Name of the variable.
  38446. * @param matrix matrix to be set.
  38447. * @returns this effect.
  38448. */
  38449. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  38450. /**
  38451. * Sets a float on a uniform variable.
  38452. * @param uniformName Name of the variable.
  38453. * @param value value to be set.
  38454. * @returns this effect.
  38455. */
  38456. setFloat(uniformName: string, value: number): Effect;
  38457. /**
  38458. * Sets a boolean on a uniform variable.
  38459. * @param uniformName Name of the variable.
  38460. * @param bool value to be set.
  38461. * @returns this effect.
  38462. */
  38463. setBool(uniformName: string, bool: boolean): Effect;
  38464. /**
  38465. * Sets a Vector2 on a uniform variable.
  38466. * @param uniformName Name of the variable.
  38467. * @param vector2 vector2 to be set.
  38468. * @returns this effect.
  38469. */
  38470. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  38471. /**
  38472. * Sets a float2 on a uniform variable.
  38473. * @param uniformName Name of the variable.
  38474. * @param x First float in float2.
  38475. * @param y Second float in float2.
  38476. * @returns this effect.
  38477. */
  38478. setFloat2(uniformName: string, x: number, y: number): Effect;
  38479. /**
  38480. * Sets a Vector3 on a uniform variable.
  38481. * @param uniformName Name of the variable.
  38482. * @param vector3 Value to be set.
  38483. * @returns this effect.
  38484. */
  38485. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  38486. /**
  38487. * Sets a float3 on a uniform variable.
  38488. * @param uniformName Name of the variable.
  38489. * @param x First float in float3.
  38490. * @param y Second float in float3.
  38491. * @param z Third float in float3.
  38492. * @returns this effect.
  38493. */
  38494. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  38495. /**
  38496. * Sets a Vector4 on a uniform variable.
  38497. * @param uniformName Name of the variable.
  38498. * @param vector4 Value to be set.
  38499. * @returns this effect.
  38500. */
  38501. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  38502. /**
  38503. * Sets a float4 on a uniform variable.
  38504. * @param uniformName Name of the variable.
  38505. * @param x First float in float4.
  38506. * @param y Second float in float4.
  38507. * @param z Third float in float4.
  38508. * @param w Fourth float in float4.
  38509. * @returns this effect.
  38510. */
  38511. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  38512. /**
  38513. * Sets a Color3 on a uniform variable.
  38514. * @param uniformName Name of the variable.
  38515. * @param color3 Value to be set.
  38516. * @returns this effect.
  38517. */
  38518. setColor3(uniformName: string, color3: IColor3Like): Effect;
  38519. /**
  38520. * Sets a Color4 on a uniform variable.
  38521. * @param uniformName Name of the variable.
  38522. * @param color3 Value to be set.
  38523. * @param alpha Alpha value to be set.
  38524. * @returns this effect.
  38525. */
  38526. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  38527. /**
  38528. * Sets a Color4 on a uniform variable
  38529. * @param uniformName defines the name of the variable
  38530. * @param color4 defines the value to be set
  38531. * @returns this effect.
  38532. */
  38533. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  38534. /** Release all associated resources */
  38535. dispose(): void;
  38536. /**
  38537. * This function will add a new shader to the shader store
  38538. * @param name the name of the shader
  38539. * @param pixelShader optional pixel shader content
  38540. * @param vertexShader optional vertex shader content
  38541. */
  38542. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  38543. /**
  38544. * Store of each shader (The can be looked up using effect.key)
  38545. */
  38546. static ShadersStore: {
  38547. [key: string]: string;
  38548. };
  38549. /**
  38550. * Store of each included file for a shader (The can be looked up using effect.key)
  38551. */
  38552. static IncludesShadersStore: {
  38553. [key: string]: string;
  38554. };
  38555. /**
  38556. * Resets the cache of effects.
  38557. */
  38558. static ResetCache(): void;
  38559. }
  38560. }
  38561. declare module BABYLON {
  38562. /**
  38563. * Interface used to describe the capabilities of the engine relatively to the current browser
  38564. */
  38565. export interface EngineCapabilities {
  38566. /** Maximum textures units per fragment shader */
  38567. maxTexturesImageUnits: number;
  38568. /** Maximum texture units per vertex shader */
  38569. maxVertexTextureImageUnits: number;
  38570. /** Maximum textures units in the entire pipeline */
  38571. maxCombinedTexturesImageUnits: number;
  38572. /** Maximum texture size */
  38573. maxTextureSize: number;
  38574. /** Maximum texture samples */
  38575. maxSamples?: number;
  38576. /** Maximum cube texture size */
  38577. maxCubemapTextureSize: number;
  38578. /** Maximum render texture size */
  38579. maxRenderTextureSize: number;
  38580. /** Maximum number of vertex attributes */
  38581. maxVertexAttribs: number;
  38582. /** Maximum number of varyings */
  38583. maxVaryingVectors: number;
  38584. /** Maximum number of uniforms per vertex shader */
  38585. maxVertexUniformVectors: number;
  38586. /** Maximum number of uniforms per fragment shader */
  38587. maxFragmentUniformVectors: number;
  38588. /** Defines if standard derivates (dx/dy) are supported */
  38589. standardDerivatives: boolean;
  38590. /** Defines if s3tc texture compression is supported */
  38591. s3tc?: WEBGL_compressed_texture_s3tc;
  38592. /** Defines if pvrtc texture compression is supported */
  38593. pvrtc: any;
  38594. /** Defines if etc1 texture compression is supported */
  38595. etc1: any;
  38596. /** Defines if etc2 texture compression is supported */
  38597. etc2: any;
  38598. /** Defines if astc texture compression is supported */
  38599. astc: any;
  38600. /** Defines if bptc texture compression is supported */
  38601. bptc: any;
  38602. /** Defines if float textures are supported */
  38603. textureFloat: boolean;
  38604. /** Defines if vertex array objects are supported */
  38605. vertexArrayObject: boolean;
  38606. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  38607. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  38608. /** Gets the maximum level of anisotropy supported */
  38609. maxAnisotropy: number;
  38610. /** Defines if instancing is supported */
  38611. instancedArrays: boolean;
  38612. /** Defines if 32 bits indices are supported */
  38613. uintIndices: boolean;
  38614. /** Defines if high precision shaders are supported */
  38615. highPrecisionShaderSupported: boolean;
  38616. /** Defines if depth reading in the fragment shader is supported */
  38617. fragmentDepthSupported: boolean;
  38618. /** Defines if float texture linear filtering is supported*/
  38619. textureFloatLinearFiltering: boolean;
  38620. /** Defines if rendering to float textures is supported */
  38621. textureFloatRender: boolean;
  38622. /** Defines if half float textures are supported*/
  38623. textureHalfFloat: boolean;
  38624. /** Defines if half float texture linear filtering is supported*/
  38625. textureHalfFloatLinearFiltering: boolean;
  38626. /** Defines if rendering to half float textures is supported */
  38627. textureHalfFloatRender: boolean;
  38628. /** Defines if textureLOD shader command is supported */
  38629. textureLOD: boolean;
  38630. /** Defines if draw buffers extension is supported */
  38631. drawBuffersExtension: boolean;
  38632. /** Defines if depth textures are supported */
  38633. depthTextureExtension: boolean;
  38634. /** Defines if float color buffer are supported */
  38635. colorBufferFloat: boolean;
  38636. /** Gets disjoint timer query extension (null if not supported) */
  38637. timerQuery?: EXT_disjoint_timer_query;
  38638. /** Defines if timestamp can be used with timer query */
  38639. canUseTimestampForTimerQuery: boolean;
  38640. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  38641. multiview?: any;
  38642. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  38643. oculusMultiview?: any;
  38644. /** Function used to let the system compiles shaders in background */
  38645. parallelShaderCompile?: {
  38646. COMPLETION_STATUS_KHR: number;
  38647. };
  38648. /** Max number of texture samples for MSAA */
  38649. maxMSAASamples: number;
  38650. /** Defines if the blend min max extension is supported */
  38651. blendMinMax: boolean;
  38652. }
  38653. }
  38654. declare module BABYLON {
  38655. /**
  38656. * @hidden
  38657. **/
  38658. export class DepthCullingState {
  38659. private _isDepthTestDirty;
  38660. private _isDepthMaskDirty;
  38661. private _isDepthFuncDirty;
  38662. private _isCullFaceDirty;
  38663. private _isCullDirty;
  38664. private _isZOffsetDirty;
  38665. private _isFrontFaceDirty;
  38666. private _depthTest;
  38667. private _depthMask;
  38668. private _depthFunc;
  38669. private _cull;
  38670. private _cullFace;
  38671. private _zOffset;
  38672. private _frontFace;
  38673. /**
  38674. * Initializes the state.
  38675. */
  38676. constructor();
  38677. get isDirty(): boolean;
  38678. get zOffset(): number;
  38679. set zOffset(value: number);
  38680. get cullFace(): Nullable<number>;
  38681. set cullFace(value: Nullable<number>);
  38682. get cull(): Nullable<boolean>;
  38683. set cull(value: Nullable<boolean>);
  38684. get depthFunc(): Nullable<number>;
  38685. set depthFunc(value: Nullable<number>);
  38686. get depthMask(): boolean;
  38687. set depthMask(value: boolean);
  38688. get depthTest(): boolean;
  38689. set depthTest(value: boolean);
  38690. get frontFace(): Nullable<number>;
  38691. set frontFace(value: Nullable<number>);
  38692. reset(): void;
  38693. apply(gl: WebGLRenderingContext): void;
  38694. }
  38695. }
  38696. declare module BABYLON {
  38697. /**
  38698. * @hidden
  38699. **/
  38700. export class StencilState {
  38701. /** 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 */
  38702. static readonly ALWAYS: number;
  38703. /** Passed to stencilOperation to specify that stencil value must be kept */
  38704. static readonly KEEP: number;
  38705. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38706. static readonly REPLACE: number;
  38707. private _isStencilTestDirty;
  38708. private _isStencilMaskDirty;
  38709. private _isStencilFuncDirty;
  38710. private _isStencilOpDirty;
  38711. private _stencilTest;
  38712. private _stencilMask;
  38713. private _stencilFunc;
  38714. private _stencilFuncRef;
  38715. private _stencilFuncMask;
  38716. private _stencilOpStencilFail;
  38717. private _stencilOpDepthFail;
  38718. private _stencilOpStencilDepthPass;
  38719. get isDirty(): boolean;
  38720. get stencilFunc(): number;
  38721. set stencilFunc(value: number);
  38722. get stencilFuncRef(): number;
  38723. set stencilFuncRef(value: number);
  38724. get stencilFuncMask(): number;
  38725. set stencilFuncMask(value: number);
  38726. get stencilOpStencilFail(): number;
  38727. set stencilOpStencilFail(value: number);
  38728. get stencilOpDepthFail(): number;
  38729. set stencilOpDepthFail(value: number);
  38730. get stencilOpStencilDepthPass(): number;
  38731. set stencilOpStencilDepthPass(value: number);
  38732. get stencilMask(): number;
  38733. set stencilMask(value: number);
  38734. get stencilTest(): boolean;
  38735. set stencilTest(value: boolean);
  38736. constructor();
  38737. reset(): void;
  38738. apply(gl: WebGLRenderingContext): void;
  38739. }
  38740. }
  38741. declare module BABYLON {
  38742. /**
  38743. * @hidden
  38744. **/
  38745. export class AlphaState {
  38746. private _isAlphaBlendDirty;
  38747. private _isBlendFunctionParametersDirty;
  38748. private _isBlendEquationParametersDirty;
  38749. private _isBlendConstantsDirty;
  38750. private _alphaBlend;
  38751. private _blendFunctionParameters;
  38752. private _blendEquationParameters;
  38753. private _blendConstants;
  38754. /**
  38755. * Initializes the state.
  38756. */
  38757. constructor();
  38758. get isDirty(): boolean;
  38759. get alphaBlend(): boolean;
  38760. set alphaBlend(value: boolean);
  38761. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38762. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38763. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38764. reset(): void;
  38765. apply(gl: WebGLRenderingContext): void;
  38766. }
  38767. }
  38768. declare module BABYLON {
  38769. /** @hidden */
  38770. export class WebGLShaderProcessor implements IShaderProcessor {
  38771. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  38772. }
  38773. }
  38774. declare module BABYLON {
  38775. /** @hidden */
  38776. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38777. attributeProcessor(attribute: string): string;
  38778. varyingProcessor(varying: string, isFragment: boolean): string;
  38779. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38780. }
  38781. }
  38782. declare module BABYLON {
  38783. /**
  38784. * Interface for attribute information associated with buffer instanciation
  38785. */
  38786. export interface InstancingAttributeInfo {
  38787. /**
  38788. * Name of the GLSL attribute
  38789. * if attribute index is not specified, this is used to retrieve the index from the effect
  38790. */
  38791. attributeName: string;
  38792. /**
  38793. * Index/offset of the attribute in the vertex shader
  38794. * if not specified, this will be computes from the name.
  38795. */
  38796. index?: number;
  38797. /**
  38798. * size of the attribute, 1, 2, 3 or 4
  38799. */
  38800. attributeSize: number;
  38801. /**
  38802. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38803. */
  38804. offset: number;
  38805. /**
  38806. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38807. * default to 1
  38808. */
  38809. divisor?: number;
  38810. /**
  38811. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38812. * default is FLOAT
  38813. */
  38814. attributeType?: number;
  38815. /**
  38816. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38817. */
  38818. normalized?: boolean;
  38819. }
  38820. }
  38821. declare module BABYLON {
  38822. interface ThinEngine {
  38823. /**
  38824. * Update a video texture
  38825. * @param texture defines the texture to update
  38826. * @param video defines the video element to use
  38827. * @param invertY defines if data must be stored with Y axis inverted
  38828. */
  38829. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38830. }
  38831. }
  38832. declare module BABYLON {
  38833. interface ThinEngine {
  38834. /**
  38835. * Creates a dynamic texture
  38836. * @param width defines the width of the texture
  38837. * @param height defines the height of the texture
  38838. * @param generateMipMaps defines if the engine should generate the mip levels
  38839. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38840. * @returns the dynamic texture inside an InternalTexture
  38841. */
  38842. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38843. /**
  38844. * Update the content of a dynamic texture
  38845. * @param texture defines the texture to update
  38846. * @param source defines the source containing the data
  38847. * @param invertY defines if data must be stored with Y axis inverted
  38848. * @param premulAlpha defines if alpha is stored as premultiplied
  38849. * @param format defines the format of the data
  38850. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38851. */
  38852. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38853. }
  38854. }
  38855. declare module BABYLON {
  38856. /**
  38857. * Settings for finer control over video usage
  38858. */
  38859. export interface VideoTextureSettings {
  38860. /**
  38861. * Applies `autoplay` to video, if specified
  38862. */
  38863. autoPlay?: boolean;
  38864. /**
  38865. * Applies `muted` to video, if specified
  38866. */
  38867. muted?: boolean;
  38868. /**
  38869. * Applies `loop` to video, if specified
  38870. */
  38871. loop?: boolean;
  38872. /**
  38873. * Automatically updates internal texture from video at every frame in the render loop
  38874. */
  38875. autoUpdateTexture: boolean;
  38876. /**
  38877. * Image src displayed during the video loading or until the user interacts with the video.
  38878. */
  38879. poster?: string;
  38880. }
  38881. /**
  38882. * If you want to display a video in your scene, this is the special texture for that.
  38883. * This special texture works similar to other textures, with the exception of a few parameters.
  38884. * @see https://doc.babylonjs.com/how_to/video_texture
  38885. */
  38886. export class VideoTexture extends Texture {
  38887. /**
  38888. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38889. */
  38890. readonly autoUpdateTexture: boolean;
  38891. /**
  38892. * The video instance used by the texture internally
  38893. */
  38894. readonly video: HTMLVideoElement;
  38895. private _onUserActionRequestedObservable;
  38896. /**
  38897. * Event triggerd when a dom action is required by the user to play the video.
  38898. * This happens due to recent changes in browser policies preventing video to auto start.
  38899. */
  38900. get onUserActionRequestedObservable(): Observable<Texture>;
  38901. private _generateMipMaps;
  38902. private _stillImageCaptured;
  38903. private _displayingPosterTexture;
  38904. private _settings;
  38905. private _createInternalTextureOnEvent;
  38906. private _frameId;
  38907. private _currentSrc;
  38908. /**
  38909. * Creates a video texture.
  38910. * If you want to display a video in your scene, this is the special texture for that.
  38911. * This special texture works similar to other textures, with the exception of a few parameters.
  38912. * @see https://doc.babylonjs.com/how_to/video_texture
  38913. * @param name optional name, will detect from video source, if not defined
  38914. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38915. * @param scene is obviously the current scene.
  38916. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38917. * @param invertY is false by default but can be used to invert video on Y axis
  38918. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38919. * @param settings allows finer control over video usage
  38920. */
  38921. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38922. private _getName;
  38923. private _getVideo;
  38924. private _createInternalTexture;
  38925. private reset;
  38926. /**
  38927. * @hidden Internal method to initiate `update`.
  38928. */
  38929. _rebuild(): void;
  38930. /**
  38931. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38932. */
  38933. update(): void;
  38934. /**
  38935. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38936. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38937. */
  38938. updateTexture(isVisible: boolean): void;
  38939. protected _updateInternalTexture: () => void;
  38940. /**
  38941. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38942. * @param url New url.
  38943. */
  38944. updateURL(url: string): void;
  38945. /**
  38946. * Clones the texture.
  38947. * @returns the cloned texture
  38948. */
  38949. clone(): VideoTexture;
  38950. /**
  38951. * Dispose the texture and release its associated resources.
  38952. */
  38953. dispose(): void;
  38954. /**
  38955. * Creates a video texture straight from a stream.
  38956. * @param scene Define the scene the texture should be created in
  38957. * @param stream Define the stream the texture should be created from
  38958. * @returns The created video texture as a promise
  38959. */
  38960. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38961. /**
  38962. * Creates a video texture straight from your WebCam video feed.
  38963. * @param scene Define the scene the texture should be created in
  38964. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38965. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38966. * @returns The created video texture as a promise
  38967. */
  38968. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38969. minWidth: number;
  38970. maxWidth: number;
  38971. minHeight: number;
  38972. maxHeight: number;
  38973. deviceId: string;
  38974. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38975. /**
  38976. * Creates a video texture straight from your WebCam video feed.
  38977. * @param scene Define the scene the texture should be created in
  38978. * @param onReady Define a callback to triggered once the texture will be ready
  38979. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38980. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38981. */
  38982. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38983. minWidth: number;
  38984. maxWidth: number;
  38985. minHeight: number;
  38986. maxHeight: number;
  38987. deviceId: string;
  38988. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38989. }
  38990. }
  38991. declare module BABYLON {
  38992. /**
  38993. * Defines the interface used by objects working like Scene
  38994. * @hidden
  38995. */
  38996. export interface ISceneLike {
  38997. _addPendingData(data: any): void;
  38998. _removePendingData(data: any): void;
  38999. offlineProvider: IOfflineProvider;
  39000. }
  39001. /**
  39002. * Information about the current host
  39003. */
  39004. export interface HostInformation {
  39005. /**
  39006. * Defines if the current host is a mobile
  39007. */
  39008. isMobile: boolean;
  39009. }
  39010. /** Interface defining initialization parameters for Engine class */
  39011. export interface EngineOptions extends WebGLContextAttributes {
  39012. /**
  39013. * Defines if the engine should no exceed a specified device ratio
  39014. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39015. */
  39016. limitDeviceRatio?: number;
  39017. /**
  39018. * Defines if webvr should be enabled automatically
  39019. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39020. */
  39021. autoEnableWebVR?: boolean;
  39022. /**
  39023. * Defines if webgl2 should be turned off even if supported
  39024. * @see https://doc.babylonjs.com/features/webgl2
  39025. */
  39026. disableWebGL2Support?: boolean;
  39027. /**
  39028. * Defines if webaudio should be initialized as well
  39029. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39030. */
  39031. audioEngine?: boolean;
  39032. /**
  39033. * Defines if animations should run using a deterministic lock step
  39034. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39035. */
  39036. deterministicLockstep?: boolean;
  39037. /** Defines the maximum steps to use with deterministic lock step mode */
  39038. lockstepMaxSteps?: number;
  39039. /** Defines the seconds between each deterministic lock step */
  39040. timeStep?: number;
  39041. /**
  39042. * Defines that engine should ignore context lost events
  39043. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39044. */
  39045. doNotHandleContextLost?: boolean;
  39046. /**
  39047. * Defines that engine should ignore modifying touch action attribute and style
  39048. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39049. */
  39050. doNotHandleTouchAction?: boolean;
  39051. /**
  39052. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39053. */
  39054. useHighPrecisionFloats?: boolean;
  39055. /**
  39056. * Make the canvas XR Compatible for XR sessions
  39057. */
  39058. xrCompatible?: boolean;
  39059. /**
  39060. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39061. */
  39062. useHighPrecisionMatrix?: boolean;
  39063. /**
  39064. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39065. */
  39066. failIfMajorPerformanceCaveat?: boolean;
  39067. }
  39068. /**
  39069. * The base engine class (root of all engines)
  39070. */
  39071. export class ThinEngine {
  39072. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39073. static ExceptionList: ({
  39074. key: string;
  39075. capture: string;
  39076. captureConstraint: number;
  39077. targets: string[];
  39078. } | {
  39079. key: string;
  39080. capture: null;
  39081. captureConstraint: null;
  39082. targets: string[];
  39083. })[];
  39084. /** @hidden */
  39085. static _TextureLoaders: IInternalTextureLoader[];
  39086. /**
  39087. * Returns the current npm package of the sdk
  39088. */
  39089. static get NpmPackage(): string;
  39090. /**
  39091. * Returns the current version of the framework
  39092. */
  39093. static get Version(): string;
  39094. /**
  39095. * Returns a string describing the current engine
  39096. */
  39097. get description(): string;
  39098. /**
  39099. * Gets or sets the epsilon value used by collision engine
  39100. */
  39101. static CollisionsEpsilon: number;
  39102. /**
  39103. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39104. */
  39105. static get ShadersRepository(): string;
  39106. static set ShadersRepository(value: string);
  39107. /** @hidden */
  39108. _shaderProcessor: IShaderProcessor;
  39109. /**
  39110. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39111. */
  39112. forcePOTTextures: boolean;
  39113. /**
  39114. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39115. */
  39116. isFullscreen: boolean;
  39117. /**
  39118. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39119. */
  39120. cullBackFaces: boolean;
  39121. /**
  39122. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39123. */
  39124. renderEvenInBackground: boolean;
  39125. /**
  39126. * Gets or sets a boolean indicating that cache can be kept between frames
  39127. */
  39128. preventCacheWipeBetweenFrames: boolean;
  39129. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39130. validateShaderPrograms: boolean;
  39131. /**
  39132. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39133. * This can provide greater z depth for distant objects.
  39134. */
  39135. useReverseDepthBuffer: boolean;
  39136. /**
  39137. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39138. */
  39139. disableUniformBuffers: boolean;
  39140. /** @hidden */
  39141. _uniformBuffers: UniformBuffer[];
  39142. /**
  39143. * Gets a boolean indicating that the engine supports uniform buffers
  39144. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39145. */
  39146. get supportsUniformBuffers(): boolean;
  39147. /** @hidden */
  39148. _gl: WebGLRenderingContext;
  39149. /** @hidden */
  39150. _webGLVersion: number;
  39151. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39152. protected _windowIsBackground: boolean;
  39153. protected _creationOptions: EngineOptions;
  39154. protected _highPrecisionShadersAllowed: boolean;
  39155. /** @hidden */
  39156. get _shouldUseHighPrecisionShader(): boolean;
  39157. /**
  39158. * Gets a boolean indicating that only power of 2 textures are supported
  39159. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39160. */
  39161. get needPOTTextures(): boolean;
  39162. /** @hidden */
  39163. _badOS: boolean;
  39164. /** @hidden */
  39165. _badDesktopOS: boolean;
  39166. private _hardwareScalingLevel;
  39167. /** @hidden */
  39168. _caps: EngineCapabilities;
  39169. private _isStencilEnable;
  39170. private _glVersion;
  39171. private _glRenderer;
  39172. private _glVendor;
  39173. /** @hidden */
  39174. _videoTextureSupported: boolean;
  39175. protected _renderingQueueLaunched: boolean;
  39176. protected _activeRenderLoops: (() => void)[];
  39177. /**
  39178. * Observable signaled when a context lost event is raised
  39179. */
  39180. onContextLostObservable: Observable<ThinEngine>;
  39181. /**
  39182. * Observable signaled when a context restored event is raised
  39183. */
  39184. onContextRestoredObservable: Observable<ThinEngine>;
  39185. private _onContextLost;
  39186. private _onContextRestored;
  39187. protected _contextWasLost: boolean;
  39188. /** @hidden */
  39189. _doNotHandleContextLost: boolean;
  39190. /**
  39191. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  39192. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  39193. */
  39194. get doNotHandleContextLost(): boolean;
  39195. set doNotHandleContextLost(value: boolean);
  39196. /**
  39197. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  39198. */
  39199. disableVertexArrayObjects: boolean;
  39200. /** @hidden */
  39201. protected _colorWrite: boolean;
  39202. /** @hidden */
  39203. protected _colorWriteChanged: boolean;
  39204. /** @hidden */
  39205. protected _depthCullingState: DepthCullingState;
  39206. /** @hidden */
  39207. protected _stencilState: StencilState;
  39208. /** @hidden */
  39209. _alphaState: AlphaState;
  39210. /** @hidden */
  39211. _alphaMode: number;
  39212. /** @hidden */
  39213. _alphaEquation: number;
  39214. /** @hidden */
  39215. _internalTexturesCache: InternalTexture[];
  39216. /** @hidden */
  39217. protected _activeChannel: number;
  39218. private _currentTextureChannel;
  39219. /** @hidden */
  39220. protected _boundTexturesCache: {
  39221. [key: string]: Nullable<InternalTexture>;
  39222. };
  39223. /** @hidden */
  39224. protected _currentEffect: Nullable<Effect>;
  39225. /** @hidden */
  39226. protected _currentProgram: Nullable<WebGLProgram>;
  39227. private _compiledEffects;
  39228. private _vertexAttribArraysEnabled;
  39229. /** @hidden */
  39230. protected _cachedViewport: Nullable<IViewportLike>;
  39231. private _cachedVertexArrayObject;
  39232. /** @hidden */
  39233. protected _cachedVertexBuffers: any;
  39234. /** @hidden */
  39235. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  39236. /** @hidden */
  39237. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  39238. /** @hidden */
  39239. _currentRenderTarget: Nullable<InternalTexture>;
  39240. private _uintIndicesCurrentlySet;
  39241. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  39242. /** @hidden */
  39243. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  39244. /** @hidden */
  39245. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  39246. private _currentBufferPointers;
  39247. private _currentInstanceLocations;
  39248. private _currentInstanceBuffers;
  39249. private _textureUnits;
  39250. /** @hidden */
  39251. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39252. /** @hidden */
  39253. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39254. /** @hidden */
  39255. _boundRenderFunction: any;
  39256. private _vaoRecordInProgress;
  39257. private _mustWipeVertexAttributes;
  39258. private _emptyTexture;
  39259. private _emptyCubeTexture;
  39260. private _emptyTexture3D;
  39261. private _emptyTexture2DArray;
  39262. /** @hidden */
  39263. _frameHandler: number;
  39264. private _nextFreeTextureSlots;
  39265. private _maxSimultaneousTextures;
  39266. private _activeRequests;
  39267. /** @hidden */
  39268. _transformTextureUrl: Nullable<(url: string) => string>;
  39269. /**
  39270. * Gets information about the current host
  39271. */
  39272. hostInformation: HostInformation;
  39273. protected get _supportsHardwareTextureRescaling(): boolean;
  39274. private _framebufferDimensionsObject;
  39275. /**
  39276. * sets the object from which width and height will be taken from when getting render width and height
  39277. * Will fallback to the gl object
  39278. * @param dimensions the framebuffer width and height that will be used.
  39279. */
  39280. set framebufferDimensionsObject(dimensions: Nullable<{
  39281. framebufferWidth: number;
  39282. framebufferHeight: number;
  39283. }>);
  39284. /**
  39285. * Gets the current viewport
  39286. */
  39287. get currentViewport(): Nullable<IViewportLike>;
  39288. /**
  39289. * Gets the default empty texture
  39290. */
  39291. get emptyTexture(): InternalTexture;
  39292. /**
  39293. * Gets the default empty 3D texture
  39294. */
  39295. get emptyTexture3D(): InternalTexture;
  39296. /**
  39297. * Gets the default empty 2D array texture
  39298. */
  39299. get emptyTexture2DArray(): InternalTexture;
  39300. /**
  39301. * Gets the default empty cube texture
  39302. */
  39303. get emptyCubeTexture(): InternalTexture;
  39304. /**
  39305. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  39306. */
  39307. readonly premultipliedAlpha: boolean;
  39308. /**
  39309. * Observable event triggered before each texture is initialized
  39310. */
  39311. onBeforeTextureInitObservable: Observable<Texture>;
  39312. /**
  39313. * Creates a new engine
  39314. * @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
  39315. * @param antialias defines enable antialiasing (default: false)
  39316. * @param options defines further options to be sent to the getContext() function
  39317. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39318. */
  39319. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39320. private _rebuildInternalTextures;
  39321. private _rebuildEffects;
  39322. /**
  39323. * Gets a boolean indicating if all created effects are ready
  39324. * @returns true if all effects are ready
  39325. */
  39326. areAllEffectsReady(): boolean;
  39327. protected _rebuildBuffers(): void;
  39328. protected _initGLContext(): void;
  39329. /**
  39330. * Gets version of the current webGL context
  39331. */
  39332. get webGLVersion(): number;
  39333. /**
  39334. * Gets a string identifying the name of the class
  39335. * @returns "Engine" string
  39336. */
  39337. getClassName(): string;
  39338. /**
  39339. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  39340. */
  39341. get isStencilEnable(): boolean;
  39342. /** @hidden */
  39343. _prepareWorkingCanvas(): void;
  39344. /**
  39345. * Reset the texture cache to empty state
  39346. */
  39347. resetTextureCache(): void;
  39348. /**
  39349. * Gets an object containing information about the current webGL context
  39350. * @returns an object containing the vender, the renderer and the version of the current webGL context
  39351. */
  39352. getGlInfo(): {
  39353. vendor: string;
  39354. renderer: string;
  39355. version: string;
  39356. };
  39357. /**
  39358. * Defines the hardware scaling level.
  39359. * By default the hardware scaling level is computed from the window device ratio.
  39360. * 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.
  39361. * @param level defines the level to use
  39362. */
  39363. setHardwareScalingLevel(level: number): void;
  39364. /**
  39365. * Gets the current hardware scaling level.
  39366. * By default the hardware scaling level is computed from the window device ratio.
  39367. * 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.
  39368. * @returns a number indicating the current hardware scaling level
  39369. */
  39370. getHardwareScalingLevel(): number;
  39371. /**
  39372. * Gets the list of loaded textures
  39373. * @returns an array containing all loaded textures
  39374. */
  39375. getLoadedTexturesCache(): InternalTexture[];
  39376. /**
  39377. * Gets the object containing all engine capabilities
  39378. * @returns the EngineCapabilities object
  39379. */
  39380. getCaps(): EngineCapabilities;
  39381. /**
  39382. * stop executing a render loop function and remove it from the execution array
  39383. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  39384. */
  39385. stopRenderLoop(renderFunction?: () => void): void;
  39386. /** @hidden */
  39387. _renderLoop(): void;
  39388. /**
  39389. * Gets the HTML canvas attached with the current webGL context
  39390. * @returns a HTML canvas
  39391. */
  39392. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  39393. /**
  39394. * Gets host window
  39395. * @returns the host window object
  39396. */
  39397. getHostWindow(): Nullable<Window>;
  39398. /**
  39399. * Gets the current render width
  39400. * @param useScreen defines if screen size must be used (or the current render target if any)
  39401. * @returns a number defining the current render width
  39402. */
  39403. getRenderWidth(useScreen?: boolean): number;
  39404. /**
  39405. * Gets the current render height
  39406. * @param useScreen defines if screen size must be used (or the current render target if any)
  39407. * @returns a number defining the current render height
  39408. */
  39409. getRenderHeight(useScreen?: boolean): number;
  39410. /**
  39411. * Can be used to override the current requestAnimationFrame requester.
  39412. * @hidden
  39413. */
  39414. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  39415. /**
  39416. * Register and execute a render loop. The engine can have more than one render function
  39417. * @param renderFunction defines the function to continuously execute
  39418. */
  39419. runRenderLoop(renderFunction: () => void): void;
  39420. /**
  39421. * Clear the current render buffer or the current render target (if any is set up)
  39422. * @param color defines the color to use
  39423. * @param backBuffer defines if the back buffer must be cleared
  39424. * @param depth defines if the depth buffer must be cleared
  39425. * @param stencil defines if the stencil buffer must be cleared
  39426. */
  39427. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  39428. private _viewportCached;
  39429. /** @hidden */
  39430. _viewport(x: number, y: number, width: number, height: number): void;
  39431. /**
  39432. * Set the WebGL's viewport
  39433. * @param viewport defines the viewport element to be used
  39434. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  39435. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  39436. */
  39437. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  39438. /**
  39439. * Begin a new frame
  39440. */
  39441. beginFrame(): void;
  39442. /**
  39443. * Enf the current frame
  39444. */
  39445. endFrame(): void;
  39446. /**
  39447. * Resize the view according to the canvas' size
  39448. */
  39449. resize(): void;
  39450. /**
  39451. * Force a specific size of the canvas
  39452. * @param width defines the new canvas' width
  39453. * @param height defines the new canvas' height
  39454. * @returns true if the size was changed
  39455. */
  39456. setSize(width: number, height: number): boolean;
  39457. /**
  39458. * Binds the frame buffer to the specified texture.
  39459. * @param texture The texture to render to or null for the default canvas
  39460. * @param faceIndex The face of the texture to render to in case of cube texture
  39461. * @param requiredWidth The width of the target to render to
  39462. * @param requiredHeight The height of the target to render to
  39463. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  39464. * @param lodLevel defines the lod level to bind to the frame buffer
  39465. * @param layer defines the 2d array index to bind to frame buffer to
  39466. */
  39467. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  39468. /** @hidden */
  39469. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  39470. /**
  39471. * Unbind the current render target texture from the webGL context
  39472. * @param texture defines the render target texture to unbind
  39473. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  39474. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  39475. */
  39476. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  39477. /**
  39478. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  39479. */
  39480. flushFramebuffer(): void;
  39481. /**
  39482. * Unbind the current render target and bind the default framebuffer
  39483. */
  39484. restoreDefaultFramebuffer(): void;
  39485. /** @hidden */
  39486. protected _resetVertexBufferBinding(): void;
  39487. /**
  39488. * Creates a vertex buffer
  39489. * @param data the data for the vertex buffer
  39490. * @returns the new WebGL static buffer
  39491. */
  39492. createVertexBuffer(data: DataArray): DataBuffer;
  39493. private _createVertexBuffer;
  39494. /**
  39495. * Creates a dynamic vertex buffer
  39496. * @param data the data for the dynamic vertex buffer
  39497. * @returns the new WebGL dynamic buffer
  39498. */
  39499. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  39500. protected _resetIndexBufferBinding(): void;
  39501. /**
  39502. * Creates a new index buffer
  39503. * @param indices defines the content of the index buffer
  39504. * @param updatable defines if the index buffer must be updatable
  39505. * @returns a new webGL buffer
  39506. */
  39507. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  39508. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  39509. /**
  39510. * Bind a webGL buffer to the webGL context
  39511. * @param buffer defines the buffer to bind
  39512. */
  39513. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  39514. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  39515. private bindBuffer;
  39516. /**
  39517. * update the bound buffer with the given data
  39518. * @param data defines the data to update
  39519. */
  39520. updateArrayBuffer(data: Float32Array): void;
  39521. private _vertexAttribPointer;
  39522. /** @hidden */
  39523. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  39524. private _bindVertexBuffersAttributes;
  39525. /**
  39526. * Records a vertex array object
  39527. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39528. * @param vertexBuffers defines the list of vertex buffers to store
  39529. * @param indexBuffer defines the index buffer to store
  39530. * @param effect defines the effect to store
  39531. * @returns the new vertex array object
  39532. */
  39533. recordVertexArrayObject(vertexBuffers: {
  39534. [key: string]: VertexBuffer;
  39535. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  39536. /**
  39537. * Bind a specific vertex array object
  39538. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  39539. * @param vertexArrayObject defines the vertex array object to bind
  39540. * @param indexBuffer defines the index buffer to bind
  39541. */
  39542. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  39543. /**
  39544. * Bind webGl buffers directly to the webGL context
  39545. * @param vertexBuffer defines the vertex buffer to bind
  39546. * @param indexBuffer defines the index buffer to bind
  39547. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  39548. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  39549. * @param effect defines the effect associated with the vertex buffer
  39550. */
  39551. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  39552. private _unbindVertexArrayObject;
  39553. /**
  39554. * Bind a list of vertex buffers to the webGL context
  39555. * @param vertexBuffers defines the list of vertex buffers to bind
  39556. * @param indexBuffer defines the index buffer to bind
  39557. * @param effect defines the effect associated with the vertex buffers
  39558. */
  39559. bindBuffers(vertexBuffers: {
  39560. [key: string]: Nullable<VertexBuffer>;
  39561. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  39562. /**
  39563. * Unbind all instance attributes
  39564. */
  39565. unbindInstanceAttributes(): void;
  39566. /**
  39567. * Release and free the memory of a vertex array object
  39568. * @param vao defines the vertex array object to delete
  39569. */
  39570. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  39571. /** @hidden */
  39572. _releaseBuffer(buffer: DataBuffer): boolean;
  39573. protected _deleteBuffer(buffer: DataBuffer): void;
  39574. /**
  39575. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  39576. * @param instancesBuffer defines the webGL buffer to update and bind
  39577. * @param data defines the data to store in the buffer
  39578. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  39579. */
  39580. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  39581. /**
  39582. * Bind the content of a webGL buffer used with instantiation
  39583. * @param instancesBuffer defines the webGL buffer to bind
  39584. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  39585. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  39586. */
  39587. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  39588. /**
  39589. * Disable the instance attribute corresponding to the name in parameter
  39590. * @param name defines the name of the attribute to disable
  39591. */
  39592. disableInstanceAttributeByName(name: string): void;
  39593. /**
  39594. * Disable the instance attribute corresponding to the location in parameter
  39595. * @param attributeLocation defines the attribute location of the attribute to disable
  39596. */
  39597. disableInstanceAttribute(attributeLocation: number): void;
  39598. /**
  39599. * Disable the attribute corresponding to the location in parameter
  39600. * @param attributeLocation defines the attribute location of the attribute to disable
  39601. */
  39602. disableAttributeByIndex(attributeLocation: number): void;
  39603. /**
  39604. * Send a draw order
  39605. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39606. * @param indexStart defines the starting index
  39607. * @param indexCount defines the number of index to draw
  39608. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39609. */
  39610. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  39611. /**
  39612. * Draw a list of points
  39613. * @param verticesStart defines the index of first vertex to draw
  39614. * @param verticesCount defines the count of vertices to draw
  39615. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39616. */
  39617. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39618. /**
  39619. * Draw a list of unindexed primitives
  39620. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  39621. * @param verticesStart defines the index of first vertex to draw
  39622. * @param verticesCount defines the count of vertices to draw
  39623. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39624. */
  39625. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39626. /**
  39627. * Draw a list of indexed primitives
  39628. * @param fillMode defines the primitive to use
  39629. * @param indexStart defines the starting index
  39630. * @param indexCount defines the number of index to draw
  39631. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39632. */
  39633. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  39634. /**
  39635. * Draw a list of unindexed primitives
  39636. * @param fillMode defines the primitive to use
  39637. * @param verticesStart defines the index of first vertex to draw
  39638. * @param verticesCount defines the count of vertices to draw
  39639. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  39640. */
  39641. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  39642. private _drawMode;
  39643. /** @hidden */
  39644. protected _reportDrawCall(): void;
  39645. /** @hidden */
  39646. _releaseEffect(effect: Effect): void;
  39647. /** @hidden */
  39648. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39649. /**
  39650. * Create a new effect (used to store vertex/fragment shaders)
  39651. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  39652. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  39653. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  39654. * @param samplers defines an array of string used to represent textures
  39655. * @param defines defines the string containing the defines to use to compile the shaders
  39656. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  39657. * @param onCompiled defines a function to call when the effect creation is successful
  39658. * @param onError defines a function to call when the effect creation has failed
  39659. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  39660. * @returns the new Effect
  39661. */
  39662. 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;
  39663. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  39664. private _compileShader;
  39665. private _compileRawShader;
  39666. /** @hidden */
  39667. _getShaderSource(shader: WebGLShader): Nullable<string>;
  39668. /**
  39669. * Directly creates a webGL program
  39670. * @param pipelineContext defines the pipeline context to attach to
  39671. * @param vertexCode defines the vertex shader code to use
  39672. * @param fragmentCode defines the fragment shader code to use
  39673. * @param context defines the webGL context to use (if not set, the current one will be used)
  39674. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39675. * @returns the new webGL program
  39676. */
  39677. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39678. /**
  39679. * Creates a webGL program
  39680. * @param pipelineContext defines the pipeline context to attach to
  39681. * @param vertexCode defines the vertex shader code to use
  39682. * @param fragmentCode defines the fragment shader code to use
  39683. * @param defines defines the string containing the defines to use to compile the shaders
  39684. * @param context defines the webGL context to use (if not set, the current one will be used)
  39685. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  39686. * @returns the new webGL program
  39687. */
  39688. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39689. /**
  39690. * Creates a new pipeline context
  39691. * @returns the new pipeline
  39692. */
  39693. createPipelineContext(): IPipelineContext;
  39694. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39695. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39696. /** @hidden */
  39697. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39698. /** @hidden */
  39699. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39700. /** @hidden */
  39701. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39702. /**
  39703. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39704. * @param pipelineContext defines the pipeline context to use
  39705. * @param uniformsNames defines the list of uniform names
  39706. * @returns an array of webGL uniform locations
  39707. */
  39708. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39709. /**
  39710. * Gets the lsit of active attributes for a given webGL program
  39711. * @param pipelineContext defines the pipeline context to use
  39712. * @param attributesNames defines the list of attribute names to get
  39713. * @returns an array of indices indicating the offset of each attribute
  39714. */
  39715. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39716. /**
  39717. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39718. * @param effect defines the effect to activate
  39719. */
  39720. enableEffect(effect: Nullable<Effect>): void;
  39721. /**
  39722. * Set the value of an uniform to a number (int)
  39723. * @param uniform defines the webGL uniform location where to store the value
  39724. * @param value defines the int number to store
  39725. * @returns true if the value was set
  39726. */
  39727. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39728. /**
  39729. * Set the value of an uniform to an array of int32
  39730. * @param uniform defines the webGL uniform location where to store the value
  39731. * @param array defines the array of int32 to store
  39732. * @returns true if the value was set
  39733. */
  39734. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39735. /**
  39736. * Set the value of an uniform to an array of int32 (stored as vec2)
  39737. * @param uniform defines the webGL uniform location where to store the value
  39738. * @param array defines the array of int32 to store
  39739. * @returns true if the value was set
  39740. */
  39741. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39742. /**
  39743. * Set the value of an uniform to an array of int32 (stored as vec3)
  39744. * @param uniform defines the webGL uniform location where to store the value
  39745. * @param array defines the array of int32 to store
  39746. * @returns true if the value was set
  39747. */
  39748. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39749. /**
  39750. * Set the value of an uniform to an array of int32 (stored as vec4)
  39751. * @param uniform defines the webGL uniform location where to store the value
  39752. * @param array defines the array of int32 to store
  39753. * @returns true if the value was set
  39754. */
  39755. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39756. /**
  39757. * Set the value of an uniform to an array of number
  39758. * @param uniform defines the webGL uniform location where to store the value
  39759. * @param array defines the array of number to store
  39760. * @returns true if the value was set
  39761. */
  39762. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39763. /**
  39764. * Set the value of an uniform to an array of number (stored as vec2)
  39765. * @param uniform defines the webGL uniform location where to store the value
  39766. * @param array defines the array of number to store
  39767. * @returns true if the value was set
  39768. */
  39769. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39770. /**
  39771. * Set the value of an uniform to an array of number (stored as vec3)
  39772. * @param uniform defines the webGL uniform location where to store the value
  39773. * @param array defines the array of number to store
  39774. * @returns true if the value was set
  39775. */
  39776. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39777. /**
  39778. * Set the value of an uniform to an array of number (stored as vec4)
  39779. * @param uniform defines the webGL uniform location where to store the value
  39780. * @param array defines the array of number to store
  39781. * @returns true if the value was set
  39782. */
  39783. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39784. /**
  39785. * Set the value of an uniform to an array of float32 (stored as matrices)
  39786. * @param uniform defines the webGL uniform location where to store the value
  39787. * @param matrices defines the array of float32 to store
  39788. * @returns true if the value was set
  39789. */
  39790. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39791. /**
  39792. * Set the value of an uniform to a matrix (3x3)
  39793. * @param uniform defines the webGL uniform location where to store the value
  39794. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39795. * @returns true if the value was set
  39796. */
  39797. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39798. /**
  39799. * Set the value of an uniform to a matrix (2x2)
  39800. * @param uniform defines the webGL uniform location where to store the value
  39801. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39802. * @returns true if the value was set
  39803. */
  39804. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39805. /**
  39806. * Set the value of an uniform to a number (float)
  39807. * @param uniform defines the webGL uniform location where to store the value
  39808. * @param value defines the float number to store
  39809. * @returns true if the value was transfered
  39810. */
  39811. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39812. /**
  39813. * Set the value of an uniform to a vec2
  39814. * @param uniform defines the webGL uniform location where to store the value
  39815. * @param x defines the 1st component of the value
  39816. * @param y defines the 2nd component of the value
  39817. * @returns true if the value was set
  39818. */
  39819. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39820. /**
  39821. * Set the value of an uniform to a vec3
  39822. * @param uniform defines the webGL uniform location where to store the value
  39823. * @param x defines the 1st component of the value
  39824. * @param y defines the 2nd component of the value
  39825. * @param z defines the 3rd component of the value
  39826. * @returns true if the value was set
  39827. */
  39828. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39829. /**
  39830. * Set the value of an uniform to a vec4
  39831. * @param uniform defines the webGL uniform location where to store the value
  39832. * @param x defines the 1st component of the value
  39833. * @param y defines the 2nd component of the value
  39834. * @param z defines the 3rd component of the value
  39835. * @param w defines the 4th component of the value
  39836. * @returns true if the value was set
  39837. */
  39838. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39839. /**
  39840. * Apply all cached states (depth, culling, stencil and alpha)
  39841. */
  39842. applyStates(): void;
  39843. /**
  39844. * Enable or disable color writing
  39845. * @param enable defines the state to set
  39846. */
  39847. setColorWrite(enable: boolean): void;
  39848. /**
  39849. * Gets a boolean indicating if color writing is enabled
  39850. * @returns the current color writing state
  39851. */
  39852. getColorWrite(): boolean;
  39853. /**
  39854. * Gets the depth culling state manager
  39855. */
  39856. get depthCullingState(): DepthCullingState;
  39857. /**
  39858. * Gets the alpha state manager
  39859. */
  39860. get alphaState(): AlphaState;
  39861. /**
  39862. * Gets the stencil state manager
  39863. */
  39864. get stencilState(): StencilState;
  39865. /**
  39866. * Clears the list of texture accessible through engine.
  39867. * This can help preventing texture load conflict due to name collision.
  39868. */
  39869. clearInternalTexturesCache(): void;
  39870. /**
  39871. * Force the entire cache to be cleared
  39872. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39873. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39874. */
  39875. wipeCaches(bruteForce?: boolean): void;
  39876. /** @hidden */
  39877. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39878. min: number;
  39879. mag: number;
  39880. };
  39881. /** @hidden */
  39882. _createTexture(): WebGLTexture;
  39883. /**
  39884. * Usually called from Texture.ts.
  39885. * Passed information to create a WebGLTexture
  39886. * @param url defines a value which contains one of the following:
  39887. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39888. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39889. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39890. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39891. * @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)
  39892. * @param scene needed for loading to the correct scene
  39893. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39894. * @param onLoad optional callback to be called upon successful completion
  39895. * @param onError optional callback to be called upon failure
  39896. * @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
  39897. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39898. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39899. * @param forcedExtension defines the extension to use to pick the right loader
  39900. * @param mimeType defines an optional mime type
  39901. * @param loaderOptions options to be passed to the loader
  39902. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39903. */
  39904. 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;
  39905. /**
  39906. * Loads an image as an HTMLImageElement.
  39907. * @param input url string, ArrayBuffer, or Blob to load
  39908. * @param onLoad callback called when the image successfully loads
  39909. * @param onError callback called when the image fails to load
  39910. * @param offlineProvider offline provider for caching
  39911. * @param mimeType optional mime type
  39912. * @returns the HTMLImageElement of the loaded image
  39913. * @hidden
  39914. */
  39915. 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>;
  39916. /**
  39917. * @hidden
  39918. */
  39919. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39920. private _unpackFlipYCached;
  39921. /**
  39922. * In case you are sharing the context with other applications, it might
  39923. * be interested to not cache the unpack flip y state to ensure a consistent
  39924. * value would be set.
  39925. */
  39926. enableUnpackFlipYCached: boolean;
  39927. /** @hidden */
  39928. _unpackFlipY(value: boolean): void;
  39929. /** @hidden */
  39930. _getUnpackAlignement(): number;
  39931. private _getTextureTarget;
  39932. /**
  39933. * Update the sampling mode of a given texture
  39934. * @param samplingMode defines the required sampling mode
  39935. * @param texture defines the texture to update
  39936. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39937. */
  39938. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39939. /**
  39940. * Update the sampling mode of a given texture
  39941. * @param texture defines the texture to update
  39942. * @param wrapU defines the texture wrap mode of the u coordinates
  39943. * @param wrapV defines the texture wrap mode of the v coordinates
  39944. * @param wrapR defines the texture wrap mode of the r coordinates
  39945. */
  39946. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39947. /** @hidden */
  39948. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39949. width: number;
  39950. height: number;
  39951. layers?: number;
  39952. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39953. /** @hidden */
  39954. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39955. /** @hidden */
  39956. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39957. /**
  39958. * Update a portion of an internal texture
  39959. * @param texture defines the texture to update
  39960. * @param imageData defines the data to store into the texture
  39961. * @param xOffset defines the x coordinates of the update rectangle
  39962. * @param yOffset defines the y coordinates of the update rectangle
  39963. * @param width defines the width of the update rectangle
  39964. * @param height defines the height of the update rectangle
  39965. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39966. * @param lod defines the lod level to update (0 by default)
  39967. */
  39968. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39969. /** @hidden */
  39970. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39971. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39972. private _prepareWebGLTexture;
  39973. /** @hidden */
  39974. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39975. private _getDepthStencilBuffer;
  39976. /** @hidden */
  39977. _releaseFramebufferObjects(texture: InternalTexture): void;
  39978. /** @hidden */
  39979. _releaseTexture(texture: InternalTexture): void;
  39980. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39981. protected _setProgram(program: WebGLProgram): void;
  39982. protected _boundUniforms: {
  39983. [key: number]: WebGLUniformLocation;
  39984. };
  39985. /**
  39986. * Binds an effect to the webGL context
  39987. * @param effect defines the effect to bind
  39988. */
  39989. bindSamplers(effect: Effect): void;
  39990. private _activateCurrentTexture;
  39991. /** @hidden */
  39992. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39993. /** @hidden */
  39994. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39995. /**
  39996. * Unbind all textures from the webGL context
  39997. */
  39998. unbindAllTextures(): void;
  39999. /**
  40000. * Sets a texture to the according uniform.
  40001. * @param channel The texture channel
  40002. * @param uniform The uniform to set
  40003. * @param texture The texture to apply
  40004. */
  40005. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>): void;
  40006. private _bindSamplerUniformToChannel;
  40007. private _getTextureWrapMode;
  40008. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  40009. /**
  40010. * Sets an array of texture to the webGL context
  40011. * @param channel defines the channel where the texture array must be set
  40012. * @param uniform defines the associated uniform location
  40013. * @param textures defines the array of textures to bind
  40014. */
  40015. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[]): void;
  40016. /** @hidden */
  40017. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40018. private _setTextureParameterFloat;
  40019. private _setTextureParameterInteger;
  40020. /**
  40021. * Unbind all vertex attributes from the webGL context
  40022. */
  40023. unbindAllAttributes(): void;
  40024. /**
  40025. * 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
  40026. */
  40027. releaseEffects(): void;
  40028. /**
  40029. * Dispose and release all associated resources
  40030. */
  40031. dispose(): void;
  40032. /**
  40033. * Attach a new callback raised when context lost event is fired
  40034. * @param callback defines the callback to call
  40035. */
  40036. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40037. /**
  40038. * Attach a new callback raised when context restored event is fired
  40039. * @param callback defines the callback to call
  40040. */
  40041. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40042. /**
  40043. * Get the current error code of the webGL context
  40044. * @returns the error code
  40045. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40046. */
  40047. getError(): number;
  40048. private _canRenderToFloatFramebuffer;
  40049. private _canRenderToHalfFloatFramebuffer;
  40050. private _canRenderToFramebuffer;
  40051. /** @hidden */
  40052. _getWebGLTextureType(type: number): number;
  40053. /** @hidden */
  40054. _getInternalFormat(format: number): number;
  40055. /** @hidden */
  40056. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40057. /** @hidden */
  40058. _getRGBAMultiSampleBufferFormat(type: number): number;
  40059. /** @hidden */
  40060. _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;
  40061. /**
  40062. * Loads a file from a url
  40063. * @param url url to load
  40064. * @param onSuccess callback called when the file successfully loads
  40065. * @param onProgress callback called while file is loading (if the server supports this mode)
  40066. * @param offlineProvider defines the offline provider for caching
  40067. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40068. * @param onError callback called when the file fails to load
  40069. * @returns a file request object
  40070. * @hidden
  40071. */
  40072. 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;
  40073. /**
  40074. * Reads pixels from the current frame buffer. Please note that this function can be slow
  40075. * @param x defines the x coordinate of the rectangle where pixels must be read
  40076. * @param y defines the y coordinate of the rectangle where pixels must be read
  40077. * @param width defines the width of the rectangle where pixels must be read
  40078. * @param height defines the height of the rectangle where pixels must be read
  40079. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  40080. * @returns a Uint8Array containing RGBA colors
  40081. */
  40082. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  40083. private static _IsSupported;
  40084. private static _HasMajorPerformanceCaveat;
  40085. /**
  40086. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40087. */
  40088. static get IsSupported(): boolean;
  40089. /**
  40090. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  40091. * @returns true if the engine can be created
  40092. * @ignorenaming
  40093. */
  40094. static isSupported(): boolean;
  40095. /**
  40096. * 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)
  40097. */
  40098. static get HasMajorPerformanceCaveat(): boolean;
  40099. /**
  40100. * Find the next highest power of two.
  40101. * @param x Number to start search from.
  40102. * @return Next highest power of two.
  40103. */
  40104. static CeilingPOT(x: number): number;
  40105. /**
  40106. * Find the next lowest power of two.
  40107. * @param x Number to start search from.
  40108. * @return Next lowest power of two.
  40109. */
  40110. static FloorPOT(x: number): number;
  40111. /**
  40112. * Find the nearest power of two.
  40113. * @param x Number to start search from.
  40114. * @return Next nearest power of two.
  40115. */
  40116. static NearestPOT(x: number): number;
  40117. /**
  40118. * Get the closest exponent of two
  40119. * @param value defines the value to approximate
  40120. * @param max defines the maximum value to return
  40121. * @param mode defines how to define the closest value
  40122. * @returns closest exponent of two of the given value
  40123. */
  40124. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  40125. /**
  40126. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  40127. * @param func - the function to be called
  40128. * @param requester - the object that will request the next frame. Falls back to window.
  40129. * @returns frame number
  40130. */
  40131. static QueueNewFrame(func: () => void, requester?: any): number;
  40132. /**
  40133. * Gets host document
  40134. * @returns the host document object
  40135. */
  40136. getHostDocument(): Nullable<Document>;
  40137. }
  40138. }
  40139. declare module BABYLON {
  40140. /**
  40141. * Defines the source of the internal texture
  40142. */
  40143. export enum InternalTextureSource {
  40144. /**
  40145. * The source of the texture data is unknown
  40146. */
  40147. Unknown = 0,
  40148. /**
  40149. * Texture data comes from an URL
  40150. */
  40151. Url = 1,
  40152. /**
  40153. * Texture data is only used for temporary storage
  40154. */
  40155. Temp = 2,
  40156. /**
  40157. * Texture data comes from raw data (ArrayBuffer)
  40158. */
  40159. Raw = 3,
  40160. /**
  40161. * Texture content is dynamic (video or dynamic texture)
  40162. */
  40163. Dynamic = 4,
  40164. /**
  40165. * Texture content is generated by rendering to it
  40166. */
  40167. RenderTarget = 5,
  40168. /**
  40169. * Texture content is part of a multi render target process
  40170. */
  40171. MultiRenderTarget = 6,
  40172. /**
  40173. * Texture data comes from a cube data file
  40174. */
  40175. Cube = 7,
  40176. /**
  40177. * Texture data comes from a raw cube data
  40178. */
  40179. CubeRaw = 8,
  40180. /**
  40181. * Texture data come from a prefiltered cube data file
  40182. */
  40183. CubePrefiltered = 9,
  40184. /**
  40185. * Texture content is raw 3D data
  40186. */
  40187. Raw3D = 10,
  40188. /**
  40189. * Texture content is raw 2D array data
  40190. */
  40191. Raw2DArray = 11,
  40192. /**
  40193. * Texture content is a depth texture
  40194. */
  40195. Depth = 12,
  40196. /**
  40197. * Texture data comes from a raw cube data encoded with RGBD
  40198. */
  40199. CubeRawRGBD = 13
  40200. }
  40201. /**
  40202. * Class used to store data associated with WebGL texture data for the engine
  40203. * This class should not be used directly
  40204. */
  40205. export class InternalTexture {
  40206. /** @hidden */
  40207. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  40208. /**
  40209. * Defines if the texture is ready
  40210. */
  40211. isReady: boolean;
  40212. /**
  40213. * Defines if the texture is a cube texture
  40214. */
  40215. isCube: boolean;
  40216. /**
  40217. * Defines if the texture contains 3D data
  40218. */
  40219. is3D: boolean;
  40220. /**
  40221. * Defines if the texture contains 2D array data
  40222. */
  40223. is2DArray: boolean;
  40224. /**
  40225. * Defines if the texture contains multiview data
  40226. */
  40227. isMultiview: boolean;
  40228. /**
  40229. * Gets the URL used to load this texture
  40230. */
  40231. url: string;
  40232. /** @hidden */
  40233. _originalUrl: string;
  40234. /**
  40235. * Gets the sampling mode of the texture
  40236. */
  40237. samplingMode: number;
  40238. /**
  40239. * Gets a boolean indicating if the texture needs mipmaps generation
  40240. */
  40241. generateMipMaps: boolean;
  40242. /**
  40243. * Gets the number of samples used by the texture (WebGL2+ only)
  40244. */
  40245. samples: number;
  40246. /**
  40247. * Gets the type of the texture (int, float...)
  40248. */
  40249. type: number;
  40250. /**
  40251. * Gets the format of the texture (RGB, RGBA...)
  40252. */
  40253. format: number;
  40254. /**
  40255. * Observable called when the texture is loaded
  40256. */
  40257. onLoadedObservable: Observable<InternalTexture>;
  40258. /**
  40259. * Gets the width of the texture
  40260. */
  40261. width: number;
  40262. /**
  40263. * Gets the height of the texture
  40264. */
  40265. height: number;
  40266. /**
  40267. * Gets the depth of the texture
  40268. */
  40269. depth: number;
  40270. /**
  40271. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  40272. */
  40273. baseWidth: number;
  40274. /**
  40275. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  40276. */
  40277. baseHeight: number;
  40278. /**
  40279. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  40280. */
  40281. baseDepth: number;
  40282. /**
  40283. * Gets a boolean indicating if the texture is inverted on Y axis
  40284. */
  40285. invertY: boolean;
  40286. /** @hidden */
  40287. _invertVScale: boolean;
  40288. /** @hidden */
  40289. _associatedChannel: number;
  40290. /** @hidden */
  40291. _source: InternalTextureSource;
  40292. /** @hidden */
  40293. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  40294. /** @hidden */
  40295. _bufferView: Nullable<ArrayBufferView>;
  40296. /** @hidden */
  40297. _bufferViewArray: Nullable<ArrayBufferView[]>;
  40298. /** @hidden */
  40299. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  40300. /** @hidden */
  40301. _size: number;
  40302. /** @hidden */
  40303. _extension: string;
  40304. /** @hidden */
  40305. _files: Nullable<string[]>;
  40306. /** @hidden */
  40307. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40308. /** @hidden */
  40309. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40310. /** @hidden */
  40311. _framebuffer: Nullable<WebGLFramebuffer>;
  40312. /** @hidden */
  40313. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  40314. /** @hidden */
  40315. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  40316. /** @hidden */
  40317. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  40318. /** @hidden */
  40319. _attachments: Nullable<number[]>;
  40320. /** @hidden */
  40321. _textureArray: Nullable<InternalTexture[]>;
  40322. /** @hidden */
  40323. _cachedCoordinatesMode: Nullable<number>;
  40324. /** @hidden */
  40325. _cachedWrapU: Nullable<number>;
  40326. /** @hidden */
  40327. _cachedWrapV: Nullable<number>;
  40328. /** @hidden */
  40329. _cachedWrapR: Nullable<number>;
  40330. /** @hidden */
  40331. _cachedAnisotropicFilteringLevel: Nullable<number>;
  40332. /** @hidden */
  40333. _isDisabled: boolean;
  40334. /** @hidden */
  40335. _compression: Nullable<string>;
  40336. /** @hidden */
  40337. _generateStencilBuffer: boolean;
  40338. /** @hidden */
  40339. _generateDepthBuffer: boolean;
  40340. /** @hidden */
  40341. _comparisonFunction: number;
  40342. /** @hidden */
  40343. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  40344. /** @hidden */
  40345. _lodGenerationScale: number;
  40346. /** @hidden */
  40347. _lodGenerationOffset: number;
  40348. /** @hidden */
  40349. _depthStencilTexture: Nullable<InternalTexture>;
  40350. /** @hidden */
  40351. _colorTextureArray: Nullable<WebGLTexture>;
  40352. /** @hidden */
  40353. _depthStencilTextureArray: Nullable<WebGLTexture>;
  40354. /** @hidden */
  40355. _lodTextureHigh: Nullable<BaseTexture>;
  40356. /** @hidden */
  40357. _lodTextureMid: Nullable<BaseTexture>;
  40358. /** @hidden */
  40359. _lodTextureLow: Nullable<BaseTexture>;
  40360. /** @hidden */
  40361. _isRGBD: boolean;
  40362. /** @hidden */
  40363. _linearSpecularLOD: boolean;
  40364. /** @hidden */
  40365. _irradianceTexture: Nullable<BaseTexture>;
  40366. /** @hidden */
  40367. _webGLTexture: Nullable<WebGLTexture>;
  40368. /** @hidden */
  40369. _references: number;
  40370. /** @hidden */
  40371. _gammaSpace: Nullable<boolean>;
  40372. private _engine;
  40373. /**
  40374. * Gets the Engine the texture belongs to.
  40375. * @returns The babylon engine
  40376. */
  40377. getEngine(): ThinEngine;
  40378. /**
  40379. * Gets the data source type of the texture
  40380. */
  40381. get source(): InternalTextureSource;
  40382. /**
  40383. * Creates a new InternalTexture
  40384. * @param engine defines the engine to use
  40385. * @param source defines the type of data that will be used
  40386. * @param delayAllocation if the texture allocation should be delayed (default: false)
  40387. */
  40388. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  40389. /**
  40390. * Increments the number of references (ie. the number of Texture that point to it)
  40391. */
  40392. incrementReferences(): void;
  40393. /**
  40394. * Change the size of the texture (not the size of the content)
  40395. * @param width defines the new width
  40396. * @param height defines the new height
  40397. * @param depth defines the new depth (1 by default)
  40398. */
  40399. updateSize(width: int, height: int, depth?: int): void;
  40400. /** @hidden */
  40401. _rebuild(): void;
  40402. /** @hidden */
  40403. _swapAndDie(target: InternalTexture): void;
  40404. /**
  40405. * Dispose the current allocated resources
  40406. */
  40407. dispose(): void;
  40408. }
  40409. }
  40410. declare module BABYLON {
  40411. /**
  40412. * Interface used to present a loading screen while loading a scene
  40413. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40414. */
  40415. export interface ILoadingScreen {
  40416. /**
  40417. * Function called to display the loading screen
  40418. */
  40419. displayLoadingUI: () => void;
  40420. /**
  40421. * Function called to hide the loading screen
  40422. */
  40423. hideLoadingUI: () => void;
  40424. /**
  40425. * Gets or sets the color to use for the background
  40426. */
  40427. loadingUIBackgroundColor: string;
  40428. /**
  40429. * Gets or sets the text to display while loading
  40430. */
  40431. loadingUIText: string;
  40432. }
  40433. /**
  40434. * Class used for the default loading screen
  40435. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40436. */
  40437. export class DefaultLoadingScreen implements ILoadingScreen {
  40438. private _renderingCanvas;
  40439. private _loadingText;
  40440. private _loadingDivBackgroundColor;
  40441. private _loadingDiv;
  40442. private _loadingTextDiv;
  40443. /** Gets or sets the logo url to use for the default loading screen */
  40444. static DefaultLogoUrl: string;
  40445. /** Gets or sets the spinner url to use for the default loading screen */
  40446. static DefaultSpinnerUrl: string;
  40447. /**
  40448. * Creates a new default loading screen
  40449. * @param _renderingCanvas defines the canvas used to render the scene
  40450. * @param _loadingText defines the default text to display
  40451. * @param _loadingDivBackgroundColor defines the default background color
  40452. */
  40453. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40454. /**
  40455. * Function called to display the loading screen
  40456. */
  40457. displayLoadingUI(): void;
  40458. /**
  40459. * Function called to hide the loading screen
  40460. */
  40461. hideLoadingUI(): void;
  40462. /**
  40463. * Gets or sets the text to display while loading
  40464. */
  40465. set loadingUIText(text: string);
  40466. get loadingUIText(): string;
  40467. /**
  40468. * Gets or sets the color to use for the background
  40469. */
  40470. get loadingUIBackgroundColor(): string;
  40471. set loadingUIBackgroundColor(color: string);
  40472. private _resizeLoadingUI;
  40473. }
  40474. }
  40475. declare module BABYLON {
  40476. /**
  40477. * Interface for any object that can request an animation frame
  40478. */
  40479. export interface ICustomAnimationFrameRequester {
  40480. /**
  40481. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40482. */
  40483. renderFunction?: Function;
  40484. /**
  40485. * Called to request the next frame to render to
  40486. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40487. */
  40488. requestAnimationFrame: Function;
  40489. /**
  40490. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40491. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40492. */
  40493. requestID?: number;
  40494. }
  40495. }
  40496. declare module BABYLON {
  40497. /**
  40498. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40499. */
  40500. export class PerformanceMonitor {
  40501. private _enabled;
  40502. private _rollingFrameTime;
  40503. private _lastFrameTimeMs;
  40504. /**
  40505. * constructor
  40506. * @param frameSampleSize The number of samples required to saturate the sliding window
  40507. */
  40508. constructor(frameSampleSize?: number);
  40509. /**
  40510. * Samples current frame
  40511. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40512. */
  40513. sampleFrame(timeMs?: number): void;
  40514. /**
  40515. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40516. */
  40517. get averageFrameTime(): number;
  40518. /**
  40519. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40520. */
  40521. get averageFrameTimeVariance(): number;
  40522. /**
  40523. * Returns the frame time of the most recent frame
  40524. */
  40525. get instantaneousFrameTime(): number;
  40526. /**
  40527. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40528. */
  40529. get averageFPS(): number;
  40530. /**
  40531. * Returns the average framerate in frames per second using the most recent frame time
  40532. */
  40533. get instantaneousFPS(): number;
  40534. /**
  40535. * Returns true if enough samples have been taken to completely fill the sliding window
  40536. */
  40537. get isSaturated(): boolean;
  40538. /**
  40539. * Enables contributions to the sliding window sample set
  40540. */
  40541. enable(): void;
  40542. /**
  40543. * Disables contributions to the sliding window sample set
  40544. * Samples will not be interpolated over the disabled period
  40545. */
  40546. disable(): void;
  40547. /**
  40548. * Returns true if sampling is enabled
  40549. */
  40550. get isEnabled(): boolean;
  40551. /**
  40552. * Resets performance monitor
  40553. */
  40554. reset(): void;
  40555. }
  40556. /**
  40557. * RollingAverage
  40558. *
  40559. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40560. */
  40561. export class RollingAverage {
  40562. /**
  40563. * Current average
  40564. */
  40565. average: number;
  40566. /**
  40567. * Current variance
  40568. */
  40569. variance: number;
  40570. protected _samples: Array<number>;
  40571. protected _sampleCount: number;
  40572. protected _pos: number;
  40573. protected _m2: number;
  40574. /**
  40575. * constructor
  40576. * @param length The number of samples required to saturate the sliding window
  40577. */
  40578. constructor(length: number);
  40579. /**
  40580. * Adds a sample to the sample set
  40581. * @param v The sample value
  40582. */
  40583. add(v: number): void;
  40584. /**
  40585. * Returns previously added values or null if outside of history or outside the sliding window domain
  40586. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40587. * @return Value previously recorded with add() or null if outside of range
  40588. */
  40589. history(i: number): number;
  40590. /**
  40591. * Returns true if enough samples have been taken to completely fill the sliding window
  40592. * @return true if sample-set saturated
  40593. */
  40594. isSaturated(): boolean;
  40595. /**
  40596. * Resets the rolling average (equivalent to 0 samples taken so far)
  40597. */
  40598. reset(): void;
  40599. /**
  40600. * Wraps a value around the sample range boundaries
  40601. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40602. * @return Wrapped position in sample range
  40603. */
  40604. protected _wrapPosition(i: number): number;
  40605. }
  40606. }
  40607. declare module BABYLON {
  40608. /**
  40609. * This class is used to track a performance counter which is number based.
  40610. * The user has access to many properties which give statistics of different nature.
  40611. *
  40612. * The implementer can track two kinds of Performance Counter: time and count.
  40613. * 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.
  40614. * 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.
  40615. */
  40616. export class PerfCounter {
  40617. /**
  40618. * Gets or sets a global boolean to turn on and off all the counters
  40619. */
  40620. static Enabled: boolean;
  40621. /**
  40622. * Returns the smallest value ever
  40623. */
  40624. get min(): number;
  40625. /**
  40626. * Returns the biggest value ever
  40627. */
  40628. get max(): number;
  40629. /**
  40630. * Returns the average value since the performance counter is running
  40631. */
  40632. get average(): number;
  40633. /**
  40634. * Returns the average value of the last second the counter was monitored
  40635. */
  40636. get lastSecAverage(): number;
  40637. /**
  40638. * Returns the current value
  40639. */
  40640. get current(): number;
  40641. /**
  40642. * Gets the accumulated total
  40643. */
  40644. get total(): number;
  40645. /**
  40646. * Gets the total value count
  40647. */
  40648. get count(): number;
  40649. /**
  40650. * Creates a new counter
  40651. */
  40652. constructor();
  40653. /**
  40654. * Call this method to start monitoring a new frame.
  40655. * 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.
  40656. */
  40657. fetchNewFrame(): void;
  40658. /**
  40659. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40660. * @param newCount the count value to add to the monitored count
  40661. * @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.
  40662. */
  40663. addCount(newCount: number, fetchResult: boolean): void;
  40664. /**
  40665. * Start monitoring this performance counter
  40666. */
  40667. beginMonitoring(): void;
  40668. /**
  40669. * Compute the time lapsed since the previous beginMonitoring() call.
  40670. * @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
  40671. */
  40672. endMonitoring(newFrame?: boolean): void;
  40673. private _fetchResult;
  40674. private _startMonitoringTime;
  40675. private _min;
  40676. private _max;
  40677. private _average;
  40678. private _current;
  40679. private _totalValueCount;
  40680. private _totalAccumulated;
  40681. private _lastSecAverage;
  40682. private _lastSecAccumulated;
  40683. private _lastSecTime;
  40684. private _lastSecValueCount;
  40685. }
  40686. }
  40687. declare module BABYLON {
  40688. interface ThinEngine {
  40689. /** @hidden */
  40690. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40691. }
  40692. }
  40693. declare module BABYLON {
  40694. /**
  40695. * Class used to work with sound analyzer using fast fourier transform (FFT)
  40696. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40697. */
  40698. export class Analyser {
  40699. /**
  40700. * Gets or sets the smoothing
  40701. * @ignorenaming
  40702. */
  40703. SMOOTHING: number;
  40704. /**
  40705. * Gets or sets the FFT table size
  40706. * @ignorenaming
  40707. */
  40708. FFT_SIZE: number;
  40709. /**
  40710. * Gets or sets the bar graph amplitude
  40711. * @ignorenaming
  40712. */
  40713. BARGRAPHAMPLITUDE: number;
  40714. /**
  40715. * Gets or sets the position of the debug canvas
  40716. * @ignorenaming
  40717. */
  40718. DEBUGCANVASPOS: {
  40719. x: number;
  40720. y: number;
  40721. };
  40722. /**
  40723. * Gets or sets the debug canvas size
  40724. * @ignorenaming
  40725. */
  40726. DEBUGCANVASSIZE: {
  40727. width: number;
  40728. height: number;
  40729. };
  40730. private _byteFreqs;
  40731. private _byteTime;
  40732. private _floatFreqs;
  40733. private _webAudioAnalyser;
  40734. private _debugCanvas;
  40735. private _debugCanvasContext;
  40736. private _scene;
  40737. private _registerFunc;
  40738. private _audioEngine;
  40739. /**
  40740. * Creates a new analyser
  40741. * @param scene defines hosting scene
  40742. */
  40743. constructor(scene: Scene);
  40744. /**
  40745. * Get the number of data values you will have to play with for the visualization
  40746. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  40747. * @returns a number
  40748. */
  40749. getFrequencyBinCount(): number;
  40750. /**
  40751. * Gets the current frequency data as a byte array
  40752. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40753. * @returns a Uint8Array
  40754. */
  40755. getByteFrequencyData(): Uint8Array;
  40756. /**
  40757. * Gets the current waveform as a byte array
  40758. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  40759. * @returns a Uint8Array
  40760. */
  40761. getByteTimeDomainData(): Uint8Array;
  40762. /**
  40763. * Gets the current frequency data as a float array
  40764. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  40765. * @returns a Float32Array
  40766. */
  40767. getFloatFrequencyData(): Float32Array;
  40768. /**
  40769. * Renders the debug canvas
  40770. */
  40771. drawDebugCanvas(): void;
  40772. /**
  40773. * Stops rendering the debug canvas and removes it
  40774. */
  40775. stopDebugCanvas(): void;
  40776. /**
  40777. * Connects two audio nodes
  40778. * @param inputAudioNode defines first node to connect
  40779. * @param outputAudioNode defines second node to connect
  40780. */
  40781. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  40782. /**
  40783. * Releases all associated resources
  40784. */
  40785. dispose(): void;
  40786. }
  40787. }
  40788. declare module BABYLON {
  40789. /**
  40790. * This represents an audio engine and it is responsible
  40791. * to play, synchronize and analyse sounds throughout the application.
  40792. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40793. */
  40794. export interface IAudioEngine extends IDisposable {
  40795. /**
  40796. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  40797. */
  40798. readonly canUseWebAudio: boolean;
  40799. /**
  40800. * Gets the current AudioContext if available.
  40801. */
  40802. readonly audioContext: Nullable<AudioContext>;
  40803. /**
  40804. * The master gain node defines the global audio volume of your audio engine.
  40805. */
  40806. readonly masterGain: GainNode;
  40807. /**
  40808. * Gets whether or not mp3 are supported by your browser.
  40809. */
  40810. readonly isMP3supported: boolean;
  40811. /**
  40812. * Gets whether or not ogg are supported by your browser.
  40813. */
  40814. readonly isOGGsupported: boolean;
  40815. /**
  40816. * Defines if Babylon should emit a warning if WebAudio is not supported.
  40817. * @ignoreNaming
  40818. */
  40819. WarnedWebAudioUnsupported: boolean;
  40820. /**
  40821. * Defines if the audio engine relies on a custom unlocked button.
  40822. * In this case, the embedded button will not be displayed.
  40823. */
  40824. useCustomUnlockedButton: boolean;
  40825. /**
  40826. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  40827. */
  40828. readonly unlocked: boolean;
  40829. /**
  40830. * Event raised when audio has been unlocked on the browser.
  40831. */
  40832. onAudioUnlockedObservable: Observable<IAudioEngine>;
  40833. /**
  40834. * Event raised when audio has been locked on the browser.
  40835. */
  40836. onAudioLockedObservable: Observable<IAudioEngine>;
  40837. /**
  40838. * Flags the audio engine in Locked state.
  40839. * This happens due to new browser policies preventing audio to autoplay.
  40840. */
  40841. lock(): void;
  40842. /**
  40843. * Unlocks the audio engine once a user action has been done on the dom.
  40844. * This is helpful to resume play once browser policies have been satisfied.
  40845. */
  40846. unlock(): void;
  40847. /**
  40848. * Gets the global volume sets on the master gain.
  40849. * @returns the global volume if set or -1 otherwise
  40850. */
  40851. getGlobalVolume(): number;
  40852. /**
  40853. * Sets the global volume of your experience (sets on the master gain).
  40854. * @param newVolume Defines the new global volume of the application
  40855. */
  40856. setGlobalVolume(newVolume: number): void;
  40857. /**
  40858. * Connect the audio engine to an audio analyser allowing some amazing
  40859. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  40860. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  40861. * @param analyser The analyser to connect to the engine
  40862. */
  40863. connectToAnalyser(analyser: Analyser): void;
  40864. }
  40865. }
  40866. declare module BABYLON {
  40867. /**
  40868. * Defines the interface used by display changed events
  40869. */
  40870. export interface IDisplayChangedEventArgs {
  40871. /** Gets the vrDisplay object (if any) */
  40872. vrDisplay: Nullable<any>;
  40873. /** Gets a boolean indicating if webVR is supported */
  40874. vrSupported: boolean;
  40875. }
  40876. /**
  40877. * Defines the interface used by objects containing a viewport (like a camera)
  40878. */
  40879. interface IViewportOwnerLike {
  40880. /**
  40881. * Gets or sets the viewport
  40882. */
  40883. viewport: IViewportLike;
  40884. }
  40885. /**
  40886. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40887. */
  40888. export class Engine extends ThinEngine {
  40889. /** Defines that alpha blending is disabled */
  40890. static readonly ALPHA_DISABLE: number;
  40891. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40892. static readonly ALPHA_ADD: number;
  40893. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40894. static readonly ALPHA_COMBINE: number;
  40895. /** Defines that alpha blending to DEST - SRC * DEST */
  40896. static readonly ALPHA_SUBTRACT: number;
  40897. /** Defines that alpha blending to SRC * DEST */
  40898. static readonly ALPHA_MULTIPLY: number;
  40899. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40900. static readonly ALPHA_MAXIMIZED: number;
  40901. /** Defines that alpha blending to SRC + DEST */
  40902. static readonly ALPHA_ONEONE: number;
  40903. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40904. static readonly ALPHA_PREMULTIPLIED: number;
  40905. /**
  40906. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40907. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40908. */
  40909. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40910. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40911. static readonly ALPHA_INTERPOLATE: number;
  40912. /**
  40913. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40914. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40915. */
  40916. static readonly ALPHA_SCREENMODE: number;
  40917. /** Defines that the ressource is not delayed*/
  40918. static readonly DELAYLOADSTATE_NONE: number;
  40919. /** Defines that the ressource was successfully delay loaded */
  40920. static readonly DELAYLOADSTATE_LOADED: number;
  40921. /** Defines that the ressource is currently delay loading */
  40922. static readonly DELAYLOADSTATE_LOADING: number;
  40923. /** Defines that the ressource is delayed and has not started loading */
  40924. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40925. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40926. static readonly NEVER: number;
  40927. /** 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 */
  40928. static readonly ALWAYS: number;
  40929. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40930. static readonly LESS: number;
  40931. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40932. static readonly EQUAL: number;
  40933. /** 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 */
  40934. static readonly LEQUAL: number;
  40935. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40936. static readonly GREATER: number;
  40937. /** 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 */
  40938. static readonly GEQUAL: number;
  40939. /** 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 */
  40940. static readonly NOTEQUAL: number;
  40941. /** Passed to stencilOperation to specify that stencil value must be kept */
  40942. static readonly KEEP: number;
  40943. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40944. static readonly REPLACE: number;
  40945. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40946. static readonly INCR: number;
  40947. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40948. static readonly DECR: number;
  40949. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40950. static readonly INVERT: number;
  40951. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40952. static readonly INCR_WRAP: number;
  40953. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40954. static readonly DECR_WRAP: number;
  40955. /** Texture is not repeating outside of 0..1 UVs */
  40956. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40957. /** Texture is repeating outside of 0..1 UVs */
  40958. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40959. /** Texture is repeating and mirrored */
  40960. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40961. /** ALPHA */
  40962. static readonly TEXTUREFORMAT_ALPHA: number;
  40963. /** LUMINANCE */
  40964. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40965. /** LUMINANCE_ALPHA */
  40966. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40967. /** RGB */
  40968. static readonly TEXTUREFORMAT_RGB: number;
  40969. /** RGBA */
  40970. static readonly TEXTUREFORMAT_RGBA: number;
  40971. /** RED */
  40972. static readonly TEXTUREFORMAT_RED: number;
  40973. /** RED (2nd reference) */
  40974. static readonly TEXTUREFORMAT_R: number;
  40975. /** RG */
  40976. static readonly TEXTUREFORMAT_RG: number;
  40977. /** RED_INTEGER */
  40978. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40979. /** RED_INTEGER (2nd reference) */
  40980. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40981. /** RG_INTEGER */
  40982. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40983. /** RGB_INTEGER */
  40984. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40985. /** RGBA_INTEGER */
  40986. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40987. /** UNSIGNED_BYTE */
  40988. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40989. /** UNSIGNED_BYTE (2nd reference) */
  40990. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40991. /** FLOAT */
  40992. static readonly TEXTURETYPE_FLOAT: number;
  40993. /** HALF_FLOAT */
  40994. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40995. /** BYTE */
  40996. static readonly TEXTURETYPE_BYTE: number;
  40997. /** SHORT */
  40998. static readonly TEXTURETYPE_SHORT: number;
  40999. /** UNSIGNED_SHORT */
  41000. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41001. /** INT */
  41002. static readonly TEXTURETYPE_INT: number;
  41003. /** UNSIGNED_INT */
  41004. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41005. /** UNSIGNED_SHORT_4_4_4_4 */
  41006. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41007. /** UNSIGNED_SHORT_5_5_5_1 */
  41008. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41009. /** UNSIGNED_SHORT_5_6_5 */
  41010. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41011. /** UNSIGNED_INT_2_10_10_10_REV */
  41012. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41013. /** UNSIGNED_INT_24_8 */
  41014. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41015. /** UNSIGNED_INT_10F_11F_11F_REV */
  41016. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41017. /** UNSIGNED_INT_5_9_9_9_REV */
  41018. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41019. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41020. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41021. /** nearest is mag = nearest and min = nearest and mip = linear */
  41022. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41023. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41024. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41025. /** Trilinear is mag = linear and min = linear and mip = linear */
  41026. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41027. /** nearest is mag = nearest and min = nearest and mip = linear */
  41028. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41029. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41030. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41031. /** Trilinear is mag = linear and min = linear and mip = linear */
  41032. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41033. /** mag = nearest and min = nearest and mip = nearest */
  41034. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41035. /** mag = nearest and min = linear and mip = nearest */
  41036. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41037. /** mag = nearest and min = linear and mip = linear */
  41038. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41039. /** mag = nearest and min = linear and mip = none */
  41040. static readonly TEXTURE_NEAREST_LINEAR: number;
  41041. /** mag = nearest and min = nearest and mip = none */
  41042. static readonly TEXTURE_NEAREST_NEAREST: number;
  41043. /** mag = linear and min = nearest and mip = nearest */
  41044. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41045. /** mag = linear and min = nearest and mip = linear */
  41046. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41047. /** mag = linear and min = linear and mip = none */
  41048. static readonly TEXTURE_LINEAR_LINEAR: number;
  41049. /** mag = linear and min = nearest and mip = none */
  41050. static readonly TEXTURE_LINEAR_NEAREST: number;
  41051. /** Explicit coordinates mode */
  41052. static readonly TEXTURE_EXPLICIT_MODE: number;
  41053. /** Spherical coordinates mode */
  41054. static readonly TEXTURE_SPHERICAL_MODE: number;
  41055. /** Planar coordinates mode */
  41056. static readonly TEXTURE_PLANAR_MODE: number;
  41057. /** Cubic coordinates mode */
  41058. static readonly TEXTURE_CUBIC_MODE: number;
  41059. /** Projection coordinates mode */
  41060. static readonly TEXTURE_PROJECTION_MODE: number;
  41061. /** Skybox coordinates mode */
  41062. static readonly TEXTURE_SKYBOX_MODE: number;
  41063. /** Inverse Cubic coordinates mode */
  41064. static readonly TEXTURE_INVCUBIC_MODE: number;
  41065. /** Equirectangular coordinates mode */
  41066. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  41067. /** Equirectangular Fixed coordinates mode */
  41068. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  41069. /** Equirectangular Fixed Mirrored coordinates mode */
  41070. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  41071. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  41072. static readonly SCALEMODE_FLOOR: number;
  41073. /** Defines that texture rescaling will look for the nearest power of 2 size */
  41074. static readonly SCALEMODE_NEAREST: number;
  41075. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  41076. static readonly SCALEMODE_CEILING: number;
  41077. /**
  41078. * Returns the current npm package of the sdk
  41079. */
  41080. static get NpmPackage(): string;
  41081. /**
  41082. * Returns the current version of the framework
  41083. */
  41084. static get Version(): string;
  41085. /** Gets the list of created engines */
  41086. static get Instances(): Engine[];
  41087. /**
  41088. * Gets the latest created engine
  41089. */
  41090. static get LastCreatedEngine(): Nullable<Engine>;
  41091. /**
  41092. * Gets the latest created scene
  41093. */
  41094. static get LastCreatedScene(): Nullable<Scene>;
  41095. /**
  41096. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  41097. * @param flag defines which part of the materials must be marked as dirty
  41098. * @param predicate defines a predicate used to filter which materials should be affected
  41099. */
  41100. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41101. /**
  41102. * Method called to create the default loading screen.
  41103. * This can be overriden in your own app.
  41104. * @param canvas The rendering canvas element
  41105. * @returns The loading screen
  41106. */
  41107. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  41108. /**
  41109. * Method called to create the default rescale post process on each engine.
  41110. */
  41111. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  41112. /**
  41113. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  41114. **/
  41115. enableOfflineSupport: boolean;
  41116. /**
  41117. * 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)
  41118. **/
  41119. disableManifestCheck: boolean;
  41120. /**
  41121. * Gets the list of created scenes
  41122. */
  41123. scenes: Scene[];
  41124. /**
  41125. * Event raised when a new scene is created
  41126. */
  41127. onNewSceneAddedObservable: Observable<Scene>;
  41128. /**
  41129. * Gets the list of created postprocesses
  41130. */
  41131. postProcesses: PostProcess[];
  41132. /**
  41133. * Gets a boolean indicating if the pointer is currently locked
  41134. */
  41135. isPointerLock: boolean;
  41136. /**
  41137. * Observable event triggered each time the rendering canvas is resized
  41138. */
  41139. onResizeObservable: Observable<Engine>;
  41140. /**
  41141. * Observable event triggered each time the canvas loses focus
  41142. */
  41143. onCanvasBlurObservable: Observable<Engine>;
  41144. /**
  41145. * Observable event triggered each time the canvas gains focus
  41146. */
  41147. onCanvasFocusObservable: Observable<Engine>;
  41148. /**
  41149. * Observable event triggered each time the canvas receives pointerout event
  41150. */
  41151. onCanvasPointerOutObservable: Observable<PointerEvent>;
  41152. /**
  41153. * Observable raised when the engine begins a new frame
  41154. */
  41155. onBeginFrameObservable: Observable<Engine>;
  41156. /**
  41157. * If set, will be used to request the next animation frame for the render loop
  41158. */
  41159. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  41160. /**
  41161. * Observable raised when the engine ends the current frame
  41162. */
  41163. onEndFrameObservable: Observable<Engine>;
  41164. /**
  41165. * Observable raised when the engine is about to compile a shader
  41166. */
  41167. onBeforeShaderCompilationObservable: Observable<Engine>;
  41168. /**
  41169. * Observable raised when the engine has jsut compiled a shader
  41170. */
  41171. onAfterShaderCompilationObservable: Observable<Engine>;
  41172. /**
  41173. * Gets the audio engine
  41174. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41175. * @ignorenaming
  41176. */
  41177. static audioEngine: IAudioEngine;
  41178. /**
  41179. * Default AudioEngine factory responsible of creating the Audio Engine.
  41180. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  41181. */
  41182. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  41183. /**
  41184. * Default offline support factory responsible of creating a tool used to store data locally.
  41185. * By default, this will create a Database object if the workload has been embedded.
  41186. */
  41187. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  41188. private _loadingScreen;
  41189. private _pointerLockRequested;
  41190. private _rescalePostProcess;
  41191. private _deterministicLockstep;
  41192. private _lockstepMaxSteps;
  41193. private _timeStep;
  41194. protected get _supportsHardwareTextureRescaling(): boolean;
  41195. private _fps;
  41196. private _deltaTime;
  41197. /** @hidden */
  41198. _drawCalls: PerfCounter;
  41199. /** 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 */
  41200. canvasTabIndex: number;
  41201. /**
  41202. * Turn this value on if you want to pause FPS computation when in background
  41203. */
  41204. disablePerformanceMonitorInBackground: boolean;
  41205. private _performanceMonitor;
  41206. /**
  41207. * Gets the performance monitor attached to this engine
  41208. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  41209. */
  41210. get performanceMonitor(): PerformanceMonitor;
  41211. private _onFocus;
  41212. private _onBlur;
  41213. private _onCanvasPointerOut;
  41214. private _onCanvasBlur;
  41215. private _onCanvasFocus;
  41216. private _onFullscreenChange;
  41217. private _onPointerLockChange;
  41218. /**
  41219. * Gets the HTML element used to attach event listeners
  41220. * @returns a HTML element
  41221. */
  41222. getInputElement(): Nullable<HTMLElement>;
  41223. /**
  41224. * Creates a new engine
  41225. * @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
  41226. * @param antialias defines enable antialiasing (default: false)
  41227. * @param options defines further options to be sent to the getContext() function
  41228. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  41229. */
  41230. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  41231. /**
  41232. * Gets current aspect ratio
  41233. * @param viewportOwner defines the camera to use to get the aspect ratio
  41234. * @param useScreen defines if screen size must be used (or the current render target if any)
  41235. * @returns a number defining the aspect ratio
  41236. */
  41237. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  41238. /**
  41239. * Gets current screen aspect ratio
  41240. * @returns a number defining the aspect ratio
  41241. */
  41242. getScreenAspectRatio(): number;
  41243. /**
  41244. * Gets the client rect of the HTML canvas attached with the current webGL context
  41245. * @returns a client rectanglee
  41246. */
  41247. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  41248. /**
  41249. * Gets the client rect of the HTML element used for events
  41250. * @returns a client rectanglee
  41251. */
  41252. getInputElementClientRect(): Nullable<ClientRect>;
  41253. /**
  41254. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  41255. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41256. * @returns true if engine is in deterministic lock step mode
  41257. */
  41258. isDeterministicLockStep(): boolean;
  41259. /**
  41260. * Gets the max steps when engine is running in deterministic lock step
  41261. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41262. * @returns the max steps
  41263. */
  41264. getLockstepMaxSteps(): number;
  41265. /**
  41266. * Returns the time in ms between steps when using deterministic lock step.
  41267. * @returns time step in (ms)
  41268. */
  41269. getTimeStep(): number;
  41270. /**
  41271. * Force the mipmap generation for the given render target texture
  41272. * @param texture defines the render target texture to use
  41273. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  41274. */
  41275. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  41276. /** States */
  41277. /**
  41278. * Set various states to the webGL context
  41279. * @param culling defines backface culling state
  41280. * @param zOffset defines the value to apply to zOffset (0 by default)
  41281. * @param force defines if states must be applied even if cache is up to date
  41282. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  41283. */
  41284. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41285. /**
  41286. * Set the z offset to apply to current rendering
  41287. * @param value defines the offset to apply
  41288. */
  41289. setZOffset(value: number): void;
  41290. /**
  41291. * Gets the current value of the zOffset
  41292. * @returns the current zOffset state
  41293. */
  41294. getZOffset(): number;
  41295. /**
  41296. * Enable or disable depth buffering
  41297. * @param enable defines the state to set
  41298. */
  41299. setDepthBuffer(enable: boolean): void;
  41300. /**
  41301. * Gets a boolean indicating if depth writing is enabled
  41302. * @returns the current depth writing state
  41303. */
  41304. getDepthWrite(): boolean;
  41305. /**
  41306. * Enable or disable depth writing
  41307. * @param enable defines the state to set
  41308. */
  41309. setDepthWrite(enable: boolean): void;
  41310. /**
  41311. * Gets a boolean indicating if stencil buffer is enabled
  41312. * @returns the current stencil buffer state
  41313. */
  41314. getStencilBuffer(): boolean;
  41315. /**
  41316. * Enable or disable the stencil buffer
  41317. * @param enable defines if the stencil buffer must be enabled or disabled
  41318. */
  41319. setStencilBuffer(enable: boolean): void;
  41320. /**
  41321. * Gets the current stencil mask
  41322. * @returns a number defining the new stencil mask to use
  41323. */
  41324. getStencilMask(): number;
  41325. /**
  41326. * Sets the current stencil mask
  41327. * @param mask defines the new stencil mask to use
  41328. */
  41329. setStencilMask(mask: number): void;
  41330. /**
  41331. * Gets the current stencil function
  41332. * @returns a number defining the stencil function to use
  41333. */
  41334. getStencilFunction(): number;
  41335. /**
  41336. * Gets the current stencil reference value
  41337. * @returns a number defining the stencil reference value to use
  41338. */
  41339. getStencilFunctionReference(): number;
  41340. /**
  41341. * Gets the current stencil mask
  41342. * @returns a number defining the stencil mask to use
  41343. */
  41344. getStencilFunctionMask(): number;
  41345. /**
  41346. * Sets the current stencil function
  41347. * @param stencilFunc defines the new stencil function to use
  41348. */
  41349. setStencilFunction(stencilFunc: number): void;
  41350. /**
  41351. * Sets the current stencil reference
  41352. * @param reference defines the new stencil reference to use
  41353. */
  41354. setStencilFunctionReference(reference: number): void;
  41355. /**
  41356. * Sets the current stencil mask
  41357. * @param mask defines the new stencil mask to use
  41358. */
  41359. setStencilFunctionMask(mask: number): void;
  41360. /**
  41361. * Gets the current stencil operation when stencil fails
  41362. * @returns a number defining stencil operation to use when stencil fails
  41363. */
  41364. getStencilOperationFail(): number;
  41365. /**
  41366. * Gets the current stencil operation when depth fails
  41367. * @returns a number defining stencil operation to use when depth fails
  41368. */
  41369. getStencilOperationDepthFail(): number;
  41370. /**
  41371. * Gets the current stencil operation when stencil passes
  41372. * @returns a number defining stencil operation to use when stencil passes
  41373. */
  41374. getStencilOperationPass(): number;
  41375. /**
  41376. * Sets the stencil operation to use when stencil fails
  41377. * @param operation defines the stencil operation to use when stencil fails
  41378. */
  41379. setStencilOperationFail(operation: number): void;
  41380. /**
  41381. * Sets the stencil operation to use when depth fails
  41382. * @param operation defines the stencil operation to use when depth fails
  41383. */
  41384. setStencilOperationDepthFail(operation: number): void;
  41385. /**
  41386. * Sets the stencil operation to use when stencil passes
  41387. * @param operation defines the stencil operation to use when stencil passes
  41388. */
  41389. setStencilOperationPass(operation: number): void;
  41390. /**
  41391. * Sets a boolean indicating if the dithering state is enabled or disabled
  41392. * @param value defines the dithering state
  41393. */
  41394. setDitheringState(value: boolean): void;
  41395. /**
  41396. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  41397. * @param value defines the rasterizer state
  41398. */
  41399. setRasterizerState(value: boolean): void;
  41400. /**
  41401. * Gets the current depth function
  41402. * @returns a number defining the depth function
  41403. */
  41404. getDepthFunction(): Nullable<number>;
  41405. /**
  41406. * Sets the current depth function
  41407. * @param depthFunc defines the function to use
  41408. */
  41409. setDepthFunction(depthFunc: number): void;
  41410. /**
  41411. * Sets the current depth function to GREATER
  41412. */
  41413. setDepthFunctionToGreater(): void;
  41414. /**
  41415. * Sets the current depth function to GEQUAL
  41416. */
  41417. setDepthFunctionToGreaterOrEqual(): void;
  41418. /**
  41419. * Sets the current depth function to LESS
  41420. */
  41421. setDepthFunctionToLess(): void;
  41422. /**
  41423. * Sets the current depth function to LEQUAL
  41424. */
  41425. setDepthFunctionToLessOrEqual(): void;
  41426. private _cachedStencilBuffer;
  41427. private _cachedStencilFunction;
  41428. private _cachedStencilMask;
  41429. private _cachedStencilOperationPass;
  41430. private _cachedStencilOperationFail;
  41431. private _cachedStencilOperationDepthFail;
  41432. private _cachedStencilReference;
  41433. /**
  41434. * Caches the the state of the stencil buffer
  41435. */
  41436. cacheStencilState(): void;
  41437. /**
  41438. * Restores the state of the stencil buffer
  41439. */
  41440. restoreStencilState(): void;
  41441. /**
  41442. * Directly set the WebGL Viewport
  41443. * @param x defines the x coordinate of the viewport (in screen space)
  41444. * @param y defines the y coordinate of the viewport (in screen space)
  41445. * @param width defines the width of the viewport (in screen space)
  41446. * @param height defines the height of the viewport (in screen space)
  41447. * @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
  41448. */
  41449. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  41450. /**
  41451. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  41452. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41453. * @param y defines the y-coordinate of the corner of the clear rectangle
  41454. * @param width defines the width of the clear rectangle
  41455. * @param height defines the height of the clear rectangle
  41456. * @param clearColor defines the clear color
  41457. */
  41458. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  41459. /**
  41460. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  41461. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  41462. * @param y defines the y-coordinate of the corner of the clear rectangle
  41463. * @param width defines the width of the clear rectangle
  41464. * @param height defines the height of the clear rectangle
  41465. */
  41466. enableScissor(x: number, y: number, width: number, height: number): void;
  41467. /**
  41468. * Disable previously set scissor test rectangle
  41469. */
  41470. disableScissor(): void;
  41471. protected _reportDrawCall(): void;
  41472. /**
  41473. * Initializes a webVR display and starts listening to display change events
  41474. * The onVRDisplayChangedObservable will be notified upon these changes
  41475. * @returns The onVRDisplayChangedObservable
  41476. */
  41477. initWebVR(): Observable<IDisplayChangedEventArgs>;
  41478. /** @hidden */
  41479. _prepareVRComponent(): void;
  41480. /** @hidden */
  41481. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  41482. /** @hidden */
  41483. _submitVRFrame(): void;
  41484. /**
  41485. * Call this function to leave webVR mode
  41486. * Will do nothing if webVR is not supported or if there is no webVR device
  41487. * @see https://doc.babylonjs.com/how_to/webvr_camera
  41488. */
  41489. disableVR(): void;
  41490. /**
  41491. * Gets a boolean indicating that the system is in VR mode and is presenting
  41492. * @returns true if VR mode is engaged
  41493. */
  41494. isVRPresenting(): boolean;
  41495. /** @hidden */
  41496. _requestVRFrame(): void;
  41497. /** @hidden */
  41498. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41499. /**
  41500. * Gets the source code of the vertex shader associated with a specific webGL program
  41501. * @param program defines the program to use
  41502. * @returns a string containing the source code of the vertex shader associated with the program
  41503. */
  41504. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  41505. /**
  41506. * Gets the source code of the fragment shader associated with a specific webGL program
  41507. * @param program defines the program to use
  41508. * @returns a string containing the source code of the fragment shader associated with the program
  41509. */
  41510. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  41511. /**
  41512. * Sets a depth stencil texture from a render target to the according uniform.
  41513. * @param channel The texture channel
  41514. * @param uniform The uniform to set
  41515. * @param texture The render target texture containing the depth stencil texture to apply
  41516. */
  41517. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  41518. /**
  41519. * Sets a texture to the webGL context from a postprocess
  41520. * @param channel defines the channel to use
  41521. * @param postProcess defines the source postprocess
  41522. */
  41523. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  41524. /**
  41525. * Binds the output of the passed in post process to the texture channel specified
  41526. * @param channel The channel the texture should be bound to
  41527. * @param postProcess The post process which's output should be bound
  41528. */
  41529. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  41530. protected _rebuildBuffers(): void;
  41531. /** @hidden */
  41532. _renderFrame(): void;
  41533. _renderLoop(): void;
  41534. /** @hidden */
  41535. _renderViews(): boolean;
  41536. /**
  41537. * Toggle full screen mode
  41538. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41539. */
  41540. switchFullscreen(requestPointerLock: boolean): void;
  41541. /**
  41542. * Enters full screen mode
  41543. * @param requestPointerLock defines if a pointer lock should be requested from the user
  41544. */
  41545. enterFullscreen(requestPointerLock: boolean): void;
  41546. /**
  41547. * Exits full screen mode
  41548. */
  41549. exitFullscreen(): void;
  41550. /**
  41551. * Enters Pointerlock mode
  41552. */
  41553. enterPointerlock(): void;
  41554. /**
  41555. * Exits Pointerlock mode
  41556. */
  41557. exitPointerlock(): void;
  41558. /**
  41559. * Begin a new frame
  41560. */
  41561. beginFrame(): void;
  41562. /**
  41563. * Enf the current frame
  41564. */
  41565. endFrame(): void;
  41566. resize(): void;
  41567. /**
  41568. * Force a specific size of the canvas
  41569. * @param width defines the new canvas' width
  41570. * @param height defines the new canvas' height
  41571. * @returns true if the size was changed
  41572. */
  41573. setSize(width: number, height: number): boolean;
  41574. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  41575. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41576. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  41577. _releaseTexture(texture: InternalTexture): void;
  41578. /**
  41579. * @hidden
  41580. * Rescales a texture
  41581. * @param source input texutre
  41582. * @param destination destination texture
  41583. * @param scene scene to use to render the resize
  41584. * @param internalFormat format to use when resizing
  41585. * @param onComplete callback to be called when resize has completed
  41586. */
  41587. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41588. /**
  41589. * Gets the current framerate
  41590. * @returns a number representing the framerate
  41591. */
  41592. getFps(): number;
  41593. /**
  41594. * Gets the time spent between current and previous frame
  41595. * @returns a number representing the delta time in ms
  41596. */
  41597. getDeltaTime(): number;
  41598. private _measureFps;
  41599. /** @hidden */
  41600. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41601. /**
  41602. * Updates the sample count of a render target texture
  41603. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41604. * @param texture defines the texture to update
  41605. * @param samples defines the sample count to set
  41606. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41607. */
  41608. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41609. /**
  41610. * Updates a depth texture Comparison Mode and Function.
  41611. * If the comparison Function is equal to 0, the mode will be set to none.
  41612. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41613. * @param texture The texture to set the comparison function for
  41614. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41615. */
  41616. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41617. /**
  41618. * Creates a webGL buffer to use with instanciation
  41619. * @param capacity defines the size of the buffer
  41620. * @returns the webGL buffer
  41621. */
  41622. createInstancesBuffer(capacity: number): DataBuffer;
  41623. /**
  41624. * Delete a webGL buffer used with instanciation
  41625. * @param buffer defines the webGL buffer to delete
  41626. */
  41627. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41628. private _clientWaitAsync;
  41629. /** @hidden */
  41630. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41631. dispose(): void;
  41632. private _disableTouchAction;
  41633. /**
  41634. * Display the loading screen
  41635. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41636. */
  41637. displayLoadingUI(): void;
  41638. /**
  41639. * Hide the loading screen
  41640. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41641. */
  41642. hideLoadingUI(): void;
  41643. /**
  41644. * Gets the current loading screen object
  41645. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41646. */
  41647. get loadingScreen(): ILoadingScreen;
  41648. /**
  41649. * Sets the current loading screen object
  41650. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41651. */
  41652. set loadingScreen(loadingScreen: ILoadingScreen);
  41653. /**
  41654. * Sets the current loading screen text
  41655. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41656. */
  41657. set loadingUIText(text: string);
  41658. /**
  41659. * Sets the current loading screen background color
  41660. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41661. */
  41662. set loadingUIBackgroundColor(color: string);
  41663. /** Pointerlock and fullscreen */
  41664. /**
  41665. * Ask the browser to promote the current element to pointerlock mode
  41666. * @param element defines the DOM element to promote
  41667. */
  41668. static _RequestPointerlock(element: HTMLElement): void;
  41669. /**
  41670. * Asks the browser to exit pointerlock mode
  41671. */
  41672. static _ExitPointerlock(): void;
  41673. /**
  41674. * Ask the browser to promote the current element to fullscreen rendering mode
  41675. * @param element defines the DOM element to promote
  41676. */
  41677. static _RequestFullscreen(element: HTMLElement): void;
  41678. /**
  41679. * Asks the browser to exit fullscreen mode
  41680. */
  41681. static _ExitFullscreen(): void;
  41682. }
  41683. }
  41684. declare module BABYLON {
  41685. /**
  41686. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41687. * during the life time of the application.
  41688. */
  41689. export class EngineStore {
  41690. /** Gets the list of created engines */
  41691. static Instances: Engine[];
  41692. /** @hidden */
  41693. static _LastCreatedScene: Nullable<Scene>;
  41694. /**
  41695. * Gets the latest created engine
  41696. */
  41697. static get LastCreatedEngine(): Nullable<Engine>;
  41698. /**
  41699. * Gets the latest created scene
  41700. */
  41701. static get LastCreatedScene(): Nullable<Scene>;
  41702. /**
  41703. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41704. * @ignorenaming
  41705. */
  41706. static UseFallbackTexture: boolean;
  41707. /**
  41708. * Texture content used if a texture cannot loaded
  41709. * @ignorenaming
  41710. */
  41711. static FallbackTexture: string;
  41712. }
  41713. }
  41714. declare module BABYLON {
  41715. /**
  41716. * Helper class that provides a small promise polyfill
  41717. */
  41718. export class PromisePolyfill {
  41719. /**
  41720. * Static function used to check if the polyfill is required
  41721. * If this is the case then the function will inject the polyfill to window.Promise
  41722. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41723. */
  41724. static Apply(force?: boolean): void;
  41725. }
  41726. }
  41727. declare module BABYLON {
  41728. /**
  41729. * Interface for screenshot methods with describe argument called `size` as object with options
  41730. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41731. */
  41732. export interface IScreenshotSize {
  41733. /**
  41734. * number in pixels for canvas height
  41735. */
  41736. height?: number;
  41737. /**
  41738. * multiplier allowing render at a higher or lower resolution
  41739. * If value is defined then height and width will be ignored and taken from camera
  41740. */
  41741. precision?: number;
  41742. /**
  41743. * number in pixels for canvas width
  41744. */
  41745. width?: number;
  41746. }
  41747. }
  41748. declare module BABYLON {
  41749. interface IColor4Like {
  41750. r: float;
  41751. g: float;
  41752. b: float;
  41753. a: float;
  41754. }
  41755. /**
  41756. * Class containing a set of static utilities functions
  41757. */
  41758. export class Tools {
  41759. /**
  41760. * Gets or sets the base URL to use to load assets
  41761. */
  41762. static get BaseUrl(): string;
  41763. static set BaseUrl(value: string);
  41764. /**
  41765. * Enable/Disable Custom HTTP Request Headers globally.
  41766. * default = false
  41767. * @see CustomRequestHeaders
  41768. */
  41769. static UseCustomRequestHeaders: boolean;
  41770. /**
  41771. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41772. * i.e. when loading files, where the server/service expects an Authorization header
  41773. */
  41774. static CustomRequestHeaders: {
  41775. [key: string]: string;
  41776. };
  41777. /**
  41778. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41779. */
  41780. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41781. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41782. /**
  41783. * Default behaviour for cors in the application.
  41784. * It can be a string if the expected behavior is identical in the entire app.
  41785. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41786. */
  41787. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41788. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41789. /**
  41790. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41791. * @ignorenaming
  41792. */
  41793. static get UseFallbackTexture(): boolean;
  41794. static set UseFallbackTexture(value: boolean);
  41795. /**
  41796. * Use this object to register external classes like custom textures or material
  41797. * to allow the laoders to instantiate them
  41798. */
  41799. static get RegisteredExternalClasses(): {
  41800. [key: string]: Object;
  41801. };
  41802. static set RegisteredExternalClasses(classes: {
  41803. [key: string]: Object;
  41804. });
  41805. /**
  41806. * Texture content used if a texture cannot loaded
  41807. * @ignorenaming
  41808. */
  41809. static get fallbackTexture(): string;
  41810. static set fallbackTexture(value: string);
  41811. /**
  41812. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41813. * @param u defines the coordinate on X axis
  41814. * @param v defines the coordinate on Y axis
  41815. * @param width defines the width of the source data
  41816. * @param height defines the height of the source data
  41817. * @param pixels defines the source byte array
  41818. * @param color defines the output color
  41819. */
  41820. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41821. /**
  41822. * Interpolates between a and b via alpha
  41823. * @param a The lower value (returned when alpha = 0)
  41824. * @param b The upper value (returned when alpha = 1)
  41825. * @param alpha The interpolation-factor
  41826. * @return The mixed value
  41827. */
  41828. static Mix(a: number, b: number, alpha: number): number;
  41829. /**
  41830. * Tries to instantiate a new object from a given class name
  41831. * @param className defines the class name to instantiate
  41832. * @returns the new object or null if the system was not able to do the instantiation
  41833. */
  41834. static Instantiate(className: string): any;
  41835. /**
  41836. * Provides a slice function that will work even on IE
  41837. * @param data defines the array to slice
  41838. * @param start defines the start of the data (optional)
  41839. * @param end defines the end of the data (optional)
  41840. * @returns the new sliced array
  41841. */
  41842. static Slice<T>(data: T, start?: number, end?: number): T;
  41843. /**
  41844. * Provides a slice function that will work even on IE
  41845. * The difference between this and Slice is that this will force-convert to array
  41846. * @param data defines the array to slice
  41847. * @param start defines the start of the data (optional)
  41848. * @param end defines the end of the data (optional)
  41849. * @returns the new sliced array
  41850. */
  41851. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  41852. /**
  41853. * Polyfill for setImmediate
  41854. * @param action defines the action to execute after the current execution block
  41855. */
  41856. static SetImmediate(action: () => void): void;
  41857. /**
  41858. * Function indicating if a number is an exponent of 2
  41859. * @param value defines the value to test
  41860. * @returns true if the value is an exponent of 2
  41861. */
  41862. static IsExponentOfTwo(value: number): boolean;
  41863. private static _tmpFloatArray;
  41864. /**
  41865. * Returns the nearest 32-bit single precision float representation of a Number
  41866. * @param value A Number. If the parameter is of a different type, it will get converted
  41867. * to a number or to NaN if it cannot be converted
  41868. * @returns number
  41869. */
  41870. static FloatRound(value: number): number;
  41871. /**
  41872. * Extracts the filename from a path
  41873. * @param path defines the path to use
  41874. * @returns the filename
  41875. */
  41876. static GetFilename(path: string): string;
  41877. /**
  41878. * Extracts the "folder" part of a path (everything before the filename).
  41879. * @param uri The URI to extract the info from
  41880. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41881. * @returns The "folder" part of the path
  41882. */
  41883. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41884. /**
  41885. * Extracts text content from a DOM element hierarchy
  41886. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41887. */
  41888. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41889. /**
  41890. * Convert an angle in radians to degrees
  41891. * @param angle defines the angle to convert
  41892. * @returns the angle in degrees
  41893. */
  41894. static ToDegrees(angle: number): number;
  41895. /**
  41896. * Convert an angle in degrees to radians
  41897. * @param angle defines the angle to convert
  41898. * @returns the angle in radians
  41899. */
  41900. static ToRadians(angle: number): number;
  41901. /**
  41902. * Returns an array if obj is not an array
  41903. * @param obj defines the object to evaluate as an array
  41904. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41905. * @returns either obj directly if obj is an array or a new array containing obj
  41906. */
  41907. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41908. /**
  41909. * Gets the pointer prefix to use
  41910. * @param engine defines the engine we are finding the prefix for
  41911. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41912. */
  41913. static GetPointerPrefix(engine: Engine): string;
  41914. /**
  41915. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41916. * @param url define the url we are trying
  41917. * @param element define the dom element where to configure the cors policy
  41918. */
  41919. static SetCorsBehavior(url: string | string[], element: {
  41920. crossOrigin: string | null;
  41921. }): void;
  41922. /**
  41923. * Removes unwanted characters from an url
  41924. * @param url defines the url to clean
  41925. * @returns the cleaned url
  41926. */
  41927. static CleanUrl(url: string): string;
  41928. /**
  41929. * Gets or sets a function used to pre-process url before using them to load assets
  41930. */
  41931. static get PreprocessUrl(): (url: string) => string;
  41932. static set PreprocessUrl(processor: (url: string) => string);
  41933. /**
  41934. * Loads an image as an HTMLImageElement.
  41935. * @param input url string, ArrayBuffer, or Blob to load
  41936. * @param onLoad callback called when the image successfully loads
  41937. * @param onError callback called when the image fails to load
  41938. * @param offlineProvider offline provider for caching
  41939. * @param mimeType optional mime type
  41940. * @returns the HTMLImageElement of the loaded image
  41941. */
  41942. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41943. /**
  41944. * Loads a file from a url
  41945. * @param url url string, ArrayBuffer, or Blob to load
  41946. * @param onSuccess callback called when the file successfully loads
  41947. * @param onProgress callback called while file is loading (if the server supports this mode)
  41948. * @param offlineProvider defines the offline provider for caching
  41949. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41950. * @param onError callback called when the file fails to load
  41951. * @returns a file request object
  41952. */
  41953. 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;
  41954. /**
  41955. * Loads a file from a url
  41956. * @param url the file url to load
  41957. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41958. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41959. */
  41960. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41961. /**
  41962. * Load a script (identified by an url). When the url returns, the
  41963. * content of this file is added into a new script element, attached to the DOM (body element)
  41964. * @param scriptUrl defines the url of the script to laod
  41965. * @param onSuccess defines the callback called when the script is loaded
  41966. * @param onError defines the callback to call if an error occurs
  41967. * @param scriptId defines the id of the script element
  41968. */
  41969. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41970. /**
  41971. * Load an asynchronous script (identified by an url). When the url returns, the
  41972. * content of this file is added into a new script element, attached to the DOM (body element)
  41973. * @param scriptUrl defines the url of the script to laod
  41974. * @param scriptId defines the id of the script element
  41975. * @returns a promise request object
  41976. */
  41977. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41978. /**
  41979. * Loads a file from a blob
  41980. * @param fileToLoad defines the blob to use
  41981. * @param callback defines the callback to call when data is loaded
  41982. * @param progressCallback defines the callback to call during loading process
  41983. * @returns a file request object
  41984. */
  41985. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41986. /**
  41987. * Reads a file from a File object
  41988. * @param file defines the file to load
  41989. * @param onSuccess defines the callback to call when data is loaded
  41990. * @param onProgress defines the callback to call during loading process
  41991. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41992. * @param onError defines the callback to call when an error occurs
  41993. * @returns a file request object
  41994. */
  41995. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41996. /**
  41997. * Creates a data url from a given string content
  41998. * @param content defines the content to convert
  41999. * @returns the new data url link
  42000. */
  42001. static FileAsURL(content: string): string;
  42002. /**
  42003. * Format the given number to a specific decimal format
  42004. * @param value defines the number to format
  42005. * @param decimals defines the number of decimals to use
  42006. * @returns the formatted string
  42007. */
  42008. static Format(value: number, decimals?: number): string;
  42009. /**
  42010. * Tries to copy an object by duplicating every property
  42011. * @param source defines the source object
  42012. * @param destination defines the target object
  42013. * @param doNotCopyList defines a list of properties to avoid
  42014. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42015. */
  42016. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42017. /**
  42018. * Gets a boolean indicating if the given object has no own property
  42019. * @param obj defines the object to test
  42020. * @returns true if object has no own property
  42021. */
  42022. static IsEmpty(obj: any): boolean;
  42023. /**
  42024. * Function used to register events at window level
  42025. * @param windowElement defines the Window object to use
  42026. * @param events defines the events to register
  42027. */
  42028. static RegisterTopRootEvents(windowElement: Window, events: {
  42029. name: string;
  42030. handler: Nullable<(e: FocusEvent) => any>;
  42031. }[]): void;
  42032. /**
  42033. * Function used to unregister events from window level
  42034. * @param windowElement defines the Window object to use
  42035. * @param events defines the events to unregister
  42036. */
  42037. static UnregisterTopRootEvents(windowElement: Window, events: {
  42038. name: string;
  42039. handler: Nullable<(e: FocusEvent) => any>;
  42040. }[]): void;
  42041. /**
  42042. * @ignore
  42043. */
  42044. static _ScreenshotCanvas: HTMLCanvasElement;
  42045. /**
  42046. * Dumps the current bound framebuffer
  42047. * @param width defines the rendering width
  42048. * @param height defines the rendering height
  42049. * @param engine defines the hosting engine
  42050. * @param successCallback defines the callback triggered once the data are available
  42051. * @param mimeType defines the mime type of the result
  42052. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  42053. */
  42054. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42055. /**
  42056. * Converts the canvas data to blob.
  42057. * This acts as a polyfill for browsers not supporting the to blob function.
  42058. * @param canvas Defines the canvas to extract the data from
  42059. * @param successCallback Defines the callback triggered once the data are available
  42060. * @param mimeType Defines the mime type of the result
  42061. */
  42062. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  42063. /**
  42064. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  42065. * @param successCallback defines the callback triggered once the data are available
  42066. * @param mimeType defines the mime type of the result
  42067. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  42068. */
  42069. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  42070. /**
  42071. * Downloads a blob in the browser
  42072. * @param blob defines the blob to download
  42073. * @param fileName defines the name of the downloaded file
  42074. */
  42075. static Download(blob: Blob, fileName: string): void;
  42076. /**
  42077. * Will return the right value of the noPreventDefault variable
  42078. * Needed to keep backwards compatibility to the old API.
  42079. *
  42080. * @param args arguments passed to the attachControl function
  42081. * @returns the correct value for noPreventDefault
  42082. */
  42083. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  42084. /**
  42085. * Captures a screenshot of the current rendering
  42086. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42087. * @param engine defines the rendering engine
  42088. * @param camera defines the source camera
  42089. * @param size This parameter can be set to a single number or to an object with the
  42090. * following (optional) properties: precision, width, height. If a single number is passed,
  42091. * it will be used for both width and height. If an object is passed, the screenshot size
  42092. * will be derived from the parameters. The precision property is a multiplier allowing
  42093. * rendering at a higher or lower resolution
  42094. * @param successCallback defines the callback receives a single parameter which contains the
  42095. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42096. * src parameter of an <img> to display it
  42097. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42098. * Check your browser for supported MIME types
  42099. */
  42100. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  42101. /**
  42102. * Captures a screenshot of the current rendering
  42103. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42104. * @param engine defines the rendering engine
  42105. * @param camera defines the source camera
  42106. * @param size This parameter can be set to a single number or to an object with the
  42107. * following (optional) properties: precision, width, height. If a single number is passed,
  42108. * it will be used for both width and height. If an object is passed, the screenshot size
  42109. * will be derived from the parameters. The precision property is a multiplier allowing
  42110. * rendering at a higher or lower resolution
  42111. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  42112. * Check your browser for supported MIME types
  42113. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42114. * to the src parameter of an <img> to display it
  42115. */
  42116. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  42117. /**
  42118. * Generates an image screenshot from the specified camera.
  42119. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42120. * @param engine The engine to use for rendering
  42121. * @param camera The camera to use for rendering
  42122. * @param size This parameter can be set to a single number or to an object with the
  42123. * following (optional) properties: precision, width, height. If a single number is passed,
  42124. * it will be used for both width and height. If an object is passed, the screenshot size
  42125. * will be derived from the parameters. The precision property is a multiplier allowing
  42126. * rendering at a higher or lower resolution
  42127. * @param successCallback The callback receives a single parameter which contains the
  42128. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  42129. * src parameter of an <img> to display it
  42130. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42131. * Check your browser for supported MIME types
  42132. * @param samples Texture samples (default: 1)
  42133. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42134. * @param fileName A name for for the downloaded file.
  42135. */
  42136. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  42137. /**
  42138. * Generates an image screenshot from the specified camera.
  42139. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  42140. * @param engine The engine to use for rendering
  42141. * @param camera The camera to use for rendering
  42142. * @param size This parameter can be set to a single number or to an object with the
  42143. * following (optional) properties: precision, width, height. If a single number is passed,
  42144. * it will be used for both width and height. If an object is passed, the screenshot size
  42145. * will be derived from the parameters. The precision property is a multiplier allowing
  42146. * rendering at a higher or lower resolution
  42147. * @param mimeType The MIME type of the screenshot image (default: image/png).
  42148. * Check your browser for supported MIME types
  42149. * @param samples Texture samples (default: 1)
  42150. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  42151. * @param fileName A name for for the downloaded file.
  42152. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  42153. * to the src parameter of an <img> to display it
  42154. */
  42155. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  42156. /**
  42157. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  42158. * Be aware Math.random() could cause collisions, but:
  42159. * "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"
  42160. * @returns a pseudo random id
  42161. */
  42162. static RandomId(): string;
  42163. /**
  42164. * Test if the given uri is a base64 string
  42165. * @param uri The uri to test
  42166. * @return True if the uri is a base64 string or false otherwise
  42167. */
  42168. static IsBase64(uri: string): boolean;
  42169. /**
  42170. * Decode the given base64 uri.
  42171. * @param uri The uri to decode
  42172. * @return The decoded base64 data.
  42173. */
  42174. static DecodeBase64(uri: string): ArrayBuffer;
  42175. /**
  42176. * Gets the absolute url.
  42177. * @param url the input url
  42178. * @return the absolute url
  42179. */
  42180. static GetAbsoluteUrl(url: string): string;
  42181. /**
  42182. * No log
  42183. */
  42184. static readonly NoneLogLevel: number;
  42185. /**
  42186. * Only message logs
  42187. */
  42188. static readonly MessageLogLevel: number;
  42189. /**
  42190. * Only warning logs
  42191. */
  42192. static readonly WarningLogLevel: number;
  42193. /**
  42194. * Only error logs
  42195. */
  42196. static readonly ErrorLogLevel: number;
  42197. /**
  42198. * All logs
  42199. */
  42200. static readonly AllLogLevel: number;
  42201. /**
  42202. * Gets a value indicating the number of loading errors
  42203. * @ignorenaming
  42204. */
  42205. static get errorsCount(): number;
  42206. /**
  42207. * Callback called when a new log is added
  42208. */
  42209. static OnNewCacheEntry: (entry: string) => void;
  42210. /**
  42211. * Log a message to the console
  42212. * @param message defines the message to log
  42213. */
  42214. static Log(message: string): void;
  42215. /**
  42216. * Write a warning message to the console
  42217. * @param message defines the message to log
  42218. */
  42219. static Warn(message: string): void;
  42220. /**
  42221. * Write an error message to the console
  42222. * @param message defines the message to log
  42223. */
  42224. static Error(message: string): void;
  42225. /**
  42226. * Gets current log cache (list of logs)
  42227. */
  42228. static get LogCache(): string;
  42229. /**
  42230. * Clears the log cache
  42231. */
  42232. static ClearLogCache(): void;
  42233. /**
  42234. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  42235. */
  42236. static set LogLevels(level: number);
  42237. /**
  42238. * Checks if the window object exists
  42239. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  42240. */
  42241. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  42242. /**
  42243. * No performance log
  42244. */
  42245. static readonly PerformanceNoneLogLevel: number;
  42246. /**
  42247. * Use user marks to log performance
  42248. */
  42249. static readonly PerformanceUserMarkLogLevel: number;
  42250. /**
  42251. * Log performance to the console
  42252. */
  42253. static readonly PerformanceConsoleLogLevel: number;
  42254. private static _performance;
  42255. /**
  42256. * Sets the current performance log level
  42257. */
  42258. static set PerformanceLogLevel(level: number);
  42259. private static _StartPerformanceCounterDisabled;
  42260. private static _EndPerformanceCounterDisabled;
  42261. private static _StartUserMark;
  42262. private static _EndUserMark;
  42263. private static _StartPerformanceConsole;
  42264. private static _EndPerformanceConsole;
  42265. /**
  42266. * Starts a performance counter
  42267. */
  42268. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42269. /**
  42270. * Ends a specific performance coutner
  42271. */
  42272. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  42273. /**
  42274. * Gets either window.performance.now() if supported or Date.now() else
  42275. */
  42276. static get Now(): number;
  42277. /**
  42278. * This method will return the name of the class used to create the instance of the given object.
  42279. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  42280. * @param object the object to get the class name from
  42281. * @param isType defines if the object is actually a type
  42282. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  42283. */
  42284. static GetClassName(object: any, isType?: boolean): string;
  42285. /**
  42286. * Gets the first element of an array satisfying a given predicate
  42287. * @param array defines the array to browse
  42288. * @param predicate defines the predicate to use
  42289. * @returns null if not found or the element
  42290. */
  42291. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  42292. /**
  42293. * This method will return the name of the full name of the class, including its owning module (if any).
  42294. * 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).
  42295. * @param object the object to get the class name from
  42296. * @param isType defines if the object is actually a type
  42297. * @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.
  42298. * @ignorenaming
  42299. */
  42300. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  42301. /**
  42302. * Returns a promise that resolves after the given amount of time.
  42303. * @param delay Number of milliseconds to delay
  42304. * @returns Promise that resolves after the given amount of time
  42305. */
  42306. static DelayAsync(delay: number): Promise<void>;
  42307. /**
  42308. * Utility function to detect if the current user agent is Safari
  42309. * @returns whether or not the current user agent is safari
  42310. */
  42311. static IsSafari(): boolean;
  42312. }
  42313. /**
  42314. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  42315. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  42316. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  42317. * @param name The name of the class, case should be preserved
  42318. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  42319. */
  42320. export function className(name: string, module?: string): (target: Object) => void;
  42321. /**
  42322. * An implementation of a loop for asynchronous functions.
  42323. */
  42324. export class AsyncLoop {
  42325. /**
  42326. * Defines the number of iterations for the loop
  42327. */
  42328. iterations: number;
  42329. /**
  42330. * Defines the current index of the loop.
  42331. */
  42332. index: number;
  42333. private _done;
  42334. private _fn;
  42335. private _successCallback;
  42336. /**
  42337. * Constructor.
  42338. * @param iterations the number of iterations.
  42339. * @param func the function to run each iteration
  42340. * @param successCallback the callback that will be called upon succesful execution
  42341. * @param offset starting offset.
  42342. */
  42343. constructor(
  42344. /**
  42345. * Defines the number of iterations for the loop
  42346. */
  42347. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  42348. /**
  42349. * Execute the next iteration. Must be called after the last iteration was finished.
  42350. */
  42351. executeNext(): void;
  42352. /**
  42353. * Break the loop and run the success callback.
  42354. */
  42355. breakLoop(): void;
  42356. /**
  42357. * Create and run an async loop.
  42358. * @param iterations the number of iterations.
  42359. * @param fn the function to run each iteration
  42360. * @param successCallback the callback that will be called upon succesful execution
  42361. * @param offset starting offset.
  42362. * @returns the created async loop object
  42363. */
  42364. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  42365. /**
  42366. * A for-loop that will run a given number of iterations synchronous and the rest async.
  42367. * @param iterations total number of iterations
  42368. * @param syncedIterations number of synchronous iterations in each async iteration.
  42369. * @param fn the function to call each iteration.
  42370. * @param callback a success call back that will be called when iterating stops.
  42371. * @param breakFunction a break condition (optional)
  42372. * @param timeout timeout settings for the setTimeout function. default - 0.
  42373. * @returns the created async loop object
  42374. */
  42375. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  42376. }
  42377. }
  42378. declare module BABYLON {
  42379. /**
  42380. * This class implement a typical dictionary using a string as key and the generic type T as value.
  42381. * The underlying implementation relies on an associative array to ensure the best performances.
  42382. * The value can be anything including 'null' but except 'undefined'
  42383. */
  42384. export class StringDictionary<T> {
  42385. /**
  42386. * This will clear this dictionary and copy the content from the 'source' one.
  42387. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  42388. * @param source the dictionary to take the content from and copy to this dictionary
  42389. */
  42390. copyFrom(source: StringDictionary<T>): void;
  42391. /**
  42392. * Get a value based from its key
  42393. * @param key the given key to get the matching value from
  42394. * @return the value if found, otherwise undefined is returned
  42395. */
  42396. get(key: string): T | undefined;
  42397. /**
  42398. * Get a value from its key or add it if it doesn't exist.
  42399. * This method will ensure you that a given key/data will be present in the dictionary.
  42400. * @param key the given key to get the matching value from
  42401. * @param factory the factory that will create the value if the key is not present in the dictionary.
  42402. * The factory will only be invoked if there's no data for the given key.
  42403. * @return the value corresponding to the key.
  42404. */
  42405. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  42406. /**
  42407. * Get a value from its key if present in the dictionary otherwise add it
  42408. * @param key the key to get the value from
  42409. * @param val if there's no such key/value pair in the dictionary add it with this value
  42410. * @return the value corresponding to the key
  42411. */
  42412. getOrAdd(key: string, val: T): T;
  42413. /**
  42414. * Check if there's a given key in the dictionary
  42415. * @param key the key to check for
  42416. * @return true if the key is present, false otherwise
  42417. */
  42418. contains(key: string): boolean;
  42419. /**
  42420. * Add a new key and its corresponding value
  42421. * @param key the key to add
  42422. * @param value the value corresponding to the key
  42423. * @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
  42424. */
  42425. add(key: string, value: T): boolean;
  42426. /**
  42427. * Update a specific value associated to a key
  42428. * @param key defines the key to use
  42429. * @param value defines the value to store
  42430. * @returns true if the value was updated (or false if the key was not found)
  42431. */
  42432. set(key: string, value: T): boolean;
  42433. /**
  42434. * Get the element of the given key and remove it from the dictionary
  42435. * @param key defines the key to search
  42436. * @returns the value associated with the key or null if not found
  42437. */
  42438. getAndRemove(key: string): Nullable<T>;
  42439. /**
  42440. * Remove a key/value from the dictionary.
  42441. * @param key the key to remove
  42442. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  42443. */
  42444. remove(key: string): boolean;
  42445. /**
  42446. * Clear the whole content of the dictionary
  42447. */
  42448. clear(): void;
  42449. /**
  42450. * Gets the current count
  42451. */
  42452. get count(): number;
  42453. /**
  42454. * Execute a callback on each key/val of the dictionary.
  42455. * Note that you can remove any element in this dictionary in the callback implementation
  42456. * @param callback the callback to execute on a given key/value pair
  42457. */
  42458. forEach(callback: (key: string, val: T) => void): void;
  42459. /**
  42460. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  42461. * If the callback returns null or undefined the method will iterate to the next key/value pair
  42462. * Note that you can remove any element in this dictionary in the callback implementation
  42463. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  42464. * @returns the first item
  42465. */
  42466. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  42467. private _count;
  42468. private _data;
  42469. }
  42470. }
  42471. declare module BABYLON {
  42472. /** @hidden */
  42473. export interface ICollisionCoordinator {
  42474. createCollider(): Collider;
  42475. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42476. init(scene: Scene): void;
  42477. }
  42478. /** @hidden */
  42479. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  42480. private _scene;
  42481. private _scaledPosition;
  42482. private _scaledVelocity;
  42483. private _finalPosition;
  42484. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  42485. createCollider(): Collider;
  42486. init(scene: Scene): void;
  42487. private _collideWithWorld;
  42488. }
  42489. }
  42490. declare module BABYLON {
  42491. /**
  42492. * Class used to manage all inputs for the scene.
  42493. */
  42494. export class InputManager {
  42495. /** The distance in pixel that you have to move to prevent some events */
  42496. static DragMovementThreshold: number;
  42497. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  42498. static LongPressDelay: number;
  42499. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  42500. static DoubleClickDelay: number;
  42501. /** If you need to check double click without raising a single click at first click, enable this flag */
  42502. static ExclusiveDoubleClickMode: boolean;
  42503. /** 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. */
  42504. private _alreadyAttached;
  42505. private _alreadyAttachedTo;
  42506. private _wheelEventName;
  42507. private _onPointerMove;
  42508. private _onPointerDown;
  42509. private _onPointerUp;
  42510. private _initClickEvent;
  42511. private _initActionManager;
  42512. private _delayedSimpleClick;
  42513. private _delayedSimpleClickTimeout;
  42514. private _previousDelayedSimpleClickTimeout;
  42515. private _meshPickProceed;
  42516. private _previousButtonPressed;
  42517. private _currentPickResult;
  42518. private _previousPickResult;
  42519. private _totalPointersPressed;
  42520. private _doubleClickOccured;
  42521. private _pointerOverMesh;
  42522. private _pickedDownMesh;
  42523. private _pickedUpMesh;
  42524. private _pointerX;
  42525. private _pointerY;
  42526. private _unTranslatedPointerX;
  42527. private _unTranslatedPointerY;
  42528. private _startingPointerPosition;
  42529. private _previousStartingPointerPosition;
  42530. private _startingPointerTime;
  42531. private _previousStartingPointerTime;
  42532. private _pointerCaptures;
  42533. private _meshUnderPointerId;
  42534. private _onKeyDown;
  42535. private _onKeyUp;
  42536. private _keyboardIsAttached;
  42537. private _onCanvasFocusObserver;
  42538. private _onCanvasBlurObserver;
  42539. private _scene;
  42540. /**
  42541. * Creates a new InputManager
  42542. * @param scene defines the hosting scene
  42543. */
  42544. constructor(scene: Scene);
  42545. /**
  42546. * Gets the mesh that is currently under the pointer
  42547. */
  42548. get meshUnderPointer(): Nullable<AbstractMesh>;
  42549. /**
  42550. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  42551. * @param pointerId the pointer id to use
  42552. * @returns The mesh under this pointer id or null if not found
  42553. */
  42554. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  42555. /**
  42556. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  42557. */
  42558. get unTranslatedPointer(): Vector2;
  42559. /**
  42560. * Gets or sets the current on-screen X position of the pointer
  42561. */
  42562. get pointerX(): number;
  42563. set pointerX(value: number);
  42564. /**
  42565. * Gets or sets the current on-screen Y position of the pointer
  42566. */
  42567. get pointerY(): number;
  42568. set pointerY(value: number);
  42569. private _updatePointerPosition;
  42570. private _processPointerMove;
  42571. private _setRayOnPointerInfo;
  42572. private _checkPrePointerObservable;
  42573. /**
  42574. * Use this method to simulate a pointer move on a mesh
  42575. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42576. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42577. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42578. */
  42579. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42580. /**
  42581. * Use this method to simulate a pointer down on a mesh
  42582. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42583. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42584. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42585. */
  42586. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  42587. private _processPointerDown;
  42588. /** @hidden */
  42589. _isPointerSwiping(): boolean;
  42590. /**
  42591. * Use this method to simulate a pointer up on a mesh
  42592. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  42593. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  42594. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  42595. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  42596. */
  42597. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  42598. private _processPointerUp;
  42599. /**
  42600. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  42601. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  42602. * @returns true if the pointer was captured
  42603. */
  42604. isPointerCaptured(pointerId?: number): boolean;
  42605. /**
  42606. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42607. * @param attachUp defines if you want to attach events to pointerup
  42608. * @param attachDown defines if you want to attach events to pointerdown
  42609. * @param attachMove defines if you want to attach events to pointermove
  42610. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42611. */
  42612. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42613. /**
  42614. * Detaches all event handlers
  42615. */
  42616. detachControl(): void;
  42617. /**
  42618. * Force the value of meshUnderPointer
  42619. * @param mesh defines the mesh to use
  42620. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42621. */
  42622. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42623. /**
  42624. * Gets the mesh under the pointer
  42625. * @returns a Mesh or null if no mesh is under the pointer
  42626. */
  42627. getPointerOverMesh(): Nullable<AbstractMesh>;
  42628. }
  42629. }
  42630. declare module BABYLON {
  42631. /**
  42632. * This class defines the direct association between an animation and a target
  42633. */
  42634. export class TargetedAnimation {
  42635. /**
  42636. * Animation to perform
  42637. */
  42638. animation: Animation;
  42639. /**
  42640. * Target to animate
  42641. */
  42642. target: any;
  42643. /**
  42644. * Returns the string "TargetedAnimation"
  42645. * @returns "TargetedAnimation"
  42646. */
  42647. getClassName(): string;
  42648. /**
  42649. * Serialize the object
  42650. * @returns the JSON object representing the current entity
  42651. */
  42652. serialize(): any;
  42653. }
  42654. /**
  42655. * Use this class to create coordinated animations on multiple targets
  42656. */
  42657. export class AnimationGroup implements IDisposable {
  42658. /** The name of the animation group */
  42659. name: string;
  42660. private _scene;
  42661. private _targetedAnimations;
  42662. private _animatables;
  42663. private _from;
  42664. private _to;
  42665. private _isStarted;
  42666. private _isPaused;
  42667. private _speedRatio;
  42668. private _loopAnimation;
  42669. private _isAdditive;
  42670. /**
  42671. * Gets or sets the unique id of the node
  42672. */
  42673. uniqueId: number;
  42674. /**
  42675. * This observable will notify when one animation have ended
  42676. */
  42677. onAnimationEndObservable: Observable<TargetedAnimation>;
  42678. /**
  42679. * Observer raised when one animation loops
  42680. */
  42681. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42682. /**
  42683. * Observer raised when all animations have looped
  42684. */
  42685. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42686. /**
  42687. * This observable will notify when all animations have ended.
  42688. */
  42689. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42690. /**
  42691. * This observable will notify when all animations have paused.
  42692. */
  42693. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42694. /**
  42695. * This observable will notify when all animations are playing.
  42696. */
  42697. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42698. /**
  42699. * Gets the first frame
  42700. */
  42701. get from(): number;
  42702. /**
  42703. * Gets the last frame
  42704. */
  42705. get to(): number;
  42706. /**
  42707. * Define if the animations are started
  42708. */
  42709. get isStarted(): boolean;
  42710. /**
  42711. * Gets a value indicating that the current group is playing
  42712. */
  42713. get isPlaying(): boolean;
  42714. /**
  42715. * Gets or sets the speed ratio to use for all animations
  42716. */
  42717. get speedRatio(): number;
  42718. /**
  42719. * Gets or sets the speed ratio to use for all animations
  42720. */
  42721. set speedRatio(value: number);
  42722. /**
  42723. * Gets or sets if all animations should loop or not
  42724. */
  42725. get loopAnimation(): boolean;
  42726. set loopAnimation(value: boolean);
  42727. /**
  42728. * Gets or sets if all animations should be evaluated additively
  42729. */
  42730. get isAdditive(): boolean;
  42731. set isAdditive(value: boolean);
  42732. /**
  42733. * Gets the targeted animations for this animation group
  42734. */
  42735. get targetedAnimations(): Array<TargetedAnimation>;
  42736. /**
  42737. * returning the list of animatables controlled by this animation group.
  42738. */
  42739. get animatables(): Array<Animatable>;
  42740. /**
  42741. * Gets the list of target animations
  42742. */
  42743. get children(): TargetedAnimation[];
  42744. /**
  42745. * Instantiates a new Animation Group.
  42746. * This helps managing several animations at once.
  42747. * @see https://doc.babylonjs.com/how_to/group
  42748. * @param name Defines the name of the group
  42749. * @param scene Defines the scene the group belongs to
  42750. */
  42751. constructor(
  42752. /** The name of the animation group */
  42753. name: string, scene?: Nullable<Scene>);
  42754. /**
  42755. * Add an animation (with its target) in the group
  42756. * @param animation defines the animation we want to add
  42757. * @param target defines the target of the animation
  42758. * @returns the TargetedAnimation object
  42759. */
  42760. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42761. /**
  42762. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42763. * It can add constant keys at begin or end
  42764. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42765. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42766. * @returns the animation group
  42767. */
  42768. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42769. private _animationLoopCount;
  42770. private _animationLoopFlags;
  42771. private _processLoop;
  42772. /**
  42773. * Start all animations on given targets
  42774. * @param loop defines if animations must loop
  42775. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42776. * @param from defines the from key (optional)
  42777. * @param to defines the to key (optional)
  42778. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42779. * @returns the current animation group
  42780. */
  42781. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42782. /**
  42783. * Pause all animations
  42784. * @returns the animation group
  42785. */
  42786. pause(): AnimationGroup;
  42787. /**
  42788. * Play all animations to initial state
  42789. * This function will start() the animations if they were not started or will restart() them if they were paused
  42790. * @param loop defines if animations must loop
  42791. * @returns the animation group
  42792. */
  42793. play(loop?: boolean): AnimationGroup;
  42794. /**
  42795. * Reset all animations to initial state
  42796. * @returns the animation group
  42797. */
  42798. reset(): AnimationGroup;
  42799. /**
  42800. * Restart animations from key 0
  42801. * @returns the animation group
  42802. */
  42803. restart(): AnimationGroup;
  42804. /**
  42805. * Stop all animations
  42806. * @returns the animation group
  42807. */
  42808. stop(): AnimationGroup;
  42809. /**
  42810. * Set animation weight for all animatables
  42811. * @param weight defines the weight to use
  42812. * @return the animationGroup
  42813. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42814. */
  42815. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42816. /**
  42817. * Synchronize and normalize all animatables with a source animatable
  42818. * @param root defines the root animatable to synchronize with
  42819. * @return the animationGroup
  42820. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42821. */
  42822. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42823. /**
  42824. * Goes to a specific frame in this animation group
  42825. * @param frame the frame number to go to
  42826. * @return the animationGroup
  42827. */
  42828. goToFrame(frame: number): AnimationGroup;
  42829. /**
  42830. * Dispose all associated resources
  42831. */
  42832. dispose(): void;
  42833. private _checkAnimationGroupEnded;
  42834. /**
  42835. * Clone the current animation group and returns a copy
  42836. * @param newName defines the name of the new group
  42837. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42838. * @returns the new aniamtion group
  42839. */
  42840. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42841. /**
  42842. * Serializes the animationGroup to an object
  42843. * @returns Serialized object
  42844. */
  42845. serialize(): any;
  42846. /**
  42847. * Returns a new AnimationGroup object parsed from the source provided.
  42848. * @param parsedAnimationGroup defines the source
  42849. * @param scene defines the scene that will receive the animationGroup
  42850. * @returns a new AnimationGroup
  42851. */
  42852. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42853. /**
  42854. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42855. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42856. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42857. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42858. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42859. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42860. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42861. */
  42862. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42863. /**
  42864. * Returns the string "AnimationGroup"
  42865. * @returns "AnimationGroup"
  42866. */
  42867. getClassName(): string;
  42868. /**
  42869. * Creates a detailled string about the object
  42870. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42871. * @returns a string representing the object
  42872. */
  42873. toString(fullDetails?: boolean): string;
  42874. }
  42875. }
  42876. declare module BABYLON {
  42877. /**
  42878. * Define an interface for all classes that will hold resources
  42879. */
  42880. export interface IDisposable {
  42881. /**
  42882. * Releases all held resources
  42883. */
  42884. dispose(): void;
  42885. }
  42886. /** Interface defining initialization parameters for Scene class */
  42887. export interface SceneOptions {
  42888. /**
  42889. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42890. * It will improve performance when the number of geometries becomes important.
  42891. */
  42892. useGeometryUniqueIdsMap?: boolean;
  42893. /**
  42894. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42895. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42896. */
  42897. useMaterialMeshMap?: boolean;
  42898. /**
  42899. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42900. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42901. */
  42902. useClonedMeshMap?: boolean;
  42903. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42904. virtual?: boolean;
  42905. }
  42906. /**
  42907. * Represents a scene to be rendered by the engine.
  42908. * @see https://doc.babylonjs.com/features/scene
  42909. */
  42910. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42911. /** The fog is deactivated */
  42912. static readonly FOGMODE_NONE: number;
  42913. /** The fog density is following an exponential function */
  42914. static readonly FOGMODE_EXP: number;
  42915. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42916. static readonly FOGMODE_EXP2: number;
  42917. /** The fog density is following a linear function. */
  42918. static readonly FOGMODE_LINEAR: number;
  42919. /**
  42920. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42921. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42922. */
  42923. static MinDeltaTime: number;
  42924. /**
  42925. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42926. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42927. */
  42928. static MaxDeltaTime: number;
  42929. /**
  42930. * Factory used to create the default material.
  42931. * @param name The name of the material to create
  42932. * @param scene The scene to create the material for
  42933. * @returns The default material
  42934. */
  42935. static DefaultMaterialFactory(scene: Scene): Material;
  42936. /**
  42937. * Factory used to create the a collision coordinator.
  42938. * @returns The collision coordinator
  42939. */
  42940. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42941. /** @hidden */
  42942. _inputManager: InputManager;
  42943. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42944. cameraToUseForPointers: Nullable<Camera>;
  42945. /** @hidden */
  42946. readonly _isScene: boolean;
  42947. /** @hidden */
  42948. _blockEntityCollection: boolean;
  42949. /**
  42950. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42951. */
  42952. autoClear: boolean;
  42953. /**
  42954. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42955. */
  42956. autoClearDepthAndStencil: boolean;
  42957. /**
  42958. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42959. */
  42960. clearColor: Color4;
  42961. /**
  42962. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42963. */
  42964. ambientColor: Color3;
  42965. /**
  42966. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42967. * It should only be one of the following (if not the default embedded one):
  42968. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42969. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42970. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42971. * The material properties need to be setup according to the type of texture in use.
  42972. */
  42973. environmentBRDFTexture: BaseTexture;
  42974. /**
  42975. * Texture used in all pbr material as the reflection texture.
  42976. * As in the majority of the scene they are the same (exception for multi room and so on),
  42977. * this is easier to reference from here than from all the materials.
  42978. */
  42979. get environmentTexture(): Nullable<BaseTexture>;
  42980. /**
  42981. * Texture used in all pbr material as the reflection texture.
  42982. * As in the majority of the scene they are the same (exception for multi room and so on),
  42983. * this is easier to set here than in all the materials.
  42984. */
  42985. set environmentTexture(value: Nullable<BaseTexture>);
  42986. /** @hidden */
  42987. protected _environmentIntensity: number;
  42988. /**
  42989. * Intensity of the environment in all pbr material.
  42990. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42991. * As in the majority of the scene they are the same (exception for multi room and so on),
  42992. * this is easier to reference from here than from all the materials.
  42993. */
  42994. get environmentIntensity(): number;
  42995. /**
  42996. * Intensity of the environment in all pbr material.
  42997. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42998. * As in the majority of the scene they are the same (exception for multi room and so on),
  42999. * this is easier to set here than in all the materials.
  43000. */
  43001. set environmentIntensity(value: number);
  43002. /** @hidden */
  43003. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43004. /**
  43005. * Default image processing configuration used either in the rendering
  43006. * Forward main pass or through the imageProcessingPostProcess if present.
  43007. * As in the majority of the scene they are the same (exception for multi camera),
  43008. * this is easier to reference from here than from all the materials and post process.
  43009. *
  43010. * No setter as we it is a shared configuration, you can set the values instead.
  43011. */
  43012. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43013. private _forceWireframe;
  43014. /**
  43015. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  43016. */
  43017. set forceWireframe(value: boolean);
  43018. get forceWireframe(): boolean;
  43019. private _skipFrustumClipping;
  43020. /**
  43021. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  43022. */
  43023. set skipFrustumClipping(value: boolean);
  43024. get skipFrustumClipping(): boolean;
  43025. private _forcePointsCloud;
  43026. /**
  43027. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  43028. */
  43029. set forcePointsCloud(value: boolean);
  43030. get forcePointsCloud(): boolean;
  43031. /**
  43032. * Gets or sets the active clipplane 1
  43033. */
  43034. clipPlane: Nullable<Plane>;
  43035. /**
  43036. * Gets or sets the active clipplane 2
  43037. */
  43038. clipPlane2: Nullable<Plane>;
  43039. /**
  43040. * Gets or sets the active clipplane 3
  43041. */
  43042. clipPlane3: Nullable<Plane>;
  43043. /**
  43044. * Gets or sets the active clipplane 4
  43045. */
  43046. clipPlane4: Nullable<Plane>;
  43047. /**
  43048. * Gets or sets the active clipplane 5
  43049. */
  43050. clipPlane5: Nullable<Plane>;
  43051. /**
  43052. * Gets or sets the active clipplane 6
  43053. */
  43054. clipPlane6: Nullable<Plane>;
  43055. /**
  43056. * Gets or sets a boolean indicating if animations are enabled
  43057. */
  43058. animationsEnabled: boolean;
  43059. private _animationPropertiesOverride;
  43060. /**
  43061. * Gets or sets the animation properties override
  43062. */
  43063. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  43064. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  43065. /**
  43066. * Gets or sets a boolean indicating if a constant deltatime has to be used
  43067. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  43068. */
  43069. useConstantAnimationDeltaTime: boolean;
  43070. /**
  43071. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  43072. * Please note that it requires to run a ray cast through the scene on every frame
  43073. */
  43074. constantlyUpdateMeshUnderPointer: boolean;
  43075. /**
  43076. * Defines the HTML cursor to use when hovering over interactive elements
  43077. */
  43078. hoverCursor: string;
  43079. /**
  43080. * Defines the HTML default cursor to use (empty by default)
  43081. */
  43082. defaultCursor: string;
  43083. /**
  43084. * Defines whether cursors are handled by the scene.
  43085. */
  43086. doNotHandleCursors: boolean;
  43087. /**
  43088. * This is used to call preventDefault() on pointer down
  43089. * in order to block unwanted artifacts like system double clicks
  43090. */
  43091. preventDefaultOnPointerDown: boolean;
  43092. /**
  43093. * This is used to call preventDefault() on pointer up
  43094. * in order to block unwanted artifacts like system double clicks
  43095. */
  43096. preventDefaultOnPointerUp: boolean;
  43097. /**
  43098. * Gets or sets user defined metadata
  43099. */
  43100. metadata: any;
  43101. /**
  43102. * For internal use only. Please do not use.
  43103. */
  43104. reservedDataStore: any;
  43105. /**
  43106. * Gets the name of the plugin used to load this scene (null by default)
  43107. */
  43108. loadingPluginName: string;
  43109. /**
  43110. * Use this array to add regular expressions used to disable offline support for specific urls
  43111. */
  43112. disableOfflineSupportExceptionRules: RegExp[];
  43113. /**
  43114. * An event triggered when the scene is disposed.
  43115. */
  43116. onDisposeObservable: Observable<Scene>;
  43117. private _onDisposeObserver;
  43118. /** Sets a function to be executed when this scene is disposed. */
  43119. set onDispose(callback: () => void);
  43120. /**
  43121. * An event triggered before rendering the scene (right after animations and physics)
  43122. */
  43123. onBeforeRenderObservable: Observable<Scene>;
  43124. private _onBeforeRenderObserver;
  43125. /** Sets a function to be executed before rendering this scene */
  43126. set beforeRender(callback: Nullable<() => void>);
  43127. /**
  43128. * An event triggered after rendering the scene
  43129. */
  43130. onAfterRenderObservable: Observable<Scene>;
  43131. /**
  43132. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  43133. */
  43134. onAfterRenderCameraObservable: Observable<Camera>;
  43135. private _onAfterRenderObserver;
  43136. /** Sets a function to be executed after rendering this scene */
  43137. set afterRender(callback: Nullable<() => void>);
  43138. /**
  43139. * An event triggered before animating the scene
  43140. */
  43141. onBeforeAnimationsObservable: Observable<Scene>;
  43142. /**
  43143. * An event triggered after animations processing
  43144. */
  43145. onAfterAnimationsObservable: Observable<Scene>;
  43146. /**
  43147. * An event triggered before draw calls are ready to be sent
  43148. */
  43149. onBeforeDrawPhaseObservable: Observable<Scene>;
  43150. /**
  43151. * An event triggered after draw calls have been sent
  43152. */
  43153. onAfterDrawPhaseObservable: Observable<Scene>;
  43154. /**
  43155. * An event triggered when the scene is ready
  43156. */
  43157. onReadyObservable: Observable<Scene>;
  43158. /**
  43159. * An event triggered before rendering a camera
  43160. */
  43161. onBeforeCameraRenderObservable: Observable<Camera>;
  43162. private _onBeforeCameraRenderObserver;
  43163. /** Sets a function to be executed before rendering a camera*/
  43164. set beforeCameraRender(callback: () => void);
  43165. /**
  43166. * An event triggered after rendering a camera
  43167. */
  43168. onAfterCameraRenderObservable: Observable<Camera>;
  43169. private _onAfterCameraRenderObserver;
  43170. /** Sets a function to be executed after rendering a camera*/
  43171. set afterCameraRender(callback: () => void);
  43172. /**
  43173. * An event triggered when active meshes evaluation is about to start
  43174. */
  43175. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  43176. /**
  43177. * An event triggered when active meshes evaluation is done
  43178. */
  43179. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  43180. /**
  43181. * An event triggered when particles rendering is about to start
  43182. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43183. */
  43184. onBeforeParticlesRenderingObservable: Observable<Scene>;
  43185. /**
  43186. * An event triggered when particles rendering is done
  43187. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  43188. */
  43189. onAfterParticlesRenderingObservable: Observable<Scene>;
  43190. /**
  43191. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  43192. */
  43193. onDataLoadedObservable: Observable<Scene>;
  43194. /**
  43195. * An event triggered when a camera is created
  43196. */
  43197. onNewCameraAddedObservable: Observable<Camera>;
  43198. /**
  43199. * An event triggered when a camera is removed
  43200. */
  43201. onCameraRemovedObservable: Observable<Camera>;
  43202. /**
  43203. * An event triggered when a light is created
  43204. */
  43205. onNewLightAddedObservable: Observable<Light>;
  43206. /**
  43207. * An event triggered when a light is removed
  43208. */
  43209. onLightRemovedObservable: Observable<Light>;
  43210. /**
  43211. * An event triggered when a geometry is created
  43212. */
  43213. onNewGeometryAddedObservable: Observable<Geometry>;
  43214. /**
  43215. * An event triggered when a geometry is removed
  43216. */
  43217. onGeometryRemovedObservable: Observable<Geometry>;
  43218. /**
  43219. * An event triggered when a transform node is created
  43220. */
  43221. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  43222. /**
  43223. * An event triggered when a transform node is removed
  43224. */
  43225. onTransformNodeRemovedObservable: Observable<TransformNode>;
  43226. /**
  43227. * An event triggered when a mesh is created
  43228. */
  43229. onNewMeshAddedObservable: Observable<AbstractMesh>;
  43230. /**
  43231. * An event triggered when a mesh is removed
  43232. */
  43233. onMeshRemovedObservable: Observable<AbstractMesh>;
  43234. /**
  43235. * An event triggered when a skeleton is created
  43236. */
  43237. onNewSkeletonAddedObservable: Observable<Skeleton>;
  43238. /**
  43239. * An event triggered when a skeleton is removed
  43240. */
  43241. onSkeletonRemovedObservable: Observable<Skeleton>;
  43242. /**
  43243. * An event triggered when a material is created
  43244. */
  43245. onNewMaterialAddedObservable: Observable<Material>;
  43246. /**
  43247. * An event triggered when a multi material is created
  43248. */
  43249. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  43250. /**
  43251. * An event triggered when a material is removed
  43252. */
  43253. onMaterialRemovedObservable: Observable<Material>;
  43254. /**
  43255. * An event triggered when a multi material is removed
  43256. */
  43257. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  43258. /**
  43259. * An event triggered when a texture is created
  43260. */
  43261. onNewTextureAddedObservable: Observable<BaseTexture>;
  43262. /**
  43263. * An event triggered when a texture is removed
  43264. */
  43265. onTextureRemovedObservable: Observable<BaseTexture>;
  43266. /**
  43267. * An event triggered when render targets are about to be rendered
  43268. * Can happen multiple times per frame.
  43269. */
  43270. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  43271. /**
  43272. * An event triggered when render targets were rendered.
  43273. * Can happen multiple times per frame.
  43274. */
  43275. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  43276. /**
  43277. * An event triggered before calculating deterministic simulation step
  43278. */
  43279. onBeforeStepObservable: Observable<Scene>;
  43280. /**
  43281. * An event triggered after calculating deterministic simulation step
  43282. */
  43283. onAfterStepObservable: Observable<Scene>;
  43284. /**
  43285. * An event triggered when the activeCamera property is updated
  43286. */
  43287. onActiveCameraChanged: Observable<Scene>;
  43288. /**
  43289. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  43290. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43291. * 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)
  43292. */
  43293. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43294. /**
  43295. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  43296. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  43297. * 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)
  43298. */
  43299. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  43300. /**
  43301. * This Observable will when a mesh has been imported into the scene.
  43302. */
  43303. onMeshImportedObservable: Observable<AbstractMesh>;
  43304. /**
  43305. * This Observable will when an animation file has been imported into the scene.
  43306. */
  43307. onAnimationFileImportedObservable: Observable<Scene>;
  43308. /**
  43309. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  43310. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  43311. */
  43312. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  43313. /** @hidden */
  43314. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  43315. /**
  43316. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  43317. */
  43318. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  43319. /**
  43320. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  43321. */
  43322. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  43323. /**
  43324. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  43325. */
  43326. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  43327. /** Callback called when a pointer move is detected */
  43328. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43329. /** Callback called when a pointer down is detected */
  43330. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  43331. /** Callback called when a pointer up is detected */
  43332. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  43333. /** Callback called when a pointer pick is detected */
  43334. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  43335. /**
  43336. * 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).
  43337. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  43338. */
  43339. onPrePointerObservable: Observable<PointerInfoPre>;
  43340. /**
  43341. * Observable event triggered each time an input event is received from the rendering canvas
  43342. */
  43343. onPointerObservable: Observable<PointerInfo>;
  43344. /**
  43345. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  43346. */
  43347. get unTranslatedPointer(): Vector2;
  43348. /**
  43349. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  43350. */
  43351. static get DragMovementThreshold(): number;
  43352. static set DragMovementThreshold(value: number);
  43353. /**
  43354. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  43355. */
  43356. static get LongPressDelay(): number;
  43357. static set LongPressDelay(value: number);
  43358. /**
  43359. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  43360. */
  43361. static get DoubleClickDelay(): number;
  43362. static set DoubleClickDelay(value: number);
  43363. /** If you need to check double click without raising a single click at first click, enable this flag */
  43364. static get ExclusiveDoubleClickMode(): boolean;
  43365. static set ExclusiveDoubleClickMode(value: boolean);
  43366. /** @hidden */
  43367. _mirroredCameraPosition: Nullable<Vector3>;
  43368. /**
  43369. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  43370. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  43371. */
  43372. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  43373. /**
  43374. * Observable event triggered each time an keyboard event is received from the hosting window
  43375. */
  43376. onKeyboardObservable: Observable<KeyboardInfo>;
  43377. private _useRightHandedSystem;
  43378. /**
  43379. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  43380. */
  43381. set useRightHandedSystem(value: boolean);
  43382. get useRightHandedSystem(): boolean;
  43383. private _timeAccumulator;
  43384. private _currentStepId;
  43385. private _currentInternalStep;
  43386. /**
  43387. * Sets the step Id used by deterministic lock step
  43388. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43389. * @param newStepId defines the step Id
  43390. */
  43391. setStepId(newStepId: number): void;
  43392. /**
  43393. * Gets the step Id used by deterministic lock step
  43394. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43395. * @returns the step Id
  43396. */
  43397. getStepId(): number;
  43398. /**
  43399. * Gets the internal step used by deterministic lock step
  43400. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43401. * @returns the internal step
  43402. */
  43403. getInternalStep(): number;
  43404. private _fogEnabled;
  43405. /**
  43406. * Gets or sets a boolean indicating if fog is enabled on this scene
  43407. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43408. * (Default is true)
  43409. */
  43410. set fogEnabled(value: boolean);
  43411. get fogEnabled(): boolean;
  43412. private _fogMode;
  43413. /**
  43414. * Gets or sets the fog mode to use
  43415. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43416. * | mode | value |
  43417. * | --- | --- |
  43418. * | FOGMODE_NONE | 0 |
  43419. * | FOGMODE_EXP | 1 |
  43420. * | FOGMODE_EXP2 | 2 |
  43421. * | FOGMODE_LINEAR | 3 |
  43422. */
  43423. set fogMode(value: number);
  43424. get fogMode(): number;
  43425. /**
  43426. * Gets or sets the fog color to use
  43427. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43428. * (Default is Color3(0.2, 0.2, 0.3))
  43429. */
  43430. fogColor: Color3;
  43431. /**
  43432. * Gets or sets the fog density to use
  43433. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43434. * (Default is 0.1)
  43435. */
  43436. fogDensity: number;
  43437. /**
  43438. * Gets or sets the fog start distance to use
  43439. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43440. * (Default is 0)
  43441. */
  43442. fogStart: number;
  43443. /**
  43444. * Gets or sets the fog end distance to use
  43445. * @see https://doc.babylonjs.com/babylon101/environment#fog
  43446. * (Default is 1000)
  43447. */
  43448. fogEnd: number;
  43449. /**
  43450. * Flag indicating that the frame buffer binding is handled by another component
  43451. */
  43452. prePass: boolean;
  43453. private _shadowsEnabled;
  43454. /**
  43455. * Gets or sets a boolean indicating if shadows are enabled on this scene
  43456. */
  43457. set shadowsEnabled(value: boolean);
  43458. get shadowsEnabled(): boolean;
  43459. private _lightsEnabled;
  43460. /**
  43461. * Gets or sets a boolean indicating if lights are enabled on this scene
  43462. */
  43463. set lightsEnabled(value: boolean);
  43464. get lightsEnabled(): boolean;
  43465. /** All of the active cameras added to this scene. */
  43466. activeCameras: Nullable<Camera[]>;
  43467. /** @hidden */
  43468. _activeCamera: Nullable<Camera>;
  43469. /** Gets or sets the current active camera */
  43470. get activeCamera(): Nullable<Camera>;
  43471. set activeCamera(value: Nullable<Camera>);
  43472. private _defaultMaterial;
  43473. /** The default material used on meshes when no material is affected */
  43474. get defaultMaterial(): Material;
  43475. /** The default material used on meshes when no material is affected */
  43476. set defaultMaterial(value: Material);
  43477. private _texturesEnabled;
  43478. /**
  43479. * Gets or sets a boolean indicating if textures are enabled on this scene
  43480. */
  43481. set texturesEnabled(value: boolean);
  43482. get texturesEnabled(): boolean;
  43483. /**
  43484. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  43485. */
  43486. physicsEnabled: boolean;
  43487. /**
  43488. * Gets or sets a boolean indicating if particles are enabled on this scene
  43489. */
  43490. particlesEnabled: boolean;
  43491. /**
  43492. * Gets or sets a boolean indicating if sprites are enabled on this scene
  43493. */
  43494. spritesEnabled: boolean;
  43495. private _skeletonsEnabled;
  43496. /**
  43497. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  43498. */
  43499. set skeletonsEnabled(value: boolean);
  43500. get skeletonsEnabled(): boolean;
  43501. /**
  43502. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  43503. */
  43504. lensFlaresEnabled: boolean;
  43505. /**
  43506. * Gets or sets a boolean indicating if collisions are enabled on this scene
  43507. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43508. */
  43509. collisionsEnabled: boolean;
  43510. private _collisionCoordinator;
  43511. /** @hidden */
  43512. get collisionCoordinator(): ICollisionCoordinator;
  43513. /**
  43514. * Defines the gravity applied to this scene (used only for collisions)
  43515. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  43516. */
  43517. gravity: Vector3;
  43518. /**
  43519. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  43520. */
  43521. postProcessesEnabled: boolean;
  43522. /**
  43523. * Gets the current postprocess manager
  43524. */
  43525. postProcessManager: PostProcessManager;
  43526. /**
  43527. * Gets or sets a boolean indicating if render targets are enabled on this scene
  43528. */
  43529. renderTargetsEnabled: boolean;
  43530. /**
  43531. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  43532. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  43533. */
  43534. dumpNextRenderTargets: boolean;
  43535. /**
  43536. * The list of user defined render targets added to the scene
  43537. */
  43538. customRenderTargets: RenderTargetTexture[];
  43539. /**
  43540. * Defines if texture loading must be delayed
  43541. * If true, textures will only be loaded when they need to be rendered
  43542. */
  43543. useDelayedTextureLoading: boolean;
  43544. /**
  43545. * Gets the list of meshes imported to the scene through SceneLoader
  43546. */
  43547. importedMeshesFiles: String[];
  43548. /**
  43549. * Gets or sets a boolean indicating if probes are enabled on this scene
  43550. */
  43551. probesEnabled: boolean;
  43552. /**
  43553. * Gets or sets the current offline provider to use to store scene data
  43554. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  43555. */
  43556. offlineProvider: IOfflineProvider;
  43557. /**
  43558. * Gets or sets the action manager associated with the scene
  43559. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43560. */
  43561. actionManager: AbstractActionManager;
  43562. private _meshesForIntersections;
  43563. /**
  43564. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  43565. */
  43566. proceduralTexturesEnabled: boolean;
  43567. private _engine;
  43568. private _totalVertices;
  43569. /** @hidden */
  43570. _activeIndices: PerfCounter;
  43571. /** @hidden */
  43572. _activeParticles: PerfCounter;
  43573. /** @hidden */
  43574. _activeBones: PerfCounter;
  43575. private _animationRatio;
  43576. /** @hidden */
  43577. _animationTimeLast: number;
  43578. /** @hidden */
  43579. _animationTime: number;
  43580. /**
  43581. * Gets or sets a general scale for animation speed
  43582. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  43583. */
  43584. animationTimeScale: number;
  43585. /** @hidden */
  43586. _cachedMaterial: Nullable<Material>;
  43587. /** @hidden */
  43588. _cachedEffect: Nullable<Effect>;
  43589. /** @hidden */
  43590. _cachedVisibility: Nullable<number>;
  43591. private _renderId;
  43592. private _frameId;
  43593. private _executeWhenReadyTimeoutId;
  43594. private _intermediateRendering;
  43595. private _viewUpdateFlag;
  43596. private _projectionUpdateFlag;
  43597. /** @hidden */
  43598. _toBeDisposed: Nullable<IDisposable>[];
  43599. private _activeRequests;
  43600. /** @hidden */
  43601. _pendingData: any[];
  43602. private _isDisposed;
  43603. /**
  43604. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  43605. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  43606. */
  43607. dispatchAllSubMeshesOfActiveMeshes: boolean;
  43608. private _activeMeshes;
  43609. private _processedMaterials;
  43610. private _renderTargets;
  43611. /** @hidden */
  43612. _activeParticleSystems: SmartArray<IParticleSystem>;
  43613. private _activeSkeletons;
  43614. private _softwareSkinnedMeshes;
  43615. private _renderingManager;
  43616. /** @hidden */
  43617. _activeAnimatables: Animatable[];
  43618. private _transformMatrix;
  43619. private _sceneUbo;
  43620. /** @hidden */
  43621. _viewMatrix: Matrix;
  43622. private _projectionMatrix;
  43623. /** @hidden */
  43624. _forcedViewPosition: Nullable<Vector3>;
  43625. /** @hidden */
  43626. _frustumPlanes: Plane[];
  43627. /**
  43628. * Gets the list of frustum planes (built from the active camera)
  43629. */
  43630. get frustumPlanes(): Plane[];
  43631. /**
  43632. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43633. * This is useful if there are more lights that the maximum simulteanous authorized
  43634. */
  43635. requireLightSorting: boolean;
  43636. /** @hidden */
  43637. readonly useMaterialMeshMap: boolean;
  43638. /** @hidden */
  43639. readonly useClonedMeshMap: boolean;
  43640. private _externalData;
  43641. private _uid;
  43642. /**
  43643. * @hidden
  43644. * Backing store of defined scene components.
  43645. */
  43646. _components: ISceneComponent[];
  43647. /**
  43648. * @hidden
  43649. * Backing store of defined scene components.
  43650. */
  43651. _serializableComponents: ISceneSerializableComponent[];
  43652. /**
  43653. * List of components to register on the next registration step.
  43654. */
  43655. private _transientComponents;
  43656. /**
  43657. * Registers the transient components if needed.
  43658. */
  43659. private _registerTransientComponents;
  43660. /**
  43661. * @hidden
  43662. * Add a component to the scene.
  43663. * Note that the ccomponent could be registered on th next frame if this is called after
  43664. * the register component stage.
  43665. * @param component Defines the component to add to the scene
  43666. */
  43667. _addComponent(component: ISceneComponent): void;
  43668. /**
  43669. * @hidden
  43670. * Gets a component from the scene.
  43671. * @param name defines the name of the component to retrieve
  43672. * @returns the component or null if not present
  43673. */
  43674. _getComponent(name: string): Nullable<ISceneComponent>;
  43675. /**
  43676. * @hidden
  43677. * Defines the actions happening before camera updates.
  43678. */
  43679. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43680. /**
  43681. * @hidden
  43682. * Defines the actions happening before clear the canvas.
  43683. */
  43684. _beforeClearStage: Stage<SimpleStageAction>;
  43685. /**
  43686. * @hidden
  43687. * Defines the actions when collecting render targets for the frame.
  43688. */
  43689. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43690. /**
  43691. * @hidden
  43692. * Defines the actions happening for one camera in the frame.
  43693. */
  43694. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43695. /**
  43696. * @hidden
  43697. * Defines the actions happening during the per mesh ready checks.
  43698. */
  43699. _isReadyForMeshStage: Stage<MeshStageAction>;
  43700. /**
  43701. * @hidden
  43702. * Defines the actions happening before evaluate active mesh checks.
  43703. */
  43704. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43705. /**
  43706. * @hidden
  43707. * Defines the actions happening during the evaluate sub mesh checks.
  43708. */
  43709. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43710. /**
  43711. * @hidden
  43712. * Defines the actions happening during the active mesh stage.
  43713. */
  43714. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  43715. /**
  43716. * @hidden
  43717. * Defines the actions happening during the per camera render target step.
  43718. */
  43719. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43720. /**
  43721. * @hidden
  43722. * Defines the actions happening just before the active camera is drawing.
  43723. */
  43724. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43725. /**
  43726. * @hidden
  43727. * Defines the actions happening just before a render target is drawing.
  43728. */
  43729. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43730. /**
  43731. * @hidden
  43732. * Defines the actions happening just before a rendering group is drawing.
  43733. */
  43734. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43735. /**
  43736. * @hidden
  43737. * Defines the actions happening just before a mesh is drawing.
  43738. */
  43739. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43740. /**
  43741. * @hidden
  43742. * Defines the actions happening just after a mesh has been drawn.
  43743. */
  43744. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43745. /**
  43746. * @hidden
  43747. * Defines the actions happening just after a rendering group has been drawn.
  43748. */
  43749. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43750. /**
  43751. * @hidden
  43752. * Defines the actions happening just after the active camera has been drawn.
  43753. */
  43754. _afterCameraDrawStage: Stage<CameraStageAction>;
  43755. /**
  43756. * @hidden
  43757. * Defines the actions happening just after a render target has been drawn.
  43758. */
  43759. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43760. /**
  43761. * @hidden
  43762. * Defines the actions happening just after rendering all cameras and computing intersections.
  43763. */
  43764. _afterRenderStage: Stage<SimpleStageAction>;
  43765. /**
  43766. * @hidden
  43767. * Defines the actions happening when a pointer move event happens.
  43768. */
  43769. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43770. /**
  43771. * @hidden
  43772. * Defines the actions happening when a pointer down event happens.
  43773. */
  43774. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43775. /**
  43776. * @hidden
  43777. * Defines the actions happening when a pointer up event happens.
  43778. */
  43779. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43780. /**
  43781. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43782. */
  43783. private geometriesByUniqueId;
  43784. /**
  43785. * Creates a new Scene
  43786. * @param engine defines the engine to use to render this scene
  43787. * @param options defines the scene options
  43788. */
  43789. constructor(engine: Engine, options?: SceneOptions);
  43790. /**
  43791. * Gets a string identifying the name of the class
  43792. * @returns "Scene" string
  43793. */
  43794. getClassName(): string;
  43795. private _defaultMeshCandidates;
  43796. /**
  43797. * @hidden
  43798. */
  43799. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43800. private _defaultSubMeshCandidates;
  43801. /**
  43802. * @hidden
  43803. */
  43804. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43805. /**
  43806. * Sets the default candidate providers for the scene.
  43807. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43808. * and getCollidingSubMeshCandidates to their default function
  43809. */
  43810. setDefaultCandidateProviders(): void;
  43811. /**
  43812. * Gets the mesh that is currently under the pointer
  43813. */
  43814. get meshUnderPointer(): Nullable<AbstractMesh>;
  43815. /**
  43816. * Gets or sets the current on-screen X position of the pointer
  43817. */
  43818. get pointerX(): number;
  43819. set pointerX(value: number);
  43820. /**
  43821. * Gets or sets the current on-screen Y position of the pointer
  43822. */
  43823. get pointerY(): number;
  43824. set pointerY(value: number);
  43825. /**
  43826. * Gets the cached material (ie. the latest rendered one)
  43827. * @returns the cached material
  43828. */
  43829. getCachedMaterial(): Nullable<Material>;
  43830. /**
  43831. * Gets the cached effect (ie. the latest rendered one)
  43832. * @returns the cached effect
  43833. */
  43834. getCachedEffect(): Nullable<Effect>;
  43835. /**
  43836. * Gets the cached visibility state (ie. the latest rendered one)
  43837. * @returns the cached visibility state
  43838. */
  43839. getCachedVisibility(): Nullable<number>;
  43840. /**
  43841. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43842. * @param material defines the current material
  43843. * @param effect defines the current effect
  43844. * @param visibility defines the current visibility state
  43845. * @returns true if one parameter is not cached
  43846. */
  43847. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43848. /**
  43849. * Gets the engine associated with the scene
  43850. * @returns an Engine
  43851. */
  43852. getEngine(): Engine;
  43853. /**
  43854. * Gets the total number of vertices rendered per frame
  43855. * @returns the total number of vertices rendered per frame
  43856. */
  43857. getTotalVertices(): number;
  43858. /**
  43859. * Gets the performance counter for total vertices
  43860. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43861. */
  43862. get totalVerticesPerfCounter(): PerfCounter;
  43863. /**
  43864. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43865. * @returns the total number of active indices rendered per frame
  43866. */
  43867. getActiveIndices(): number;
  43868. /**
  43869. * Gets the performance counter for active indices
  43870. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43871. */
  43872. get totalActiveIndicesPerfCounter(): PerfCounter;
  43873. /**
  43874. * Gets the total number of active particles rendered per frame
  43875. * @returns the total number of active particles rendered per frame
  43876. */
  43877. getActiveParticles(): number;
  43878. /**
  43879. * Gets the performance counter for active particles
  43880. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43881. */
  43882. get activeParticlesPerfCounter(): PerfCounter;
  43883. /**
  43884. * Gets the total number of active bones rendered per frame
  43885. * @returns the total number of active bones rendered per frame
  43886. */
  43887. getActiveBones(): number;
  43888. /**
  43889. * Gets the performance counter for active bones
  43890. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43891. */
  43892. get activeBonesPerfCounter(): PerfCounter;
  43893. /**
  43894. * Gets the array of active meshes
  43895. * @returns an array of AbstractMesh
  43896. */
  43897. getActiveMeshes(): SmartArray<AbstractMesh>;
  43898. /**
  43899. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43900. * @returns a number
  43901. */
  43902. getAnimationRatio(): number;
  43903. /**
  43904. * Gets an unique Id for the current render phase
  43905. * @returns a number
  43906. */
  43907. getRenderId(): number;
  43908. /**
  43909. * Gets an unique Id for the current frame
  43910. * @returns a number
  43911. */
  43912. getFrameId(): number;
  43913. /** Call this function if you want to manually increment the render Id*/
  43914. incrementRenderId(): void;
  43915. private _createUbo;
  43916. /**
  43917. * Use this method to simulate a pointer move on a mesh
  43918. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43919. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43920. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43921. * @returns the current scene
  43922. */
  43923. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43924. /**
  43925. * Use this method to simulate a pointer down on a mesh
  43926. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43927. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43928. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43929. * @returns the current scene
  43930. */
  43931. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43932. /**
  43933. * Use this method to simulate a pointer up on a mesh
  43934. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43935. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43936. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43937. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43938. * @returns the current scene
  43939. */
  43940. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43941. /**
  43942. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43943. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43944. * @returns true if the pointer was captured
  43945. */
  43946. isPointerCaptured(pointerId?: number): boolean;
  43947. /**
  43948. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43949. * @param attachUp defines if you want to attach events to pointerup
  43950. * @param attachDown defines if you want to attach events to pointerdown
  43951. * @param attachMove defines if you want to attach events to pointermove
  43952. */
  43953. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43954. /** Detaches all event handlers*/
  43955. detachControl(): void;
  43956. /**
  43957. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43958. * Delay loaded resources are not taking in account
  43959. * @return true if all required resources are ready
  43960. */
  43961. isReady(): boolean;
  43962. /** Resets all cached information relative to material (including effect and visibility) */
  43963. resetCachedMaterial(): void;
  43964. /**
  43965. * Registers a function to be called before every frame render
  43966. * @param func defines the function to register
  43967. */
  43968. registerBeforeRender(func: () => void): void;
  43969. /**
  43970. * Unregisters a function called before every frame render
  43971. * @param func defines the function to unregister
  43972. */
  43973. unregisterBeforeRender(func: () => void): void;
  43974. /**
  43975. * Registers a function to be called after every frame render
  43976. * @param func defines the function to register
  43977. */
  43978. registerAfterRender(func: () => void): void;
  43979. /**
  43980. * Unregisters a function called after every frame render
  43981. * @param func defines the function to unregister
  43982. */
  43983. unregisterAfterRender(func: () => void): void;
  43984. private _executeOnceBeforeRender;
  43985. /**
  43986. * The provided function will run before render once and will be disposed afterwards.
  43987. * A timeout delay can be provided so that the function will be executed in N ms.
  43988. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43989. * @param func The function to be executed.
  43990. * @param timeout optional delay in ms
  43991. */
  43992. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43993. /** @hidden */
  43994. _addPendingData(data: any): void;
  43995. /** @hidden */
  43996. _removePendingData(data: any): void;
  43997. /**
  43998. * Returns the number of items waiting to be loaded
  43999. * @returns the number of items waiting to be loaded
  44000. */
  44001. getWaitingItemsCount(): number;
  44002. /**
  44003. * Returns a boolean indicating if the scene is still loading data
  44004. */
  44005. get isLoading(): boolean;
  44006. /**
  44007. * Registers a function to be executed when the scene is ready
  44008. * @param {Function} func - the function to be executed
  44009. */
  44010. executeWhenReady(func: () => void): void;
  44011. /**
  44012. * Returns a promise that resolves when the scene is ready
  44013. * @returns A promise that resolves when the scene is ready
  44014. */
  44015. whenReadyAsync(): Promise<void>;
  44016. /** @hidden */
  44017. _checkIsReady(): void;
  44018. /**
  44019. * Gets all animatable attached to the scene
  44020. */
  44021. get animatables(): Animatable[];
  44022. /**
  44023. * Resets the last animation time frame.
  44024. * Useful to override when animations start running when loading a scene for the first time.
  44025. */
  44026. resetLastAnimationTimeFrame(): void;
  44027. /**
  44028. * Gets the current view matrix
  44029. * @returns a Matrix
  44030. */
  44031. getViewMatrix(): Matrix;
  44032. /**
  44033. * Gets the current projection matrix
  44034. * @returns a Matrix
  44035. */
  44036. getProjectionMatrix(): Matrix;
  44037. /**
  44038. * Gets the current transform matrix
  44039. * @returns a Matrix made of View * Projection
  44040. */
  44041. getTransformMatrix(): Matrix;
  44042. /**
  44043. * Sets the current transform matrix
  44044. * @param viewL defines the View matrix to use
  44045. * @param projectionL defines the Projection matrix to use
  44046. * @param viewR defines the right View matrix to use (if provided)
  44047. * @param projectionR defines the right Projection matrix to use (if provided)
  44048. */
  44049. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  44050. /**
  44051. * Gets the uniform buffer used to store scene data
  44052. * @returns a UniformBuffer
  44053. */
  44054. getSceneUniformBuffer(): UniformBuffer;
  44055. /**
  44056. * Gets an unique (relatively to the current scene) Id
  44057. * @returns an unique number for the scene
  44058. */
  44059. getUniqueId(): number;
  44060. /**
  44061. * Add a mesh to the list of scene's meshes
  44062. * @param newMesh defines the mesh to add
  44063. * @param recursive if all child meshes should also be added to the scene
  44064. */
  44065. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  44066. /**
  44067. * Remove a mesh for the list of scene's meshes
  44068. * @param toRemove defines the mesh to remove
  44069. * @param recursive if all child meshes should also be removed from the scene
  44070. * @returns the index where the mesh was in the mesh list
  44071. */
  44072. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  44073. /**
  44074. * Add a transform node to the list of scene's transform nodes
  44075. * @param newTransformNode defines the transform node to add
  44076. */
  44077. addTransformNode(newTransformNode: TransformNode): void;
  44078. /**
  44079. * Remove a transform node for the list of scene's transform nodes
  44080. * @param toRemove defines the transform node to remove
  44081. * @returns the index where the transform node was in the transform node list
  44082. */
  44083. removeTransformNode(toRemove: TransformNode): number;
  44084. /**
  44085. * Remove a skeleton for the list of scene's skeletons
  44086. * @param toRemove defines the skeleton to remove
  44087. * @returns the index where the skeleton was in the skeleton list
  44088. */
  44089. removeSkeleton(toRemove: Skeleton): number;
  44090. /**
  44091. * Remove a morph target for the list of scene's morph targets
  44092. * @param toRemove defines the morph target to remove
  44093. * @returns the index where the morph target was in the morph target list
  44094. */
  44095. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  44096. /**
  44097. * Remove a light for the list of scene's lights
  44098. * @param toRemove defines the light to remove
  44099. * @returns the index where the light was in the light list
  44100. */
  44101. removeLight(toRemove: Light): number;
  44102. /**
  44103. * Remove a camera for the list of scene's cameras
  44104. * @param toRemove defines the camera to remove
  44105. * @returns the index where the camera was in the camera list
  44106. */
  44107. removeCamera(toRemove: Camera): number;
  44108. /**
  44109. * Remove a particle system for the list of scene's particle systems
  44110. * @param toRemove defines the particle system to remove
  44111. * @returns the index where the particle system was in the particle system list
  44112. */
  44113. removeParticleSystem(toRemove: IParticleSystem): number;
  44114. /**
  44115. * Remove a animation for the list of scene's animations
  44116. * @param toRemove defines the animation to remove
  44117. * @returns the index where the animation was in the animation list
  44118. */
  44119. removeAnimation(toRemove: Animation): number;
  44120. /**
  44121. * Will stop the animation of the given target
  44122. * @param target - the target
  44123. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  44124. * @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)
  44125. */
  44126. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  44127. /**
  44128. * Removes the given animation group from this scene.
  44129. * @param toRemove The animation group to remove
  44130. * @returns The index of the removed animation group
  44131. */
  44132. removeAnimationGroup(toRemove: AnimationGroup): number;
  44133. /**
  44134. * Removes the given multi-material from this scene.
  44135. * @param toRemove The multi-material to remove
  44136. * @returns The index of the removed multi-material
  44137. */
  44138. removeMultiMaterial(toRemove: MultiMaterial): number;
  44139. /**
  44140. * Removes the given material from this scene.
  44141. * @param toRemove The material to remove
  44142. * @returns The index of the removed material
  44143. */
  44144. removeMaterial(toRemove: Material): number;
  44145. /**
  44146. * Removes the given action manager from this scene.
  44147. * @param toRemove The action manager to remove
  44148. * @returns The index of the removed action manager
  44149. */
  44150. removeActionManager(toRemove: AbstractActionManager): number;
  44151. /**
  44152. * Removes the given texture from this scene.
  44153. * @param toRemove The texture to remove
  44154. * @returns The index of the removed texture
  44155. */
  44156. removeTexture(toRemove: BaseTexture): number;
  44157. /**
  44158. * Adds the given light to this scene
  44159. * @param newLight The light to add
  44160. */
  44161. addLight(newLight: Light): void;
  44162. /**
  44163. * Sorts the list list based on light priorities
  44164. */
  44165. sortLightsByPriority(): void;
  44166. /**
  44167. * Adds the given camera to this scene
  44168. * @param newCamera The camera to add
  44169. */
  44170. addCamera(newCamera: Camera): void;
  44171. /**
  44172. * Adds the given skeleton to this scene
  44173. * @param newSkeleton The skeleton to add
  44174. */
  44175. addSkeleton(newSkeleton: Skeleton): void;
  44176. /**
  44177. * Adds the given particle system to this scene
  44178. * @param newParticleSystem The particle system to add
  44179. */
  44180. addParticleSystem(newParticleSystem: IParticleSystem): void;
  44181. /**
  44182. * Adds the given animation to this scene
  44183. * @param newAnimation The animation to add
  44184. */
  44185. addAnimation(newAnimation: Animation): void;
  44186. /**
  44187. * Adds the given animation group to this scene.
  44188. * @param newAnimationGroup The animation group to add
  44189. */
  44190. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  44191. /**
  44192. * Adds the given multi-material to this scene
  44193. * @param newMultiMaterial The multi-material to add
  44194. */
  44195. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  44196. /**
  44197. * Adds the given material to this scene
  44198. * @param newMaterial The material to add
  44199. */
  44200. addMaterial(newMaterial: Material): void;
  44201. /**
  44202. * Adds the given morph target to this scene
  44203. * @param newMorphTargetManager The morph target to add
  44204. */
  44205. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  44206. /**
  44207. * Adds the given geometry to this scene
  44208. * @param newGeometry The geometry to add
  44209. */
  44210. addGeometry(newGeometry: Geometry): void;
  44211. /**
  44212. * Adds the given action manager to this scene
  44213. * @param newActionManager The action manager to add
  44214. */
  44215. addActionManager(newActionManager: AbstractActionManager): void;
  44216. /**
  44217. * Adds the given texture to this scene.
  44218. * @param newTexture The texture to add
  44219. */
  44220. addTexture(newTexture: BaseTexture): void;
  44221. /**
  44222. * Switch active camera
  44223. * @param newCamera defines the new active camera
  44224. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  44225. */
  44226. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  44227. /**
  44228. * sets the active camera of the scene using its ID
  44229. * @param id defines the camera's ID
  44230. * @return the new active camera or null if none found.
  44231. */
  44232. setActiveCameraByID(id: string): Nullable<Camera>;
  44233. /**
  44234. * sets the active camera of the scene using its name
  44235. * @param name defines the camera's name
  44236. * @returns the new active camera or null if none found.
  44237. */
  44238. setActiveCameraByName(name: string): Nullable<Camera>;
  44239. /**
  44240. * get an animation group using its name
  44241. * @param name defines the material's name
  44242. * @return the animation group or null if none found.
  44243. */
  44244. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  44245. /**
  44246. * Get a material using its unique id
  44247. * @param uniqueId defines the material's unique id
  44248. * @return the material or null if none found.
  44249. */
  44250. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  44251. /**
  44252. * get a material using its id
  44253. * @param id defines the material's ID
  44254. * @return the material or null if none found.
  44255. */
  44256. getMaterialByID(id: string): Nullable<Material>;
  44257. /**
  44258. * Gets a the last added material using a given id
  44259. * @param id defines the material's ID
  44260. * @return the last material with the given id or null if none found.
  44261. */
  44262. getLastMaterialByID(id: string): Nullable<Material>;
  44263. /**
  44264. * Gets a material using its name
  44265. * @param name defines the material's name
  44266. * @return the material or null if none found.
  44267. */
  44268. getMaterialByName(name: string): Nullable<Material>;
  44269. /**
  44270. * Get a texture using its unique id
  44271. * @param uniqueId defines the texture's unique id
  44272. * @return the texture or null if none found.
  44273. */
  44274. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  44275. /**
  44276. * Gets a camera using its id
  44277. * @param id defines the id to look for
  44278. * @returns the camera or null if not found
  44279. */
  44280. getCameraByID(id: string): Nullable<Camera>;
  44281. /**
  44282. * Gets a camera using its unique id
  44283. * @param uniqueId defines the unique id to look for
  44284. * @returns the camera or null if not found
  44285. */
  44286. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  44287. /**
  44288. * Gets a camera using its name
  44289. * @param name defines the camera's name
  44290. * @return the camera or null if none found.
  44291. */
  44292. getCameraByName(name: string): Nullable<Camera>;
  44293. /**
  44294. * Gets a bone using its id
  44295. * @param id defines the bone's id
  44296. * @return the bone or null if not found
  44297. */
  44298. getBoneByID(id: string): Nullable<Bone>;
  44299. /**
  44300. * Gets a bone using its id
  44301. * @param name defines the bone's name
  44302. * @return the bone or null if not found
  44303. */
  44304. getBoneByName(name: string): Nullable<Bone>;
  44305. /**
  44306. * Gets a light node using its name
  44307. * @param name defines the the light's name
  44308. * @return the light or null if none found.
  44309. */
  44310. getLightByName(name: string): Nullable<Light>;
  44311. /**
  44312. * Gets a light node using its id
  44313. * @param id defines the light's id
  44314. * @return the light or null if none found.
  44315. */
  44316. getLightByID(id: string): Nullable<Light>;
  44317. /**
  44318. * Gets a light node using its scene-generated unique ID
  44319. * @param uniqueId defines the light's unique id
  44320. * @return the light or null if none found.
  44321. */
  44322. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  44323. /**
  44324. * Gets a particle system by id
  44325. * @param id defines the particle system id
  44326. * @return the corresponding system or null if none found
  44327. */
  44328. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  44329. /**
  44330. * Gets a geometry using its ID
  44331. * @param id defines the geometry's id
  44332. * @return the geometry or null if none found.
  44333. */
  44334. getGeometryByID(id: string): Nullable<Geometry>;
  44335. private _getGeometryByUniqueID;
  44336. /**
  44337. * Add a new geometry to this scene
  44338. * @param geometry defines the geometry to be added to the scene.
  44339. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  44340. * @return a boolean defining if the geometry was added or not
  44341. */
  44342. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  44343. /**
  44344. * Removes an existing geometry
  44345. * @param geometry defines the geometry to be removed from the scene
  44346. * @return a boolean defining if the geometry was removed or not
  44347. */
  44348. removeGeometry(geometry: Geometry): boolean;
  44349. /**
  44350. * Gets the list of geometries attached to the scene
  44351. * @returns an array of Geometry
  44352. */
  44353. getGeometries(): Geometry[];
  44354. /**
  44355. * Gets the first added mesh found of a given ID
  44356. * @param id defines the id to search for
  44357. * @return the mesh found or null if not found at all
  44358. */
  44359. getMeshByID(id: string): Nullable<AbstractMesh>;
  44360. /**
  44361. * Gets a list of meshes using their id
  44362. * @param id defines the id to search for
  44363. * @returns a list of meshes
  44364. */
  44365. getMeshesByID(id: string): Array<AbstractMesh>;
  44366. /**
  44367. * Gets the first added transform node found of a given ID
  44368. * @param id defines the id to search for
  44369. * @return the found transform node or null if not found at all.
  44370. */
  44371. getTransformNodeByID(id: string): Nullable<TransformNode>;
  44372. /**
  44373. * Gets a transform node with its auto-generated unique id
  44374. * @param uniqueId efines the unique id to search for
  44375. * @return the found transform node or null if not found at all.
  44376. */
  44377. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  44378. /**
  44379. * Gets a list of transform nodes using their id
  44380. * @param id defines the id to search for
  44381. * @returns a list of transform nodes
  44382. */
  44383. getTransformNodesByID(id: string): Array<TransformNode>;
  44384. /**
  44385. * Gets a mesh with its auto-generated unique id
  44386. * @param uniqueId defines the unique id to search for
  44387. * @return the found mesh or null if not found at all.
  44388. */
  44389. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  44390. /**
  44391. * Gets a the last added mesh using a given id
  44392. * @param id defines the id to search for
  44393. * @return the found mesh or null if not found at all.
  44394. */
  44395. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  44396. /**
  44397. * Gets a the last added node (Mesh, Camera, Light) using a given id
  44398. * @param id defines the id to search for
  44399. * @return the found node or null if not found at all
  44400. */
  44401. getLastEntryByID(id: string): Nullable<Node>;
  44402. /**
  44403. * Gets a node (Mesh, Camera, Light) using a given id
  44404. * @param id defines the id to search for
  44405. * @return the found node or null if not found at all
  44406. */
  44407. getNodeByID(id: string): Nullable<Node>;
  44408. /**
  44409. * Gets a node (Mesh, Camera, Light) using a given name
  44410. * @param name defines the name to search for
  44411. * @return the found node or null if not found at all.
  44412. */
  44413. getNodeByName(name: string): Nullable<Node>;
  44414. /**
  44415. * Gets a mesh using a given name
  44416. * @param name defines the name to search for
  44417. * @return the found mesh or null if not found at all.
  44418. */
  44419. getMeshByName(name: string): Nullable<AbstractMesh>;
  44420. /**
  44421. * Gets a transform node using a given name
  44422. * @param name defines the name to search for
  44423. * @return the found transform node or null if not found at all.
  44424. */
  44425. getTransformNodeByName(name: string): Nullable<TransformNode>;
  44426. /**
  44427. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  44428. * @param id defines the id to search for
  44429. * @return the found skeleton or null if not found at all.
  44430. */
  44431. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  44432. /**
  44433. * Gets a skeleton using a given auto generated unique id
  44434. * @param uniqueId defines the unique id to search for
  44435. * @return the found skeleton or null if not found at all.
  44436. */
  44437. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  44438. /**
  44439. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  44440. * @param id defines the id to search for
  44441. * @return the found skeleton or null if not found at all.
  44442. */
  44443. getSkeletonById(id: string): Nullable<Skeleton>;
  44444. /**
  44445. * Gets a skeleton using a given name
  44446. * @param name defines the name to search for
  44447. * @return the found skeleton or null if not found at all.
  44448. */
  44449. getSkeletonByName(name: string): Nullable<Skeleton>;
  44450. /**
  44451. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  44452. * @param id defines the id to search for
  44453. * @return the found morph target manager or null if not found at all.
  44454. */
  44455. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  44456. /**
  44457. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  44458. * @param id defines the id to search for
  44459. * @return the found morph target or null if not found at all.
  44460. */
  44461. getMorphTargetById(id: string): Nullable<MorphTarget>;
  44462. /**
  44463. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  44464. * @param name defines the name to search for
  44465. * @return the found morph target or null if not found at all.
  44466. */
  44467. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  44468. /**
  44469. * Gets a post process using a given name (if many are found, this function will pick the first one)
  44470. * @param name defines the name to search for
  44471. * @return the found post process or null if not found at all.
  44472. */
  44473. getPostProcessByName(name: string): Nullable<PostProcess>;
  44474. /**
  44475. * Gets a boolean indicating if the given mesh is active
  44476. * @param mesh defines the mesh to look for
  44477. * @returns true if the mesh is in the active list
  44478. */
  44479. isActiveMesh(mesh: AbstractMesh): boolean;
  44480. /**
  44481. * Return a unique id as a string which can serve as an identifier for the scene
  44482. */
  44483. get uid(): string;
  44484. /**
  44485. * Add an externaly attached data from its key.
  44486. * This method call will fail and return false, if such key already exists.
  44487. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  44488. * @param key the unique key that identifies the data
  44489. * @param data the data object to associate to the key for this Engine instance
  44490. * @return true if no such key were already present and the data was added successfully, false otherwise
  44491. */
  44492. addExternalData<T>(key: string, data: T): boolean;
  44493. /**
  44494. * Get an externaly attached data from its key
  44495. * @param key the unique key that identifies the data
  44496. * @return the associated data, if present (can be null), or undefined if not present
  44497. */
  44498. getExternalData<T>(key: string): Nullable<T>;
  44499. /**
  44500. * Get an externaly attached data from its key, create it using a factory if it's not already present
  44501. * @param key the unique key that identifies the data
  44502. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  44503. * @return the associated data, can be null if the factory returned null.
  44504. */
  44505. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  44506. /**
  44507. * Remove an externaly attached data from the Engine instance
  44508. * @param key the unique key that identifies the data
  44509. * @return true if the data was successfully removed, false if it doesn't exist
  44510. */
  44511. removeExternalData(key: string): boolean;
  44512. private _evaluateSubMesh;
  44513. /**
  44514. * Clear the processed materials smart array preventing retention point in material dispose.
  44515. */
  44516. freeProcessedMaterials(): void;
  44517. private _preventFreeActiveMeshesAndRenderingGroups;
  44518. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  44519. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  44520. * when disposing several meshes in a row or a hierarchy of meshes.
  44521. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  44522. */
  44523. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  44524. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  44525. /**
  44526. * Clear the active meshes smart array preventing retention point in mesh dispose.
  44527. */
  44528. freeActiveMeshes(): void;
  44529. /**
  44530. * Clear the info related to rendering groups preventing retention points during dispose.
  44531. */
  44532. freeRenderingGroups(): void;
  44533. /** @hidden */
  44534. _isInIntermediateRendering(): boolean;
  44535. /**
  44536. * Lambda returning the list of potentially active meshes.
  44537. */
  44538. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  44539. /**
  44540. * Lambda returning the list of potentially active sub meshes.
  44541. */
  44542. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  44543. /**
  44544. * Lambda returning the list of potentially intersecting sub meshes.
  44545. */
  44546. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  44547. /**
  44548. * Lambda returning the list of potentially colliding sub meshes.
  44549. */
  44550. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  44551. /** @hidden */
  44552. _activeMeshesFrozen: boolean;
  44553. private _skipEvaluateActiveMeshesCompletely;
  44554. /**
  44555. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  44556. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  44557. * @param onSuccess optional success callback
  44558. * @param onError optional error callback
  44559. * @returns the current scene
  44560. */
  44561. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  44562. /**
  44563. * Use this function to restart evaluating active meshes on every frame
  44564. * @returns the current scene
  44565. */
  44566. unfreezeActiveMeshes(): Scene;
  44567. private _evaluateActiveMeshes;
  44568. private _activeMesh;
  44569. /**
  44570. * Update the transform matrix to update from the current active camera
  44571. * @param force defines a boolean used to force the update even if cache is up to date
  44572. */
  44573. updateTransformMatrix(force?: boolean): void;
  44574. private _bindFrameBuffer;
  44575. /** @hidden */
  44576. _allowPostProcessClearColor: boolean;
  44577. /** @hidden */
  44578. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  44579. private _processSubCameras;
  44580. private _checkIntersections;
  44581. /** @hidden */
  44582. _advancePhysicsEngineStep(step: number): void;
  44583. /**
  44584. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  44585. */
  44586. getDeterministicFrameTime: () => number;
  44587. /** @hidden */
  44588. _animate(): void;
  44589. /** Execute all animations (for a frame) */
  44590. animate(): void;
  44591. /**
  44592. * Render the scene
  44593. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  44594. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  44595. */
  44596. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  44597. /**
  44598. * Freeze all materials
  44599. * A frozen material will not be updatable but should be faster to render
  44600. */
  44601. freezeMaterials(): void;
  44602. /**
  44603. * Unfreeze all materials
  44604. * A frozen material will not be updatable but should be faster to render
  44605. */
  44606. unfreezeMaterials(): void;
  44607. /**
  44608. * Releases all held ressources
  44609. */
  44610. dispose(): void;
  44611. /**
  44612. * Gets if the scene is already disposed
  44613. */
  44614. get isDisposed(): boolean;
  44615. /**
  44616. * Call this function to reduce memory footprint of the scene.
  44617. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44618. */
  44619. clearCachedVertexData(): void;
  44620. /**
  44621. * This function will remove the local cached buffer data from texture.
  44622. * It will save memory but will prevent the texture from being rebuilt
  44623. */
  44624. cleanCachedTextureBuffer(): void;
  44625. /**
  44626. * Get the world extend vectors with an optional filter
  44627. *
  44628. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44629. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44630. */
  44631. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44632. min: Vector3;
  44633. max: Vector3;
  44634. };
  44635. /**
  44636. * Creates a ray that can be used to pick in the scene
  44637. * @param x defines the x coordinate of the origin (on-screen)
  44638. * @param y defines the y coordinate of the origin (on-screen)
  44639. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44640. * @param camera defines the camera to use for the picking
  44641. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44642. * @returns a Ray
  44643. */
  44644. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44645. /**
  44646. * Creates a ray that can be used to pick in the scene
  44647. * @param x defines the x coordinate of the origin (on-screen)
  44648. * @param y defines the y coordinate of the origin (on-screen)
  44649. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44650. * @param result defines the ray where to store the picking ray
  44651. * @param camera defines the camera to use for the picking
  44652. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44653. * @returns the current scene
  44654. */
  44655. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44656. /**
  44657. * Creates a ray that can be used to pick in the scene
  44658. * @param x defines the x coordinate of the origin (on-screen)
  44659. * @param y defines the y coordinate of the origin (on-screen)
  44660. * @param camera defines the camera to use for the picking
  44661. * @returns a Ray
  44662. */
  44663. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44664. /**
  44665. * Creates a ray that can be used to pick in the scene
  44666. * @param x defines the x coordinate of the origin (on-screen)
  44667. * @param y defines the y coordinate of the origin (on-screen)
  44668. * @param result defines the ray where to store the picking ray
  44669. * @param camera defines the camera to use for the picking
  44670. * @returns the current scene
  44671. */
  44672. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44673. /** Launch a ray to try to pick a mesh in the scene
  44674. * @param x position on screen
  44675. * @param y position on screen
  44676. * @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
  44677. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44678. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44679. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44680. * @returns a PickingInfo
  44681. */
  44682. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44683. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44684. * @param x position on screen
  44685. * @param y position on screen
  44686. * @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
  44687. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44688. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44689. * @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)
  44690. */
  44691. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44692. /** Use the given ray to pick a mesh in the scene
  44693. * @param ray The ray to use to pick meshes
  44694. * @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
  44695. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44696. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44697. * @returns a PickingInfo
  44698. */
  44699. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44700. /**
  44701. * Launch a ray to try to pick a mesh in the scene
  44702. * @param x X position on screen
  44703. * @param y Y position on screen
  44704. * @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
  44705. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44706. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44707. * @returns an array of PickingInfo
  44708. */
  44709. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44710. /**
  44711. * Launch a ray to try to pick a mesh in the scene
  44712. * @param ray Ray to use
  44713. * @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
  44714. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44715. * @returns an array of PickingInfo
  44716. */
  44717. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44718. /**
  44719. * Force the value of meshUnderPointer
  44720. * @param mesh defines the mesh to use
  44721. * @param pointerId optional pointer id when using more than one pointer
  44722. */
  44723. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44724. /**
  44725. * Gets the mesh under the pointer
  44726. * @returns a Mesh or null if no mesh is under the pointer
  44727. */
  44728. getPointerOverMesh(): Nullable<AbstractMesh>;
  44729. /** @hidden */
  44730. _rebuildGeometries(): void;
  44731. /** @hidden */
  44732. _rebuildTextures(): void;
  44733. private _getByTags;
  44734. /**
  44735. * Get a list of meshes by tags
  44736. * @param tagsQuery defines the tags query to use
  44737. * @param forEach defines a predicate used to filter results
  44738. * @returns an array of Mesh
  44739. */
  44740. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44741. /**
  44742. * Get a list of cameras by tags
  44743. * @param tagsQuery defines the tags query to use
  44744. * @param forEach defines a predicate used to filter results
  44745. * @returns an array of Camera
  44746. */
  44747. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44748. /**
  44749. * Get a list of lights by tags
  44750. * @param tagsQuery defines the tags query to use
  44751. * @param forEach defines a predicate used to filter results
  44752. * @returns an array of Light
  44753. */
  44754. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44755. /**
  44756. * Get a list of materials by tags
  44757. * @param tagsQuery defines the tags query to use
  44758. * @param forEach defines a predicate used to filter results
  44759. * @returns an array of Material
  44760. */
  44761. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44762. /**
  44763. * Get a list of transform nodes by tags
  44764. * @param tagsQuery defines the tags query to use
  44765. * @param forEach defines a predicate used to filter results
  44766. * @returns an array of TransformNode
  44767. */
  44768. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44769. /**
  44770. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44771. * This allowed control for front to back rendering or reversly depending of the special needs.
  44772. *
  44773. * @param renderingGroupId The rendering group id corresponding to its index
  44774. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44775. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44776. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44777. */
  44778. 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;
  44779. /**
  44780. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44781. *
  44782. * @param renderingGroupId The rendering group id corresponding to its index
  44783. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44784. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44785. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44786. */
  44787. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44788. /**
  44789. * Gets the current auto clear configuration for one rendering group of the rendering
  44790. * manager.
  44791. * @param index the rendering group index to get the information for
  44792. * @returns The auto clear setup for the requested rendering group
  44793. */
  44794. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44795. private _blockMaterialDirtyMechanism;
  44796. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44797. get blockMaterialDirtyMechanism(): boolean;
  44798. set blockMaterialDirtyMechanism(value: boolean);
  44799. /**
  44800. * Will flag all materials as dirty to trigger new shader compilation
  44801. * @param flag defines the flag used to specify which material part must be marked as dirty
  44802. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44803. */
  44804. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44805. /** @hidden */
  44806. _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;
  44807. /** @hidden */
  44808. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44809. /** @hidden */
  44810. _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;
  44811. /** @hidden */
  44812. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44813. /** @hidden */
  44814. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44815. /** @hidden */
  44816. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44817. }
  44818. }
  44819. declare module BABYLON {
  44820. /**
  44821. * Set of assets to keep when moving a scene into an asset container.
  44822. */
  44823. export class KeepAssets extends AbstractScene {
  44824. }
  44825. /**
  44826. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44827. */
  44828. export class InstantiatedEntries {
  44829. /**
  44830. * List of new root nodes (eg. nodes with no parent)
  44831. */
  44832. rootNodes: TransformNode[];
  44833. /**
  44834. * List of new skeletons
  44835. */
  44836. skeletons: Skeleton[];
  44837. /**
  44838. * List of new animation groups
  44839. */
  44840. animationGroups: AnimationGroup[];
  44841. }
  44842. /**
  44843. * Container with a set of assets that can be added or removed from a scene.
  44844. */
  44845. export class AssetContainer extends AbstractScene {
  44846. private _wasAddedToScene;
  44847. /**
  44848. * The scene the AssetContainer belongs to.
  44849. */
  44850. scene: Scene;
  44851. /**
  44852. * Instantiates an AssetContainer.
  44853. * @param scene The scene the AssetContainer belongs to.
  44854. */
  44855. constructor(scene: Scene);
  44856. /**
  44857. * Instantiate or clone all meshes and add the new ones to the scene.
  44858. * Skeletons and animation groups will all be cloned
  44859. * @param nameFunction defines an optional function used to get new names for clones
  44860. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44861. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44862. */
  44863. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44864. /**
  44865. * Adds all the assets from the container to the scene.
  44866. */
  44867. addAllToScene(): void;
  44868. /**
  44869. * Removes all the assets in the container from the scene
  44870. */
  44871. removeAllFromScene(): void;
  44872. /**
  44873. * Disposes all the assets in the container
  44874. */
  44875. dispose(): void;
  44876. private _moveAssets;
  44877. /**
  44878. * Removes all the assets contained in the scene and adds them to the container.
  44879. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44880. */
  44881. moveAllFromScene(keepAssets?: KeepAssets): void;
  44882. /**
  44883. * 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.
  44884. * @returns the root mesh
  44885. */
  44886. createRootMesh(): Mesh;
  44887. /**
  44888. * Merge animations (direct and animation groups) from this asset container into a scene
  44889. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44890. * @param animatables set of animatables to retarget to a node from the scene
  44891. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44892. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44893. */
  44894. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44895. }
  44896. }
  44897. declare module BABYLON {
  44898. /**
  44899. * Defines how the parser contract is defined.
  44900. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44901. */
  44902. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44903. /**
  44904. * Defines how the individual parser contract is defined.
  44905. * These parser can parse an individual asset
  44906. */
  44907. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44908. /**
  44909. * Base class of the scene acting as a container for the different elements composing a scene.
  44910. * This class is dynamically extended by the different components of the scene increasing
  44911. * flexibility and reducing coupling
  44912. */
  44913. export abstract class AbstractScene {
  44914. /**
  44915. * Stores the list of available parsers in the application.
  44916. */
  44917. private static _BabylonFileParsers;
  44918. /**
  44919. * Stores the list of available individual parsers in the application.
  44920. */
  44921. private static _IndividualBabylonFileParsers;
  44922. /**
  44923. * Adds a parser in the list of available ones
  44924. * @param name Defines the name of the parser
  44925. * @param parser Defines the parser to add
  44926. */
  44927. static AddParser(name: string, parser: BabylonFileParser): void;
  44928. /**
  44929. * Gets a general parser from the list of avaialble ones
  44930. * @param name Defines the name of the parser
  44931. * @returns the requested parser or null
  44932. */
  44933. static GetParser(name: string): Nullable<BabylonFileParser>;
  44934. /**
  44935. * Adds n individual parser in the list of available ones
  44936. * @param name Defines the name of the parser
  44937. * @param parser Defines the parser to add
  44938. */
  44939. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44940. /**
  44941. * Gets an individual parser from the list of avaialble ones
  44942. * @param name Defines the name of the parser
  44943. * @returns the requested parser or null
  44944. */
  44945. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44946. /**
  44947. * Parser json data and populate both a scene and its associated container object
  44948. * @param jsonData Defines the data to parse
  44949. * @param scene Defines the scene to parse the data for
  44950. * @param container Defines the container attached to the parsing sequence
  44951. * @param rootUrl Defines the root url of the data
  44952. */
  44953. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44954. /**
  44955. * Gets the list of root nodes (ie. nodes with no parent)
  44956. */
  44957. rootNodes: Node[];
  44958. /** All of the cameras added to this scene
  44959. * @see https://doc.babylonjs.com/babylon101/cameras
  44960. */
  44961. cameras: Camera[];
  44962. /**
  44963. * All of the lights added to this scene
  44964. * @see https://doc.babylonjs.com/babylon101/lights
  44965. */
  44966. lights: Light[];
  44967. /**
  44968. * All of the (abstract) meshes added to this scene
  44969. */
  44970. meshes: AbstractMesh[];
  44971. /**
  44972. * The list of skeletons added to the scene
  44973. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44974. */
  44975. skeletons: Skeleton[];
  44976. /**
  44977. * All of the particle systems added to this scene
  44978. * @see https://doc.babylonjs.com/babylon101/particles
  44979. */
  44980. particleSystems: IParticleSystem[];
  44981. /**
  44982. * Gets a list of Animations associated with the scene
  44983. */
  44984. animations: Animation[];
  44985. /**
  44986. * All of the animation groups added to this scene
  44987. * @see https://doc.babylonjs.com/how_to/group
  44988. */
  44989. animationGroups: AnimationGroup[];
  44990. /**
  44991. * All of the multi-materials added to this scene
  44992. * @see https://doc.babylonjs.com/how_to/multi_materials
  44993. */
  44994. multiMaterials: MultiMaterial[];
  44995. /**
  44996. * All of the materials added to this scene
  44997. * In the context of a Scene, it is not supposed to be modified manually.
  44998. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44999. * Note also that the order of the Material within the array is not significant and might change.
  45000. * @see https://doc.babylonjs.com/babylon101/materials
  45001. */
  45002. materials: Material[];
  45003. /**
  45004. * The list of morph target managers added to the scene
  45005. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  45006. */
  45007. morphTargetManagers: MorphTargetManager[];
  45008. /**
  45009. * The list of geometries used in the scene.
  45010. */
  45011. geometries: Geometry[];
  45012. /**
  45013. * All of the tranform nodes added to this scene
  45014. * In the context of a Scene, it is not supposed to be modified manually.
  45015. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  45016. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  45017. * @see https://doc.babylonjs.com/how_to/transformnode
  45018. */
  45019. transformNodes: TransformNode[];
  45020. /**
  45021. * ActionManagers available on the scene.
  45022. */
  45023. actionManagers: AbstractActionManager[];
  45024. /**
  45025. * Textures to keep.
  45026. */
  45027. textures: BaseTexture[];
  45028. /** @hidden */
  45029. protected _environmentTexture: Nullable<BaseTexture>;
  45030. /**
  45031. * Texture used in all pbr material as the reflection texture.
  45032. * As in the majority of the scene they are the same (exception for multi room and so on),
  45033. * this is easier to reference from here than from all the materials.
  45034. */
  45035. get environmentTexture(): Nullable<BaseTexture>;
  45036. set environmentTexture(value: Nullable<BaseTexture>);
  45037. /**
  45038. * The list of postprocesses added to the scene
  45039. */
  45040. postProcesses: PostProcess[];
  45041. /**
  45042. * @returns all meshes, lights, cameras, transformNodes and bones
  45043. */
  45044. getNodes(): Array<Node>;
  45045. }
  45046. }
  45047. declare module BABYLON {
  45048. /**
  45049. * Interface used to define options for Sound class
  45050. */
  45051. export interface ISoundOptions {
  45052. /**
  45053. * Does the sound autoplay once loaded.
  45054. */
  45055. autoplay?: boolean;
  45056. /**
  45057. * Does the sound loop after it finishes playing once.
  45058. */
  45059. loop?: boolean;
  45060. /**
  45061. * Sound's volume
  45062. */
  45063. volume?: number;
  45064. /**
  45065. * Is it a spatial sound?
  45066. */
  45067. spatialSound?: boolean;
  45068. /**
  45069. * Maximum distance to hear that sound
  45070. */
  45071. maxDistance?: number;
  45072. /**
  45073. * Uses user defined attenuation function
  45074. */
  45075. useCustomAttenuation?: boolean;
  45076. /**
  45077. * Define the roll off factor of spatial sounds.
  45078. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45079. */
  45080. rolloffFactor?: number;
  45081. /**
  45082. * Define the reference distance the sound should be heard perfectly.
  45083. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45084. */
  45085. refDistance?: number;
  45086. /**
  45087. * Define the distance attenuation model the sound will follow.
  45088. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45089. */
  45090. distanceModel?: string;
  45091. /**
  45092. * Defines the playback speed (1 by default)
  45093. */
  45094. playbackRate?: number;
  45095. /**
  45096. * Defines if the sound is from a streaming source
  45097. */
  45098. streaming?: boolean;
  45099. /**
  45100. * Defines an optional length (in seconds) inside the sound file
  45101. */
  45102. length?: number;
  45103. /**
  45104. * Defines an optional offset (in seconds) inside the sound file
  45105. */
  45106. offset?: number;
  45107. /**
  45108. * If true, URLs will not be required to state the audio file codec to use.
  45109. */
  45110. skipCodecCheck?: boolean;
  45111. }
  45112. }
  45113. declare module BABYLON {
  45114. /**
  45115. * Defines a sound that can be played in the application.
  45116. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  45117. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45118. */
  45119. export class Sound {
  45120. /**
  45121. * The name of the sound in the scene.
  45122. */
  45123. name: string;
  45124. /**
  45125. * Does the sound autoplay once loaded.
  45126. */
  45127. autoplay: boolean;
  45128. private _loop;
  45129. /**
  45130. * Does the sound loop after it finishes playing once.
  45131. */
  45132. get loop(): boolean;
  45133. set loop(value: boolean);
  45134. /**
  45135. * Does the sound use a custom attenuation curve to simulate the falloff
  45136. * happening when the source gets further away from the camera.
  45137. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45138. */
  45139. useCustomAttenuation: boolean;
  45140. /**
  45141. * The sound track id this sound belongs to.
  45142. */
  45143. soundTrackId: number;
  45144. /**
  45145. * Is this sound currently played.
  45146. */
  45147. isPlaying: boolean;
  45148. /**
  45149. * Is this sound currently paused.
  45150. */
  45151. isPaused: boolean;
  45152. /**
  45153. * Does this sound enables spatial sound.
  45154. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45155. */
  45156. spatialSound: boolean;
  45157. /**
  45158. * Define the reference distance the sound should be heard perfectly.
  45159. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45160. */
  45161. refDistance: number;
  45162. /**
  45163. * Define the roll off factor of spatial sounds.
  45164. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45165. */
  45166. rolloffFactor: number;
  45167. /**
  45168. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  45169. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45170. */
  45171. maxDistance: number;
  45172. /**
  45173. * Define the distance attenuation model the sound will follow.
  45174. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45175. */
  45176. distanceModel: string;
  45177. /**
  45178. * @hidden
  45179. * Back Compat
  45180. **/
  45181. onended: () => any;
  45182. /**
  45183. * Gets or sets an object used to store user defined information for the sound.
  45184. */
  45185. metadata: any;
  45186. /**
  45187. * Observable event when the current playing sound finishes.
  45188. */
  45189. onEndedObservable: Observable<Sound>;
  45190. /**
  45191. * Gets the current time for the sound.
  45192. */
  45193. get currentTime(): number;
  45194. private _panningModel;
  45195. private _playbackRate;
  45196. private _streaming;
  45197. private _startTime;
  45198. private _startOffset;
  45199. private _position;
  45200. /** @hidden */
  45201. _positionInEmitterSpace: boolean;
  45202. private _localDirection;
  45203. private _volume;
  45204. private _isReadyToPlay;
  45205. private _isDirectional;
  45206. private _readyToPlayCallback;
  45207. private _audioBuffer;
  45208. private _soundSource;
  45209. private _streamingSource;
  45210. private _soundPanner;
  45211. private _soundGain;
  45212. private _inputAudioNode;
  45213. private _outputAudioNode;
  45214. private _coneInnerAngle;
  45215. private _coneOuterAngle;
  45216. private _coneOuterGain;
  45217. private _scene;
  45218. private _connectedTransformNode;
  45219. private _customAttenuationFunction;
  45220. private _registerFunc;
  45221. private _isOutputConnected;
  45222. private _htmlAudioElement;
  45223. private _urlType;
  45224. private _length?;
  45225. private _offset?;
  45226. /** @hidden */
  45227. static _SceneComponentInitialization: (scene: Scene) => void;
  45228. /**
  45229. * Create a sound and attach it to a scene
  45230. * @param name Name of your sound
  45231. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  45232. * @param scene defines the scene the sound belongs to
  45233. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  45234. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  45235. */
  45236. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  45237. /**
  45238. * Release the sound and its associated resources
  45239. */
  45240. dispose(): void;
  45241. /**
  45242. * Gets if the sounds is ready to be played or not.
  45243. * @returns true if ready, otherwise false
  45244. */
  45245. isReady(): boolean;
  45246. /**
  45247. * Get the current class name.
  45248. * @returns current class name
  45249. */
  45250. getClassName(): string;
  45251. private _soundLoaded;
  45252. /**
  45253. * Sets the data of the sound from an audiobuffer
  45254. * @param audioBuffer The audioBuffer containing the data
  45255. */
  45256. setAudioBuffer(audioBuffer: AudioBuffer): void;
  45257. /**
  45258. * Updates the current sounds options such as maxdistance, loop...
  45259. * @param options A JSON object containing values named as the object properties
  45260. */
  45261. updateOptions(options: ISoundOptions): void;
  45262. private _createSpatialParameters;
  45263. private _updateSpatialParameters;
  45264. /**
  45265. * Switch the panning model to HRTF:
  45266. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45267. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45268. */
  45269. switchPanningModelToHRTF(): void;
  45270. /**
  45271. * Switch the panning model to Equal Power:
  45272. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45274. */
  45275. switchPanningModelToEqualPower(): void;
  45276. private _switchPanningModel;
  45277. /**
  45278. * Connect this sound to a sound track audio node like gain...
  45279. * @param soundTrackAudioNode the sound track audio node to connect to
  45280. */
  45281. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  45282. /**
  45283. * Transform this sound into a directional source
  45284. * @param coneInnerAngle Size of the inner cone in degree
  45285. * @param coneOuterAngle Size of the outer cone in degree
  45286. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  45287. */
  45288. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  45289. /**
  45290. * Gets or sets the inner angle for the directional cone.
  45291. */
  45292. get directionalConeInnerAngle(): number;
  45293. /**
  45294. * Gets or sets the inner angle for the directional cone.
  45295. */
  45296. set directionalConeInnerAngle(value: number);
  45297. /**
  45298. * Gets or sets the outer angle for the directional cone.
  45299. */
  45300. get directionalConeOuterAngle(): number;
  45301. /**
  45302. * Gets or sets the outer angle for the directional cone.
  45303. */
  45304. set directionalConeOuterAngle(value: number);
  45305. /**
  45306. * Sets the position of the emitter if spatial sound is enabled
  45307. * @param newPosition Defines the new posisiton
  45308. */
  45309. setPosition(newPosition: Vector3): void;
  45310. /**
  45311. * Sets the local direction of the emitter if spatial sound is enabled
  45312. * @param newLocalDirection Defines the new local direction
  45313. */
  45314. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  45315. private _updateDirection;
  45316. /** @hidden */
  45317. updateDistanceFromListener(): void;
  45318. /**
  45319. * Sets a new custom attenuation function for the sound.
  45320. * @param callback Defines the function used for the attenuation
  45321. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  45322. */
  45323. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  45324. /**
  45325. * Play the sound
  45326. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  45327. * @param offset (optional) Start the sound at a specific time in seconds
  45328. * @param length (optional) Sound duration (in seconds)
  45329. */
  45330. play(time?: number, offset?: number, length?: number): void;
  45331. private _onended;
  45332. /**
  45333. * Stop the sound
  45334. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  45335. */
  45336. stop(time?: number): void;
  45337. /**
  45338. * Put the sound in pause
  45339. */
  45340. pause(): void;
  45341. /**
  45342. * Sets a dedicated volume for this sounds
  45343. * @param newVolume Define the new volume of the sound
  45344. * @param time Define time for gradual change to new volume
  45345. */
  45346. setVolume(newVolume: number, time?: number): void;
  45347. /**
  45348. * Set the sound play back rate
  45349. * @param newPlaybackRate Define the playback rate the sound should be played at
  45350. */
  45351. setPlaybackRate(newPlaybackRate: number): void;
  45352. /**
  45353. * Gets the volume of the sound.
  45354. * @returns the volume of the sound
  45355. */
  45356. getVolume(): number;
  45357. /**
  45358. * Attach the sound to a dedicated mesh
  45359. * @param transformNode The transform node to connect the sound with
  45360. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45361. */
  45362. attachToMesh(transformNode: TransformNode): void;
  45363. /**
  45364. * Detach the sound from the previously attached mesh
  45365. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  45366. */
  45367. detachFromMesh(): void;
  45368. private _onRegisterAfterWorldMatrixUpdate;
  45369. /**
  45370. * Clone the current sound in the scene.
  45371. * @returns the new sound clone
  45372. */
  45373. clone(): Nullable<Sound>;
  45374. /**
  45375. * Gets the current underlying audio buffer containing the data
  45376. * @returns the audio buffer
  45377. */
  45378. getAudioBuffer(): Nullable<AudioBuffer>;
  45379. /**
  45380. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  45381. * @returns the source node
  45382. */
  45383. getSoundSource(): Nullable<AudioBufferSourceNode>;
  45384. /**
  45385. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  45386. * @returns the gain node
  45387. */
  45388. getSoundGain(): Nullable<GainNode>;
  45389. /**
  45390. * Serializes the Sound in a JSON representation
  45391. * @returns the JSON representation of the sound
  45392. */
  45393. serialize(): any;
  45394. /**
  45395. * Parse a JSON representation of a sound to innstantiate in a given scene
  45396. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  45397. * @param scene Define the scene the new parsed sound should be created in
  45398. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  45399. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  45400. * @returns the newly parsed sound
  45401. */
  45402. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  45403. }
  45404. }
  45405. declare module BABYLON {
  45406. /**
  45407. * This defines an action helpful to play a defined sound on a triggered action.
  45408. */
  45409. export class PlaySoundAction extends Action {
  45410. private _sound;
  45411. /**
  45412. * Instantiate the action
  45413. * @param triggerOptions defines the trigger options
  45414. * @param sound defines the sound to play
  45415. * @param condition defines the trigger related conditions
  45416. */
  45417. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45418. /** @hidden */
  45419. _prepare(): void;
  45420. /**
  45421. * Execute the action and play the sound.
  45422. */
  45423. execute(): void;
  45424. /**
  45425. * Serializes the actions and its related information.
  45426. * @param parent defines the object to serialize in
  45427. * @returns the serialized object
  45428. */
  45429. serialize(parent: any): any;
  45430. }
  45431. /**
  45432. * This defines an action helpful to stop a defined sound on a triggered action.
  45433. */
  45434. export class StopSoundAction extends Action {
  45435. private _sound;
  45436. /**
  45437. * Instantiate the action
  45438. * @param triggerOptions defines the trigger options
  45439. * @param sound defines the sound to stop
  45440. * @param condition defines the trigger related conditions
  45441. */
  45442. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  45443. /** @hidden */
  45444. _prepare(): void;
  45445. /**
  45446. * Execute the action and stop the sound.
  45447. */
  45448. execute(): void;
  45449. /**
  45450. * Serializes the actions and its related information.
  45451. * @param parent defines the object to serialize in
  45452. * @returns the serialized object
  45453. */
  45454. serialize(parent: any): any;
  45455. }
  45456. }
  45457. declare module BABYLON {
  45458. /**
  45459. * This defines an action responsible to change the value of a property
  45460. * by interpolating between its current value and the newly set one once triggered.
  45461. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  45462. */
  45463. export class InterpolateValueAction extends Action {
  45464. /**
  45465. * Defines the path of the property where the value should be interpolated
  45466. */
  45467. propertyPath: string;
  45468. /**
  45469. * Defines the target value at the end of the interpolation.
  45470. */
  45471. value: any;
  45472. /**
  45473. * Defines the time it will take for the property to interpolate to the value.
  45474. */
  45475. duration: number;
  45476. /**
  45477. * Defines if the other scene animations should be stopped when the action has been triggered
  45478. */
  45479. stopOtherAnimations?: boolean;
  45480. /**
  45481. * Defines a callback raised once the interpolation animation has been done.
  45482. */
  45483. onInterpolationDone?: () => void;
  45484. /**
  45485. * Observable triggered once the interpolation animation has been done.
  45486. */
  45487. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  45488. private _target;
  45489. private _effectiveTarget;
  45490. private _property;
  45491. /**
  45492. * Instantiate the action
  45493. * @param triggerOptions defines the trigger options
  45494. * @param target defines the object containing the value to interpolate
  45495. * @param propertyPath defines the path to the property in the target object
  45496. * @param value defines the target value at the end of the interpolation
  45497. * @param duration deines the time it will take for the property to interpolate to the value.
  45498. * @param condition defines the trigger related conditions
  45499. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  45500. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  45501. */
  45502. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  45503. /** @hidden */
  45504. _prepare(): void;
  45505. /**
  45506. * Execute the action starts the value interpolation.
  45507. */
  45508. execute(): void;
  45509. /**
  45510. * Serializes the actions and its related information.
  45511. * @param parent defines the object to serialize in
  45512. * @returns the serialized object
  45513. */
  45514. serialize(parent: any): any;
  45515. }
  45516. }
  45517. declare module BABYLON {
  45518. /**
  45519. * This represents the default audio engine used in babylon.
  45520. * It is responsible to play, synchronize and analyse sounds throughout the application.
  45521. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45522. */
  45523. export class AudioEngine implements IAudioEngine {
  45524. private _audioContext;
  45525. private _audioContextInitialized;
  45526. private _muteButton;
  45527. private _hostElement;
  45528. /**
  45529. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  45530. */
  45531. canUseWebAudio: boolean;
  45532. /**
  45533. * The master gain node defines the global audio volume of your audio engine.
  45534. */
  45535. masterGain: GainNode;
  45536. /**
  45537. * Defines if Babylon should emit a warning if WebAudio is not supported.
  45538. * @ignoreNaming
  45539. */
  45540. WarnedWebAudioUnsupported: boolean;
  45541. /**
  45542. * Gets whether or not mp3 are supported by your browser.
  45543. */
  45544. isMP3supported: boolean;
  45545. /**
  45546. * Gets whether or not ogg are supported by your browser.
  45547. */
  45548. isOGGsupported: boolean;
  45549. /**
  45550. * Gets whether audio has been unlocked on the device.
  45551. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  45552. * a user interaction has happened.
  45553. */
  45554. unlocked: boolean;
  45555. /**
  45556. * Defines if the audio engine relies on a custom unlocked button.
  45557. * In this case, the embedded button will not be displayed.
  45558. */
  45559. useCustomUnlockedButton: boolean;
  45560. /**
  45561. * Event raised when audio has been unlocked on the browser.
  45562. */
  45563. onAudioUnlockedObservable: Observable<IAudioEngine>;
  45564. /**
  45565. * Event raised when audio has been locked on the browser.
  45566. */
  45567. onAudioLockedObservable: Observable<IAudioEngine>;
  45568. /**
  45569. * Gets the current AudioContext if available.
  45570. */
  45571. get audioContext(): Nullable<AudioContext>;
  45572. private _connectedAnalyser;
  45573. /**
  45574. * Instantiates a new audio engine.
  45575. *
  45576. * There should be only one per page as some browsers restrict the number
  45577. * of audio contexts you can create.
  45578. * @param hostElement defines the host element where to display the mute icon if necessary
  45579. */
  45580. constructor(hostElement?: Nullable<HTMLElement>);
  45581. /**
  45582. * Flags the audio engine in Locked state.
  45583. * This happens due to new browser policies preventing audio to autoplay.
  45584. */
  45585. lock(): void;
  45586. /**
  45587. * Unlocks the audio engine once a user action has been done on the dom.
  45588. * This is helpful to resume play once browser policies have been satisfied.
  45589. */
  45590. unlock(): void;
  45591. private _resumeAudioContext;
  45592. private _initializeAudioContext;
  45593. private _tryToRun;
  45594. private _triggerRunningState;
  45595. private _triggerSuspendedState;
  45596. private _displayMuteButton;
  45597. private _moveButtonToTopLeft;
  45598. private _onResize;
  45599. private _hideMuteButton;
  45600. /**
  45601. * Destroy and release the resources associated with the audio ccontext.
  45602. */
  45603. dispose(): void;
  45604. /**
  45605. * Gets the global volume sets on the master gain.
  45606. * @returns the global volume if set or -1 otherwise
  45607. */
  45608. getGlobalVolume(): number;
  45609. /**
  45610. * Sets the global volume of your experience (sets on the master gain).
  45611. * @param newVolume Defines the new global volume of the application
  45612. */
  45613. setGlobalVolume(newVolume: number): void;
  45614. /**
  45615. * Connect the audio engine to an audio analyser allowing some amazing
  45616. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45617. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45618. * @param analyser The analyser to connect to the engine
  45619. */
  45620. connectToAnalyser(analyser: Analyser): void;
  45621. }
  45622. }
  45623. declare module BABYLON {
  45624. /**
  45625. * Options allowed during the creation of a sound track.
  45626. */
  45627. export interface ISoundTrackOptions {
  45628. /**
  45629. * The volume the sound track should take during creation
  45630. */
  45631. volume?: number;
  45632. /**
  45633. * Define if the sound track is the main sound track of the scene
  45634. */
  45635. mainTrack?: boolean;
  45636. }
  45637. /**
  45638. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  45639. * It will be also used in a future release to apply effects on a specific track.
  45640. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45641. */
  45642. export class SoundTrack {
  45643. /**
  45644. * The unique identifier of the sound track in the scene.
  45645. */
  45646. id: number;
  45647. /**
  45648. * The list of sounds included in the sound track.
  45649. */
  45650. soundCollection: Array<Sound>;
  45651. private _outputAudioNode;
  45652. private _scene;
  45653. private _connectedAnalyser;
  45654. private _options;
  45655. private _isInitialized;
  45656. /**
  45657. * Creates a new sound track.
  45658. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  45659. * @param scene Define the scene the sound track belongs to
  45660. * @param options
  45661. */
  45662. constructor(scene: Scene, options?: ISoundTrackOptions);
  45663. private _initializeSoundTrackAudioGraph;
  45664. /**
  45665. * Release the sound track and its associated resources
  45666. */
  45667. dispose(): void;
  45668. /**
  45669. * Adds a sound to this sound track
  45670. * @param sound define the cound to add
  45671. * @ignoreNaming
  45672. */
  45673. addSound(sound: Sound): void;
  45674. /**
  45675. * Removes a sound to this sound track
  45676. * @param sound define the cound to remove
  45677. * @ignoreNaming
  45678. */
  45679. removeSound(sound: Sound): void;
  45680. /**
  45681. * Set a global volume for the full sound track.
  45682. * @param newVolume Define the new volume of the sound track
  45683. */
  45684. setVolume(newVolume: number): void;
  45685. /**
  45686. * Switch the panning model to HRTF:
  45687. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  45688. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45689. */
  45690. switchPanningModelToHRTF(): void;
  45691. /**
  45692. * Switch the panning model to Equal Power:
  45693. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  45694. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  45695. */
  45696. switchPanningModelToEqualPower(): void;
  45697. /**
  45698. * Connect the sound track to an audio analyser allowing some amazing
  45699. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  45700. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  45701. * @param analyser The analyser to connect to the engine
  45702. */
  45703. connectToAnalyser(analyser: Analyser): void;
  45704. }
  45705. }
  45706. declare module BABYLON {
  45707. interface AbstractScene {
  45708. /**
  45709. * The list of sounds used in the scene.
  45710. */
  45711. sounds: Nullable<Array<Sound>>;
  45712. }
  45713. interface Scene {
  45714. /**
  45715. * @hidden
  45716. * Backing field
  45717. */
  45718. _mainSoundTrack: SoundTrack;
  45719. /**
  45720. * The main sound track played by the scene.
  45721. * It cotains your primary collection of sounds.
  45722. */
  45723. mainSoundTrack: SoundTrack;
  45724. /**
  45725. * The list of sound tracks added to the scene
  45726. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45727. */
  45728. soundTracks: Nullable<Array<SoundTrack>>;
  45729. /**
  45730. * Gets a sound using a given name
  45731. * @param name defines the name to search for
  45732. * @return the found sound or null if not found at all.
  45733. */
  45734. getSoundByName(name: string): Nullable<Sound>;
  45735. /**
  45736. * Gets or sets if audio support is enabled
  45737. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45738. */
  45739. audioEnabled: boolean;
  45740. /**
  45741. * Gets or sets if audio will be output to headphones
  45742. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45743. */
  45744. headphone: boolean;
  45745. /**
  45746. * Gets or sets custom audio listener position provider
  45747. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45748. */
  45749. audioListenerPositionProvider: Nullable<() => Vector3>;
  45750. /**
  45751. * Gets or sets a refresh rate when using 3D audio positioning
  45752. */
  45753. audioPositioningRefreshRate: number;
  45754. }
  45755. /**
  45756. * Defines the sound scene component responsible to manage any sounds
  45757. * in a given scene.
  45758. */
  45759. export class AudioSceneComponent implements ISceneSerializableComponent {
  45760. private static _CameraDirectionLH;
  45761. private static _CameraDirectionRH;
  45762. /**
  45763. * The component name helpfull to identify the component in the list of scene components.
  45764. */
  45765. readonly name: string;
  45766. /**
  45767. * The scene the component belongs to.
  45768. */
  45769. scene: Scene;
  45770. private _audioEnabled;
  45771. /**
  45772. * Gets whether audio is enabled or not.
  45773. * Please use related enable/disable method to switch state.
  45774. */
  45775. get audioEnabled(): boolean;
  45776. private _headphone;
  45777. /**
  45778. * Gets whether audio is outputing to headphone or not.
  45779. * Please use the according Switch methods to change output.
  45780. */
  45781. get headphone(): boolean;
  45782. /**
  45783. * Gets or sets a refresh rate when using 3D audio positioning
  45784. */
  45785. audioPositioningRefreshRate: number;
  45786. private _audioListenerPositionProvider;
  45787. /**
  45788. * Gets the current audio listener position provider
  45789. */
  45790. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45791. /**
  45792. * Sets a custom listener position for all sounds in the scene
  45793. * By default, this is the position of the first active camera
  45794. */
  45795. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45796. /**
  45797. * Creates a new instance of the component for the given scene
  45798. * @param scene Defines the scene to register the component in
  45799. */
  45800. constructor(scene: Scene);
  45801. /**
  45802. * Registers the component in a given scene
  45803. */
  45804. register(): void;
  45805. /**
  45806. * Rebuilds the elements related to this component in case of
  45807. * context lost for instance.
  45808. */
  45809. rebuild(): void;
  45810. /**
  45811. * Serializes the component data to the specified json object
  45812. * @param serializationObject The object to serialize to
  45813. */
  45814. serialize(serializationObject: any): void;
  45815. /**
  45816. * Adds all the elements from the container to the scene
  45817. * @param container the container holding the elements
  45818. */
  45819. addFromContainer(container: AbstractScene): void;
  45820. /**
  45821. * Removes all the elements in the container from the scene
  45822. * @param container contains the elements to remove
  45823. * @param dispose if the removed element should be disposed (default: false)
  45824. */
  45825. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45826. /**
  45827. * Disposes the component and the associated ressources.
  45828. */
  45829. dispose(): void;
  45830. /**
  45831. * Disables audio in the associated scene.
  45832. */
  45833. disableAudio(): void;
  45834. /**
  45835. * Enables audio in the associated scene.
  45836. */
  45837. enableAudio(): void;
  45838. /**
  45839. * Switch audio to headphone output.
  45840. */
  45841. switchAudioModeForHeadphones(): void;
  45842. /**
  45843. * Switch audio to normal speakers.
  45844. */
  45845. switchAudioModeForNormalSpeakers(): void;
  45846. private _cachedCameraDirection;
  45847. private _cachedCameraPosition;
  45848. private _lastCheck;
  45849. private _afterRender;
  45850. }
  45851. }
  45852. declare module BABYLON {
  45853. /**
  45854. * Wraps one or more Sound objects and selects one with random weight for playback.
  45855. */
  45856. export class WeightedSound {
  45857. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45858. loop: boolean;
  45859. private _coneInnerAngle;
  45860. private _coneOuterAngle;
  45861. private _volume;
  45862. /** A Sound is currently playing. */
  45863. isPlaying: boolean;
  45864. /** A Sound is currently paused. */
  45865. isPaused: boolean;
  45866. private _sounds;
  45867. private _weights;
  45868. private _currentIndex?;
  45869. /**
  45870. * Creates a new WeightedSound from the list of sounds given.
  45871. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45872. * @param sounds Array of Sounds that will be selected from.
  45873. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45874. */
  45875. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45876. /**
  45877. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45878. */
  45879. get directionalConeInnerAngle(): number;
  45880. /**
  45881. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45882. */
  45883. set directionalConeInnerAngle(value: number);
  45884. /**
  45885. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45886. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45887. */
  45888. get directionalConeOuterAngle(): number;
  45889. /**
  45890. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45891. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45892. */
  45893. set directionalConeOuterAngle(value: number);
  45894. /**
  45895. * Playback volume.
  45896. */
  45897. get volume(): number;
  45898. /**
  45899. * Playback volume.
  45900. */
  45901. set volume(value: number);
  45902. private _onended;
  45903. /**
  45904. * Suspend playback
  45905. */
  45906. pause(): void;
  45907. /**
  45908. * Stop playback
  45909. */
  45910. stop(): void;
  45911. /**
  45912. * Start playback.
  45913. * @param startOffset Position the clip head at a specific time in seconds.
  45914. */
  45915. play(startOffset?: number): void;
  45916. }
  45917. }
  45918. declare module BABYLON {
  45919. /**
  45920. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45921. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45922. */
  45923. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45924. /**
  45925. * Gets the name of the behavior.
  45926. */
  45927. get name(): string;
  45928. /**
  45929. * The easing function used by animations
  45930. */
  45931. static EasingFunction: BackEase;
  45932. /**
  45933. * The easing mode used by animations
  45934. */
  45935. static EasingMode: number;
  45936. /**
  45937. * The duration of the animation, in milliseconds
  45938. */
  45939. transitionDuration: number;
  45940. /**
  45941. * Length of the distance animated by the transition when lower radius is reached
  45942. */
  45943. lowerRadiusTransitionRange: number;
  45944. /**
  45945. * Length of the distance animated by the transition when upper radius is reached
  45946. */
  45947. upperRadiusTransitionRange: number;
  45948. private _autoTransitionRange;
  45949. /**
  45950. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45951. */
  45952. get autoTransitionRange(): boolean;
  45953. /**
  45954. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45955. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45956. */
  45957. set autoTransitionRange(value: boolean);
  45958. private _attachedCamera;
  45959. private _onAfterCheckInputsObserver;
  45960. private _onMeshTargetChangedObserver;
  45961. /**
  45962. * Initializes the behavior.
  45963. */
  45964. init(): void;
  45965. /**
  45966. * Attaches the behavior to its arc rotate camera.
  45967. * @param camera Defines the camera to attach the behavior to
  45968. */
  45969. attach(camera: ArcRotateCamera): void;
  45970. /**
  45971. * Detaches the behavior from its current arc rotate camera.
  45972. */
  45973. detach(): void;
  45974. private _radiusIsAnimating;
  45975. private _radiusBounceTransition;
  45976. private _animatables;
  45977. private _cachedWheelPrecision;
  45978. /**
  45979. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45980. * @param radiusLimit The limit to check against.
  45981. * @return Bool to indicate if at limit.
  45982. */
  45983. private _isRadiusAtLimit;
  45984. /**
  45985. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45986. * @param radiusDelta The delta by which to animate to. Can be negative.
  45987. */
  45988. private _applyBoundRadiusAnimation;
  45989. /**
  45990. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45991. */
  45992. protected _clearAnimationLocks(): void;
  45993. /**
  45994. * Stops and removes all animations that have been applied to the camera
  45995. */
  45996. stopAllAnimations(): void;
  45997. }
  45998. }
  45999. declare module BABYLON {
  46000. /**
  46001. * 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.
  46002. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46003. */
  46004. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  46005. /**
  46006. * Gets the name of the behavior.
  46007. */
  46008. get name(): string;
  46009. private _mode;
  46010. private _radiusScale;
  46011. private _positionScale;
  46012. private _defaultElevation;
  46013. private _elevationReturnTime;
  46014. private _elevationReturnWaitTime;
  46015. private _zoomStopsAnimation;
  46016. private _framingTime;
  46017. /**
  46018. * The easing function used by animations
  46019. */
  46020. static EasingFunction: ExponentialEase;
  46021. /**
  46022. * The easing mode used by animations
  46023. */
  46024. static EasingMode: number;
  46025. /**
  46026. * Sets the current mode used by the behavior
  46027. */
  46028. set mode(mode: number);
  46029. /**
  46030. * Gets current mode used by the behavior.
  46031. */
  46032. get mode(): number;
  46033. /**
  46034. * Sets the scale applied to the radius (1 by default)
  46035. */
  46036. set radiusScale(radius: number);
  46037. /**
  46038. * Gets the scale applied to the radius
  46039. */
  46040. get radiusScale(): number;
  46041. /**
  46042. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46043. */
  46044. set positionScale(scale: number);
  46045. /**
  46046. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  46047. */
  46048. get positionScale(): number;
  46049. /**
  46050. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46051. * behaviour is triggered, in radians.
  46052. */
  46053. set defaultElevation(elevation: number);
  46054. /**
  46055. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  46056. * behaviour is triggered, in radians.
  46057. */
  46058. get defaultElevation(): number;
  46059. /**
  46060. * Sets the time (in milliseconds) taken to return to the default beta position.
  46061. * Negative value indicates camera should not return to default.
  46062. */
  46063. set elevationReturnTime(speed: number);
  46064. /**
  46065. * Gets the time (in milliseconds) taken to return to the default beta position.
  46066. * Negative value indicates camera should not return to default.
  46067. */
  46068. get elevationReturnTime(): number;
  46069. /**
  46070. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46071. */
  46072. set elevationReturnWaitTime(time: number);
  46073. /**
  46074. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  46075. */
  46076. get elevationReturnWaitTime(): number;
  46077. /**
  46078. * Sets the flag that indicates if user zooming should stop animation.
  46079. */
  46080. set zoomStopsAnimation(flag: boolean);
  46081. /**
  46082. * Gets the flag that indicates if user zooming should stop animation.
  46083. */
  46084. get zoomStopsAnimation(): boolean;
  46085. /**
  46086. * Sets the transition time when framing the mesh, in milliseconds
  46087. */
  46088. set framingTime(time: number);
  46089. /**
  46090. * Gets the transition time when framing the mesh, in milliseconds
  46091. */
  46092. get framingTime(): number;
  46093. /**
  46094. * Define if the behavior should automatically change the configured
  46095. * camera limits and sensibilities.
  46096. */
  46097. autoCorrectCameraLimitsAndSensibility: boolean;
  46098. private _onPrePointerObservableObserver;
  46099. private _onAfterCheckInputsObserver;
  46100. private _onMeshTargetChangedObserver;
  46101. private _attachedCamera;
  46102. private _isPointerDown;
  46103. private _lastInteractionTime;
  46104. /**
  46105. * Initializes the behavior.
  46106. */
  46107. init(): void;
  46108. /**
  46109. * Attaches the behavior to its arc rotate camera.
  46110. * @param camera Defines the camera to attach the behavior to
  46111. */
  46112. attach(camera: ArcRotateCamera): void;
  46113. /**
  46114. * Detaches the behavior from its current arc rotate camera.
  46115. */
  46116. detach(): void;
  46117. private _animatables;
  46118. private _betaIsAnimating;
  46119. private _betaTransition;
  46120. private _radiusTransition;
  46121. private _vectorTransition;
  46122. /**
  46123. * Targets the given mesh and updates zoom level accordingly.
  46124. * @param mesh The mesh to target.
  46125. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46126. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46127. */
  46128. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46129. /**
  46130. * Targets the given mesh with its children and updates zoom level accordingly.
  46131. * @param mesh The mesh to target.
  46132. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46133. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46134. */
  46135. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46136. /**
  46137. * Targets the given meshes with their children and updates zoom level accordingly.
  46138. * @param meshes The mesh to target.
  46139. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46140. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46141. */
  46142. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46143. /**
  46144. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  46145. * @param minimumWorld Determines the smaller position of the bounding box extend
  46146. * @param maximumWorld Determines the bigger position of the bounding box extend
  46147. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  46148. * @param onAnimationEnd Callback triggered at the end of the framing animation
  46149. */
  46150. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  46151. /**
  46152. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  46153. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  46154. * frustum width.
  46155. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  46156. * to fully enclose the mesh in the viewing frustum.
  46157. */
  46158. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  46159. /**
  46160. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  46161. * is automatically returned to its default position (expected to be above ground plane).
  46162. */
  46163. private _maintainCameraAboveGround;
  46164. /**
  46165. * Returns the frustum slope based on the canvas ratio and camera FOV
  46166. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  46167. */
  46168. private _getFrustumSlope;
  46169. /**
  46170. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  46171. */
  46172. private _clearAnimationLocks;
  46173. /**
  46174. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46175. */
  46176. private _applyUserInteraction;
  46177. /**
  46178. * Stops and removes all animations that have been applied to the camera
  46179. */
  46180. stopAllAnimations(): void;
  46181. /**
  46182. * Gets a value indicating if the user is moving the camera
  46183. */
  46184. get isUserIsMoving(): boolean;
  46185. /**
  46186. * The camera can move all the way towards the mesh.
  46187. */
  46188. static IgnoreBoundsSizeMode: number;
  46189. /**
  46190. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  46191. */
  46192. static FitFrustumSidesMode: number;
  46193. }
  46194. }
  46195. declare module BABYLON {
  46196. /**
  46197. * Base class for Camera Pointer Inputs.
  46198. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  46199. * for example usage.
  46200. */
  46201. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  46202. /**
  46203. * Defines the camera the input is attached to.
  46204. */
  46205. abstract camera: Camera;
  46206. /**
  46207. * Whether keyboard modifier keys are pressed at time of last mouse event.
  46208. */
  46209. protected _altKey: boolean;
  46210. protected _ctrlKey: boolean;
  46211. protected _metaKey: boolean;
  46212. protected _shiftKey: boolean;
  46213. /**
  46214. * Which mouse buttons were pressed at time of last mouse event.
  46215. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  46216. */
  46217. protected _buttonsPressed: number;
  46218. /**
  46219. * Defines the buttons associated with the input to handle camera move.
  46220. */
  46221. buttons: number[];
  46222. /**
  46223. * Attach the input controls to a specific dom element to get the input from.
  46224. * @param element Defines the element the controls should be listened from
  46225. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46226. */
  46227. attachControl(noPreventDefault?: boolean): void;
  46228. /**
  46229. * Detach the current controls from the specified dom element.
  46230. */
  46231. detachControl(): void;
  46232. /**
  46233. * Gets the class name of the current input.
  46234. * @returns the class name
  46235. */
  46236. getClassName(): string;
  46237. /**
  46238. * Get the friendly name associated with the input class.
  46239. * @returns the input friendly name
  46240. */
  46241. getSimpleName(): string;
  46242. /**
  46243. * Called on pointer POINTERDOUBLETAP event.
  46244. * Override this method to provide functionality on POINTERDOUBLETAP event.
  46245. */
  46246. protected onDoubleTap(type: string): void;
  46247. /**
  46248. * Called on pointer POINTERMOVE event if only a single touch is active.
  46249. * Override this method to provide functionality.
  46250. */
  46251. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46252. /**
  46253. * Called on pointer POINTERMOVE event if multiple touches are active.
  46254. * Override this method to provide functionality.
  46255. */
  46256. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46257. /**
  46258. * Called on JS contextmenu event.
  46259. * Override this method to provide functionality.
  46260. */
  46261. protected onContextMenu(evt: PointerEvent): void;
  46262. /**
  46263. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46264. * press.
  46265. * Override this method to provide functionality.
  46266. */
  46267. protected onButtonDown(evt: PointerEvent): void;
  46268. /**
  46269. * Called each time a new POINTERUP event occurs. Ie, for each button
  46270. * release.
  46271. * Override this method to provide functionality.
  46272. */
  46273. protected onButtonUp(evt: PointerEvent): void;
  46274. /**
  46275. * Called when window becomes inactive.
  46276. * Override this method to provide functionality.
  46277. */
  46278. protected onLostFocus(): void;
  46279. private _pointerInput;
  46280. private _observer;
  46281. private _onLostFocus;
  46282. private pointA;
  46283. private pointB;
  46284. }
  46285. }
  46286. declare module BABYLON {
  46287. /**
  46288. * Manage the pointers inputs to control an arc rotate camera.
  46289. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46290. */
  46291. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  46292. /**
  46293. * Defines the camera the input is attached to.
  46294. */
  46295. camera: ArcRotateCamera;
  46296. /**
  46297. * Gets the class name of the current input.
  46298. * @returns the class name
  46299. */
  46300. getClassName(): string;
  46301. /**
  46302. * Defines the buttons associated with the input to handle camera move.
  46303. */
  46304. buttons: number[];
  46305. /**
  46306. * Defines the pointer angular sensibility along the X axis or how fast is
  46307. * the camera rotating.
  46308. */
  46309. angularSensibilityX: number;
  46310. /**
  46311. * Defines the pointer angular sensibility along the Y axis or how fast is
  46312. * the camera rotating.
  46313. */
  46314. angularSensibilityY: number;
  46315. /**
  46316. * Defines the pointer pinch precision or how fast is the camera zooming.
  46317. */
  46318. pinchPrecision: number;
  46319. /**
  46320. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46321. * from 0.
  46322. * It defines the percentage of current camera.radius to use as delta when
  46323. * pinch zoom is used.
  46324. */
  46325. pinchDeltaPercentage: number;
  46326. /**
  46327. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46328. * that any object in the plane at the camera's target point will scale
  46329. * perfectly with finger motion.
  46330. * Overrides pinchDeltaPercentage and pinchPrecision.
  46331. */
  46332. useNaturalPinchZoom: boolean;
  46333. /**
  46334. * Defines the pointer panning sensibility or how fast is the camera moving.
  46335. */
  46336. panningSensibility: number;
  46337. /**
  46338. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  46339. */
  46340. multiTouchPanning: boolean;
  46341. /**
  46342. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  46343. * zoom (pinch) through multitouch.
  46344. */
  46345. multiTouchPanAndZoom: boolean;
  46346. /**
  46347. * Revers pinch action direction.
  46348. */
  46349. pinchInwards: boolean;
  46350. private _isPanClick;
  46351. private _twoFingerActivityCount;
  46352. private _isPinching;
  46353. /**
  46354. * Called on pointer POINTERMOVE event if only a single touch is active.
  46355. */
  46356. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46357. /**
  46358. * Called on pointer POINTERDOUBLETAP event.
  46359. */
  46360. protected onDoubleTap(type: string): void;
  46361. /**
  46362. * Called on pointer POINTERMOVE event if multiple touches are active.
  46363. */
  46364. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46365. /**
  46366. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  46367. * press.
  46368. */
  46369. protected onButtonDown(evt: PointerEvent): void;
  46370. /**
  46371. * Called each time a new POINTERUP event occurs. Ie, for each button
  46372. * release.
  46373. */
  46374. protected onButtonUp(evt: PointerEvent): void;
  46375. /**
  46376. * Called when window becomes inactive.
  46377. */
  46378. protected onLostFocus(): void;
  46379. }
  46380. }
  46381. declare module BABYLON {
  46382. /**
  46383. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  46384. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46385. */
  46386. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  46387. /**
  46388. * Defines the camera the input is attached to.
  46389. */
  46390. camera: ArcRotateCamera;
  46391. /**
  46392. * Defines the list of key codes associated with the up action (increase alpha)
  46393. */
  46394. keysUp: number[];
  46395. /**
  46396. * Defines the list of key codes associated with the down action (decrease alpha)
  46397. */
  46398. keysDown: number[];
  46399. /**
  46400. * Defines the list of key codes associated with the left action (increase beta)
  46401. */
  46402. keysLeft: number[];
  46403. /**
  46404. * Defines the list of key codes associated with the right action (decrease beta)
  46405. */
  46406. keysRight: number[];
  46407. /**
  46408. * Defines the list of key codes associated with the reset action.
  46409. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  46410. */
  46411. keysReset: number[];
  46412. /**
  46413. * Defines the panning sensibility of the inputs.
  46414. * (How fast is the camera panning)
  46415. */
  46416. panningSensibility: number;
  46417. /**
  46418. * Defines the zooming sensibility of the inputs.
  46419. * (How fast is the camera zooming)
  46420. */
  46421. zoomingSensibility: number;
  46422. /**
  46423. * Defines whether maintaining the alt key down switch the movement mode from
  46424. * orientation to zoom.
  46425. */
  46426. useAltToZoom: boolean;
  46427. /**
  46428. * Rotation speed of the camera
  46429. */
  46430. angularSpeed: number;
  46431. private _keys;
  46432. private _ctrlPressed;
  46433. private _altPressed;
  46434. private _onCanvasBlurObserver;
  46435. private _onKeyboardObserver;
  46436. private _engine;
  46437. private _scene;
  46438. /**
  46439. * Attach the input controls to a specific dom element to get the input from.
  46440. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46441. */
  46442. attachControl(noPreventDefault?: boolean): void;
  46443. /**
  46444. * Detach the current controls from the specified dom element.
  46445. */
  46446. detachControl(): void;
  46447. /**
  46448. * Update the current camera state depending on the inputs that have been used this frame.
  46449. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46450. */
  46451. checkInputs(): void;
  46452. /**
  46453. * Gets the class name of the current intput.
  46454. * @returns the class name
  46455. */
  46456. getClassName(): string;
  46457. /**
  46458. * Get the friendly name associated with the input class.
  46459. * @returns the input friendly name
  46460. */
  46461. getSimpleName(): string;
  46462. }
  46463. }
  46464. declare module BABYLON {
  46465. /**
  46466. * Manage the mouse wheel inputs to control an arc rotate camera.
  46467. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46468. */
  46469. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  46470. /**
  46471. * Defines the camera the input is attached to.
  46472. */
  46473. camera: ArcRotateCamera;
  46474. /**
  46475. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46476. */
  46477. wheelPrecision: number;
  46478. /**
  46479. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46480. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46481. */
  46482. wheelDeltaPercentage: number;
  46483. private _wheel;
  46484. private _observer;
  46485. private computeDeltaFromMouseWheelLegacyEvent;
  46486. /**
  46487. * Attach the input controls to a specific dom element to get the input from.
  46488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46489. */
  46490. attachControl(noPreventDefault?: boolean): void;
  46491. /**
  46492. * Detach the current controls from the specified dom element.
  46493. */
  46494. detachControl(): void;
  46495. /**
  46496. * Gets the class name of the current intput.
  46497. * @returns the class name
  46498. */
  46499. getClassName(): string;
  46500. /**
  46501. * Get the friendly name associated with the input class.
  46502. * @returns the input friendly name
  46503. */
  46504. getSimpleName(): string;
  46505. }
  46506. }
  46507. declare module BABYLON {
  46508. /**
  46509. * Default Inputs manager for the ArcRotateCamera.
  46510. * It groups all the default supported inputs for ease of use.
  46511. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46512. */
  46513. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  46514. /**
  46515. * Instantiates a new ArcRotateCameraInputsManager.
  46516. * @param camera Defines the camera the inputs belong to
  46517. */
  46518. constructor(camera: ArcRotateCamera);
  46519. /**
  46520. * Add mouse wheel input support to the input manager.
  46521. * @returns the current input manager
  46522. */
  46523. addMouseWheel(): ArcRotateCameraInputsManager;
  46524. /**
  46525. * Add pointers input support to the input manager.
  46526. * @returns the current input manager
  46527. */
  46528. addPointers(): ArcRotateCameraInputsManager;
  46529. /**
  46530. * Add keyboard input support to the input manager.
  46531. * @returns the current input manager
  46532. */
  46533. addKeyboard(): ArcRotateCameraInputsManager;
  46534. }
  46535. }
  46536. declare module BABYLON {
  46537. /**
  46538. * This represents an orbital type of camera.
  46539. *
  46540. * 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.
  46541. * 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.
  46542. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  46543. */
  46544. export class ArcRotateCamera extends TargetCamera {
  46545. /**
  46546. * Defines the rotation angle of the camera along the longitudinal axis.
  46547. */
  46548. alpha: number;
  46549. /**
  46550. * Defines the rotation angle of the camera along the latitudinal axis.
  46551. */
  46552. beta: number;
  46553. /**
  46554. * Defines the radius of the camera from it s target point.
  46555. */
  46556. radius: number;
  46557. protected _target: Vector3;
  46558. protected _targetHost: Nullable<AbstractMesh>;
  46559. /**
  46560. * Defines the target point of the camera.
  46561. * The camera looks towards it form the radius distance.
  46562. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  46563. */
  46564. get target(): Vector3;
  46565. set target(value: Vector3);
  46566. /**
  46567. * Define the current local position of the camera in the scene
  46568. */
  46569. get position(): Vector3;
  46570. set position(newPosition: Vector3);
  46571. protected _upToYMatrix: Matrix;
  46572. protected _YToUpMatrix: Matrix;
  46573. /**
  46574. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  46575. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  46576. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  46577. */
  46578. set upVector(vec: Vector3);
  46579. get upVector(): Vector3;
  46580. /**
  46581. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  46582. */
  46583. setMatUp(): void;
  46584. /**
  46585. * Current inertia value on the longitudinal axis.
  46586. * The bigger this number the longer it will take for the camera to stop.
  46587. */
  46588. inertialAlphaOffset: number;
  46589. /**
  46590. * Current inertia value on the latitudinal axis.
  46591. * The bigger this number the longer it will take for the camera to stop.
  46592. */
  46593. inertialBetaOffset: number;
  46594. /**
  46595. * Current inertia value on the radius axis.
  46596. * The bigger this number the longer it will take for the camera to stop.
  46597. */
  46598. inertialRadiusOffset: number;
  46599. /**
  46600. * Minimum allowed angle on the longitudinal axis.
  46601. * This can help limiting how the Camera is able to move in the scene.
  46602. */
  46603. lowerAlphaLimit: Nullable<number>;
  46604. /**
  46605. * Maximum allowed angle on the longitudinal axis.
  46606. * This can help limiting how the Camera is able to move in the scene.
  46607. */
  46608. upperAlphaLimit: Nullable<number>;
  46609. /**
  46610. * Minimum allowed angle on the latitudinal axis.
  46611. * This can help limiting how the Camera is able to move in the scene.
  46612. */
  46613. lowerBetaLimit: number;
  46614. /**
  46615. * Maximum allowed angle on the latitudinal axis.
  46616. * This can help limiting how the Camera is able to move in the scene.
  46617. */
  46618. upperBetaLimit: number;
  46619. /**
  46620. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  46621. * This can help limiting how the Camera is able to move in the scene.
  46622. */
  46623. lowerRadiusLimit: Nullable<number>;
  46624. /**
  46625. * Maximum allowed distance of the camera to the target (The camera can not get further).
  46626. * This can help limiting how the Camera is able to move in the scene.
  46627. */
  46628. upperRadiusLimit: Nullable<number>;
  46629. /**
  46630. * Defines the current inertia value used during panning of the camera along the X axis.
  46631. */
  46632. inertialPanningX: number;
  46633. /**
  46634. * Defines the current inertia value used during panning of the camera along the Y axis.
  46635. */
  46636. inertialPanningY: number;
  46637. /**
  46638. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  46639. * Basically if your fingers moves away from more than this distance you will be considered
  46640. * in pinch mode.
  46641. */
  46642. pinchToPanMaxDistance: number;
  46643. /**
  46644. * Defines the maximum distance the camera can pan.
  46645. * This could help keeping the cammera always in your scene.
  46646. */
  46647. panningDistanceLimit: Nullable<number>;
  46648. /**
  46649. * Defines the target of the camera before paning.
  46650. */
  46651. panningOriginTarget: Vector3;
  46652. /**
  46653. * Defines the value of the inertia used during panning.
  46654. * 0 would mean stop inertia and one would mean no decelleration at all.
  46655. */
  46656. panningInertia: number;
  46657. /**
  46658. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  46659. */
  46660. get angularSensibilityX(): number;
  46661. set angularSensibilityX(value: number);
  46662. /**
  46663. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  46664. */
  46665. get angularSensibilityY(): number;
  46666. set angularSensibilityY(value: number);
  46667. /**
  46668. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  46669. */
  46670. get pinchPrecision(): number;
  46671. set pinchPrecision(value: number);
  46672. /**
  46673. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  46674. * It will be used instead of pinchDeltaPrecision if different from 0.
  46675. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46676. */
  46677. get pinchDeltaPercentage(): number;
  46678. set pinchDeltaPercentage(value: number);
  46679. /**
  46680. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  46681. * and pinch delta percentage.
  46682. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  46683. * that any object in the plane at the camera's target point will scale
  46684. * perfectly with finger motion.
  46685. */
  46686. get useNaturalPinchZoom(): boolean;
  46687. set useNaturalPinchZoom(value: boolean);
  46688. /**
  46689. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  46690. */
  46691. get panningSensibility(): number;
  46692. set panningSensibility(value: number);
  46693. /**
  46694. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  46695. */
  46696. get keysUp(): number[];
  46697. set keysUp(value: number[]);
  46698. /**
  46699. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  46700. */
  46701. get keysDown(): number[];
  46702. set keysDown(value: number[]);
  46703. /**
  46704. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  46705. */
  46706. get keysLeft(): number[];
  46707. set keysLeft(value: number[]);
  46708. /**
  46709. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  46710. */
  46711. get keysRight(): number[];
  46712. set keysRight(value: number[]);
  46713. /**
  46714. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  46715. */
  46716. get wheelPrecision(): number;
  46717. set wheelPrecision(value: number);
  46718. /**
  46719. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  46720. * It will be used instead of pinchDeltaPrecision if different from 0.
  46721. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  46722. */
  46723. get wheelDeltaPercentage(): number;
  46724. set wheelDeltaPercentage(value: number);
  46725. /**
  46726. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  46727. */
  46728. zoomOnFactor: number;
  46729. /**
  46730. * Defines a screen offset for the camera position.
  46731. */
  46732. targetScreenOffset: Vector2;
  46733. /**
  46734. * Allows the camera to be completely reversed.
  46735. * If false the camera can not arrive upside down.
  46736. */
  46737. allowUpsideDown: boolean;
  46738. /**
  46739. * Define if double tap/click is used to restore the previously saved state of the camera.
  46740. */
  46741. useInputToRestoreState: boolean;
  46742. /** @hidden */
  46743. _viewMatrix: Matrix;
  46744. /** @hidden */
  46745. _useCtrlForPanning: boolean;
  46746. /** @hidden */
  46747. _panningMouseButton: number;
  46748. /**
  46749. * Defines the input associated to the camera.
  46750. */
  46751. inputs: ArcRotateCameraInputsManager;
  46752. /** @hidden */
  46753. _reset: () => void;
  46754. /**
  46755. * Defines the allowed panning axis.
  46756. */
  46757. panningAxis: Vector3;
  46758. protected _localDirection: Vector3;
  46759. protected _transformedDirection: Vector3;
  46760. private _bouncingBehavior;
  46761. /**
  46762. * Gets the bouncing behavior of the camera if it has been enabled.
  46763. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46764. */
  46765. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46766. /**
  46767. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46768. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46769. */
  46770. get useBouncingBehavior(): boolean;
  46771. set useBouncingBehavior(value: boolean);
  46772. private _framingBehavior;
  46773. /**
  46774. * Gets the framing behavior of the camera if it has been enabled.
  46775. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46776. */
  46777. get framingBehavior(): Nullable<FramingBehavior>;
  46778. /**
  46779. * Defines if the framing behavior of the camera is enabled on the camera.
  46780. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46781. */
  46782. get useFramingBehavior(): boolean;
  46783. set useFramingBehavior(value: boolean);
  46784. private _autoRotationBehavior;
  46785. /**
  46786. * Gets the auto rotation behavior of the camera if it has been enabled.
  46787. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46788. */
  46789. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46790. /**
  46791. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46792. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46793. */
  46794. get useAutoRotationBehavior(): boolean;
  46795. set useAutoRotationBehavior(value: boolean);
  46796. /**
  46797. * Observable triggered when the mesh target has been changed on the camera.
  46798. */
  46799. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46800. /**
  46801. * Event raised when the camera is colliding with a mesh.
  46802. */
  46803. onCollide: (collidedMesh: AbstractMesh) => void;
  46804. /**
  46805. * Defines whether the camera should check collision with the objects oh the scene.
  46806. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46807. */
  46808. checkCollisions: boolean;
  46809. /**
  46810. * Defines the collision radius of the camera.
  46811. * This simulates a sphere around the camera.
  46812. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46813. */
  46814. collisionRadius: Vector3;
  46815. protected _collider: Collider;
  46816. protected _previousPosition: Vector3;
  46817. protected _collisionVelocity: Vector3;
  46818. protected _newPosition: Vector3;
  46819. protected _previousAlpha: number;
  46820. protected _previousBeta: number;
  46821. protected _previousRadius: number;
  46822. protected _collisionTriggered: boolean;
  46823. protected _targetBoundingCenter: Nullable<Vector3>;
  46824. private _computationVector;
  46825. /**
  46826. * Instantiates a new ArcRotateCamera in a given scene
  46827. * @param name Defines the name of the camera
  46828. * @param alpha Defines the camera rotation along the logitudinal axis
  46829. * @param beta Defines the camera rotation along the latitudinal axis
  46830. * @param radius Defines the camera distance from its target
  46831. * @param target Defines the camera target
  46832. * @param scene Defines the scene the camera belongs to
  46833. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46834. */
  46835. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46836. /** @hidden */
  46837. _initCache(): void;
  46838. /** @hidden */
  46839. _updateCache(ignoreParentClass?: boolean): void;
  46840. protected _getTargetPosition(): Vector3;
  46841. private _storedAlpha;
  46842. private _storedBeta;
  46843. private _storedRadius;
  46844. private _storedTarget;
  46845. private _storedTargetScreenOffset;
  46846. /**
  46847. * Stores the current state of the camera (alpha, beta, radius and target)
  46848. * @returns the camera itself
  46849. */
  46850. storeState(): Camera;
  46851. /**
  46852. * @hidden
  46853. * Restored camera state. You must call storeState() first
  46854. */
  46855. _restoreStateValues(): boolean;
  46856. /** @hidden */
  46857. _isSynchronizedViewMatrix(): boolean;
  46858. /**
  46859. * Attach the input controls to a specific dom element to get the input from.
  46860. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46861. */
  46862. attachControl(noPreventDefault?: boolean): void;
  46863. /**
  46864. * Attach the input controls to a specific dom element to get the input from.
  46865. * @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
  46866. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46867. */
  46868. attachControl(ignored: any, noPreventDefault?: boolean): void;
  46869. /**
  46870. * Attached controls to the current camera.
  46871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46872. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46873. */
  46874. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46875. /**
  46876. * Attached controls to the current camera.
  46877. * @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
  46878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46879. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46880. */
  46881. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  46882. /**
  46883. * Attached controls to the current camera.
  46884. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46885. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46886. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46887. */
  46888. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  46889. /**
  46890. * Detach the current controls from the specified dom element.
  46891. */
  46892. detachControl(): void;
  46893. /**
  46894. * Detach the current controls from the specified dom element.
  46895. * @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
  46896. */
  46897. detachControl(ignored: any): void;
  46898. /** @hidden */
  46899. _checkInputs(): void;
  46900. protected _checkLimits(): void;
  46901. /**
  46902. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46903. */
  46904. rebuildAnglesAndRadius(): void;
  46905. /**
  46906. * Use a position to define the current camera related information like alpha, beta and radius
  46907. * @param position Defines the position to set the camera at
  46908. */
  46909. setPosition(position: Vector3): void;
  46910. /**
  46911. * Defines the target the camera should look at.
  46912. * This will automatically adapt alpha beta and radius to fit within the new target.
  46913. * @param target Defines the new target as a Vector or a mesh
  46914. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46915. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46916. */
  46917. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46918. /** @hidden */
  46919. _getViewMatrix(): Matrix;
  46920. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46921. /**
  46922. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46923. * @param meshes Defines the mesh to zoom on
  46924. * @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)
  46925. */
  46926. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46927. /**
  46928. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46929. * The target will be changed but the radius
  46930. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46931. * @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)
  46932. */
  46933. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46934. min: Vector3;
  46935. max: Vector3;
  46936. distance: number;
  46937. }, doNotUpdateMaxZ?: boolean): void;
  46938. /**
  46939. * @override
  46940. * Override Camera.createRigCamera
  46941. */
  46942. createRigCamera(name: string, cameraIndex: number): Camera;
  46943. /**
  46944. * @hidden
  46945. * @override
  46946. * Override Camera._updateRigCameras
  46947. */
  46948. _updateRigCameras(): void;
  46949. /**
  46950. * Destroy the camera and release the current resources hold by it.
  46951. */
  46952. dispose(): void;
  46953. /**
  46954. * Gets the current object class name.
  46955. * @return the class name
  46956. */
  46957. getClassName(): string;
  46958. }
  46959. }
  46960. declare module BABYLON {
  46961. /**
  46962. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46963. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46964. */
  46965. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46966. /**
  46967. * Gets the name of the behavior.
  46968. */
  46969. get name(): string;
  46970. private _zoomStopsAnimation;
  46971. private _idleRotationSpeed;
  46972. private _idleRotationWaitTime;
  46973. private _idleRotationSpinupTime;
  46974. /**
  46975. * Sets the flag that indicates if user zooming should stop animation.
  46976. */
  46977. set zoomStopsAnimation(flag: boolean);
  46978. /**
  46979. * Gets the flag that indicates if user zooming should stop animation.
  46980. */
  46981. get zoomStopsAnimation(): boolean;
  46982. /**
  46983. * Sets the default speed at which the camera rotates around the model.
  46984. */
  46985. set idleRotationSpeed(speed: number);
  46986. /**
  46987. * Gets the default speed at which the camera rotates around the model.
  46988. */
  46989. get idleRotationSpeed(): number;
  46990. /**
  46991. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46992. */
  46993. set idleRotationWaitTime(time: number);
  46994. /**
  46995. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46996. */
  46997. get idleRotationWaitTime(): number;
  46998. /**
  46999. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47000. */
  47001. set idleRotationSpinupTime(time: number);
  47002. /**
  47003. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  47004. */
  47005. get idleRotationSpinupTime(): number;
  47006. /**
  47007. * Gets a value indicating if the camera is currently rotating because of this behavior
  47008. */
  47009. get rotationInProgress(): boolean;
  47010. private _onPrePointerObservableObserver;
  47011. private _onAfterCheckInputsObserver;
  47012. private _attachedCamera;
  47013. private _isPointerDown;
  47014. private _lastFrameTime;
  47015. private _lastInteractionTime;
  47016. private _cameraRotationSpeed;
  47017. /**
  47018. * Initializes the behavior.
  47019. */
  47020. init(): void;
  47021. /**
  47022. * Attaches the behavior to its arc rotate camera.
  47023. * @param camera Defines the camera to attach the behavior to
  47024. */
  47025. attach(camera: ArcRotateCamera): void;
  47026. /**
  47027. * Detaches the behavior from its current arc rotate camera.
  47028. */
  47029. detach(): void;
  47030. /**
  47031. * Returns true if user is scrolling.
  47032. * @return true if user is scrolling.
  47033. */
  47034. private _userIsZooming;
  47035. private _lastFrameRadius;
  47036. private _shouldAnimationStopForInteraction;
  47037. /**
  47038. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47039. */
  47040. private _applyUserInteraction;
  47041. private _userIsMoving;
  47042. }
  47043. }
  47044. declare module BABYLON {
  47045. /**
  47046. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  47047. */
  47048. export class AttachToBoxBehavior implements Behavior<Mesh> {
  47049. private ui;
  47050. /**
  47051. * The name of the behavior
  47052. */
  47053. name: string;
  47054. /**
  47055. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  47056. */
  47057. distanceAwayFromFace: number;
  47058. /**
  47059. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  47060. */
  47061. distanceAwayFromBottomOfFace: number;
  47062. private _faceVectors;
  47063. private _target;
  47064. private _scene;
  47065. private _onRenderObserver;
  47066. private _tmpMatrix;
  47067. private _tmpVector;
  47068. /**
  47069. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  47070. * @param ui The transform node that should be attched to the mesh
  47071. */
  47072. constructor(ui: TransformNode);
  47073. /**
  47074. * Initializes the behavior
  47075. */
  47076. init(): void;
  47077. private _closestFace;
  47078. private _zeroVector;
  47079. private _lookAtTmpMatrix;
  47080. private _lookAtToRef;
  47081. /**
  47082. * Attaches the AttachToBoxBehavior to the passed in mesh
  47083. * @param target The mesh that the specified node will be attached to
  47084. */
  47085. attach(target: Mesh): void;
  47086. /**
  47087. * Detaches the behavior from the mesh
  47088. */
  47089. detach(): void;
  47090. }
  47091. }
  47092. declare module BABYLON {
  47093. /**
  47094. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  47095. */
  47096. export class FadeInOutBehavior implements Behavior<Mesh> {
  47097. /**
  47098. * Time in milliseconds to delay before fading in (Default: 0)
  47099. */
  47100. delay: number;
  47101. /**
  47102. * Time in milliseconds for the mesh to fade in (Default: 300)
  47103. */
  47104. fadeInTime: number;
  47105. private _millisecondsPerFrame;
  47106. private _hovered;
  47107. private _hoverValue;
  47108. private _ownerNode;
  47109. /**
  47110. * Instatiates the FadeInOutBehavior
  47111. */
  47112. constructor();
  47113. /**
  47114. * The name of the behavior
  47115. */
  47116. get name(): string;
  47117. /**
  47118. * Initializes the behavior
  47119. */
  47120. init(): void;
  47121. /**
  47122. * Attaches the fade behavior on the passed in mesh
  47123. * @param ownerNode The mesh that will be faded in/out once attached
  47124. */
  47125. attach(ownerNode: Mesh): void;
  47126. /**
  47127. * Detaches the behavior from the mesh
  47128. */
  47129. detach(): void;
  47130. /**
  47131. * Triggers the mesh to begin fading in or out
  47132. * @param value if the object should fade in or out (true to fade in)
  47133. */
  47134. fadeIn(value: boolean): void;
  47135. private _update;
  47136. private _setAllVisibility;
  47137. }
  47138. }
  47139. declare module BABYLON {
  47140. /**
  47141. * Class containing a set of static utilities functions for managing Pivots
  47142. * @hidden
  47143. */
  47144. export class PivotTools {
  47145. private static _PivotCached;
  47146. private static _OldPivotPoint;
  47147. private static _PivotTranslation;
  47148. private static _PivotTmpVector;
  47149. private static _PivotPostMultiplyPivotMatrix;
  47150. /** @hidden */
  47151. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  47152. /** @hidden */
  47153. static _RestorePivotPoint(mesh: AbstractMesh): void;
  47154. }
  47155. }
  47156. declare module BABYLON {
  47157. /**
  47158. * Class containing static functions to help procedurally build meshes
  47159. */
  47160. export class PlaneBuilder {
  47161. /**
  47162. * Creates a plane mesh
  47163. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  47164. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  47165. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  47166. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47167. * * 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
  47168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47169. * @param name defines the name of the mesh
  47170. * @param options defines the options used to create the mesh
  47171. * @param scene defines the hosting scene
  47172. * @returns the plane mesh
  47173. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  47174. */
  47175. static CreatePlane(name: string, options: {
  47176. size?: number;
  47177. width?: number;
  47178. height?: number;
  47179. sideOrientation?: number;
  47180. frontUVs?: Vector4;
  47181. backUVs?: Vector4;
  47182. updatable?: boolean;
  47183. sourcePlane?: Plane;
  47184. }, scene?: Nullable<Scene>): Mesh;
  47185. }
  47186. }
  47187. declare module BABYLON {
  47188. /**
  47189. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  47190. */
  47191. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  47192. private static _AnyMouseID;
  47193. /**
  47194. * Abstract mesh the behavior is set on
  47195. */
  47196. attachedNode: AbstractMesh;
  47197. private _dragPlane;
  47198. private _scene;
  47199. private _pointerObserver;
  47200. private _beforeRenderObserver;
  47201. private static _planeScene;
  47202. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  47203. /**
  47204. * 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)
  47205. */
  47206. maxDragAngle: number;
  47207. /**
  47208. * @hidden
  47209. */
  47210. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  47211. /**
  47212. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47213. */
  47214. currentDraggingPointerID: number;
  47215. /**
  47216. * The last position where the pointer hit the drag plane in world space
  47217. */
  47218. lastDragPosition: Vector3;
  47219. /**
  47220. * If the behavior is currently in a dragging state
  47221. */
  47222. dragging: boolean;
  47223. /**
  47224. * 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)
  47225. */
  47226. dragDeltaRatio: number;
  47227. /**
  47228. * If the drag plane orientation should be updated during the dragging (Default: true)
  47229. */
  47230. updateDragPlane: boolean;
  47231. private _debugMode;
  47232. private _moving;
  47233. /**
  47234. * Fires each time the attached mesh is dragged with the pointer
  47235. * * delta between last drag position and current drag position in world space
  47236. * * dragDistance along the drag axis
  47237. * * dragPlaneNormal normal of the current drag plane used during the drag
  47238. * * dragPlanePoint in world space where the drag intersects the drag plane
  47239. */
  47240. onDragObservable: Observable<{
  47241. delta: Vector3;
  47242. dragPlanePoint: Vector3;
  47243. dragPlaneNormal: Vector3;
  47244. dragDistance: number;
  47245. pointerId: number;
  47246. }>;
  47247. /**
  47248. * Fires each time a drag begins (eg. mouse down on mesh)
  47249. */
  47250. onDragStartObservable: Observable<{
  47251. dragPlanePoint: Vector3;
  47252. pointerId: number;
  47253. }>;
  47254. /**
  47255. * Fires each time a drag ends (eg. mouse release after drag)
  47256. */
  47257. onDragEndObservable: Observable<{
  47258. dragPlanePoint: Vector3;
  47259. pointerId: number;
  47260. }>;
  47261. /**
  47262. * If the attached mesh should be moved when dragged
  47263. */
  47264. moveAttached: boolean;
  47265. /**
  47266. * If the drag behavior will react to drag events (Default: true)
  47267. */
  47268. enabled: boolean;
  47269. /**
  47270. * If pointer events should start and release the drag (Default: true)
  47271. */
  47272. startAndReleaseDragOnPointerEvents: boolean;
  47273. /**
  47274. * If camera controls should be detached during the drag
  47275. */
  47276. detachCameraControls: boolean;
  47277. /**
  47278. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  47279. */
  47280. useObjectOrientationForDragging: boolean;
  47281. private _options;
  47282. /**
  47283. * Gets the options used by the behavior
  47284. */
  47285. get options(): {
  47286. dragAxis?: Vector3;
  47287. dragPlaneNormal?: Vector3;
  47288. };
  47289. /**
  47290. * Sets the options used by the behavior
  47291. */
  47292. set options(options: {
  47293. dragAxis?: Vector3;
  47294. dragPlaneNormal?: Vector3;
  47295. });
  47296. /**
  47297. * Creates a pointer drag behavior that can be attached to a mesh
  47298. * @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)
  47299. */
  47300. constructor(options?: {
  47301. dragAxis?: Vector3;
  47302. dragPlaneNormal?: Vector3;
  47303. });
  47304. /**
  47305. * Predicate to determine if it is valid to move the object to a new position when it is moved
  47306. */
  47307. validateDrag: (targetPosition: Vector3) => boolean;
  47308. /**
  47309. * The name of the behavior
  47310. */
  47311. get name(): string;
  47312. /**
  47313. * Initializes the behavior
  47314. */
  47315. init(): void;
  47316. private _tmpVector;
  47317. private _alternatePickedPoint;
  47318. private _worldDragAxis;
  47319. private _targetPosition;
  47320. private _attachedToElement;
  47321. /**
  47322. * Attaches the drag behavior the passed in mesh
  47323. * @param ownerNode The mesh that will be dragged around once attached
  47324. * @param predicate Predicate to use for pick filtering
  47325. */
  47326. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  47327. /**
  47328. * Force relase the drag action by code.
  47329. */
  47330. releaseDrag(): void;
  47331. private _startDragRay;
  47332. private _lastPointerRay;
  47333. /**
  47334. * Simulates the start of a pointer drag event on the behavior
  47335. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  47336. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  47337. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  47338. */
  47339. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47340. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  47341. private _dragDelta;
  47342. protected _moveDrag(ray: Ray): void;
  47343. private _pickWithRayOnDragPlane;
  47344. private _pointA;
  47345. private _pointC;
  47346. private _localAxis;
  47347. private _lookAt;
  47348. private _updateDragPlanePosition;
  47349. /**
  47350. * Detaches the behavior from the mesh
  47351. */
  47352. detach(): void;
  47353. }
  47354. }
  47355. declare module BABYLON {
  47356. /**
  47357. * A behavior that when attached to a mesh will allow the mesh to be scaled
  47358. */
  47359. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  47360. private _dragBehaviorA;
  47361. private _dragBehaviorB;
  47362. private _startDistance;
  47363. private _initialScale;
  47364. private _targetScale;
  47365. private _ownerNode;
  47366. private _sceneRenderObserver;
  47367. /**
  47368. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  47369. */
  47370. constructor();
  47371. /**
  47372. * The name of the behavior
  47373. */
  47374. get name(): string;
  47375. /**
  47376. * Initializes the behavior
  47377. */
  47378. init(): void;
  47379. private _getCurrentDistance;
  47380. /**
  47381. * Attaches the scale behavior the passed in mesh
  47382. * @param ownerNode The mesh that will be scaled around once attached
  47383. */
  47384. attach(ownerNode: Mesh): void;
  47385. /**
  47386. * Detaches the behavior from the mesh
  47387. */
  47388. detach(): void;
  47389. }
  47390. }
  47391. declare module BABYLON {
  47392. /**
  47393. * 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
  47394. */
  47395. export class SixDofDragBehavior implements Behavior<Mesh> {
  47396. private static _virtualScene;
  47397. private _ownerNode;
  47398. private _sceneRenderObserver;
  47399. private _scene;
  47400. private _targetPosition;
  47401. private _virtualOriginMesh;
  47402. private _virtualDragMesh;
  47403. private _pointerObserver;
  47404. private _moving;
  47405. private _startingOrientation;
  47406. private _attachedToElement;
  47407. /**
  47408. * 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)
  47409. */
  47410. private zDragFactor;
  47411. /**
  47412. * If the object should rotate to face the drag origin
  47413. */
  47414. rotateDraggedObject: boolean;
  47415. /**
  47416. * If the behavior is currently in a dragging state
  47417. */
  47418. dragging: boolean;
  47419. /**
  47420. * 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)
  47421. */
  47422. dragDeltaRatio: number;
  47423. /**
  47424. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  47425. */
  47426. currentDraggingPointerID: number;
  47427. /**
  47428. * If camera controls should be detached during the drag
  47429. */
  47430. detachCameraControls: boolean;
  47431. /**
  47432. * Fires each time a drag starts
  47433. */
  47434. onDragStartObservable: Observable<{}>;
  47435. /**
  47436. * Fires each time a drag happens
  47437. */
  47438. onDragObservable: Observable<void>;
  47439. /**
  47440. * Fires each time a drag ends (eg. mouse release after drag)
  47441. */
  47442. onDragEndObservable: Observable<{}>;
  47443. /**
  47444. * 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
  47445. */
  47446. constructor();
  47447. /**
  47448. * The name of the behavior
  47449. */
  47450. get name(): string;
  47451. /**
  47452. * Initializes the behavior
  47453. */
  47454. init(): void;
  47455. /**
  47456. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  47457. */
  47458. private get _pointerCamera();
  47459. /**
  47460. * Attaches the scale behavior the passed in mesh
  47461. * @param ownerNode The mesh that will be scaled around once attached
  47462. */
  47463. attach(ownerNode: Mesh): void;
  47464. /**
  47465. * Detaches the behavior from the mesh
  47466. */
  47467. detach(): void;
  47468. }
  47469. }
  47470. declare module BABYLON {
  47471. /**
  47472. * Class used to apply inverse kinematics to bones
  47473. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  47474. */
  47475. export class BoneIKController {
  47476. private static _tmpVecs;
  47477. private static _tmpQuat;
  47478. private static _tmpMats;
  47479. /**
  47480. * Gets or sets the target mesh
  47481. */
  47482. targetMesh: AbstractMesh;
  47483. /** Gets or sets the mesh used as pole */
  47484. poleTargetMesh: AbstractMesh;
  47485. /**
  47486. * Gets or sets the bone used as pole
  47487. */
  47488. poleTargetBone: Nullable<Bone>;
  47489. /**
  47490. * Gets or sets the target position
  47491. */
  47492. targetPosition: Vector3;
  47493. /**
  47494. * Gets or sets the pole target position
  47495. */
  47496. poleTargetPosition: Vector3;
  47497. /**
  47498. * Gets or sets the pole target local offset
  47499. */
  47500. poleTargetLocalOffset: Vector3;
  47501. /**
  47502. * Gets or sets the pole angle
  47503. */
  47504. poleAngle: number;
  47505. /**
  47506. * Gets or sets the mesh associated with the controller
  47507. */
  47508. mesh: AbstractMesh;
  47509. /**
  47510. * 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)
  47511. */
  47512. slerpAmount: number;
  47513. private _bone1Quat;
  47514. private _bone1Mat;
  47515. private _bone2Ang;
  47516. private _bone1;
  47517. private _bone2;
  47518. private _bone1Length;
  47519. private _bone2Length;
  47520. private _maxAngle;
  47521. private _maxReach;
  47522. private _rightHandedSystem;
  47523. private _bendAxis;
  47524. private _slerping;
  47525. private _adjustRoll;
  47526. /**
  47527. * Gets or sets maximum allowed angle
  47528. */
  47529. get maxAngle(): number;
  47530. set maxAngle(value: number);
  47531. /**
  47532. * Creates a new BoneIKController
  47533. * @param mesh defines the mesh to control
  47534. * @param bone defines the bone to control
  47535. * @param options defines options to set up the controller
  47536. */
  47537. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  47538. targetMesh?: AbstractMesh;
  47539. poleTargetMesh?: AbstractMesh;
  47540. poleTargetBone?: Bone;
  47541. poleTargetLocalOffset?: Vector3;
  47542. poleAngle?: number;
  47543. bendAxis?: Vector3;
  47544. maxAngle?: number;
  47545. slerpAmount?: number;
  47546. });
  47547. private _setMaxAngle;
  47548. /**
  47549. * Force the controller to update the bones
  47550. */
  47551. update(): void;
  47552. }
  47553. }
  47554. declare module BABYLON {
  47555. /**
  47556. * Class used to make a bone look toward a point in space
  47557. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  47558. */
  47559. export class BoneLookController {
  47560. private static _tmpVecs;
  47561. private static _tmpQuat;
  47562. private static _tmpMats;
  47563. /**
  47564. * The target Vector3 that the bone will look at
  47565. */
  47566. target: Vector3;
  47567. /**
  47568. * The mesh that the bone is attached to
  47569. */
  47570. mesh: AbstractMesh;
  47571. /**
  47572. * The bone that will be looking to the target
  47573. */
  47574. bone: Bone;
  47575. /**
  47576. * The up axis of the coordinate system that is used when the bone is rotated
  47577. */
  47578. upAxis: Vector3;
  47579. /**
  47580. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  47581. */
  47582. upAxisSpace: Space;
  47583. /**
  47584. * Used to make an adjustment to the yaw of the bone
  47585. */
  47586. adjustYaw: number;
  47587. /**
  47588. * Used to make an adjustment to the pitch of the bone
  47589. */
  47590. adjustPitch: number;
  47591. /**
  47592. * Used to make an adjustment to the roll of the bone
  47593. */
  47594. adjustRoll: number;
  47595. /**
  47596. * 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)
  47597. */
  47598. slerpAmount: number;
  47599. private _minYaw;
  47600. private _maxYaw;
  47601. private _minPitch;
  47602. private _maxPitch;
  47603. private _minYawSin;
  47604. private _minYawCos;
  47605. private _maxYawSin;
  47606. private _maxYawCos;
  47607. private _midYawConstraint;
  47608. private _minPitchTan;
  47609. private _maxPitchTan;
  47610. private _boneQuat;
  47611. private _slerping;
  47612. private _transformYawPitch;
  47613. private _transformYawPitchInv;
  47614. private _firstFrameSkipped;
  47615. private _yawRange;
  47616. private _fowardAxis;
  47617. /**
  47618. * Gets or sets the minimum yaw angle that the bone can look to
  47619. */
  47620. get minYaw(): number;
  47621. set minYaw(value: number);
  47622. /**
  47623. * Gets or sets the maximum yaw angle that the bone can look to
  47624. */
  47625. get maxYaw(): number;
  47626. set maxYaw(value: number);
  47627. /**
  47628. * Gets or sets the minimum pitch angle that the bone can look to
  47629. */
  47630. get minPitch(): number;
  47631. set minPitch(value: number);
  47632. /**
  47633. * Gets or sets the maximum pitch angle that the bone can look to
  47634. */
  47635. get maxPitch(): number;
  47636. set maxPitch(value: number);
  47637. /**
  47638. * Create a BoneLookController
  47639. * @param mesh the mesh that the bone belongs to
  47640. * @param bone the bone that will be looking to the target
  47641. * @param target the target Vector3 to look at
  47642. * @param options optional settings:
  47643. * * maxYaw: the maximum angle the bone will yaw to
  47644. * * minYaw: the minimum angle the bone will yaw to
  47645. * * maxPitch: the maximum angle the bone will pitch to
  47646. * * minPitch: the minimum angle the bone will yaw to
  47647. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  47648. * * upAxis: the up axis of the coordinate system
  47649. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  47650. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  47651. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  47652. * * adjustYaw: used to make an adjustment to the yaw of the bone
  47653. * * adjustPitch: used to make an adjustment to the pitch of the bone
  47654. * * adjustRoll: used to make an adjustment to the roll of the bone
  47655. **/
  47656. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  47657. maxYaw?: number;
  47658. minYaw?: number;
  47659. maxPitch?: number;
  47660. minPitch?: number;
  47661. slerpAmount?: number;
  47662. upAxis?: Vector3;
  47663. upAxisSpace?: Space;
  47664. yawAxis?: Vector3;
  47665. pitchAxis?: Vector3;
  47666. adjustYaw?: number;
  47667. adjustPitch?: number;
  47668. adjustRoll?: number;
  47669. });
  47670. /**
  47671. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  47672. */
  47673. update(): void;
  47674. private _getAngleDiff;
  47675. private _getAngleBetween;
  47676. private _isAngleBetween;
  47677. }
  47678. }
  47679. declare module BABYLON {
  47680. /**
  47681. * Manage the gamepad inputs to control an arc rotate camera.
  47682. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47683. */
  47684. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  47685. /**
  47686. * Defines the camera the input is attached to.
  47687. */
  47688. camera: ArcRotateCamera;
  47689. /**
  47690. * Defines the gamepad the input is gathering event from.
  47691. */
  47692. gamepad: Nullable<Gamepad>;
  47693. /**
  47694. * Defines the gamepad rotation sensiblity.
  47695. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47696. */
  47697. gamepadRotationSensibility: number;
  47698. /**
  47699. * Defines the gamepad move sensiblity.
  47700. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47701. */
  47702. gamepadMoveSensibility: number;
  47703. private _yAxisScale;
  47704. /**
  47705. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47706. */
  47707. get invertYAxis(): boolean;
  47708. set invertYAxis(value: boolean);
  47709. private _onGamepadConnectedObserver;
  47710. private _onGamepadDisconnectedObserver;
  47711. /**
  47712. * Attach the input controls to a specific dom element to get the input from.
  47713. */
  47714. attachControl(): void;
  47715. /**
  47716. * Detach the current controls from the specified dom element.
  47717. */
  47718. detachControl(): void;
  47719. /**
  47720. * Update the current camera state depending on the inputs that have been used this frame.
  47721. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47722. */
  47723. checkInputs(): void;
  47724. /**
  47725. * Gets the class name of the current intput.
  47726. * @returns the class name
  47727. */
  47728. getClassName(): string;
  47729. /**
  47730. * Get the friendly name associated with the input class.
  47731. * @returns the input friendly name
  47732. */
  47733. getSimpleName(): string;
  47734. }
  47735. }
  47736. declare module BABYLON {
  47737. interface ArcRotateCameraInputsManager {
  47738. /**
  47739. * Add orientation input support to the input manager.
  47740. * @returns the current input manager
  47741. */
  47742. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  47743. }
  47744. /**
  47745. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  47746. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47747. */
  47748. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  47749. /**
  47750. * Defines the camera the input is attached to.
  47751. */
  47752. camera: ArcRotateCamera;
  47753. /**
  47754. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47755. */
  47756. alphaCorrection: number;
  47757. /**
  47758. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47759. */
  47760. gammaCorrection: number;
  47761. private _alpha;
  47762. private _gamma;
  47763. private _dirty;
  47764. private _deviceOrientationHandler;
  47765. /**
  47766. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47767. */
  47768. constructor();
  47769. /**
  47770. * Attach the input controls to a specific dom element to get the input from.
  47771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47772. */
  47773. attachControl(noPreventDefault?: boolean): void;
  47774. /** @hidden */
  47775. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47776. /**
  47777. * Update the current camera state depending on the inputs that have been used this frame.
  47778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47779. */
  47780. checkInputs(): void;
  47781. /**
  47782. * Detach the current controls from the specified dom element.
  47783. */
  47784. detachControl(): void;
  47785. /**
  47786. * Gets the class name of the current intput.
  47787. * @returns the class name
  47788. */
  47789. getClassName(): string;
  47790. /**
  47791. * Get the friendly name associated with the input class.
  47792. * @returns the input friendly name
  47793. */
  47794. getSimpleName(): string;
  47795. }
  47796. }
  47797. declare module BABYLON {
  47798. /**
  47799. * Listen to mouse events to control the camera.
  47800. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47801. */
  47802. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47803. /**
  47804. * Defines the camera the input is attached to.
  47805. */
  47806. camera: FlyCamera;
  47807. /**
  47808. * Defines if touch is enabled. (Default is true.)
  47809. */
  47810. touchEnabled: boolean;
  47811. /**
  47812. * Defines the buttons associated with the input to handle camera rotation.
  47813. */
  47814. buttons: number[];
  47815. /**
  47816. * Assign buttons for Yaw control.
  47817. */
  47818. buttonsYaw: number[];
  47819. /**
  47820. * Assign buttons for Pitch control.
  47821. */
  47822. buttonsPitch: number[];
  47823. /**
  47824. * Assign buttons for Roll control.
  47825. */
  47826. buttonsRoll: number[];
  47827. /**
  47828. * Detect if any button is being pressed while mouse is moved.
  47829. * -1 = Mouse locked.
  47830. * 0 = Left button.
  47831. * 1 = Middle Button.
  47832. * 2 = Right Button.
  47833. */
  47834. activeButton: number;
  47835. /**
  47836. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47837. * Higher values reduce its sensitivity.
  47838. */
  47839. angularSensibility: number;
  47840. private _observer;
  47841. private _rollObserver;
  47842. private previousPosition;
  47843. private noPreventDefault;
  47844. private element;
  47845. /**
  47846. * Listen to mouse events to control the camera.
  47847. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47848. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47849. */
  47850. constructor(touchEnabled?: boolean);
  47851. /**
  47852. * Attach the mouse control to the HTML DOM element.
  47853. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47854. */
  47855. attachControl(noPreventDefault?: boolean): void;
  47856. /**
  47857. * Detach the current controls from the specified dom element.
  47858. */
  47859. detachControl(): void;
  47860. /**
  47861. * Gets the class name of the current input.
  47862. * @returns the class name.
  47863. */
  47864. getClassName(): string;
  47865. /**
  47866. * Get the friendly name associated with the input class.
  47867. * @returns the input's friendly name.
  47868. */
  47869. getSimpleName(): string;
  47870. private _pointerInput;
  47871. private _onMouseMove;
  47872. /**
  47873. * Rotate camera by mouse offset.
  47874. */
  47875. private rotateCamera;
  47876. }
  47877. }
  47878. declare module BABYLON {
  47879. /**
  47880. * Default Inputs manager for the FlyCamera.
  47881. * It groups all the default supported inputs for ease of use.
  47882. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47883. */
  47884. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47885. /**
  47886. * Instantiates a new FlyCameraInputsManager.
  47887. * @param camera Defines the camera the inputs belong to.
  47888. */
  47889. constructor(camera: FlyCamera);
  47890. /**
  47891. * Add keyboard input support to the input manager.
  47892. * @returns the new FlyCameraKeyboardMoveInput().
  47893. */
  47894. addKeyboard(): FlyCameraInputsManager;
  47895. /**
  47896. * Add mouse input support to the input manager.
  47897. * @param touchEnabled Enable touch screen support.
  47898. * @returns the new FlyCameraMouseInput().
  47899. */
  47900. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47901. }
  47902. }
  47903. declare module BABYLON {
  47904. /**
  47905. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47906. * such as in a 3D Space Shooter or a Flight Simulator.
  47907. */
  47908. export class FlyCamera extends TargetCamera {
  47909. /**
  47910. * Define the collision ellipsoid of the camera.
  47911. * This is helpful for simulating a camera body, like a player's body.
  47912. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47913. */
  47914. ellipsoid: Vector3;
  47915. /**
  47916. * Define an offset for the position of the ellipsoid around the camera.
  47917. * This can be helpful if the camera is attached away from the player's body center,
  47918. * such as at its head.
  47919. */
  47920. ellipsoidOffset: Vector3;
  47921. /**
  47922. * Enable or disable collisions of the camera with the rest of the scene objects.
  47923. */
  47924. checkCollisions: boolean;
  47925. /**
  47926. * Enable or disable gravity on the camera.
  47927. */
  47928. applyGravity: boolean;
  47929. /**
  47930. * Define the current direction the camera is moving to.
  47931. */
  47932. cameraDirection: Vector3;
  47933. /**
  47934. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47935. * This overrides and empties cameraRotation.
  47936. */
  47937. rotationQuaternion: Quaternion;
  47938. /**
  47939. * Track Roll to maintain the wanted Rolling when looking around.
  47940. */
  47941. _trackRoll: number;
  47942. /**
  47943. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47944. */
  47945. rollCorrect: number;
  47946. /**
  47947. * Mimic a banked turn, Rolling the camera when Yawing.
  47948. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47949. */
  47950. bankedTurn: boolean;
  47951. /**
  47952. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47953. */
  47954. bankedTurnLimit: number;
  47955. /**
  47956. * Value of 0 disables the banked Roll.
  47957. * Value of 1 is equal to the Yaw angle in radians.
  47958. */
  47959. bankedTurnMultiplier: number;
  47960. /**
  47961. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47962. */
  47963. inputs: FlyCameraInputsManager;
  47964. /**
  47965. * Gets the input sensibility for mouse input.
  47966. * Higher values reduce sensitivity.
  47967. */
  47968. get angularSensibility(): number;
  47969. /**
  47970. * Sets the input sensibility for a mouse input.
  47971. * Higher values reduce sensitivity.
  47972. */
  47973. set angularSensibility(value: number);
  47974. /**
  47975. * Get the keys for camera movement forward.
  47976. */
  47977. get keysForward(): number[];
  47978. /**
  47979. * Set the keys for camera movement forward.
  47980. */
  47981. set keysForward(value: number[]);
  47982. /**
  47983. * Get the keys for camera movement backward.
  47984. */
  47985. get keysBackward(): number[];
  47986. set keysBackward(value: number[]);
  47987. /**
  47988. * Get the keys for camera movement up.
  47989. */
  47990. get keysUp(): number[];
  47991. /**
  47992. * Set the keys for camera movement up.
  47993. */
  47994. set keysUp(value: number[]);
  47995. /**
  47996. * Get the keys for camera movement down.
  47997. */
  47998. get keysDown(): number[];
  47999. /**
  48000. * Set the keys for camera movement down.
  48001. */
  48002. set keysDown(value: number[]);
  48003. /**
  48004. * Get the keys for camera movement left.
  48005. */
  48006. get keysLeft(): number[];
  48007. /**
  48008. * Set the keys for camera movement left.
  48009. */
  48010. set keysLeft(value: number[]);
  48011. /**
  48012. * Set the keys for camera movement right.
  48013. */
  48014. get keysRight(): number[];
  48015. /**
  48016. * Set the keys for camera movement right.
  48017. */
  48018. set keysRight(value: number[]);
  48019. /**
  48020. * Event raised when the camera collides with a mesh in the scene.
  48021. */
  48022. onCollide: (collidedMesh: AbstractMesh) => void;
  48023. private _collider;
  48024. private _needMoveForGravity;
  48025. private _oldPosition;
  48026. private _diffPosition;
  48027. private _newPosition;
  48028. /** @hidden */
  48029. _localDirection: Vector3;
  48030. /** @hidden */
  48031. _transformedDirection: Vector3;
  48032. /**
  48033. * Instantiates a FlyCamera.
  48034. * This is a flying camera, designed for 3D movement and rotation in all directions,
  48035. * such as in a 3D Space Shooter or a Flight Simulator.
  48036. * @param name Define the name of the camera in the scene.
  48037. * @param position Define the starting position of the camera in the scene.
  48038. * @param scene Define the scene the camera belongs to.
  48039. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  48040. */
  48041. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48042. /**
  48043. * Attach the input controls to a specific dom element to get the input from.
  48044. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48045. */
  48046. attachControl(noPreventDefault?: boolean): void;
  48047. /**
  48048. * Detach a control from the HTML DOM element.
  48049. * The camera will stop reacting to that input.
  48050. */
  48051. detachControl(): void;
  48052. private _collisionMask;
  48053. /**
  48054. * Get the mask that the camera ignores in collision events.
  48055. */
  48056. get collisionMask(): number;
  48057. /**
  48058. * Set the mask that the camera ignores in collision events.
  48059. */
  48060. set collisionMask(mask: number);
  48061. /** @hidden */
  48062. _collideWithWorld(displacement: Vector3): void;
  48063. /** @hidden */
  48064. private _onCollisionPositionChange;
  48065. /** @hidden */
  48066. _checkInputs(): void;
  48067. /** @hidden */
  48068. _decideIfNeedsToMove(): boolean;
  48069. /** @hidden */
  48070. _updatePosition(): void;
  48071. /**
  48072. * Restore the Roll to its target value at the rate specified.
  48073. * @param rate - Higher means slower restoring.
  48074. * @hidden
  48075. */
  48076. restoreRoll(rate: number): void;
  48077. /**
  48078. * Destroy the camera and release the current resources held by it.
  48079. */
  48080. dispose(): void;
  48081. /**
  48082. * Get the current object class name.
  48083. * @returns the class name.
  48084. */
  48085. getClassName(): string;
  48086. }
  48087. }
  48088. declare module BABYLON {
  48089. /**
  48090. * Listen to keyboard events to control the camera.
  48091. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48092. */
  48093. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  48094. /**
  48095. * Defines the camera the input is attached to.
  48096. */
  48097. camera: FlyCamera;
  48098. /**
  48099. * The list of keyboard keys used to control the forward move of the camera.
  48100. */
  48101. keysForward: number[];
  48102. /**
  48103. * The list of keyboard keys used to control the backward move of the camera.
  48104. */
  48105. keysBackward: number[];
  48106. /**
  48107. * The list of keyboard keys used to control the forward move of the camera.
  48108. */
  48109. keysUp: number[];
  48110. /**
  48111. * The list of keyboard keys used to control the backward move of the camera.
  48112. */
  48113. keysDown: number[];
  48114. /**
  48115. * The list of keyboard keys used to control the right strafe move of the camera.
  48116. */
  48117. keysRight: number[];
  48118. /**
  48119. * The list of keyboard keys used to control the left strafe move of the camera.
  48120. */
  48121. keysLeft: number[];
  48122. private _keys;
  48123. private _onCanvasBlurObserver;
  48124. private _onKeyboardObserver;
  48125. private _engine;
  48126. private _scene;
  48127. /**
  48128. * Attach the input controls to a specific dom element to get the input from.
  48129. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48130. */
  48131. attachControl(noPreventDefault?: boolean): void;
  48132. /**
  48133. * Detach the current controls from the specified dom element.
  48134. */
  48135. detachControl(): void;
  48136. /**
  48137. * Gets the class name of the current intput.
  48138. * @returns the class name
  48139. */
  48140. getClassName(): string;
  48141. /** @hidden */
  48142. _onLostFocus(e: FocusEvent): void;
  48143. /**
  48144. * Get the friendly name associated with the input class.
  48145. * @returns the input friendly name
  48146. */
  48147. getSimpleName(): string;
  48148. /**
  48149. * Update the current camera state depending on the inputs that have been used this frame.
  48150. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48151. */
  48152. checkInputs(): void;
  48153. }
  48154. }
  48155. declare module BABYLON {
  48156. /**
  48157. * Manage the mouse wheel inputs to control a follow camera.
  48158. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48159. */
  48160. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  48161. /**
  48162. * Defines the camera the input is attached to.
  48163. */
  48164. camera: FollowCamera;
  48165. /**
  48166. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  48167. */
  48168. axisControlRadius: boolean;
  48169. /**
  48170. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  48171. */
  48172. axisControlHeight: boolean;
  48173. /**
  48174. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  48175. */
  48176. axisControlRotation: boolean;
  48177. /**
  48178. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  48179. * relation to mouseWheel events.
  48180. */
  48181. wheelPrecision: number;
  48182. /**
  48183. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  48184. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  48185. */
  48186. wheelDeltaPercentage: number;
  48187. private _wheel;
  48188. private _observer;
  48189. /**
  48190. * Attach the input controls to a specific dom element to get the input from.
  48191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48192. */
  48193. attachControl(noPreventDefault?: boolean): void;
  48194. /**
  48195. * Detach the current controls from the specified dom element.
  48196. */
  48197. detachControl(): void;
  48198. /**
  48199. * Gets the class name of the current intput.
  48200. * @returns the class name
  48201. */
  48202. getClassName(): string;
  48203. /**
  48204. * Get the friendly name associated with the input class.
  48205. * @returns the input friendly name
  48206. */
  48207. getSimpleName(): string;
  48208. }
  48209. }
  48210. declare module BABYLON {
  48211. /**
  48212. * Manage the pointers inputs to control an follow camera.
  48213. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48214. */
  48215. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  48216. /**
  48217. * Defines the camera the input is attached to.
  48218. */
  48219. camera: FollowCamera;
  48220. /**
  48221. * Gets the class name of the current input.
  48222. * @returns the class name
  48223. */
  48224. getClassName(): string;
  48225. /**
  48226. * Defines the pointer angular sensibility along the X axis or how fast is
  48227. * the camera rotating.
  48228. * A negative number will reverse the axis direction.
  48229. */
  48230. angularSensibilityX: number;
  48231. /**
  48232. * Defines the pointer angular sensibility along the Y axis or how fast is
  48233. * the camera rotating.
  48234. * A negative number will reverse the axis direction.
  48235. */
  48236. angularSensibilityY: number;
  48237. /**
  48238. * Defines the pointer pinch precision or how fast is the camera zooming.
  48239. * A negative number will reverse the axis direction.
  48240. */
  48241. pinchPrecision: number;
  48242. /**
  48243. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  48244. * from 0.
  48245. * It defines the percentage of current camera.radius to use as delta when
  48246. * pinch zoom is used.
  48247. */
  48248. pinchDeltaPercentage: number;
  48249. /**
  48250. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  48251. */
  48252. axisXControlRadius: boolean;
  48253. /**
  48254. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  48255. */
  48256. axisXControlHeight: boolean;
  48257. /**
  48258. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  48259. */
  48260. axisXControlRotation: boolean;
  48261. /**
  48262. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  48263. */
  48264. axisYControlRadius: boolean;
  48265. /**
  48266. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  48267. */
  48268. axisYControlHeight: boolean;
  48269. /**
  48270. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  48271. */
  48272. axisYControlRotation: boolean;
  48273. /**
  48274. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  48275. */
  48276. axisPinchControlRadius: boolean;
  48277. /**
  48278. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  48279. */
  48280. axisPinchControlHeight: boolean;
  48281. /**
  48282. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  48283. */
  48284. axisPinchControlRotation: boolean;
  48285. /**
  48286. * Log error messages if basic misconfiguration has occurred.
  48287. */
  48288. warningEnable: boolean;
  48289. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48290. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48291. private _warningCounter;
  48292. private _warning;
  48293. }
  48294. }
  48295. declare module BABYLON {
  48296. /**
  48297. * Default Inputs manager for the FollowCamera.
  48298. * It groups all the default supported inputs for ease of use.
  48299. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48300. */
  48301. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  48302. /**
  48303. * Instantiates a new FollowCameraInputsManager.
  48304. * @param camera Defines the camera the inputs belong to
  48305. */
  48306. constructor(camera: FollowCamera);
  48307. /**
  48308. * Add keyboard input support to the input manager.
  48309. * @returns the current input manager
  48310. */
  48311. addKeyboard(): FollowCameraInputsManager;
  48312. /**
  48313. * Add mouse wheel input support to the input manager.
  48314. * @returns the current input manager
  48315. */
  48316. addMouseWheel(): FollowCameraInputsManager;
  48317. /**
  48318. * Add pointers input support to the input manager.
  48319. * @returns the current input manager
  48320. */
  48321. addPointers(): FollowCameraInputsManager;
  48322. /**
  48323. * Add orientation input support to the input manager.
  48324. * @returns the current input manager
  48325. */
  48326. addVRDeviceOrientation(): FollowCameraInputsManager;
  48327. }
  48328. }
  48329. declare module BABYLON {
  48330. /**
  48331. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  48332. * an arc rotate version arcFollowCamera are available.
  48333. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48334. */
  48335. export class FollowCamera extends TargetCamera {
  48336. /**
  48337. * Distance the follow camera should follow an object at
  48338. */
  48339. radius: number;
  48340. /**
  48341. * Minimum allowed distance of the camera to the axis of rotation
  48342. * (The camera can not get closer).
  48343. * This can help limiting how the Camera is able to move in the scene.
  48344. */
  48345. lowerRadiusLimit: Nullable<number>;
  48346. /**
  48347. * Maximum allowed distance of the camera to the axis of rotation
  48348. * (The camera can not get further).
  48349. * This can help limiting how the Camera is able to move in the scene.
  48350. */
  48351. upperRadiusLimit: Nullable<number>;
  48352. /**
  48353. * Define a rotation offset between the camera and the object it follows
  48354. */
  48355. rotationOffset: number;
  48356. /**
  48357. * Minimum allowed angle to camera position relative to target object.
  48358. * This can help limiting how the Camera is able to move in the scene.
  48359. */
  48360. lowerRotationOffsetLimit: Nullable<number>;
  48361. /**
  48362. * Maximum allowed angle to camera position relative to target object.
  48363. * This can help limiting how the Camera is able to move in the scene.
  48364. */
  48365. upperRotationOffsetLimit: Nullable<number>;
  48366. /**
  48367. * Define a height offset between the camera and the object it follows.
  48368. * It can help following an object from the top (like a car chaing a plane)
  48369. */
  48370. heightOffset: number;
  48371. /**
  48372. * Minimum allowed height of camera position relative to target object.
  48373. * This can help limiting how the Camera is able to move in the scene.
  48374. */
  48375. lowerHeightOffsetLimit: Nullable<number>;
  48376. /**
  48377. * Maximum allowed height of camera position relative to target object.
  48378. * This can help limiting how the Camera is able to move in the scene.
  48379. */
  48380. upperHeightOffsetLimit: Nullable<number>;
  48381. /**
  48382. * Define how fast the camera can accelerate to follow it s target.
  48383. */
  48384. cameraAcceleration: number;
  48385. /**
  48386. * Define the speed limit of the camera following an object.
  48387. */
  48388. maxCameraSpeed: number;
  48389. /**
  48390. * Define the target of the camera.
  48391. */
  48392. lockedTarget: Nullable<AbstractMesh>;
  48393. /**
  48394. * Defines the input associated with the camera.
  48395. */
  48396. inputs: FollowCameraInputsManager;
  48397. /**
  48398. * Instantiates the follow camera.
  48399. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48400. * @param name Define the name of the camera in the scene
  48401. * @param position Define the position of the camera
  48402. * @param scene Define the scene the camera belong to
  48403. * @param lockedTarget Define the target of the camera
  48404. */
  48405. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  48406. private _follow;
  48407. /**
  48408. * Attach the input controls to a specific dom element to get the input from.
  48409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48410. */
  48411. attachControl(noPreventDefault?: boolean): void;
  48412. /**
  48413. * Detach the current controls from the specified dom element.
  48414. */
  48415. detachControl(): void;
  48416. /** @hidden */
  48417. _checkInputs(): void;
  48418. private _checkLimits;
  48419. /**
  48420. * Gets the camera class name.
  48421. * @returns the class name
  48422. */
  48423. getClassName(): string;
  48424. }
  48425. /**
  48426. * Arc Rotate version of the follow camera.
  48427. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  48428. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48429. */
  48430. export class ArcFollowCamera extends TargetCamera {
  48431. /** The longitudinal angle of the camera */
  48432. alpha: number;
  48433. /** The latitudinal angle of the camera */
  48434. beta: number;
  48435. /** The radius of the camera from its target */
  48436. radius: number;
  48437. private _cartesianCoordinates;
  48438. /** Define the camera target (the mesh it should follow) */
  48439. private _meshTarget;
  48440. /**
  48441. * Instantiates a new ArcFollowCamera
  48442. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  48443. * @param name Define the name of the camera
  48444. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  48445. * @param beta Define the rotation angle of the camera around the elevation axis
  48446. * @param radius Define the radius of the camera from its target point
  48447. * @param target Define the target of the camera
  48448. * @param scene Define the scene the camera belongs to
  48449. */
  48450. constructor(name: string,
  48451. /** The longitudinal angle of the camera */
  48452. alpha: number,
  48453. /** The latitudinal angle of the camera */
  48454. beta: number,
  48455. /** The radius of the camera from its target */
  48456. radius: number,
  48457. /** Define the camera target (the mesh it should follow) */
  48458. target: Nullable<AbstractMesh>, scene: Scene);
  48459. private _follow;
  48460. /** @hidden */
  48461. _checkInputs(): void;
  48462. /**
  48463. * Returns the class name of the object.
  48464. * It is mostly used internally for serialization purposes.
  48465. */
  48466. getClassName(): string;
  48467. }
  48468. }
  48469. declare module BABYLON {
  48470. /**
  48471. * Manage the keyboard inputs to control the movement of a follow camera.
  48472. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48473. */
  48474. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  48475. /**
  48476. * Defines the camera the input is attached to.
  48477. */
  48478. camera: FollowCamera;
  48479. /**
  48480. * Defines the list of key codes associated with the up action (increase heightOffset)
  48481. */
  48482. keysHeightOffsetIncr: number[];
  48483. /**
  48484. * Defines the list of key codes associated with the down action (decrease heightOffset)
  48485. */
  48486. keysHeightOffsetDecr: number[];
  48487. /**
  48488. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  48489. */
  48490. keysHeightOffsetModifierAlt: boolean;
  48491. /**
  48492. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  48493. */
  48494. keysHeightOffsetModifierCtrl: boolean;
  48495. /**
  48496. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  48497. */
  48498. keysHeightOffsetModifierShift: boolean;
  48499. /**
  48500. * Defines the list of key codes associated with the left action (increase rotationOffset)
  48501. */
  48502. keysRotationOffsetIncr: number[];
  48503. /**
  48504. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  48505. */
  48506. keysRotationOffsetDecr: number[];
  48507. /**
  48508. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  48509. */
  48510. keysRotationOffsetModifierAlt: boolean;
  48511. /**
  48512. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  48513. */
  48514. keysRotationOffsetModifierCtrl: boolean;
  48515. /**
  48516. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  48517. */
  48518. keysRotationOffsetModifierShift: boolean;
  48519. /**
  48520. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  48521. */
  48522. keysRadiusIncr: number[];
  48523. /**
  48524. * Defines the list of key codes associated with the zoom-out action (increase radius)
  48525. */
  48526. keysRadiusDecr: number[];
  48527. /**
  48528. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  48529. */
  48530. keysRadiusModifierAlt: boolean;
  48531. /**
  48532. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  48533. */
  48534. keysRadiusModifierCtrl: boolean;
  48535. /**
  48536. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  48537. */
  48538. keysRadiusModifierShift: boolean;
  48539. /**
  48540. * Defines the rate of change of heightOffset.
  48541. */
  48542. heightSensibility: number;
  48543. /**
  48544. * Defines the rate of change of rotationOffset.
  48545. */
  48546. rotationSensibility: number;
  48547. /**
  48548. * Defines the rate of change of radius.
  48549. */
  48550. radiusSensibility: number;
  48551. private _keys;
  48552. private _ctrlPressed;
  48553. private _altPressed;
  48554. private _shiftPressed;
  48555. private _onCanvasBlurObserver;
  48556. private _onKeyboardObserver;
  48557. private _engine;
  48558. private _scene;
  48559. /**
  48560. * Attach the input controls to a specific dom element to get the input from.
  48561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48562. */
  48563. attachControl(noPreventDefault?: boolean): void;
  48564. /**
  48565. * Detach the current controls from the specified dom element.
  48566. */
  48567. detachControl(): void;
  48568. /**
  48569. * Update the current camera state depending on the inputs that have been used this frame.
  48570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48571. */
  48572. checkInputs(): void;
  48573. /**
  48574. * Gets the class name of the current input.
  48575. * @returns the class name
  48576. */
  48577. getClassName(): string;
  48578. /**
  48579. * Get the friendly name associated with the input class.
  48580. * @returns the input friendly name
  48581. */
  48582. getSimpleName(): string;
  48583. /**
  48584. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48585. * allow modification of the heightOffset value.
  48586. */
  48587. private _modifierHeightOffset;
  48588. /**
  48589. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48590. * allow modification of the rotationOffset value.
  48591. */
  48592. private _modifierRotationOffset;
  48593. /**
  48594. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  48595. * allow modification of the radius value.
  48596. */
  48597. private _modifierRadius;
  48598. }
  48599. }
  48600. declare module BABYLON {
  48601. interface FreeCameraInputsManager {
  48602. /**
  48603. * @hidden
  48604. */
  48605. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  48606. /**
  48607. * Add orientation input support to the input manager.
  48608. * @returns the current input manager
  48609. */
  48610. addDeviceOrientation(): FreeCameraInputsManager;
  48611. }
  48612. /**
  48613. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  48614. * Screen rotation is taken into account.
  48615. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48616. */
  48617. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  48618. private _camera;
  48619. private _screenOrientationAngle;
  48620. private _constantTranform;
  48621. private _screenQuaternion;
  48622. private _alpha;
  48623. private _beta;
  48624. private _gamma;
  48625. /**
  48626. * Can be used to detect if a device orientation sensor is available on a device
  48627. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  48628. * @returns a promise that will resolve on orientation change
  48629. */
  48630. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  48631. /**
  48632. * @hidden
  48633. */
  48634. _onDeviceOrientationChangedObservable: Observable<void>;
  48635. /**
  48636. * Instantiates a new input
  48637. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48638. */
  48639. constructor();
  48640. /**
  48641. * Define the camera controlled by the input.
  48642. */
  48643. get camera(): FreeCamera;
  48644. set camera(camera: FreeCamera);
  48645. /**
  48646. * Attach the input controls to a specific dom element to get the input from.
  48647. */
  48648. attachControl(): void;
  48649. private _orientationChanged;
  48650. private _deviceOrientation;
  48651. /**
  48652. * Detach the current controls from the specified dom element.
  48653. */
  48654. detachControl(): void;
  48655. /**
  48656. * Update the current camera state depending on the inputs that have been used this frame.
  48657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48658. */
  48659. checkInputs(): void;
  48660. /**
  48661. * Gets the class name of the current intput.
  48662. * @returns the class name
  48663. */
  48664. getClassName(): string;
  48665. /**
  48666. * Get the friendly name associated with the input class.
  48667. * @returns the input friendly name
  48668. */
  48669. getSimpleName(): string;
  48670. }
  48671. }
  48672. declare module BABYLON {
  48673. /**
  48674. * Manage the gamepad inputs to control a free camera.
  48675. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48676. */
  48677. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  48678. /**
  48679. * Define the camera the input is attached to.
  48680. */
  48681. camera: FreeCamera;
  48682. /**
  48683. * Define the Gamepad controlling the input
  48684. */
  48685. gamepad: Nullable<Gamepad>;
  48686. /**
  48687. * Defines the gamepad rotation sensiblity.
  48688. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48689. */
  48690. gamepadAngularSensibility: number;
  48691. /**
  48692. * Defines the gamepad move sensiblity.
  48693. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48694. */
  48695. gamepadMoveSensibility: number;
  48696. private _yAxisScale;
  48697. /**
  48698. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  48699. */
  48700. get invertYAxis(): boolean;
  48701. set invertYAxis(value: boolean);
  48702. private _onGamepadConnectedObserver;
  48703. private _onGamepadDisconnectedObserver;
  48704. private _cameraTransform;
  48705. private _deltaTransform;
  48706. private _vector3;
  48707. private _vector2;
  48708. /**
  48709. * Attach the input controls to a specific dom element to get the input from.
  48710. */
  48711. attachControl(): void;
  48712. /**
  48713. * Detach the current controls from the specified dom element.
  48714. */
  48715. detachControl(): void;
  48716. /**
  48717. * Update the current camera state depending on the inputs that have been used this frame.
  48718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48719. */
  48720. checkInputs(): void;
  48721. /**
  48722. * Gets the class name of the current intput.
  48723. * @returns the class name
  48724. */
  48725. getClassName(): string;
  48726. /**
  48727. * Get the friendly name associated with the input class.
  48728. * @returns the input friendly name
  48729. */
  48730. getSimpleName(): string;
  48731. }
  48732. }
  48733. declare module BABYLON {
  48734. /**
  48735. * Defines the potential axis of a Joystick
  48736. */
  48737. export enum JoystickAxis {
  48738. /** X axis */
  48739. X = 0,
  48740. /** Y axis */
  48741. Y = 1,
  48742. /** Z axis */
  48743. Z = 2
  48744. }
  48745. /**
  48746. * Represents the different customization options available
  48747. * for VirtualJoystick
  48748. */
  48749. interface VirtualJoystickCustomizations {
  48750. /**
  48751. * Size of the joystick's puck
  48752. */
  48753. puckSize: number;
  48754. /**
  48755. * Size of the joystick's container
  48756. */
  48757. containerSize: number;
  48758. /**
  48759. * Color of the joystick && puck
  48760. */
  48761. color: string;
  48762. /**
  48763. * Image URL for the joystick's puck
  48764. */
  48765. puckImage?: string;
  48766. /**
  48767. * Image URL for the joystick's container
  48768. */
  48769. containerImage?: string;
  48770. /**
  48771. * Defines the unmoving position of the joystick container
  48772. */
  48773. position?: {
  48774. x: number;
  48775. y: number;
  48776. };
  48777. /**
  48778. * Defines whether or not the joystick container is always visible
  48779. */
  48780. alwaysVisible: boolean;
  48781. /**
  48782. * Defines whether or not to limit the movement of the puck to the joystick's container
  48783. */
  48784. limitToContainer: boolean;
  48785. }
  48786. /**
  48787. * Class used to define virtual joystick (used in touch mode)
  48788. */
  48789. export class VirtualJoystick {
  48790. /**
  48791. * Gets or sets a boolean indicating that left and right values must be inverted
  48792. */
  48793. reverseLeftRight: boolean;
  48794. /**
  48795. * Gets or sets a boolean indicating that up and down values must be inverted
  48796. */
  48797. reverseUpDown: boolean;
  48798. /**
  48799. * Gets the offset value for the position (ie. the change of the position value)
  48800. */
  48801. deltaPosition: Vector3;
  48802. /**
  48803. * Gets a boolean indicating if the virtual joystick was pressed
  48804. */
  48805. pressed: boolean;
  48806. /**
  48807. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48808. */
  48809. static Canvas: Nullable<HTMLCanvasElement>;
  48810. /**
  48811. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48812. */
  48813. limitToContainer: boolean;
  48814. private static _globalJoystickIndex;
  48815. private static _alwaysVisibleSticks;
  48816. private static vjCanvasContext;
  48817. private static vjCanvasWidth;
  48818. private static vjCanvasHeight;
  48819. private static halfWidth;
  48820. private static _GetDefaultOptions;
  48821. private _action;
  48822. private _axisTargetedByLeftAndRight;
  48823. private _axisTargetedByUpAndDown;
  48824. private _joystickSensibility;
  48825. private _inversedSensibility;
  48826. private _joystickPointerID;
  48827. private _joystickColor;
  48828. private _joystickPointerPos;
  48829. private _joystickPreviousPointerPos;
  48830. private _joystickPointerStartPos;
  48831. private _deltaJoystickVector;
  48832. private _leftJoystick;
  48833. private _touches;
  48834. private _joystickPosition;
  48835. private _alwaysVisible;
  48836. private _puckImage;
  48837. private _containerImage;
  48838. private _joystickPuckSize;
  48839. private _joystickContainerSize;
  48840. private _clearPuckSize;
  48841. private _clearContainerSize;
  48842. private _clearPuckSizeOffset;
  48843. private _clearContainerSizeOffset;
  48844. private _onPointerDownHandlerRef;
  48845. private _onPointerMoveHandlerRef;
  48846. private _onPointerUpHandlerRef;
  48847. private _onResize;
  48848. /**
  48849. * Creates a new virtual joystick
  48850. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48851. * @param customizations Defines the options we want to customize the VirtualJoystick
  48852. */
  48853. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48854. /**
  48855. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48856. * @param newJoystickSensibility defines the new sensibility
  48857. */
  48858. setJoystickSensibility(newJoystickSensibility: number): void;
  48859. private _onPointerDown;
  48860. private _onPointerMove;
  48861. private _onPointerUp;
  48862. /**
  48863. * Change the color of the virtual joystick
  48864. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48865. */
  48866. setJoystickColor(newColor: string): void;
  48867. /**
  48868. * Size of the joystick's container
  48869. */
  48870. set containerSize(newSize: number);
  48871. get containerSize(): number;
  48872. /**
  48873. * Size of the joystick's puck
  48874. */
  48875. set puckSize(newSize: number);
  48876. get puckSize(): number;
  48877. /**
  48878. * Clears the set position of the joystick
  48879. */
  48880. clearPosition(): void;
  48881. /**
  48882. * Defines whether or not the joystick container is always visible
  48883. */
  48884. set alwaysVisible(value: boolean);
  48885. get alwaysVisible(): boolean;
  48886. /**
  48887. * Sets the constant position of the Joystick container
  48888. * @param x X axis coordinate
  48889. * @param y Y axis coordinate
  48890. */
  48891. setPosition(x: number, y: number): void;
  48892. /**
  48893. * Defines a callback to call when the joystick is touched
  48894. * @param action defines the callback
  48895. */
  48896. setActionOnTouch(action: () => any): void;
  48897. /**
  48898. * Defines which axis you'd like to control for left & right
  48899. * @param axis defines the axis to use
  48900. */
  48901. setAxisForLeftRight(axis: JoystickAxis): void;
  48902. /**
  48903. * Defines which axis you'd like to control for up & down
  48904. * @param axis defines the axis to use
  48905. */
  48906. setAxisForUpDown(axis: JoystickAxis): void;
  48907. /**
  48908. * Clears the canvas from the previous puck / container draw
  48909. */
  48910. private _clearPreviousDraw;
  48911. /**
  48912. * Loads `urlPath` to be used for the container's image
  48913. * @param urlPath defines the urlPath of an image to use
  48914. */
  48915. setContainerImage(urlPath: string): void;
  48916. /**
  48917. * Loads `urlPath` to be used for the puck's image
  48918. * @param urlPath defines the urlPath of an image to use
  48919. */
  48920. setPuckImage(urlPath: string): void;
  48921. /**
  48922. * Draws the Virtual Joystick's container
  48923. */
  48924. private _drawContainer;
  48925. /**
  48926. * Draws the Virtual Joystick's puck
  48927. */
  48928. private _drawPuck;
  48929. private _drawVirtualJoystick;
  48930. /**
  48931. * Release internal HTML canvas
  48932. */
  48933. releaseCanvas(): void;
  48934. }
  48935. }
  48936. declare module BABYLON {
  48937. interface FreeCameraInputsManager {
  48938. /**
  48939. * Add virtual joystick input support to the input manager.
  48940. * @returns the current input manager
  48941. */
  48942. addVirtualJoystick(): FreeCameraInputsManager;
  48943. }
  48944. /**
  48945. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48946. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48947. */
  48948. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48949. /**
  48950. * Defines the camera the input is attached to.
  48951. */
  48952. camera: FreeCamera;
  48953. private _leftjoystick;
  48954. private _rightjoystick;
  48955. /**
  48956. * Gets the left stick of the virtual joystick.
  48957. * @returns The virtual Joystick
  48958. */
  48959. getLeftJoystick(): VirtualJoystick;
  48960. /**
  48961. * Gets the right stick of the virtual joystick.
  48962. * @returns The virtual Joystick
  48963. */
  48964. getRightJoystick(): VirtualJoystick;
  48965. /**
  48966. * Update the current camera state depending on the inputs that have been used this frame.
  48967. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48968. */
  48969. checkInputs(): void;
  48970. /**
  48971. * Attach the input controls to a specific dom element to get the input from.
  48972. */
  48973. attachControl(): void;
  48974. /**
  48975. * Detach the current controls from the specified dom element.
  48976. */
  48977. detachControl(): void;
  48978. /**
  48979. * Gets the class name of the current intput.
  48980. * @returns the class name
  48981. */
  48982. getClassName(): string;
  48983. /**
  48984. * Get the friendly name associated with the input class.
  48985. * @returns the input friendly name
  48986. */
  48987. getSimpleName(): string;
  48988. }
  48989. }
  48990. declare module BABYLON {
  48991. /**
  48992. * This represents a FPS type of camera controlled by touch.
  48993. * This is like a universal camera minus the Gamepad controls.
  48994. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48995. */
  48996. export class TouchCamera extends FreeCamera {
  48997. /**
  48998. * Defines the touch sensibility for rotation.
  48999. * The higher the faster.
  49000. */
  49001. get touchAngularSensibility(): number;
  49002. set touchAngularSensibility(value: number);
  49003. /**
  49004. * Defines the touch sensibility for move.
  49005. * The higher the faster.
  49006. */
  49007. get touchMoveSensibility(): number;
  49008. set touchMoveSensibility(value: number);
  49009. /**
  49010. * Instantiates a new touch camera.
  49011. * This represents a FPS type of camera controlled by touch.
  49012. * This is like a universal camera minus the Gamepad controls.
  49013. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49014. * @param name Define the name of the camera in the scene
  49015. * @param position Define the start position of the camera in the scene
  49016. * @param scene Define the scene the camera belongs to
  49017. */
  49018. constructor(name: string, position: Vector3, scene: Scene);
  49019. /**
  49020. * Gets the current object class name.
  49021. * @return the class name
  49022. */
  49023. getClassName(): string;
  49024. /** @hidden */
  49025. _setupInputs(): void;
  49026. }
  49027. }
  49028. declare module BABYLON {
  49029. /**
  49030. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  49031. * being tilted forward or back and left or right.
  49032. */
  49033. export class DeviceOrientationCamera extends FreeCamera {
  49034. private _initialQuaternion;
  49035. private _quaternionCache;
  49036. private _tmpDragQuaternion;
  49037. private _disablePointerInputWhenUsingDeviceOrientation;
  49038. /**
  49039. * Creates a new device orientation camera
  49040. * @param name The name of the camera
  49041. * @param position The start position camera
  49042. * @param scene The scene the camera belongs to
  49043. */
  49044. constructor(name: string, position: Vector3, scene: Scene);
  49045. /**
  49046. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  49047. */
  49048. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  49049. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  49050. private _dragFactor;
  49051. /**
  49052. * Enabled turning on the y axis when the orientation sensor is active
  49053. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  49054. */
  49055. enableHorizontalDragging(dragFactor?: number): void;
  49056. /**
  49057. * Gets the current instance class name ("DeviceOrientationCamera").
  49058. * This helps avoiding instanceof at run time.
  49059. * @returns the class name
  49060. */
  49061. getClassName(): string;
  49062. /**
  49063. * @hidden
  49064. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  49065. */
  49066. _checkInputs(): void;
  49067. /**
  49068. * Reset the camera to its default orientation on the specified axis only.
  49069. * @param axis The axis to reset
  49070. */
  49071. resetToCurrentRotation(axis?: Axis): void;
  49072. }
  49073. }
  49074. declare module BABYLON {
  49075. /**
  49076. * Defines supported buttons for XBox360 compatible gamepads
  49077. */
  49078. export enum Xbox360Button {
  49079. /** A */
  49080. A = 0,
  49081. /** B */
  49082. B = 1,
  49083. /** X */
  49084. X = 2,
  49085. /** Y */
  49086. Y = 3,
  49087. /** Left button */
  49088. LB = 4,
  49089. /** Right button */
  49090. RB = 5,
  49091. /** Back */
  49092. Back = 8,
  49093. /** Start */
  49094. Start = 9,
  49095. /** Left stick */
  49096. LeftStick = 10,
  49097. /** Right stick */
  49098. RightStick = 11
  49099. }
  49100. /** Defines values for XBox360 DPad */
  49101. export enum Xbox360Dpad {
  49102. /** Up */
  49103. Up = 12,
  49104. /** Down */
  49105. Down = 13,
  49106. /** Left */
  49107. Left = 14,
  49108. /** Right */
  49109. Right = 15
  49110. }
  49111. /**
  49112. * Defines a XBox360 gamepad
  49113. */
  49114. export class Xbox360Pad extends Gamepad {
  49115. private _leftTrigger;
  49116. private _rightTrigger;
  49117. private _onlefttriggerchanged;
  49118. private _onrighttriggerchanged;
  49119. private _onbuttondown;
  49120. private _onbuttonup;
  49121. private _ondpaddown;
  49122. private _ondpadup;
  49123. /** Observable raised when a button is pressed */
  49124. onButtonDownObservable: Observable<Xbox360Button>;
  49125. /** Observable raised when a button is released */
  49126. onButtonUpObservable: Observable<Xbox360Button>;
  49127. /** Observable raised when a pad is pressed */
  49128. onPadDownObservable: Observable<Xbox360Dpad>;
  49129. /** Observable raised when a pad is released */
  49130. onPadUpObservable: Observable<Xbox360Dpad>;
  49131. private _buttonA;
  49132. private _buttonB;
  49133. private _buttonX;
  49134. private _buttonY;
  49135. private _buttonBack;
  49136. private _buttonStart;
  49137. private _buttonLB;
  49138. private _buttonRB;
  49139. private _buttonLeftStick;
  49140. private _buttonRightStick;
  49141. private _dPadUp;
  49142. private _dPadDown;
  49143. private _dPadLeft;
  49144. private _dPadRight;
  49145. private _isXboxOnePad;
  49146. /**
  49147. * Creates a new XBox360 gamepad object
  49148. * @param id defines the id of this gamepad
  49149. * @param index defines its index
  49150. * @param gamepad defines the internal HTML gamepad object
  49151. * @param xboxOne defines if it is a XBox One gamepad
  49152. */
  49153. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  49154. /**
  49155. * Defines the callback to call when left trigger is pressed
  49156. * @param callback defines the callback to use
  49157. */
  49158. onlefttriggerchanged(callback: (value: number) => void): void;
  49159. /**
  49160. * Defines the callback to call when right trigger is pressed
  49161. * @param callback defines the callback to use
  49162. */
  49163. onrighttriggerchanged(callback: (value: number) => void): void;
  49164. /**
  49165. * Gets the left trigger value
  49166. */
  49167. get leftTrigger(): number;
  49168. /**
  49169. * Sets the left trigger value
  49170. */
  49171. set leftTrigger(newValue: number);
  49172. /**
  49173. * Gets the right trigger value
  49174. */
  49175. get rightTrigger(): number;
  49176. /**
  49177. * Sets the right trigger value
  49178. */
  49179. set rightTrigger(newValue: number);
  49180. /**
  49181. * Defines the callback to call when a button is pressed
  49182. * @param callback defines the callback to use
  49183. */
  49184. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  49185. /**
  49186. * Defines the callback to call when a button is released
  49187. * @param callback defines the callback to use
  49188. */
  49189. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  49190. /**
  49191. * Defines the callback to call when a pad is pressed
  49192. * @param callback defines the callback to use
  49193. */
  49194. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  49195. /**
  49196. * Defines the callback to call when a pad is released
  49197. * @param callback defines the callback to use
  49198. */
  49199. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  49200. private _setButtonValue;
  49201. private _setDPadValue;
  49202. /**
  49203. * Gets the value of the `A` button
  49204. */
  49205. get buttonA(): number;
  49206. /**
  49207. * Sets the value of the `A` button
  49208. */
  49209. set buttonA(value: number);
  49210. /**
  49211. * Gets the value of the `B` button
  49212. */
  49213. get buttonB(): number;
  49214. /**
  49215. * Sets the value of the `B` button
  49216. */
  49217. set buttonB(value: number);
  49218. /**
  49219. * Gets the value of the `X` button
  49220. */
  49221. get buttonX(): number;
  49222. /**
  49223. * Sets the value of the `X` button
  49224. */
  49225. set buttonX(value: number);
  49226. /**
  49227. * Gets the value of the `Y` button
  49228. */
  49229. get buttonY(): number;
  49230. /**
  49231. * Sets the value of the `Y` button
  49232. */
  49233. set buttonY(value: number);
  49234. /**
  49235. * Gets the value of the `Start` button
  49236. */
  49237. get buttonStart(): number;
  49238. /**
  49239. * Sets the value of the `Start` button
  49240. */
  49241. set buttonStart(value: number);
  49242. /**
  49243. * Gets the value of the `Back` button
  49244. */
  49245. get buttonBack(): number;
  49246. /**
  49247. * Sets the value of the `Back` button
  49248. */
  49249. set buttonBack(value: number);
  49250. /**
  49251. * Gets the value of the `Left` button
  49252. */
  49253. get buttonLB(): number;
  49254. /**
  49255. * Sets the value of the `Left` button
  49256. */
  49257. set buttonLB(value: number);
  49258. /**
  49259. * Gets the value of the `Right` button
  49260. */
  49261. get buttonRB(): number;
  49262. /**
  49263. * Sets the value of the `Right` button
  49264. */
  49265. set buttonRB(value: number);
  49266. /**
  49267. * Gets the value of the Left joystick
  49268. */
  49269. get buttonLeftStick(): number;
  49270. /**
  49271. * Sets the value of the Left joystick
  49272. */
  49273. set buttonLeftStick(value: number);
  49274. /**
  49275. * Gets the value of the Right joystick
  49276. */
  49277. get buttonRightStick(): number;
  49278. /**
  49279. * Sets the value of the Right joystick
  49280. */
  49281. set buttonRightStick(value: number);
  49282. /**
  49283. * Gets the value of D-pad up
  49284. */
  49285. get dPadUp(): number;
  49286. /**
  49287. * Sets the value of D-pad up
  49288. */
  49289. set dPadUp(value: number);
  49290. /**
  49291. * Gets the value of D-pad down
  49292. */
  49293. get dPadDown(): number;
  49294. /**
  49295. * Sets the value of D-pad down
  49296. */
  49297. set dPadDown(value: number);
  49298. /**
  49299. * Gets the value of D-pad left
  49300. */
  49301. get dPadLeft(): number;
  49302. /**
  49303. * Sets the value of D-pad left
  49304. */
  49305. set dPadLeft(value: number);
  49306. /**
  49307. * Gets the value of D-pad right
  49308. */
  49309. get dPadRight(): number;
  49310. /**
  49311. * Sets the value of D-pad right
  49312. */
  49313. set dPadRight(value: number);
  49314. /**
  49315. * Force the gamepad to synchronize with device values
  49316. */
  49317. update(): void;
  49318. /**
  49319. * Disposes the gamepad
  49320. */
  49321. dispose(): void;
  49322. }
  49323. }
  49324. declare module BABYLON {
  49325. /**
  49326. * Defines supported buttons for DualShock compatible gamepads
  49327. */
  49328. export enum DualShockButton {
  49329. /** Cross */
  49330. Cross = 0,
  49331. /** Circle */
  49332. Circle = 1,
  49333. /** Square */
  49334. Square = 2,
  49335. /** Triangle */
  49336. Triangle = 3,
  49337. /** L1 */
  49338. L1 = 4,
  49339. /** R1 */
  49340. R1 = 5,
  49341. /** Share */
  49342. Share = 8,
  49343. /** Options */
  49344. Options = 9,
  49345. /** Left stick */
  49346. LeftStick = 10,
  49347. /** Right stick */
  49348. RightStick = 11
  49349. }
  49350. /** Defines values for DualShock DPad */
  49351. export enum DualShockDpad {
  49352. /** Up */
  49353. Up = 12,
  49354. /** Down */
  49355. Down = 13,
  49356. /** Left */
  49357. Left = 14,
  49358. /** Right */
  49359. Right = 15
  49360. }
  49361. /**
  49362. * Defines a DualShock gamepad
  49363. */
  49364. export class DualShockPad extends Gamepad {
  49365. private _leftTrigger;
  49366. private _rightTrigger;
  49367. private _onlefttriggerchanged;
  49368. private _onrighttriggerchanged;
  49369. private _onbuttondown;
  49370. private _onbuttonup;
  49371. private _ondpaddown;
  49372. private _ondpadup;
  49373. /** Observable raised when a button is pressed */
  49374. onButtonDownObservable: Observable<DualShockButton>;
  49375. /** Observable raised when a button is released */
  49376. onButtonUpObservable: Observable<DualShockButton>;
  49377. /** Observable raised when a pad is pressed */
  49378. onPadDownObservable: Observable<DualShockDpad>;
  49379. /** Observable raised when a pad is released */
  49380. onPadUpObservable: Observable<DualShockDpad>;
  49381. private _buttonCross;
  49382. private _buttonCircle;
  49383. private _buttonSquare;
  49384. private _buttonTriangle;
  49385. private _buttonShare;
  49386. private _buttonOptions;
  49387. private _buttonL1;
  49388. private _buttonR1;
  49389. private _buttonLeftStick;
  49390. private _buttonRightStick;
  49391. private _dPadUp;
  49392. private _dPadDown;
  49393. private _dPadLeft;
  49394. private _dPadRight;
  49395. /**
  49396. * Creates a new DualShock gamepad object
  49397. * @param id defines the id of this gamepad
  49398. * @param index defines its index
  49399. * @param gamepad defines the internal HTML gamepad object
  49400. */
  49401. constructor(id: string, index: number, gamepad: any);
  49402. /**
  49403. * Defines the callback to call when left trigger is pressed
  49404. * @param callback defines the callback to use
  49405. */
  49406. onlefttriggerchanged(callback: (value: number) => void): void;
  49407. /**
  49408. * Defines the callback to call when right trigger is pressed
  49409. * @param callback defines the callback to use
  49410. */
  49411. onrighttriggerchanged(callback: (value: number) => void): void;
  49412. /**
  49413. * Gets the left trigger value
  49414. */
  49415. get leftTrigger(): number;
  49416. /**
  49417. * Sets the left trigger value
  49418. */
  49419. set leftTrigger(newValue: number);
  49420. /**
  49421. * Gets the right trigger value
  49422. */
  49423. get rightTrigger(): number;
  49424. /**
  49425. * Sets the right trigger value
  49426. */
  49427. set rightTrigger(newValue: number);
  49428. /**
  49429. * Defines the callback to call when a button is pressed
  49430. * @param callback defines the callback to use
  49431. */
  49432. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  49433. /**
  49434. * Defines the callback to call when a button is released
  49435. * @param callback defines the callback to use
  49436. */
  49437. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  49438. /**
  49439. * Defines the callback to call when a pad is pressed
  49440. * @param callback defines the callback to use
  49441. */
  49442. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  49443. /**
  49444. * Defines the callback to call when a pad is released
  49445. * @param callback defines the callback to use
  49446. */
  49447. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  49448. private _setButtonValue;
  49449. private _setDPadValue;
  49450. /**
  49451. * Gets the value of the `Cross` button
  49452. */
  49453. get buttonCross(): number;
  49454. /**
  49455. * Sets the value of the `Cross` button
  49456. */
  49457. set buttonCross(value: number);
  49458. /**
  49459. * Gets the value of the `Circle` button
  49460. */
  49461. get buttonCircle(): number;
  49462. /**
  49463. * Sets the value of the `Circle` button
  49464. */
  49465. set buttonCircle(value: number);
  49466. /**
  49467. * Gets the value of the `Square` button
  49468. */
  49469. get buttonSquare(): number;
  49470. /**
  49471. * Sets the value of the `Square` button
  49472. */
  49473. set buttonSquare(value: number);
  49474. /**
  49475. * Gets the value of the `Triangle` button
  49476. */
  49477. get buttonTriangle(): number;
  49478. /**
  49479. * Sets the value of the `Triangle` button
  49480. */
  49481. set buttonTriangle(value: number);
  49482. /**
  49483. * Gets the value of the `Options` button
  49484. */
  49485. get buttonOptions(): number;
  49486. /**
  49487. * Sets the value of the `Options` button
  49488. */
  49489. set buttonOptions(value: number);
  49490. /**
  49491. * Gets the value of the `Share` button
  49492. */
  49493. get buttonShare(): number;
  49494. /**
  49495. * Sets the value of the `Share` button
  49496. */
  49497. set buttonShare(value: number);
  49498. /**
  49499. * Gets the value of the `L1` button
  49500. */
  49501. get buttonL1(): number;
  49502. /**
  49503. * Sets the value of the `L1` button
  49504. */
  49505. set buttonL1(value: number);
  49506. /**
  49507. * Gets the value of the `R1` button
  49508. */
  49509. get buttonR1(): number;
  49510. /**
  49511. * Sets the value of the `R1` button
  49512. */
  49513. set buttonR1(value: number);
  49514. /**
  49515. * Gets the value of the Left joystick
  49516. */
  49517. get buttonLeftStick(): number;
  49518. /**
  49519. * Sets the value of the Left joystick
  49520. */
  49521. set buttonLeftStick(value: number);
  49522. /**
  49523. * Gets the value of the Right joystick
  49524. */
  49525. get buttonRightStick(): number;
  49526. /**
  49527. * Sets the value of the Right joystick
  49528. */
  49529. set buttonRightStick(value: number);
  49530. /**
  49531. * Gets the value of D-pad up
  49532. */
  49533. get dPadUp(): number;
  49534. /**
  49535. * Sets the value of D-pad up
  49536. */
  49537. set dPadUp(value: number);
  49538. /**
  49539. * Gets the value of D-pad down
  49540. */
  49541. get dPadDown(): number;
  49542. /**
  49543. * Sets the value of D-pad down
  49544. */
  49545. set dPadDown(value: number);
  49546. /**
  49547. * Gets the value of D-pad left
  49548. */
  49549. get dPadLeft(): number;
  49550. /**
  49551. * Sets the value of D-pad left
  49552. */
  49553. set dPadLeft(value: number);
  49554. /**
  49555. * Gets the value of D-pad right
  49556. */
  49557. get dPadRight(): number;
  49558. /**
  49559. * Sets the value of D-pad right
  49560. */
  49561. set dPadRight(value: number);
  49562. /**
  49563. * Force the gamepad to synchronize with device values
  49564. */
  49565. update(): void;
  49566. /**
  49567. * Disposes the gamepad
  49568. */
  49569. dispose(): void;
  49570. }
  49571. }
  49572. declare module BABYLON {
  49573. /**
  49574. * Manager for handling gamepads
  49575. */
  49576. export class GamepadManager {
  49577. private _scene?;
  49578. private _babylonGamepads;
  49579. private _oneGamepadConnected;
  49580. /** @hidden */
  49581. _isMonitoring: boolean;
  49582. private _gamepadEventSupported;
  49583. private _gamepadSupport?;
  49584. /**
  49585. * observable to be triggered when the gamepad controller has been connected
  49586. */
  49587. onGamepadConnectedObservable: Observable<Gamepad>;
  49588. /**
  49589. * observable to be triggered when the gamepad controller has been disconnected
  49590. */
  49591. onGamepadDisconnectedObservable: Observable<Gamepad>;
  49592. private _onGamepadConnectedEvent;
  49593. private _onGamepadDisconnectedEvent;
  49594. /**
  49595. * Initializes the gamepad manager
  49596. * @param _scene BabylonJS scene
  49597. */
  49598. constructor(_scene?: Scene | undefined);
  49599. /**
  49600. * The gamepads in the game pad manager
  49601. */
  49602. get gamepads(): Gamepad[];
  49603. /**
  49604. * Get the gamepad controllers based on type
  49605. * @param type The type of gamepad controller
  49606. * @returns Nullable gamepad
  49607. */
  49608. getGamepadByType(type?: number): Nullable<Gamepad>;
  49609. /**
  49610. * Disposes the gamepad manager
  49611. */
  49612. dispose(): void;
  49613. private _addNewGamepad;
  49614. private _startMonitoringGamepads;
  49615. private _stopMonitoringGamepads;
  49616. /** @hidden */
  49617. _checkGamepadsStatus(): void;
  49618. private _updateGamepadObjects;
  49619. }
  49620. }
  49621. declare module BABYLON {
  49622. interface Scene {
  49623. /** @hidden */
  49624. _gamepadManager: Nullable<GamepadManager>;
  49625. /**
  49626. * Gets the gamepad manager associated with the scene
  49627. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  49628. */
  49629. gamepadManager: GamepadManager;
  49630. }
  49631. /**
  49632. * Interface representing a free camera inputs manager
  49633. */
  49634. interface FreeCameraInputsManager {
  49635. /**
  49636. * Adds gamepad input support to the FreeCameraInputsManager.
  49637. * @returns the FreeCameraInputsManager
  49638. */
  49639. addGamepad(): FreeCameraInputsManager;
  49640. }
  49641. /**
  49642. * Interface representing an arc rotate camera inputs manager
  49643. */
  49644. interface ArcRotateCameraInputsManager {
  49645. /**
  49646. * Adds gamepad input support to the ArcRotateCamera InputManager.
  49647. * @returns the camera inputs manager
  49648. */
  49649. addGamepad(): ArcRotateCameraInputsManager;
  49650. }
  49651. /**
  49652. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  49653. */
  49654. export class GamepadSystemSceneComponent implements ISceneComponent {
  49655. /**
  49656. * The component name helpfull to identify the component in the list of scene components.
  49657. */
  49658. readonly name: string;
  49659. /**
  49660. * The scene the component belongs to.
  49661. */
  49662. scene: Scene;
  49663. /**
  49664. * Creates a new instance of the component for the given scene
  49665. * @param scene Defines the scene to register the component in
  49666. */
  49667. constructor(scene: Scene);
  49668. /**
  49669. * Registers the component in a given scene
  49670. */
  49671. register(): void;
  49672. /**
  49673. * Rebuilds the elements related to this component in case of
  49674. * context lost for instance.
  49675. */
  49676. rebuild(): void;
  49677. /**
  49678. * Disposes the component and the associated ressources
  49679. */
  49680. dispose(): void;
  49681. private _beforeCameraUpdate;
  49682. }
  49683. }
  49684. declare module BABYLON {
  49685. /**
  49686. * 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,
  49687. * which still works and will still be found in many Playgrounds.
  49688. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49689. */
  49690. export class UniversalCamera extends TouchCamera {
  49691. /**
  49692. * Defines the gamepad rotation sensiblity.
  49693. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49694. */
  49695. get gamepadAngularSensibility(): number;
  49696. set gamepadAngularSensibility(value: number);
  49697. /**
  49698. * Defines the gamepad move sensiblity.
  49699. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49700. */
  49701. get gamepadMoveSensibility(): number;
  49702. set gamepadMoveSensibility(value: number);
  49703. /**
  49704. * 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,
  49705. * which still works and will still be found in many Playgrounds.
  49706. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49707. * @param name Define the name of the camera in the scene
  49708. * @param position Define the start position of the camera in the scene
  49709. * @param scene Define the scene the camera belongs to
  49710. */
  49711. constructor(name: string, position: Vector3, scene: Scene);
  49712. /**
  49713. * Gets the current object class name.
  49714. * @return the class name
  49715. */
  49716. getClassName(): string;
  49717. }
  49718. }
  49719. declare module BABYLON {
  49720. /**
  49721. * This represents a FPS type of camera. This is only here for back compat purpose.
  49722. * Please use the UniversalCamera instead as both are identical.
  49723. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49724. */
  49725. export class GamepadCamera extends UniversalCamera {
  49726. /**
  49727. * Instantiates a new Gamepad Camera
  49728. * This represents a FPS type of camera. This is only here for back compat purpose.
  49729. * Please use the UniversalCamera instead as both are identical.
  49730. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49731. * @param name Define the name of the camera in the scene
  49732. * @param position Define the start position of the camera in the scene
  49733. * @param scene Define the scene the camera belongs to
  49734. */
  49735. constructor(name: string, position: Vector3, scene: Scene);
  49736. /**
  49737. * Gets the current object class name.
  49738. * @return the class name
  49739. */
  49740. getClassName(): string;
  49741. }
  49742. }
  49743. declare module BABYLON {
  49744. /** @hidden */
  49745. export var passPixelShader: {
  49746. name: string;
  49747. shader: string;
  49748. };
  49749. }
  49750. declare module BABYLON {
  49751. /** @hidden */
  49752. export var passCubePixelShader: {
  49753. name: string;
  49754. shader: string;
  49755. };
  49756. }
  49757. declare module BABYLON {
  49758. /**
  49759. * PassPostProcess which produces an output the same as it's input
  49760. */
  49761. export class PassPostProcess extends PostProcess {
  49762. /**
  49763. * Gets a string identifying the name of the class
  49764. * @returns "PassPostProcess" string
  49765. */
  49766. getClassName(): string;
  49767. /**
  49768. * Creates the PassPostProcess
  49769. * @param name The name of the effect.
  49770. * @param options The required width/height ratio to downsize to before computing the render pass.
  49771. * @param camera The camera to apply the render pass to.
  49772. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49773. * @param engine The engine which the post process will be applied. (default: current engine)
  49774. * @param reusable If the post process can be reused on the same frame. (default: false)
  49775. * @param textureType The type of texture to be used when performing the post processing.
  49776. * @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)
  49777. */
  49778. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49779. /** @hidden */
  49780. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49781. }
  49782. /**
  49783. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49784. */
  49785. export class PassCubePostProcess extends PostProcess {
  49786. private _face;
  49787. /**
  49788. * Gets or sets the cube face to display.
  49789. * * 0 is +X
  49790. * * 1 is -X
  49791. * * 2 is +Y
  49792. * * 3 is -Y
  49793. * * 4 is +Z
  49794. * * 5 is -Z
  49795. */
  49796. get face(): number;
  49797. set face(value: number);
  49798. /**
  49799. * Gets a string identifying the name of the class
  49800. * @returns "PassCubePostProcess" string
  49801. */
  49802. getClassName(): string;
  49803. /**
  49804. * Creates the PassCubePostProcess
  49805. * @param name The name of the effect.
  49806. * @param options The required width/height ratio to downsize to before computing the render pass.
  49807. * @param camera The camera to apply the render pass to.
  49808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49809. * @param engine The engine which the post process will be applied. (default: current engine)
  49810. * @param reusable If the post process can be reused on the same frame. (default: false)
  49811. * @param textureType The type of texture to be used when performing the post processing.
  49812. * @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)
  49813. */
  49814. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49815. /** @hidden */
  49816. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49817. }
  49818. }
  49819. declare module BABYLON {
  49820. /** @hidden */
  49821. export var anaglyphPixelShader: {
  49822. name: string;
  49823. shader: string;
  49824. };
  49825. }
  49826. declare module BABYLON {
  49827. /**
  49828. * Postprocess used to generate anaglyphic rendering
  49829. */
  49830. export class AnaglyphPostProcess extends PostProcess {
  49831. private _passedProcess;
  49832. /**
  49833. * Gets a string identifying the name of the class
  49834. * @returns "AnaglyphPostProcess" string
  49835. */
  49836. getClassName(): string;
  49837. /**
  49838. * Creates a new AnaglyphPostProcess
  49839. * @param name defines postprocess name
  49840. * @param options defines creation options or target ratio scale
  49841. * @param rigCameras defines cameras using this postprocess
  49842. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49843. * @param engine defines hosting engine
  49844. * @param reusable defines if the postprocess will be reused multiple times per frame
  49845. */
  49846. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49847. }
  49848. }
  49849. declare module BABYLON {
  49850. /**
  49851. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49852. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49853. */
  49854. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49855. /**
  49856. * Creates a new AnaglyphArcRotateCamera
  49857. * @param name defines camera name
  49858. * @param alpha defines alpha angle (in radians)
  49859. * @param beta defines beta angle (in radians)
  49860. * @param radius defines radius
  49861. * @param target defines camera target
  49862. * @param interaxialDistance defines distance between each color axis
  49863. * @param scene defines the hosting scene
  49864. */
  49865. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49866. /**
  49867. * Gets camera class name
  49868. * @returns AnaglyphArcRotateCamera
  49869. */
  49870. getClassName(): string;
  49871. }
  49872. }
  49873. declare module BABYLON {
  49874. /**
  49875. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49876. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49877. */
  49878. export class AnaglyphFreeCamera extends FreeCamera {
  49879. /**
  49880. * Creates a new AnaglyphFreeCamera
  49881. * @param name defines camera name
  49882. * @param position defines initial position
  49883. * @param interaxialDistance defines distance between each color axis
  49884. * @param scene defines the hosting scene
  49885. */
  49886. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49887. /**
  49888. * Gets camera class name
  49889. * @returns AnaglyphFreeCamera
  49890. */
  49891. getClassName(): string;
  49892. }
  49893. }
  49894. declare module BABYLON {
  49895. /**
  49896. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49897. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49898. */
  49899. export class AnaglyphGamepadCamera extends GamepadCamera {
  49900. /**
  49901. * Creates a new AnaglyphGamepadCamera
  49902. * @param name defines camera name
  49903. * @param position defines initial position
  49904. * @param interaxialDistance defines distance between each color axis
  49905. * @param scene defines the hosting scene
  49906. */
  49907. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49908. /**
  49909. * Gets camera class name
  49910. * @returns AnaglyphGamepadCamera
  49911. */
  49912. getClassName(): string;
  49913. }
  49914. }
  49915. declare module BABYLON {
  49916. /**
  49917. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49918. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49919. */
  49920. export class AnaglyphUniversalCamera extends UniversalCamera {
  49921. /**
  49922. * Creates a new AnaglyphUniversalCamera
  49923. * @param name defines camera name
  49924. * @param position defines initial position
  49925. * @param interaxialDistance defines distance between each color axis
  49926. * @param scene defines the hosting scene
  49927. */
  49928. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49929. /**
  49930. * Gets camera class name
  49931. * @returns AnaglyphUniversalCamera
  49932. */
  49933. getClassName(): string;
  49934. }
  49935. }
  49936. declare module BABYLON {
  49937. /**
  49938. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49939. * @see https://doc.babylonjs.com/features/cameras
  49940. */
  49941. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49942. /**
  49943. * Creates a new StereoscopicArcRotateCamera
  49944. * @param name defines camera name
  49945. * @param alpha defines alpha angle (in radians)
  49946. * @param beta defines beta angle (in radians)
  49947. * @param radius defines radius
  49948. * @param target defines camera target
  49949. * @param interaxialDistance defines distance between each color axis
  49950. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49951. * @param scene defines the hosting scene
  49952. */
  49953. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49954. /**
  49955. * Gets camera class name
  49956. * @returns StereoscopicArcRotateCamera
  49957. */
  49958. getClassName(): string;
  49959. }
  49960. }
  49961. declare module BABYLON {
  49962. /**
  49963. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49964. * @see https://doc.babylonjs.com/features/cameras
  49965. */
  49966. export class StereoscopicFreeCamera extends FreeCamera {
  49967. /**
  49968. * Creates a new StereoscopicFreeCamera
  49969. * @param name defines camera name
  49970. * @param position defines initial position
  49971. * @param interaxialDistance defines distance between each color axis
  49972. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49973. * @param scene defines the hosting scene
  49974. */
  49975. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49976. /**
  49977. * Gets camera class name
  49978. * @returns StereoscopicFreeCamera
  49979. */
  49980. getClassName(): string;
  49981. }
  49982. }
  49983. declare module BABYLON {
  49984. /**
  49985. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49986. * @see https://doc.babylonjs.com/features/cameras
  49987. */
  49988. export class StereoscopicGamepadCamera extends GamepadCamera {
  49989. /**
  49990. * Creates a new StereoscopicGamepadCamera
  49991. * @param name defines camera name
  49992. * @param position defines initial position
  49993. * @param interaxialDistance defines distance between each color axis
  49994. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49995. * @param scene defines the hosting scene
  49996. */
  49997. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49998. /**
  49999. * Gets camera class name
  50000. * @returns StereoscopicGamepadCamera
  50001. */
  50002. getClassName(): string;
  50003. }
  50004. }
  50005. declare module BABYLON {
  50006. /**
  50007. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  50008. * @see https://doc.babylonjs.com/features/cameras
  50009. */
  50010. export class StereoscopicUniversalCamera extends UniversalCamera {
  50011. /**
  50012. * Creates a new StereoscopicUniversalCamera
  50013. * @param name defines camera name
  50014. * @param position defines initial position
  50015. * @param interaxialDistance defines distance between each color axis
  50016. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  50017. * @param scene defines the hosting scene
  50018. */
  50019. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  50020. /**
  50021. * Gets camera class name
  50022. * @returns StereoscopicUniversalCamera
  50023. */
  50024. getClassName(): string;
  50025. }
  50026. }
  50027. declare module BABYLON {
  50028. /**
  50029. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  50030. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  50031. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  50032. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  50033. */
  50034. export class VirtualJoysticksCamera extends FreeCamera {
  50035. /**
  50036. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  50037. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  50038. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  50039. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  50040. * @param name Define the name of the camera in the scene
  50041. * @param position Define the start position of the camera in the scene
  50042. * @param scene Define the scene the camera belongs to
  50043. */
  50044. constructor(name: string, position: Vector3, scene: Scene);
  50045. /**
  50046. * Gets the current object class name.
  50047. * @return the class name
  50048. */
  50049. getClassName(): string;
  50050. }
  50051. }
  50052. declare module BABYLON {
  50053. /**
  50054. * This represents all the required metrics to create a VR camera.
  50055. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  50056. */
  50057. export class VRCameraMetrics {
  50058. /**
  50059. * Define the horizontal resolution off the screen.
  50060. */
  50061. hResolution: number;
  50062. /**
  50063. * Define the vertical resolution off the screen.
  50064. */
  50065. vResolution: number;
  50066. /**
  50067. * Define the horizontal screen size.
  50068. */
  50069. hScreenSize: number;
  50070. /**
  50071. * Define the vertical screen size.
  50072. */
  50073. vScreenSize: number;
  50074. /**
  50075. * Define the vertical screen center position.
  50076. */
  50077. vScreenCenter: number;
  50078. /**
  50079. * Define the distance of the eyes to the screen.
  50080. */
  50081. eyeToScreenDistance: number;
  50082. /**
  50083. * Define the distance between both lenses
  50084. */
  50085. lensSeparationDistance: number;
  50086. /**
  50087. * Define the distance between both viewer's eyes.
  50088. */
  50089. interpupillaryDistance: number;
  50090. /**
  50091. * Define the distortion factor of the VR postprocess.
  50092. * Please, touch with care.
  50093. */
  50094. distortionK: number[];
  50095. /**
  50096. * Define the chromatic aberration correction factors for the VR post process.
  50097. */
  50098. chromaAbCorrection: number[];
  50099. /**
  50100. * Define the scale factor of the post process.
  50101. * The smaller the better but the slower.
  50102. */
  50103. postProcessScaleFactor: number;
  50104. /**
  50105. * Define an offset for the lens center.
  50106. */
  50107. lensCenterOffset: number;
  50108. /**
  50109. * Define if the current vr camera should compensate the distortion of the lense or not.
  50110. */
  50111. compensateDistortion: boolean;
  50112. /**
  50113. * Defines if multiview should be enabled when rendering (Default: false)
  50114. */
  50115. multiviewEnabled: boolean;
  50116. /**
  50117. * Gets the rendering aspect ratio based on the provided resolutions.
  50118. */
  50119. get aspectRatio(): number;
  50120. /**
  50121. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  50122. */
  50123. get aspectRatioFov(): number;
  50124. /**
  50125. * @hidden
  50126. */
  50127. get leftHMatrix(): Matrix;
  50128. /**
  50129. * @hidden
  50130. */
  50131. get rightHMatrix(): Matrix;
  50132. /**
  50133. * @hidden
  50134. */
  50135. get leftPreViewMatrix(): Matrix;
  50136. /**
  50137. * @hidden
  50138. */
  50139. get rightPreViewMatrix(): Matrix;
  50140. /**
  50141. * Get the default VRMetrics based on the most generic setup.
  50142. * @returns the default vr metrics
  50143. */
  50144. static GetDefault(): VRCameraMetrics;
  50145. }
  50146. }
  50147. declare module BABYLON {
  50148. /** @hidden */
  50149. export var vrDistortionCorrectionPixelShader: {
  50150. name: string;
  50151. shader: string;
  50152. };
  50153. }
  50154. declare module BABYLON {
  50155. /**
  50156. * VRDistortionCorrectionPostProcess used for mobile VR
  50157. */
  50158. export class VRDistortionCorrectionPostProcess extends PostProcess {
  50159. private _isRightEye;
  50160. private _distortionFactors;
  50161. private _postProcessScaleFactor;
  50162. private _lensCenterOffset;
  50163. private _scaleIn;
  50164. private _scaleFactor;
  50165. private _lensCenter;
  50166. /**
  50167. * Gets a string identifying the name of the class
  50168. * @returns "VRDistortionCorrectionPostProcess" string
  50169. */
  50170. getClassName(): string;
  50171. /**
  50172. * Initializes the VRDistortionCorrectionPostProcess
  50173. * @param name The name of the effect.
  50174. * @param camera The camera to apply the render pass to.
  50175. * @param isRightEye If this is for the right eye distortion
  50176. * @param vrMetrics All the required metrics for the VR camera
  50177. */
  50178. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  50179. }
  50180. }
  50181. declare module BABYLON {
  50182. /**
  50183. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  50184. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50185. */
  50186. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  50187. /**
  50188. * Creates a new VRDeviceOrientationArcRotateCamera
  50189. * @param name defines camera name
  50190. * @param alpha defines the camera rotation along the logitudinal axis
  50191. * @param beta defines the camera rotation along the latitudinal axis
  50192. * @param radius defines the camera distance from its target
  50193. * @param target defines the camera target
  50194. * @param scene defines the scene the camera belongs to
  50195. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50196. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50197. */
  50198. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50199. /**
  50200. * Gets camera class name
  50201. * @returns VRDeviceOrientationArcRotateCamera
  50202. */
  50203. getClassName(): string;
  50204. }
  50205. }
  50206. declare module BABYLON {
  50207. /**
  50208. * Camera used to simulate VR rendering (based on FreeCamera)
  50209. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50210. */
  50211. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  50212. /**
  50213. * Creates a new VRDeviceOrientationFreeCamera
  50214. * @param name defines camera name
  50215. * @param position defines the start position of the camera
  50216. * @param scene defines the scene the camera belongs to
  50217. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50218. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50219. */
  50220. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50221. /**
  50222. * Gets camera class name
  50223. * @returns VRDeviceOrientationFreeCamera
  50224. */
  50225. getClassName(): string;
  50226. }
  50227. }
  50228. declare module BABYLON {
  50229. /**
  50230. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  50231. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  50232. */
  50233. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  50234. /**
  50235. * Creates a new VRDeviceOrientationGamepadCamera
  50236. * @param name defines camera name
  50237. * @param position defines the start position of the camera
  50238. * @param scene defines the scene the camera belongs to
  50239. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  50240. * @param vrCameraMetrics defines the vr metrics associated to the camera
  50241. */
  50242. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  50243. /**
  50244. * Gets camera class name
  50245. * @returns VRDeviceOrientationGamepadCamera
  50246. */
  50247. getClassName(): string;
  50248. }
  50249. }
  50250. declare module BABYLON {
  50251. /**
  50252. * A class extending Texture allowing drawing on a texture
  50253. * @see https://doc.babylonjs.com/how_to/dynamictexture
  50254. */
  50255. export class DynamicTexture extends Texture {
  50256. private _generateMipMaps;
  50257. private _canvas;
  50258. private _context;
  50259. /**
  50260. * Creates a DynamicTexture
  50261. * @param name defines the name of the texture
  50262. * @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
  50263. * @param scene defines the scene where you want the texture
  50264. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  50265. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  50266. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  50267. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  50268. */
  50269. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  50270. /**
  50271. * Get the current class name of the texture useful for serialization or dynamic coding.
  50272. * @returns "DynamicTexture"
  50273. */
  50274. getClassName(): string;
  50275. /**
  50276. * Gets the current state of canRescale
  50277. */
  50278. get canRescale(): boolean;
  50279. private _recreate;
  50280. /**
  50281. * Scales the texture
  50282. * @param ratio the scale factor to apply to both width and height
  50283. */
  50284. scale(ratio: number): void;
  50285. /**
  50286. * Resizes the texture
  50287. * @param width the new width
  50288. * @param height the new height
  50289. */
  50290. scaleTo(width: number, height: number): void;
  50291. /**
  50292. * Gets the context of the canvas used by the texture
  50293. * @returns the canvas context of the dynamic texture
  50294. */
  50295. getContext(): CanvasRenderingContext2D;
  50296. /**
  50297. * Clears the texture
  50298. */
  50299. clear(): void;
  50300. /**
  50301. * Updates the texture
  50302. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50303. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  50304. */
  50305. update(invertY?: boolean, premulAlpha?: boolean): void;
  50306. /**
  50307. * Draws text onto the texture
  50308. * @param text defines the text to be drawn
  50309. * @param x defines the placement of the text from the left
  50310. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  50311. * @param font defines the font to be used with font-style, font-size, font-name
  50312. * @param color defines the color used for the text
  50313. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  50314. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  50315. * @param update defines whether texture is immediately update (default is true)
  50316. */
  50317. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  50318. /**
  50319. * Clones the texture
  50320. * @returns the clone of the texture.
  50321. */
  50322. clone(): DynamicTexture;
  50323. /**
  50324. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  50325. * @returns a serialized dynamic texture object
  50326. */
  50327. serialize(): any;
  50328. private _IsCanvasElement;
  50329. /** @hidden */
  50330. _rebuild(): void;
  50331. }
  50332. }
  50333. declare module BABYLON {
  50334. /**
  50335. * Class containing static functions to help procedurally build meshes
  50336. */
  50337. export class GroundBuilder {
  50338. /**
  50339. * Creates a ground mesh
  50340. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50341. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50343. * @param name defines the name of the mesh
  50344. * @param options defines the options used to create the mesh
  50345. * @param scene defines the hosting scene
  50346. * @returns the ground mesh
  50347. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50348. */
  50349. static CreateGround(name: string, options: {
  50350. width?: number;
  50351. height?: number;
  50352. subdivisions?: number;
  50353. subdivisionsX?: number;
  50354. subdivisionsY?: number;
  50355. updatable?: boolean;
  50356. }, scene: any): Mesh;
  50357. /**
  50358. * Creates a tiled ground mesh
  50359. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50360. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50361. * * 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
  50362. * * 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
  50363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50364. * @param name defines the name of the mesh
  50365. * @param options defines the options used to create the mesh
  50366. * @param scene defines the hosting scene
  50367. * @returns the tiled ground mesh
  50368. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50369. */
  50370. static CreateTiledGround(name: string, options: {
  50371. xmin: number;
  50372. zmin: number;
  50373. xmax: number;
  50374. zmax: number;
  50375. subdivisions?: {
  50376. w: number;
  50377. h: number;
  50378. };
  50379. precision?: {
  50380. w: number;
  50381. h: number;
  50382. };
  50383. updatable?: boolean;
  50384. }, scene?: Nullable<Scene>): Mesh;
  50385. /**
  50386. * Creates a ground mesh from a height map
  50387. * * The parameter `url` sets the URL of the height map image resource.
  50388. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50389. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50390. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50391. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50392. * * 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.
  50393. * * 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).
  50394. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50396. * @param name defines the name of the mesh
  50397. * @param url defines the url to the height map
  50398. * @param options defines the options used to create the mesh
  50399. * @param scene defines the hosting scene
  50400. * @returns the ground mesh
  50401. * @see https://doc.babylonjs.com/babylon101/height_map
  50402. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50403. */
  50404. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50405. width?: number;
  50406. height?: number;
  50407. subdivisions?: number;
  50408. minHeight?: number;
  50409. maxHeight?: number;
  50410. colorFilter?: Color3;
  50411. alphaFilter?: number;
  50412. updatable?: boolean;
  50413. onReady?: (mesh: GroundMesh) => void;
  50414. }, scene?: Nullable<Scene>): GroundMesh;
  50415. }
  50416. }
  50417. declare module BABYLON {
  50418. /**
  50419. * Class containing static functions to help procedurally build meshes
  50420. */
  50421. export class TorusBuilder {
  50422. /**
  50423. * Creates a torus mesh
  50424. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  50425. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  50426. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  50427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50428. * * 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
  50429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50430. * @param name defines the name of the mesh
  50431. * @param options defines the options used to create the mesh
  50432. * @param scene defines the hosting scene
  50433. * @returns the torus mesh
  50434. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  50435. */
  50436. static CreateTorus(name: string, options: {
  50437. diameter?: number;
  50438. thickness?: number;
  50439. tessellation?: number;
  50440. updatable?: boolean;
  50441. sideOrientation?: number;
  50442. frontUVs?: Vector4;
  50443. backUVs?: Vector4;
  50444. }, scene: any): Mesh;
  50445. }
  50446. }
  50447. declare module BABYLON {
  50448. /**
  50449. * Class containing static functions to help procedurally build meshes
  50450. */
  50451. export class CylinderBuilder {
  50452. /**
  50453. * Creates a cylinder or a cone mesh
  50454. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  50455. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  50456. * * 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.
  50457. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  50458. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  50459. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  50460. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  50461. * * 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).
  50462. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  50463. * * 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).
  50464. * * 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
  50465. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  50466. * * 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
  50467. * * 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.
  50468. * * If `enclose` is false, a ring surface is one element.
  50469. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  50470. * * 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
  50471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50472. * * 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
  50473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50474. * @param name defines the name of the mesh
  50475. * @param options defines the options used to create the mesh
  50476. * @param scene defines the hosting scene
  50477. * @returns the cylinder mesh
  50478. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  50479. */
  50480. static CreateCylinder(name: string, options: {
  50481. height?: number;
  50482. diameterTop?: number;
  50483. diameterBottom?: number;
  50484. diameter?: number;
  50485. tessellation?: number;
  50486. subdivisions?: number;
  50487. arc?: number;
  50488. faceColors?: Color4[];
  50489. faceUV?: Vector4[];
  50490. updatable?: boolean;
  50491. hasRings?: boolean;
  50492. enclose?: boolean;
  50493. cap?: number;
  50494. sideOrientation?: number;
  50495. frontUVs?: Vector4;
  50496. backUVs?: Vector4;
  50497. }, scene: any): Mesh;
  50498. }
  50499. }
  50500. declare module BABYLON {
  50501. /**
  50502. * States of the webXR experience
  50503. */
  50504. export enum WebXRState {
  50505. /**
  50506. * Transitioning to being in XR mode
  50507. */
  50508. ENTERING_XR = 0,
  50509. /**
  50510. * Transitioning to non XR mode
  50511. */
  50512. EXITING_XR = 1,
  50513. /**
  50514. * In XR mode and presenting
  50515. */
  50516. IN_XR = 2,
  50517. /**
  50518. * Not entered XR mode
  50519. */
  50520. NOT_IN_XR = 3
  50521. }
  50522. /**
  50523. * The state of the XR camera's tracking
  50524. */
  50525. export enum WebXRTrackingState {
  50526. /**
  50527. * No transformation received, device is not being tracked
  50528. */
  50529. NOT_TRACKING = 0,
  50530. /**
  50531. * Tracking lost - using emulated position
  50532. */
  50533. TRACKING_LOST = 1,
  50534. /**
  50535. * Transformation tracking works normally
  50536. */
  50537. TRACKING = 2
  50538. }
  50539. /**
  50540. * Abstraction of the XR render target
  50541. */
  50542. export interface WebXRRenderTarget extends IDisposable {
  50543. /**
  50544. * xrpresent context of the canvas which can be used to display/mirror xr content
  50545. */
  50546. canvasContext: WebGLRenderingContext;
  50547. /**
  50548. * xr layer for the canvas
  50549. */
  50550. xrLayer: Nullable<XRWebGLLayer>;
  50551. /**
  50552. * Initializes the xr layer for the session
  50553. * @param xrSession xr session
  50554. * @returns a promise that will resolve once the XR Layer has been created
  50555. */
  50556. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50557. }
  50558. }
  50559. declare module BABYLON {
  50560. /**
  50561. * COnfiguration object for WebXR output canvas
  50562. */
  50563. export class WebXRManagedOutputCanvasOptions {
  50564. /**
  50565. * An optional canvas in case you wish to create it yourself and provide it here.
  50566. * If not provided, a new canvas will be created
  50567. */
  50568. canvasElement?: HTMLCanvasElement;
  50569. /**
  50570. * Options for this XR Layer output
  50571. */
  50572. canvasOptions?: XRWebGLLayerInit;
  50573. /**
  50574. * CSS styling for a newly created canvas (if not provided)
  50575. */
  50576. newCanvasCssStyle?: string;
  50577. /**
  50578. * Get the default values of the configuration object
  50579. * @param engine defines the engine to use (can be null)
  50580. * @returns default values of this configuration object
  50581. */
  50582. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  50583. }
  50584. /**
  50585. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  50586. */
  50587. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  50588. private _options;
  50589. private _canvas;
  50590. private _engine;
  50591. private _originalCanvasSize;
  50592. /**
  50593. * Rendering context of the canvas which can be used to display/mirror xr content
  50594. */
  50595. canvasContext: WebGLRenderingContext;
  50596. /**
  50597. * xr layer for the canvas
  50598. */
  50599. xrLayer: Nullable<XRWebGLLayer>;
  50600. /**
  50601. * Obseervers registered here will be triggered when the xr layer was initialized
  50602. */
  50603. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  50604. /**
  50605. * Initializes the canvas to be added/removed upon entering/exiting xr
  50606. * @param _xrSessionManager The XR Session manager
  50607. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  50608. */
  50609. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  50610. /**
  50611. * Disposes of the object
  50612. */
  50613. dispose(): void;
  50614. /**
  50615. * Initializes the xr layer for the session
  50616. * @param xrSession xr session
  50617. * @returns a promise that will resolve once the XR Layer has been created
  50618. */
  50619. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  50620. private _addCanvas;
  50621. private _removeCanvas;
  50622. private _setCanvasSize;
  50623. private _setManagedOutputCanvas;
  50624. }
  50625. }
  50626. declare module BABYLON {
  50627. /**
  50628. * Manages an XRSession to work with Babylon's engine
  50629. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  50630. */
  50631. export class WebXRSessionManager implements IDisposable {
  50632. /** The scene which the session should be created for */
  50633. scene: Scene;
  50634. private _referenceSpace;
  50635. private _rttProvider;
  50636. private _sessionEnded;
  50637. private _xrNavigator;
  50638. private baseLayer;
  50639. /**
  50640. * The base reference space from which the session started. good if you want to reset your
  50641. * reference space
  50642. */
  50643. baseReferenceSpace: XRReferenceSpace;
  50644. /**
  50645. * Current XR frame
  50646. */
  50647. currentFrame: Nullable<XRFrame>;
  50648. /** WebXR timestamp updated every frame */
  50649. currentTimestamp: number;
  50650. /**
  50651. * Used just in case of a failure to initialize an immersive session.
  50652. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  50653. */
  50654. defaultHeightCompensation: number;
  50655. /**
  50656. * Fires every time a new xrFrame arrives which can be used to update the camera
  50657. */
  50658. onXRFrameObservable: Observable<XRFrame>;
  50659. /**
  50660. * Fires when the reference space changed
  50661. */
  50662. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  50663. /**
  50664. * Fires when the xr session is ended either by the device or manually done
  50665. */
  50666. onXRSessionEnded: Observable<any>;
  50667. /**
  50668. * Fires when the xr session is ended either by the device or manually done
  50669. */
  50670. onXRSessionInit: Observable<XRSession>;
  50671. /**
  50672. * Underlying xr session
  50673. */
  50674. session: XRSession;
  50675. /**
  50676. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  50677. * or get the offset the player is currently at.
  50678. */
  50679. viewerReferenceSpace: XRReferenceSpace;
  50680. /**
  50681. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  50682. * @param scene The scene which the session should be created for
  50683. */
  50684. constructor(
  50685. /** The scene which the session should be created for */
  50686. scene: Scene);
  50687. /**
  50688. * The current reference space used in this session. This reference space can constantly change!
  50689. * It is mainly used to offset the camera's position.
  50690. */
  50691. get referenceSpace(): XRReferenceSpace;
  50692. /**
  50693. * Set a new reference space and triggers the observable
  50694. */
  50695. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  50696. /**
  50697. * Disposes of the session manager
  50698. */
  50699. dispose(): void;
  50700. /**
  50701. * Stops the xrSession and restores the render loop
  50702. * @returns Promise which resolves after it exits XR
  50703. */
  50704. exitXRAsync(): Promise<void>;
  50705. /**
  50706. * Gets the correct render target texture to be rendered this frame for this eye
  50707. * @param eye the eye for which to get the render target
  50708. * @returns the render target for the specified eye
  50709. */
  50710. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  50711. /**
  50712. * Creates a WebXRRenderTarget object for the XR session
  50713. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  50714. * @param options optional options to provide when creating a new render target
  50715. * @returns a WebXR render target to which the session can render
  50716. */
  50717. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  50718. /**
  50719. * Initializes the manager
  50720. * After initialization enterXR can be called to start an XR session
  50721. * @returns Promise which resolves after it is initialized
  50722. */
  50723. initializeAsync(): Promise<void>;
  50724. /**
  50725. * Initializes an xr session
  50726. * @param xrSessionMode mode to initialize
  50727. * @param xrSessionInit defines optional and required values to pass to the session builder
  50728. * @returns a promise which will resolve once the session has been initialized
  50729. */
  50730. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  50731. /**
  50732. * Checks if a session would be supported for the creation options specified
  50733. * @param sessionMode session mode to check if supported eg. immersive-vr
  50734. * @returns A Promise that resolves to true if supported and false if not
  50735. */
  50736. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50737. /**
  50738. * Resets the reference space to the one started the session
  50739. */
  50740. resetReferenceSpace(): void;
  50741. /**
  50742. * Starts rendering to the xr layer
  50743. */
  50744. runXRRenderLoop(): void;
  50745. /**
  50746. * Sets the reference space on the xr session
  50747. * @param referenceSpaceType space to set
  50748. * @returns a promise that will resolve once the reference space has been set
  50749. */
  50750. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50751. /**
  50752. * Updates the render state of the session
  50753. * @param state state to set
  50754. * @returns a promise that resolves once the render state has been updated
  50755. */
  50756. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50757. /**
  50758. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50759. * @param sessionMode defines the session to test
  50760. * @returns a promise with boolean as final value
  50761. */
  50762. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50763. private _createRenderTargetTexture;
  50764. }
  50765. }
  50766. declare module BABYLON {
  50767. /**
  50768. * WebXR Camera which holds the views for the xrSession
  50769. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50770. */
  50771. export class WebXRCamera extends FreeCamera {
  50772. private _xrSessionManager;
  50773. private _firstFrame;
  50774. private _referenceQuaternion;
  50775. private _referencedPosition;
  50776. private _xrInvPositionCache;
  50777. private _xrInvQuaternionCache;
  50778. private _trackingState;
  50779. /**
  50780. * Observable raised before camera teleportation
  50781. */
  50782. onBeforeCameraTeleport: Observable<Vector3>;
  50783. /**
  50784. * Observable raised after camera teleportation
  50785. */
  50786. onAfterCameraTeleport: Observable<Vector3>;
  50787. /**
  50788. * Notifies when the camera's tracking state has changed.
  50789. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  50790. */
  50791. onTrackingStateChanged: Observable<WebXRTrackingState>;
  50792. /**
  50793. * Should position compensation execute on first frame.
  50794. * This is used when copying the position from a native (non XR) camera
  50795. */
  50796. compensateOnFirstFrame: boolean;
  50797. /**
  50798. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50799. * @param name the name of the camera
  50800. * @param scene the scene to add the camera to
  50801. * @param _xrSessionManager a constructed xr session manager
  50802. */
  50803. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50804. /**
  50805. * Get the current XR tracking state of the camera
  50806. */
  50807. get trackingState(): WebXRTrackingState;
  50808. private _setTrackingState;
  50809. /**
  50810. * Return the user's height, unrelated to the current ground.
  50811. * This will be the y position of this camera, when ground level is 0.
  50812. */
  50813. get realWorldHeight(): number;
  50814. /** @hidden */
  50815. _updateForDualEyeDebugging(): void;
  50816. /**
  50817. * Sets this camera's transformation based on a non-vr camera
  50818. * @param otherCamera the non-vr camera to copy the transformation from
  50819. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50820. */
  50821. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50822. /**
  50823. * Gets the current instance class name ("WebXRCamera").
  50824. * @returns the class name
  50825. */
  50826. getClassName(): string;
  50827. private _rotate180;
  50828. private _updateFromXRSession;
  50829. private _updateNumberOfRigCameras;
  50830. private _updateReferenceSpace;
  50831. private _updateReferenceSpaceOffset;
  50832. }
  50833. }
  50834. declare module BABYLON {
  50835. /**
  50836. * Defining the interface required for a (webxr) feature
  50837. */
  50838. export interface IWebXRFeature extends IDisposable {
  50839. /**
  50840. * Is this feature attached
  50841. */
  50842. attached: boolean;
  50843. /**
  50844. * Should auto-attach be disabled?
  50845. */
  50846. disableAutoAttach: boolean;
  50847. /**
  50848. * Attach the feature to the session
  50849. * Will usually be called by the features manager
  50850. *
  50851. * @param force should attachment be forced (even when already attached)
  50852. * @returns true if successful.
  50853. */
  50854. attach(force?: boolean): boolean;
  50855. /**
  50856. * Detach the feature from the session
  50857. * Will usually be called by the features manager
  50858. *
  50859. * @returns true if successful.
  50860. */
  50861. detach(): boolean;
  50862. /**
  50863. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50864. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50865. *
  50866. * @returns whether or not the feature is compatible in this environment
  50867. */
  50868. isCompatible(): boolean;
  50869. /**
  50870. * Was this feature disposed;
  50871. */
  50872. isDisposed: boolean;
  50873. /**
  50874. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50875. */
  50876. xrNativeFeatureName?: string;
  50877. /**
  50878. * A list of (Babylon WebXR) features this feature depends on
  50879. */
  50880. dependsOn?: string[];
  50881. }
  50882. /**
  50883. * A list of the currently available features without referencing them
  50884. */
  50885. export class WebXRFeatureName {
  50886. /**
  50887. * The name of the anchor system feature
  50888. */
  50889. static readonly ANCHOR_SYSTEM: string;
  50890. /**
  50891. * The name of the background remover feature
  50892. */
  50893. static readonly BACKGROUND_REMOVER: string;
  50894. /**
  50895. * The name of the hit test feature
  50896. */
  50897. static readonly HIT_TEST: string;
  50898. /**
  50899. * physics impostors for xr controllers feature
  50900. */
  50901. static readonly PHYSICS_CONTROLLERS: string;
  50902. /**
  50903. * The name of the plane detection feature
  50904. */
  50905. static readonly PLANE_DETECTION: string;
  50906. /**
  50907. * The name of the pointer selection feature
  50908. */
  50909. static readonly POINTER_SELECTION: string;
  50910. /**
  50911. * The name of the teleportation feature
  50912. */
  50913. static readonly TELEPORTATION: string;
  50914. /**
  50915. * The name of the feature points feature.
  50916. */
  50917. static readonly FEATURE_POINTS: string;
  50918. /**
  50919. * The name of the hand tracking feature.
  50920. */
  50921. static readonly HAND_TRACKING: string;
  50922. }
  50923. /**
  50924. * Defining the constructor of a feature. Used to register the modules.
  50925. */
  50926. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50927. /**
  50928. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50929. * It is mainly used in AR sessions.
  50930. *
  50931. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50932. */
  50933. export class WebXRFeaturesManager implements IDisposable {
  50934. private _xrSessionManager;
  50935. private static readonly _AvailableFeatures;
  50936. private _features;
  50937. /**
  50938. * constructs a new features manages.
  50939. *
  50940. * @param _xrSessionManager an instance of WebXRSessionManager
  50941. */
  50942. constructor(_xrSessionManager: WebXRSessionManager);
  50943. /**
  50944. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50945. * Mainly used internally.
  50946. *
  50947. * @param featureName the name of the feature to register
  50948. * @param constructorFunction the function used to construct the module
  50949. * @param version the (babylon) version of the module
  50950. * @param stable is that a stable version of this module
  50951. */
  50952. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50953. /**
  50954. * Returns a constructor of a specific feature.
  50955. *
  50956. * @param featureName the name of the feature to construct
  50957. * @param version the version of the feature to load
  50958. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50959. * @param options optional options provided to the module.
  50960. * @returns a function that, when called, will return a new instance of this feature
  50961. */
  50962. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50963. /**
  50964. * Can be used to return the list of features currently registered
  50965. *
  50966. * @returns an Array of available features
  50967. */
  50968. static GetAvailableFeatures(): string[];
  50969. /**
  50970. * Gets the versions available for a specific feature
  50971. * @param featureName the name of the feature
  50972. * @returns an array with the available versions
  50973. */
  50974. static GetAvailableVersions(featureName: string): string[];
  50975. /**
  50976. * Return the latest unstable version of this feature
  50977. * @param featureName the name of the feature to search
  50978. * @returns the version number. if not found will return -1
  50979. */
  50980. static GetLatestVersionOfFeature(featureName: string): number;
  50981. /**
  50982. * Return the latest stable version of this feature
  50983. * @param featureName the name of the feature to search
  50984. * @returns the version number. if not found will return -1
  50985. */
  50986. static GetStableVersionOfFeature(featureName: string): number;
  50987. /**
  50988. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50989. * Can be used during a session to start a feature
  50990. * @param featureName the name of feature to attach
  50991. */
  50992. attachFeature(featureName: string): void;
  50993. /**
  50994. * Can be used inside a session or when the session ends to detach a specific feature
  50995. * @param featureName the name of the feature to detach
  50996. */
  50997. detachFeature(featureName: string): void;
  50998. /**
  50999. * Used to disable an already-enabled feature
  51000. * The feature will be disposed and will be recreated once enabled.
  51001. * @param featureName the feature to disable
  51002. * @returns true if disable was successful
  51003. */
  51004. disableFeature(featureName: string | {
  51005. Name: string;
  51006. }): boolean;
  51007. /**
  51008. * dispose this features manager
  51009. */
  51010. dispose(): void;
  51011. /**
  51012. * 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.
  51013. * 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.
  51014. *
  51015. * @param featureName the name of the feature to load or the class of the feature
  51016. * @param version optional version to load. if not provided the latest version will be enabled
  51017. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  51018. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  51019. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  51020. * @returns a new constructed feature or throws an error if feature not found.
  51021. */
  51022. enableFeature(featureName: string | {
  51023. Name: string;
  51024. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  51025. /**
  51026. * get the implementation of an enabled feature.
  51027. * @param featureName the name of the feature to load
  51028. * @returns the feature class, if found
  51029. */
  51030. getEnabledFeature(featureName: string): IWebXRFeature;
  51031. /**
  51032. * Get the list of enabled features
  51033. * @returns an array of enabled features
  51034. */
  51035. getEnabledFeatures(): string[];
  51036. /**
  51037. * This function will exten the session creation configuration object with enabled features.
  51038. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  51039. * according to the defined "required" variable, provided during enableFeature call
  51040. * @param xrSessionInit the xr Session init object to extend
  51041. *
  51042. * @returns an extended XRSessionInit object
  51043. */
  51044. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  51045. }
  51046. }
  51047. declare module BABYLON {
  51048. /**
  51049. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  51050. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  51051. */
  51052. export class WebXRExperienceHelper implements IDisposable {
  51053. private scene;
  51054. private _nonVRCamera;
  51055. private _originalSceneAutoClear;
  51056. private _supported;
  51057. /**
  51058. * Camera used to render xr content
  51059. */
  51060. camera: WebXRCamera;
  51061. /** A features manager for this xr session */
  51062. featuresManager: WebXRFeaturesManager;
  51063. /**
  51064. * Observers registered here will be triggered after the camera's initial transformation is set
  51065. * This can be used to set a different ground level or an extra rotation.
  51066. *
  51067. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  51068. * to the position set after this observable is done executing.
  51069. */
  51070. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  51071. /**
  51072. * Fires when the state of the experience helper has changed
  51073. */
  51074. onStateChangedObservable: Observable<WebXRState>;
  51075. /** Session manager used to keep track of xr session */
  51076. sessionManager: WebXRSessionManager;
  51077. /**
  51078. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  51079. */
  51080. state: WebXRState;
  51081. /**
  51082. * Creates a WebXRExperienceHelper
  51083. * @param scene The scene the helper should be created in
  51084. */
  51085. private constructor();
  51086. /**
  51087. * Creates the experience helper
  51088. * @param scene the scene to attach the experience helper to
  51089. * @returns a promise for the experience helper
  51090. */
  51091. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  51092. /**
  51093. * Disposes of the experience helper
  51094. */
  51095. dispose(): void;
  51096. /**
  51097. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  51098. * @param sessionMode options for the XR session
  51099. * @param referenceSpaceType frame of reference of the XR session
  51100. * @param renderTarget the output canvas that will be used to enter XR mode
  51101. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  51102. * @returns promise that resolves after xr mode has entered
  51103. */
  51104. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  51105. /**
  51106. * Exits XR mode and returns the scene to its original state
  51107. * @returns promise that resolves after xr mode has exited
  51108. */
  51109. exitXRAsync(): Promise<void>;
  51110. private _nonXRToXRCamera;
  51111. private _setState;
  51112. }
  51113. }
  51114. declare module BABYLON {
  51115. /**
  51116. * X-Y values for axes in WebXR
  51117. */
  51118. export interface IWebXRMotionControllerAxesValue {
  51119. /**
  51120. * The value of the x axis
  51121. */
  51122. x: number;
  51123. /**
  51124. * The value of the y-axis
  51125. */
  51126. y: number;
  51127. }
  51128. /**
  51129. * changed / previous values for the values of this component
  51130. */
  51131. export interface IWebXRMotionControllerComponentChangesValues<T> {
  51132. /**
  51133. * current (this frame) value
  51134. */
  51135. current: T;
  51136. /**
  51137. * previous (last change) value
  51138. */
  51139. previous: T;
  51140. }
  51141. /**
  51142. * Represents changes in the component between current frame and last values recorded
  51143. */
  51144. export interface IWebXRMotionControllerComponentChanges {
  51145. /**
  51146. * will be populated with previous and current values if axes changed
  51147. */
  51148. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  51149. /**
  51150. * will be populated with previous and current values if pressed changed
  51151. */
  51152. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51153. /**
  51154. * will be populated with previous and current values if touched changed
  51155. */
  51156. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  51157. /**
  51158. * will be populated with previous and current values if value changed
  51159. */
  51160. value?: IWebXRMotionControllerComponentChangesValues<number>;
  51161. }
  51162. /**
  51163. * This class represents a single component (for example button or thumbstick) of a motion controller
  51164. */
  51165. export class WebXRControllerComponent implements IDisposable {
  51166. /**
  51167. * the id of this component
  51168. */
  51169. id: string;
  51170. /**
  51171. * the type of the component
  51172. */
  51173. type: MotionControllerComponentType;
  51174. private _buttonIndex;
  51175. private _axesIndices;
  51176. private _axes;
  51177. private _changes;
  51178. private _currentValue;
  51179. private _hasChanges;
  51180. private _pressed;
  51181. private _touched;
  51182. /**
  51183. * button component type
  51184. */
  51185. static BUTTON_TYPE: MotionControllerComponentType;
  51186. /**
  51187. * squeeze component type
  51188. */
  51189. static SQUEEZE_TYPE: MotionControllerComponentType;
  51190. /**
  51191. * Thumbstick component type
  51192. */
  51193. static THUMBSTICK_TYPE: MotionControllerComponentType;
  51194. /**
  51195. * Touchpad component type
  51196. */
  51197. static TOUCHPAD_TYPE: MotionControllerComponentType;
  51198. /**
  51199. * trigger component type
  51200. */
  51201. static TRIGGER_TYPE: MotionControllerComponentType;
  51202. /**
  51203. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  51204. * the axes data changes
  51205. */
  51206. onAxisValueChangedObservable: Observable<{
  51207. x: number;
  51208. y: number;
  51209. }>;
  51210. /**
  51211. * Observers registered here will be triggered when the state of a button changes
  51212. * State change is either pressed / touched / value
  51213. */
  51214. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  51215. /**
  51216. * Creates a new component for a motion controller.
  51217. * It is created by the motion controller itself
  51218. *
  51219. * @param id the id of this component
  51220. * @param type the type of the component
  51221. * @param _buttonIndex index in the buttons array of the gamepad
  51222. * @param _axesIndices indices of the values in the axes array of the gamepad
  51223. */
  51224. constructor(
  51225. /**
  51226. * the id of this component
  51227. */
  51228. id: string,
  51229. /**
  51230. * the type of the component
  51231. */
  51232. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  51233. /**
  51234. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  51235. */
  51236. get axes(): IWebXRMotionControllerAxesValue;
  51237. /**
  51238. * Get the changes. Elements will be populated only if they changed with their previous and current value
  51239. */
  51240. get changes(): IWebXRMotionControllerComponentChanges;
  51241. /**
  51242. * Return whether or not the component changed the last frame
  51243. */
  51244. get hasChanges(): boolean;
  51245. /**
  51246. * is the button currently pressed
  51247. */
  51248. get pressed(): boolean;
  51249. /**
  51250. * is the button currently touched
  51251. */
  51252. get touched(): boolean;
  51253. /**
  51254. * Get the current value of this component
  51255. */
  51256. get value(): number;
  51257. /**
  51258. * Dispose this component
  51259. */
  51260. dispose(): void;
  51261. /**
  51262. * Are there axes correlating to this component
  51263. * @return true is axes data is available
  51264. */
  51265. isAxes(): boolean;
  51266. /**
  51267. * Is this component a button (hence - pressable)
  51268. * @returns true if can be pressed
  51269. */
  51270. isButton(): boolean;
  51271. /**
  51272. * update this component using the gamepad object it is in. Called on every frame
  51273. * @param nativeController the native gamepad controller object
  51274. */
  51275. update(nativeController: IMinimalMotionControllerObject): void;
  51276. }
  51277. }
  51278. declare module BABYLON {
  51279. /**
  51280. * Type used for the success callback of ImportMesh
  51281. */
  51282. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  51283. /**
  51284. * Interface used for the result of ImportMeshAsync
  51285. */
  51286. export interface ISceneLoaderAsyncResult {
  51287. /**
  51288. * The array of loaded meshes
  51289. */
  51290. readonly meshes: AbstractMesh[];
  51291. /**
  51292. * The array of loaded particle systems
  51293. */
  51294. readonly particleSystems: IParticleSystem[];
  51295. /**
  51296. * The array of loaded skeletons
  51297. */
  51298. readonly skeletons: Skeleton[];
  51299. /**
  51300. * The array of loaded animation groups
  51301. */
  51302. readonly animationGroups: AnimationGroup[];
  51303. /**
  51304. * The array of loaded transform nodes
  51305. */
  51306. readonly transformNodes: TransformNode[];
  51307. /**
  51308. * The array of loaded geometries
  51309. */
  51310. readonly geometries: Geometry[];
  51311. /**
  51312. * The array of loaded lights
  51313. */
  51314. readonly lights: Light[];
  51315. }
  51316. /**
  51317. * Interface used to represent data loading progression
  51318. */
  51319. export interface ISceneLoaderProgressEvent {
  51320. /**
  51321. * Defines if data length to load can be evaluated
  51322. */
  51323. readonly lengthComputable: boolean;
  51324. /**
  51325. * Defines the loaded data length
  51326. */
  51327. readonly loaded: number;
  51328. /**
  51329. * Defines the data length to load
  51330. */
  51331. readonly total: number;
  51332. }
  51333. /**
  51334. * Interface used by SceneLoader plugins to define supported file extensions
  51335. */
  51336. export interface ISceneLoaderPluginExtensions {
  51337. /**
  51338. * Defines the list of supported extensions
  51339. */
  51340. [extension: string]: {
  51341. isBinary: boolean;
  51342. };
  51343. }
  51344. /**
  51345. * Interface used by SceneLoader plugin factory
  51346. */
  51347. export interface ISceneLoaderPluginFactory {
  51348. /**
  51349. * Defines the name of the factory
  51350. */
  51351. name: string;
  51352. /**
  51353. * Function called to create a new plugin
  51354. * @return the new plugin
  51355. */
  51356. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  51357. /**
  51358. * The callback that returns true if the data can be directly loaded.
  51359. * @param data string containing the file data
  51360. * @returns if the data can be loaded directly
  51361. */
  51362. canDirectLoad?(data: string): boolean;
  51363. }
  51364. /**
  51365. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  51366. */
  51367. export interface ISceneLoaderPluginBase {
  51368. /**
  51369. * The friendly name of this plugin.
  51370. */
  51371. name: string;
  51372. /**
  51373. * The file extensions supported by this plugin.
  51374. */
  51375. extensions: string | ISceneLoaderPluginExtensions;
  51376. /**
  51377. * The callback called when loading from a url.
  51378. * @param scene scene loading this url
  51379. * @param url url to load
  51380. * @param onSuccess callback called when the file successfully loads
  51381. * @param onProgress callback called while file is loading (if the server supports this mode)
  51382. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  51383. * @param onError callback called when the file fails to load
  51384. * @returns a file request object
  51385. */
  51386. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51387. /**
  51388. * The callback called when loading from a file object.
  51389. * @param scene scene loading this file
  51390. * @param file defines the file to load
  51391. * @param onSuccess defines the callback to call when data is loaded
  51392. * @param onProgress defines the callback to call during loading process
  51393. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  51394. * @param onError defines the callback to call when an error occurs
  51395. * @returns a file request object
  51396. */
  51397. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  51398. /**
  51399. * The callback that returns true if the data can be directly loaded.
  51400. * @param data string containing the file data
  51401. * @returns if the data can be loaded directly
  51402. */
  51403. canDirectLoad?(data: string): boolean;
  51404. /**
  51405. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  51406. * @param scene scene loading this data
  51407. * @param data string containing the data
  51408. * @returns data to pass to the plugin
  51409. */
  51410. directLoad?(scene: Scene, data: string): any;
  51411. /**
  51412. * The callback that allows custom handling of the root url based on the response url.
  51413. * @param rootUrl the original root url
  51414. * @param responseURL the response url if available
  51415. * @returns the new root url
  51416. */
  51417. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  51418. }
  51419. /**
  51420. * Interface used to define a SceneLoader plugin
  51421. */
  51422. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  51423. /**
  51424. * Import meshes into a scene.
  51425. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51426. * @param scene The scene to import into
  51427. * @param data The data to import
  51428. * @param rootUrl The root url for scene and resources
  51429. * @param meshes The meshes array to import into
  51430. * @param particleSystems The particle systems array to import into
  51431. * @param skeletons The skeletons array to import into
  51432. * @param onError The callback when import fails
  51433. * @returns True if successful or false otherwise
  51434. */
  51435. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  51436. /**
  51437. * Load into a scene.
  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 True if successful or false otherwise
  51443. */
  51444. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  51445. /**
  51446. * Load into an asset container.
  51447. * @param scene The scene to load into
  51448. * @param data The data to import
  51449. * @param rootUrl The root url for scene and resources
  51450. * @param onError The callback when import fails
  51451. * @returns The loaded asset container
  51452. */
  51453. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  51454. }
  51455. /**
  51456. * Interface used to define an async SceneLoader plugin
  51457. */
  51458. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  51459. /**
  51460. * Import meshes into a scene.
  51461. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51462. * @param scene The scene to import into
  51463. * @param data The data to import
  51464. * @param rootUrl The root url for scene and resources
  51465. * @param onProgress The callback when the load progresses
  51466. * @param fileName Defines the name of the file to load
  51467. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  51468. */
  51469. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  51470. /**
  51471. * Load into a scene.
  51472. * @param scene The scene to load into
  51473. * @param data The data to import
  51474. * @param rootUrl The root url for scene and resources
  51475. * @param onProgress The callback when the load progresses
  51476. * @param fileName Defines the name of the file to load
  51477. * @returns Nothing
  51478. */
  51479. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  51480. /**
  51481. * Load into an asset container.
  51482. * @param scene The scene to load into
  51483. * @param data The data to import
  51484. * @param rootUrl The root url for scene and resources
  51485. * @param onProgress The callback when the load progresses
  51486. * @param fileName Defines the name of the file to load
  51487. * @returns The loaded asset container
  51488. */
  51489. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  51490. }
  51491. /**
  51492. * Mode that determines how to handle old animation groups before loading new ones.
  51493. */
  51494. export enum SceneLoaderAnimationGroupLoadingMode {
  51495. /**
  51496. * Reset all old animations to initial state then dispose them.
  51497. */
  51498. Clean = 0,
  51499. /**
  51500. * Stop all old animations.
  51501. */
  51502. Stop = 1,
  51503. /**
  51504. * Restart old animations from first frame.
  51505. */
  51506. Sync = 2,
  51507. /**
  51508. * Old animations remains untouched.
  51509. */
  51510. NoSync = 3
  51511. }
  51512. /**
  51513. * Defines a plugin registered by the SceneLoader
  51514. */
  51515. interface IRegisteredPlugin {
  51516. /**
  51517. * Defines the plugin to use
  51518. */
  51519. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51520. /**
  51521. * Defines if the plugin supports binary data
  51522. */
  51523. isBinary: boolean;
  51524. }
  51525. /**
  51526. * Class used to load scene from various file formats using registered plugins
  51527. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  51528. */
  51529. export class SceneLoader {
  51530. /**
  51531. * No logging while loading
  51532. */
  51533. static readonly NO_LOGGING: number;
  51534. /**
  51535. * Minimal logging while loading
  51536. */
  51537. static readonly MINIMAL_LOGGING: number;
  51538. /**
  51539. * Summary logging while loading
  51540. */
  51541. static readonly SUMMARY_LOGGING: number;
  51542. /**
  51543. * Detailled logging while loading
  51544. */
  51545. static readonly DETAILED_LOGGING: number;
  51546. /**
  51547. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  51548. */
  51549. static get ForceFullSceneLoadingForIncremental(): boolean;
  51550. static set ForceFullSceneLoadingForIncremental(value: boolean);
  51551. /**
  51552. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  51553. */
  51554. static get ShowLoadingScreen(): boolean;
  51555. static set ShowLoadingScreen(value: boolean);
  51556. /**
  51557. * Defines the current logging level (while loading the scene)
  51558. * @ignorenaming
  51559. */
  51560. static get loggingLevel(): number;
  51561. static set loggingLevel(value: number);
  51562. /**
  51563. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  51564. */
  51565. static get CleanBoneMatrixWeights(): boolean;
  51566. static set CleanBoneMatrixWeights(value: boolean);
  51567. /**
  51568. * Event raised when a plugin is used to load a scene
  51569. */
  51570. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  51571. private static _registeredPlugins;
  51572. private static _showingLoadingScreen;
  51573. /**
  51574. * Gets the default plugin (used to load Babylon files)
  51575. * @returns the .babylon plugin
  51576. */
  51577. static GetDefaultPlugin(): IRegisteredPlugin;
  51578. private static _GetPluginForExtension;
  51579. private static _GetPluginForDirectLoad;
  51580. private static _GetPluginForFilename;
  51581. private static _GetDirectLoad;
  51582. private static _LoadData;
  51583. private static _GetFileInfo;
  51584. /**
  51585. * Gets a plugin that can load the given extension
  51586. * @param extension defines the extension to load
  51587. * @returns a plugin or null if none works
  51588. */
  51589. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  51590. /**
  51591. * Gets a boolean indicating that the given extension can be loaded
  51592. * @param extension defines the extension to load
  51593. * @returns true if the extension is supported
  51594. */
  51595. static IsPluginForExtensionAvailable(extension: string): boolean;
  51596. /**
  51597. * Adds a new plugin to the list of registered plugins
  51598. * @param plugin defines the plugin to add
  51599. */
  51600. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  51601. /**
  51602. * Import meshes into a scene
  51603. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51604. * @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)
  51605. * @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)
  51606. * @param scene the instance of BABYLON.Scene to append to
  51607. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  51608. * @param onProgress a callback with a progress event for each file being loaded
  51609. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51610. * @param pluginExtension the extension used to determine the plugin
  51611. * @returns The loaded plugin
  51612. */
  51613. 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>;
  51614. /**
  51615. * Import meshes into a scene
  51616. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  51617. * @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)
  51618. * @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)
  51619. * @param scene the instance of BABYLON.Scene to append to
  51620. * @param onProgress a callback with a progress event for each file being loaded
  51621. * @param pluginExtension the extension used to determine the plugin
  51622. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  51623. */
  51624. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  51625. /**
  51626. * Load a scene
  51627. * @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)
  51628. * @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)
  51629. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51630. * @param onSuccess a callback with the scene when import succeeds
  51631. * @param onProgress a callback with a progress event for each file being loaded
  51632. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51633. * @param pluginExtension the extension used to determine the plugin
  51634. * @returns The loaded plugin
  51635. */
  51636. 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>;
  51637. /**
  51638. * Load a scene
  51639. * @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)
  51640. * @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)
  51641. * @param engine is the instance of BABYLON.Engine to use to create the scene
  51642. * @param onProgress a callback with a progress event for each file being loaded
  51643. * @param pluginExtension the extension used to determine the plugin
  51644. * @returns The loaded scene
  51645. */
  51646. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51647. /**
  51648. * Append a scene
  51649. * @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)
  51650. * @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)
  51651. * @param scene is the instance of BABYLON.Scene to append to
  51652. * @param onSuccess a callback with the scene when import succeeds
  51653. * @param onProgress a callback with a progress event for each file being loaded
  51654. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51655. * @param pluginExtension the extension used to determine the plugin
  51656. * @returns The loaded plugin
  51657. */
  51658. 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>;
  51659. /**
  51660. * Append a scene
  51661. * @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)
  51662. * @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)
  51663. * @param scene is the instance of BABYLON.Scene to append to
  51664. * @param onProgress a callback with a progress event for each file being loaded
  51665. * @param pluginExtension the extension used to determine the plugin
  51666. * @returns The given scene
  51667. */
  51668. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  51669. /**
  51670. * Load a scene into an asset container
  51671. * @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)
  51672. * @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)
  51673. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51674. * @param onSuccess a callback with the scene when import succeeds
  51675. * @param onProgress a callback with a progress event for each file being loaded
  51676. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51677. * @param pluginExtension the extension used to determine the plugin
  51678. * @returns The loaded plugin
  51679. */
  51680. 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>;
  51681. /**
  51682. * Load a scene into an asset container
  51683. * @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)
  51684. * @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)
  51685. * @param scene is the instance of Scene to append to
  51686. * @param onProgress a callback with a progress event for each file being loaded
  51687. * @param pluginExtension the extension used to determine the plugin
  51688. * @returns The loaded asset container
  51689. */
  51690. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  51691. /**
  51692. * Import animations from a file into a scene
  51693. * @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)
  51694. * @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)
  51695. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51696. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51697. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51698. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51699. * @param onSuccess a callback with the scene when import succeeds
  51700. * @param onProgress a callback with a progress event for each file being loaded
  51701. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51702. * @param pluginExtension the extension used to determine the plugin
  51703. */
  51704. 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;
  51705. /**
  51706. * Import animations from a file into a scene
  51707. * @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)
  51708. * @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)
  51709. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  51710. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  51711. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  51712. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  51713. * @param onSuccess a callback with the scene when import succeeds
  51714. * @param onProgress a callback with a progress event for each file being loaded
  51715. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  51716. * @param pluginExtension the extension used to determine the plugin
  51717. * @returns the updated scene with imported animations
  51718. */
  51719. 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>;
  51720. }
  51721. }
  51722. declare module BABYLON {
  51723. /**
  51724. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  51725. */
  51726. export type MotionControllerHandedness = "none" | "left" | "right";
  51727. /**
  51728. * The type of components available in motion controllers.
  51729. * This is not the name of the component.
  51730. */
  51731. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  51732. /**
  51733. * The state of a controller component
  51734. */
  51735. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  51736. /**
  51737. * The schema of motion controller layout.
  51738. * No object will be initialized using this interface
  51739. * This is used just to define the profile.
  51740. */
  51741. export interface IMotionControllerLayout {
  51742. /**
  51743. * Path to load the assets. Usually relative to the base path
  51744. */
  51745. assetPath: string;
  51746. /**
  51747. * Available components (unsorted)
  51748. */
  51749. components: {
  51750. /**
  51751. * A map of component Ids
  51752. */
  51753. [componentId: string]: {
  51754. /**
  51755. * The type of input the component outputs
  51756. */
  51757. type: MotionControllerComponentType;
  51758. /**
  51759. * The indices of this component in the gamepad object
  51760. */
  51761. gamepadIndices: {
  51762. /**
  51763. * Index of button
  51764. */
  51765. button?: number;
  51766. /**
  51767. * If available, index of x-axis
  51768. */
  51769. xAxis?: number;
  51770. /**
  51771. * If available, index of y-axis
  51772. */
  51773. yAxis?: number;
  51774. };
  51775. /**
  51776. * The mesh's root node name
  51777. */
  51778. rootNodeName: string;
  51779. /**
  51780. * Animation definitions for this model
  51781. */
  51782. visualResponses: {
  51783. [stateKey: string]: {
  51784. /**
  51785. * What property will be animated
  51786. */
  51787. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51788. /**
  51789. * What states influence this visual response
  51790. */
  51791. states: MotionControllerComponentStateType[];
  51792. /**
  51793. * Type of animation - movement or visibility
  51794. */
  51795. valueNodeProperty: "transform" | "visibility";
  51796. /**
  51797. * Base node name to move. Its position will be calculated according to the min and max nodes
  51798. */
  51799. valueNodeName?: string;
  51800. /**
  51801. * Minimum movement node
  51802. */
  51803. minNodeName?: string;
  51804. /**
  51805. * Max movement node
  51806. */
  51807. maxNodeName?: string;
  51808. };
  51809. };
  51810. /**
  51811. * If touch enabled, what is the name of node to display user feedback
  51812. */
  51813. touchPointNodeName?: string;
  51814. };
  51815. };
  51816. /**
  51817. * Is it xr standard mapping or not
  51818. */
  51819. gamepadMapping: "" | "xr-standard";
  51820. /**
  51821. * Base root node of this entire model
  51822. */
  51823. rootNodeName: string;
  51824. /**
  51825. * Defines the main button component id
  51826. */
  51827. selectComponentId: string;
  51828. }
  51829. /**
  51830. * A definition for the layout map in the input profile
  51831. */
  51832. export interface IMotionControllerLayoutMap {
  51833. /**
  51834. * Layouts with handedness type as a key
  51835. */
  51836. [handedness: string]: IMotionControllerLayout;
  51837. }
  51838. /**
  51839. * The XR Input profile schema
  51840. * Profiles can be found here:
  51841. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51842. */
  51843. export interface IMotionControllerProfile {
  51844. /**
  51845. * fallback profiles for this profileId
  51846. */
  51847. fallbackProfileIds: string[];
  51848. /**
  51849. * The layout map, with handedness as key
  51850. */
  51851. layouts: IMotionControllerLayoutMap;
  51852. /**
  51853. * The id of this profile
  51854. * correlates to the profile(s) in the xrInput.profiles array
  51855. */
  51856. profileId: string;
  51857. }
  51858. /**
  51859. * A helper-interface for the 3 meshes needed for controller button animation
  51860. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51861. */
  51862. export interface IMotionControllerButtonMeshMap {
  51863. /**
  51864. * the mesh that defines the pressed value mesh position.
  51865. * This is used to find the max-position of this button
  51866. */
  51867. pressedMesh: AbstractMesh;
  51868. /**
  51869. * the mesh that defines the unpressed value mesh position.
  51870. * This is used to find the min (or initial) position of this button
  51871. */
  51872. unpressedMesh: AbstractMesh;
  51873. /**
  51874. * The mesh that will be changed when value changes
  51875. */
  51876. valueMesh: AbstractMesh;
  51877. }
  51878. /**
  51879. * A helper-interface for the 3 meshes needed for controller axis animation.
  51880. * This will be expanded when touchpad animations are fully supported
  51881. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51882. */
  51883. export interface IMotionControllerMeshMap {
  51884. /**
  51885. * the mesh that defines the maximum value mesh position.
  51886. */
  51887. maxMesh?: AbstractMesh;
  51888. /**
  51889. * the mesh that defines the minimum value mesh position.
  51890. */
  51891. minMesh?: AbstractMesh;
  51892. /**
  51893. * The mesh that will be changed when axis value changes
  51894. */
  51895. valueMesh?: AbstractMesh;
  51896. }
  51897. /**
  51898. * The elements needed for change-detection of the gamepad objects in motion controllers
  51899. */
  51900. export interface IMinimalMotionControllerObject {
  51901. /**
  51902. * Available axes of this controller
  51903. */
  51904. axes: number[];
  51905. /**
  51906. * An array of available buttons
  51907. */
  51908. buttons: Array<{
  51909. /**
  51910. * Value of the button/trigger
  51911. */
  51912. value: number;
  51913. /**
  51914. * If the button/trigger is currently touched
  51915. */
  51916. touched: boolean;
  51917. /**
  51918. * If the button/trigger is currently pressed
  51919. */
  51920. pressed: boolean;
  51921. }>;
  51922. /**
  51923. * EXPERIMENTAL haptic support.
  51924. */
  51925. hapticActuators?: Array<{
  51926. pulse: (value: number, duration: number) => Promise<boolean>;
  51927. }>;
  51928. }
  51929. /**
  51930. * An Abstract Motion controller
  51931. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51932. * Each component has an observable to check for changes in value and state
  51933. */
  51934. export abstract class WebXRAbstractMotionController implements IDisposable {
  51935. protected scene: Scene;
  51936. protected layout: IMotionControllerLayout;
  51937. /**
  51938. * The gamepad object correlating to this controller
  51939. */
  51940. gamepadObject: IMinimalMotionControllerObject;
  51941. /**
  51942. * handedness (left/right/none) of this controller
  51943. */
  51944. handedness: MotionControllerHandedness;
  51945. private _initComponent;
  51946. private _modelReady;
  51947. /**
  51948. * A map of components (WebXRControllerComponent) in this motion controller
  51949. * Components have a ComponentType and can also have both button and axis definitions
  51950. */
  51951. readonly components: {
  51952. [id: string]: WebXRControllerComponent;
  51953. };
  51954. /**
  51955. * Disable the model's animation. Can be set at any time.
  51956. */
  51957. disableAnimation: boolean;
  51958. /**
  51959. * Observers registered here will be triggered when the model of this controller is done loading
  51960. */
  51961. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51962. /**
  51963. * The profile id of this motion controller
  51964. */
  51965. abstract profileId: string;
  51966. /**
  51967. * The root mesh of the model. It is null if the model was not yet initialized
  51968. */
  51969. rootMesh: Nullable<AbstractMesh>;
  51970. /**
  51971. * constructs a new abstract motion controller
  51972. * @param scene the scene to which the model of the controller will be added
  51973. * @param layout The profile layout to load
  51974. * @param gamepadObject The gamepad object correlating to this controller
  51975. * @param handedness handedness (left/right/none) of this controller
  51976. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51977. */
  51978. constructor(scene: Scene, layout: IMotionControllerLayout,
  51979. /**
  51980. * The gamepad object correlating to this controller
  51981. */
  51982. gamepadObject: IMinimalMotionControllerObject,
  51983. /**
  51984. * handedness (left/right/none) of this controller
  51985. */
  51986. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51987. /**
  51988. * Dispose this controller, the model mesh and all its components
  51989. */
  51990. dispose(): void;
  51991. /**
  51992. * Returns all components of specific type
  51993. * @param type the type to search for
  51994. * @return an array of components with this type
  51995. */
  51996. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51997. /**
  51998. * get a component based an its component id as defined in layout.components
  51999. * @param id the id of the component
  52000. * @returns the component correlates to the id or undefined if not found
  52001. */
  52002. getComponent(id: string): WebXRControllerComponent;
  52003. /**
  52004. * Get the list of components available in this motion controller
  52005. * @returns an array of strings correlating to available components
  52006. */
  52007. getComponentIds(): string[];
  52008. /**
  52009. * Get the first component of specific type
  52010. * @param type type of component to find
  52011. * @return a controller component or null if not found
  52012. */
  52013. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  52014. /**
  52015. * Get the main (Select) component of this controller as defined in the layout
  52016. * @returns the main component of this controller
  52017. */
  52018. getMainComponent(): WebXRControllerComponent;
  52019. /**
  52020. * Loads the model correlating to this controller
  52021. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  52022. * @returns A promise fulfilled with the result of the model loading
  52023. */
  52024. loadModel(): Promise<boolean>;
  52025. /**
  52026. * Update this model using the current XRFrame
  52027. * @param xrFrame the current xr frame to use and update the model
  52028. */
  52029. updateFromXRFrame(xrFrame: XRFrame): void;
  52030. /**
  52031. * Backwards compatibility due to a deeply-integrated typo
  52032. */
  52033. get handness(): XREye;
  52034. /**
  52035. * Pulse (vibrate) this controller
  52036. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  52037. * Consecutive calls to this function will cancel the last pulse call
  52038. *
  52039. * @param value the strength of the pulse in 0.0...1.0 range
  52040. * @param duration Duration of the pulse in milliseconds
  52041. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  52042. * @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
  52043. */
  52044. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  52045. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52046. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  52047. /**
  52048. * Moves the axis on the controller mesh based on its current state
  52049. * @param axis the index of the axis
  52050. * @param axisValue the value of the axis which determines the meshes new position
  52051. * @hidden
  52052. */
  52053. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  52054. /**
  52055. * Update the model itself with the current frame data
  52056. * @param xrFrame the frame to use for updating the model mesh
  52057. */
  52058. protected updateModel(xrFrame: XRFrame): void;
  52059. /**
  52060. * Get the filename and path for this controller's model
  52061. * @returns a map of filename and path
  52062. */
  52063. protected abstract _getFilenameAndPath(): {
  52064. filename: string;
  52065. path: string;
  52066. };
  52067. /**
  52068. * This function is called before the mesh is loaded. It checks for loading constraints.
  52069. * For example, this function can check if the GLB loader is available
  52070. * If this function returns false, the generic controller will be loaded instead
  52071. * @returns Is the client ready to load the mesh
  52072. */
  52073. protected abstract _getModelLoadingConstraints(): boolean;
  52074. /**
  52075. * This function will be called after the model was successfully loaded and can be used
  52076. * for mesh transformations before it is available for the user
  52077. * @param meshes the loaded meshes
  52078. */
  52079. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  52080. /**
  52081. * Set the root mesh for this controller. Important for the WebXR controller class
  52082. * @param meshes the loaded meshes
  52083. */
  52084. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  52085. /**
  52086. * A function executed each frame that updates the mesh (if needed)
  52087. * @param xrFrame the current xrFrame
  52088. */
  52089. protected abstract _updateModel(xrFrame: XRFrame): void;
  52090. private _getGenericFilenameAndPath;
  52091. private _getGenericParentMesh;
  52092. }
  52093. }
  52094. declare module BABYLON {
  52095. /**
  52096. * A generic trigger-only motion controller for WebXR
  52097. */
  52098. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  52099. /**
  52100. * Static version of the profile id of this controller
  52101. */
  52102. static ProfileId: string;
  52103. profileId: string;
  52104. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  52105. protected _getFilenameAndPath(): {
  52106. filename: string;
  52107. path: string;
  52108. };
  52109. protected _getModelLoadingConstraints(): boolean;
  52110. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  52111. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52112. protected _updateModel(): void;
  52113. }
  52114. }
  52115. declare module BABYLON {
  52116. /**
  52117. * Class containing static functions to help procedurally build meshes
  52118. */
  52119. export class SphereBuilder {
  52120. /**
  52121. * Creates a sphere mesh
  52122. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52123. * * 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`)
  52124. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52125. * * 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
  52126. * * 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)
  52127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52128. * * 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
  52129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52130. * @param name defines the name of the mesh
  52131. * @param options defines the options used to create the mesh
  52132. * @param scene defines the hosting scene
  52133. * @returns the sphere mesh
  52134. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52135. */
  52136. static CreateSphere(name: string, options: {
  52137. segments?: number;
  52138. diameter?: number;
  52139. diameterX?: number;
  52140. diameterY?: number;
  52141. diameterZ?: number;
  52142. arc?: number;
  52143. slice?: number;
  52144. sideOrientation?: number;
  52145. frontUVs?: Vector4;
  52146. backUVs?: Vector4;
  52147. updatable?: boolean;
  52148. }, scene?: Nullable<Scene>): Mesh;
  52149. }
  52150. }
  52151. declare module BABYLON {
  52152. /**
  52153. * A profiled motion controller has its profile loaded from an online repository.
  52154. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  52155. */
  52156. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  52157. private _repositoryUrl;
  52158. private _buttonMeshMapping;
  52159. private _touchDots;
  52160. /**
  52161. * The profile ID of this controller. Will be populated when the controller initializes.
  52162. */
  52163. profileId: string;
  52164. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  52165. dispose(): void;
  52166. protected _getFilenameAndPath(): {
  52167. filename: string;
  52168. path: string;
  52169. };
  52170. protected _getModelLoadingConstraints(): boolean;
  52171. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  52172. protected _setRootMesh(meshes: AbstractMesh[]): void;
  52173. protected _updateModel(_xrFrame: XRFrame): void;
  52174. }
  52175. }
  52176. declare module BABYLON {
  52177. /**
  52178. * A construction function type to create a new controller based on an xrInput object
  52179. */
  52180. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  52181. /**
  52182. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  52183. *
  52184. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  52185. * it should be replaced with auto-loaded controllers.
  52186. *
  52187. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  52188. */
  52189. export class WebXRMotionControllerManager {
  52190. private static _AvailableControllers;
  52191. private static _Fallbacks;
  52192. private static _ProfileLoadingPromises;
  52193. private static _ProfilesList;
  52194. /**
  52195. * The base URL of the online controller repository. Can be changed at any time.
  52196. */
  52197. static BaseRepositoryUrl: string;
  52198. /**
  52199. * Which repository gets priority - local or online
  52200. */
  52201. static PrioritizeOnlineRepository: boolean;
  52202. /**
  52203. * Use the online repository, or use only locally-defined controllers
  52204. */
  52205. static UseOnlineRepository: boolean;
  52206. /**
  52207. * Clear the cache used for profile loading and reload when requested again
  52208. */
  52209. static ClearProfilesCache(): void;
  52210. /**
  52211. * Register the default fallbacks.
  52212. * This function is called automatically when this file is imported.
  52213. */
  52214. static DefaultFallbacks(): void;
  52215. /**
  52216. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  52217. * @param profileId the profile to which a fallback needs to be found
  52218. * @return an array with corresponding fallback profiles
  52219. */
  52220. static FindFallbackWithProfileId(profileId: string): string[];
  52221. /**
  52222. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  52223. * The order of search:
  52224. *
  52225. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  52226. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  52227. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  52228. * 4) return the generic trigger controller if none were found
  52229. *
  52230. * @param xrInput the xrInput to which a new controller is initialized
  52231. * @param scene the scene to which the model will be added
  52232. * @param forceProfile force a certain profile for this controller
  52233. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  52234. */
  52235. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  52236. /**
  52237. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  52238. *
  52239. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  52240. *
  52241. * @param type the profile type to register
  52242. * @param constructFunction the function to be called when loading this profile
  52243. */
  52244. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  52245. /**
  52246. * Register a fallback to a specific profile.
  52247. * @param profileId the profileId that will receive the fallbacks
  52248. * @param fallbacks A list of fallback profiles
  52249. */
  52250. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  52251. /**
  52252. * Will update the list of profiles available in the repository
  52253. * @return a promise that resolves to a map of profiles available online
  52254. */
  52255. static UpdateProfilesList(): Promise<{
  52256. [profile: string]: string;
  52257. }>;
  52258. private static _LoadProfileFromRepository;
  52259. private static _LoadProfilesFromAvailableControllers;
  52260. }
  52261. }
  52262. declare module BABYLON {
  52263. /**
  52264. * Configuration options for the WebXR controller creation
  52265. */
  52266. export interface IWebXRControllerOptions {
  52267. /**
  52268. * Should the controller mesh be animated when a user interacts with it
  52269. * The pressed buttons / thumbstick and touchpad animations will be disabled
  52270. */
  52271. disableMotionControllerAnimation?: boolean;
  52272. /**
  52273. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  52274. */
  52275. doNotLoadControllerMesh?: boolean;
  52276. /**
  52277. * Force a specific controller type for this controller.
  52278. * This can be used when creating your own profile or when testing different controllers
  52279. */
  52280. forceControllerProfile?: string;
  52281. /**
  52282. * Defines a rendering group ID for meshes that will be loaded.
  52283. * This is for the default controllers only.
  52284. */
  52285. renderingGroupId?: number;
  52286. }
  52287. /**
  52288. * Represents an XR controller
  52289. */
  52290. export class WebXRInputSource {
  52291. private _scene;
  52292. /** The underlying input source for the controller */
  52293. inputSource: XRInputSource;
  52294. private _options;
  52295. private _tmpVector;
  52296. private _uniqueId;
  52297. private _disposed;
  52298. /**
  52299. * 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
  52300. */
  52301. grip?: AbstractMesh;
  52302. /**
  52303. * If available, this is the gamepad object related to this controller.
  52304. * Using this object it is possible to get click events and trackpad changes of the
  52305. * webxr controller that is currently being used.
  52306. */
  52307. motionController?: WebXRAbstractMotionController;
  52308. /**
  52309. * Event that fires when the controller is removed/disposed.
  52310. * The object provided as event data is this controller, after associated assets were disposed.
  52311. * uniqueId is still available.
  52312. */
  52313. onDisposeObservable: Observable<WebXRInputSource>;
  52314. /**
  52315. * Will be triggered when the mesh associated with the motion controller is done loading.
  52316. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  52317. * A shortened version of controller -> motion controller -> on mesh loaded.
  52318. */
  52319. onMeshLoadedObservable: Observable<AbstractMesh>;
  52320. /**
  52321. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  52322. */
  52323. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  52324. /**
  52325. * Pointer which can be used to select objects or attach a visible laser to
  52326. */
  52327. pointer: AbstractMesh;
  52328. /**
  52329. * Creates the input source object
  52330. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  52331. * @param _scene the scene which the controller should be associated to
  52332. * @param inputSource the underlying input source for the controller
  52333. * @param _options options for this controller creation
  52334. */
  52335. constructor(_scene: Scene,
  52336. /** The underlying input source for the controller */
  52337. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  52338. /**
  52339. * Get this controllers unique id
  52340. */
  52341. get uniqueId(): string;
  52342. /**
  52343. * Disposes of the object
  52344. */
  52345. dispose(): void;
  52346. /**
  52347. * Gets a world space ray coming from the pointer or grip
  52348. * @param result the resulting ray
  52349. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  52350. */
  52351. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  52352. /**
  52353. * Updates the controller pose based on the given XRFrame
  52354. * @param xrFrame xr frame to update the pose with
  52355. * @param referenceSpace reference space to use
  52356. */
  52357. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  52358. }
  52359. }
  52360. declare module BABYLON {
  52361. /**
  52362. * The schema for initialization options of the XR Input class
  52363. */
  52364. export interface IWebXRInputOptions {
  52365. /**
  52366. * If set to true no model will be automatically loaded
  52367. */
  52368. doNotLoadControllerMeshes?: boolean;
  52369. /**
  52370. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  52371. * If not found, the xr input profile data will be used.
  52372. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  52373. */
  52374. forceInputProfile?: string;
  52375. /**
  52376. * Do not send a request to the controller repository to load the profile.
  52377. *
  52378. * Instead, use the controllers available in babylon itself.
  52379. */
  52380. disableOnlineControllerRepository?: boolean;
  52381. /**
  52382. * A custom URL for the controllers repository
  52383. */
  52384. customControllersRepositoryURL?: string;
  52385. /**
  52386. * Should the controller model's components not move according to the user input
  52387. */
  52388. disableControllerAnimation?: boolean;
  52389. /**
  52390. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  52391. */
  52392. controllerOptions?: IWebXRControllerOptions;
  52393. }
  52394. /**
  52395. * XR input used to track XR inputs such as controllers/rays
  52396. */
  52397. export class WebXRInput implements IDisposable {
  52398. /**
  52399. * the xr session manager for this session
  52400. */
  52401. xrSessionManager: WebXRSessionManager;
  52402. /**
  52403. * the WebXR camera for this session. Mainly used for teleportation
  52404. */
  52405. xrCamera: WebXRCamera;
  52406. private readonly options;
  52407. /**
  52408. * XR controllers being tracked
  52409. */
  52410. controllers: Array<WebXRInputSource>;
  52411. private _frameObserver;
  52412. private _sessionEndedObserver;
  52413. private _sessionInitObserver;
  52414. /**
  52415. * Event when a controller has been connected/added
  52416. */
  52417. onControllerAddedObservable: Observable<WebXRInputSource>;
  52418. /**
  52419. * Event when a controller has been removed/disconnected
  52420. */
  52421. onControllerRemovedObservable: Observable<WebXRInputSource>;
  52422. /**
  52423. * Initializes the WebXRInput
  52424. * @param xrSessionManager the xr session manager for this session
  52425. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  52426. * @param options = initialization options for this xr input
  52427. */
  52428. constructor(
  52429. /**
  52430. * the xr session manager for this session
  52431. */
  52432. xrSessionManager: WebXRSessionManager,
  52433. /**
  52434. * the WebXR camera for this session. Mainly used for teleportation
  52435. */
  52436. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  52437. private _onInputSourcesChange;
  52438. private _addAndRemoveControllers;
  52439. /**
  52440. * Disposes of the object
  52441. */
  52442. dispose(): void;
  52443. }
  52444. }
  52445. declare module BABYLON {
  52446. /**
  52447. * This is the base class for all WebXR features.
  52448. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  52449. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  52450. */
  52451. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  52452. protected _xrSessionManager: WebXRSessionManager;
  52453. private _attached;
  52454. private _removeOnDetach;
  52455. /**
  52456. * Is this feature disposed?
  52457. */
  52458. isDisposed: boolean;
  52459. /**
  52460. * Should auto-attach be disabled?
  52461. */
  52462. disableAutoAttach: boolean;
  52463. /**
  52464. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  52465. */
  52466. xrNativeFeatureName: string;
  52467. /**
  52468. * Construct a new (abstract) WebXR feature
  52469. * @param _xrSessionManager the xr session manager for this feature
  52470. */
  52471. constructor(_xrSessionManager: WebXRSessionManager);
  52472. /**
  52473. * Is this feature attached
  52474. */
  52475. get attached(): boolean;
  52476. /**
  52477. * attach this feature
  52478. *
  52479. * @param force should attachment be forced (even when already attached)
  52480. * @returns true if successful, false is failed or already attached
  52481. */
  52482. attach(force?: boolean): boolean;
  52483. /**
  52484. * detach this feature.
  52485. *
  52486. * @returns true if successful, false if failed or already detached
  52487. */
  52488. detach(): boolean;
  52489. /**
  52490. * Dispose this feature and all of the resources attached
  52491. */
  52492. dispose(): void;
  52493. /**
  52494. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52495. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52496. *
  52497. * @returns whether or not the feature is compatible in this environment
  52498. */
  52499. isCompatible(): boolean;
  52500. /**
  52501. * This is used to register callbacks that will automatically be removed when detach is called.
  52502. * @param observable the observable to which the observer will be attached
  52503. * @param callback the callback to register
  52504. */
  52505. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  52506. /**
  52507. * Code in this function will be executed on each xrFrame received from the browser.
  52508. * This function will not execute after the feature is detached.
  52509. * @param _xrFrame the current frame
  52510. */
  52511. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  52512. }
  52513. }
  52514. declare module BABYLON {
  52515. /**
  52516. * Renders a layer on top of an existing scene
  52517. */
  52518. export class UtilityLayerRenderer implements IDisposable {
  52519. /** the original scene that will be rendered on top of */
  52520. originalScene: Scene;
  52521. private _pointerCaptures;
  52522. private _lastPointerEvents;
  52523. private static _DefaultUtilityLayer;
  52524. private static _DefaultKeepDepthUtilityLayer;
  52525. private _sharedGizmoLight;
  52526. private _renderCamera;
  52527. /**
  52528. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  52529. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  52530. * @returns the camera that is used when rendering the utility layer
  52531. */
  52532. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  52533. /**
  52534. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  52535. * @param cam the camera that should be used when rendering the utility layer
  52536. */
  52537. setRenderCamera(cam: Nullable<Camera>): void;
  52538. /**
  52539. * @hidden
  52540. * Light which used by gizmos to get light shading
  52541. */
  52542. _getSharedGizmoLight(): HemisphericLight;
  52543. /**
  52544. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  52545. */
  52546. pickUtilitySceneFirst: boolean;
  52547. /**
  52548. * 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)
  52549. */
  52550. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  52551. /**
  52552. * 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)
  52553. */
  52554. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  52555. /**
  52556. * The scene that is rendered on top of the original scene
  52557. */
  52558. utilityLayerScene: Scene;
  52559. /**
  52560. * If the utility layer should automatically be rendered on top of existing scene
  52561. */
  52562. shouldRender: boolean;
  52563. /**
  52564. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  52565. */
  52566. onlyCheckPointerDownEvents: boolean;
  52567. /**
  52568. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  52569. */
  52570. processAllEvents: boolean;
  52571. /**
  52572. * Observable raised when the pointer move from the utility layer scene to the main scene
  52573. */
  52574. onPointerOutObservable: Observable<number>;
  52575. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  52576. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  52577. private _afterRenderObserver;
  52578. private _sceneDisposeObserver;
  52579. private _originalPointerObserver;
  52580. /**
  52581. * Instantiates a UtilityLayerRenderer
  52582. * @param originalScene the original scene that will be rendered on top of
  52583. * @param handleEvents boolean indicating if the utility layer should handle events
  52584. */
  52585. constructor(
  52586. /** the original scene that will be rendered on top of */
  52587. originalScene: Scene, handleEvents?: boolean);
  52588. private _notifyObservers;
  52589. /**
  52590. * Renders the utility layers scene on top of the original scene
  52591. */
  52592. render(): void;
  52593. /**
  52594. * Disposes of the renderer
  52595. */
  52596. dispose(): void;
  52597. private _updateCamera;
  52598. }
  52599. }
  52600. declare module BABYLON {
  52601. /**
  52602. * Options interface for the pointer selection module
  52603. */
  52604. export interface IWebXRControllerPointerSelectionOptions {
  52605. /**
  52606. * if provided, this scene will be used to render meshes.
  52607. */
  52608. customUtilityLayerScene?: Scene;
  52609. /**
  52610. * 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)
  52611. * If not disabled, the last picked point will be used to execute a pointer up event
  52612. * If disabled, pointer up event will be triggered right after the pointer down event.
  52613. * Used in screen and gaze target ray mode only
  52614. */
  52615. disablePointerUpOnTouchOut: boolean;
  52616. /**
  52617. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  52618. */
  52619. forceGazeMode: boolean;
  52620. /**
  52621. * 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
  52622. * to start a new countdown to the pointer down event.
  52623. * Defaults to 1.
  52624. */
  52625. gazeModePointerMovedFactor?: number;
  52626. /**
  52627. * Different button type to use instead of the main component
  52628. */
  52629. overrideButtonId?: string;
  52630. /**
  52631. * use this rendering group id for the meshes (optional)
  52632. */
  52633. renderingGroupId?: number;
  52634. /**
  52635. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  52636. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  52637. * 3000 means 3 seconds between pointing at something and selecting it
  52638. */
  52639. timeToSelect?: number;
  52640. /**
  52641. * Should meshes created here be added to a utility layer or the main scene
  52642. */
  52643. useUtilityLayer?: boolean;
  52644. /**
  52645. * Optional WebXR camera to be used for gaze selection
  52646. */
  52647. gazeCamera?: WebXRCamera;
  52648. /**
  52649. * the xr input to use with this pointer selection
  52650. */
  52651. xrInput: WebXRInput;
  52652. /**
  52653. * Should the scene pointerX and pointerY update be disabled
  52654. * This is required for fullscreen AR GUI, but might slow down other experiences.
  52655. * Disable in VR, if not needed.
  52656. * The first rig camera (left eye) will be used to calculate the projection
  52657. */
  52658. disableScenePointerVectorUpdate: boolean;
  52659. /**
  52660. * Enable pointer selection on all controllers instead of switching between them
  52661. */
  52662. enablePointerSelectionOnAllControllers?: boolean;
  52663. /**
  52664. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  52665. * If switch is enabled, it will still allow the user to switch between the different controllers
  52666. */
  52667. preferredHandedness?: XRHandedness;
  52668. /**
  52669. * Disable switching the pointer selection from one controller to the other.
  52670. * 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
  52671. */
  52672. disableSwitchOnClick?: boolean;
  52673. /**
  52674. * The maximum distance of the pointer selection feature. Defaults to 100.
  52675. */
  52676. maxPointerDistance?: number;
  52677. }
  52678. /**
  52679. * A module that will enable pointer selection for motion controllers of XR Input Sources
  52680. */
  52681. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  52682. private readonly _options;
  52683. private static _idCounter;
  52684. private _attachController;
  52685. private _controllers;
  52686. private _scene;
  52687. private _tmpVectorForPickCompare;
  52688. private _attachedController;
  52689. /**
  52690. * The module's name
  52691. */
  52692. static readonly Name: string;
  52693. /**
  52694. * The (Babylon) version of this module.
  52695. * This is an integer representing the implementation version.
  52696. * This number does not correspond to the WebXR specs version
  52697. */
  52698. static readonly Version: number;
  52699. /**
  52700. * Disable lighting on the laser pointer (so it will always be visible)
  52701. */
  52702. disablePointerLighting: boolean;
  52703. /**
  52704. * Disable lighting on the selection mesh (so it will always be visible)
  52705. */
  52706. disableSelectionMeshLighting: boolean;
  52707. /**
  52708. * Should the laser pointer be displayed
  52709. */
  52710. displayLaserPointer: boolean;
  52711. /**
  52712. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  52713. */
  52714. displaySelectionMesh: boolean;
  52715. /**
  52716. * This color will be set to the laser pointer when selection is triggered
  52717. */
  52718. laserPointerPickedColor: Color3;
  52719. /**
  52720. * Default color of the laser pointer
  52721. */
  52722. laserPointerDefaultColor: Color3;
  52723. /**
  52724. * default color of the selection ring
  52725. */
  52726. selectionMeshDefaultColor: Color3;
  52727. /**
  52728. * This color will be applied to the selection ring when selection is triggered
  52729. */
  52730. selectionMeshPickedColor: Color3;
  52731. /**
  52732. * Optional filter to be used for ray selection. This predicate shares behavior with
  52733. * scene.pointerMovePredicate which takes priority if it is also assigned.
  52734. */
  52735. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52736. /**
  52737. * constructs a new background remover module
  52738. * @param _xrSessionManager the session manager for this module
  52739. * @param _options read-only options to be used in this module
  52740. */
  52741. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  52742. /**
  52743. * attach this feature
  52744. * Will usually be called by the features manager
  52745. *
  52746. * @returns true if successful.
  52747. */
  52748. attach(): boolean;
  52749. /**
  52750. * detach this feature.
  52751. * Will usually be called by the features manager
  52752. *
  52753. * @returns true if successful.
  52754. */
  52755. detach(): boolean;
  52756. /**
  52757. * Will get the mesh under a specific pointer.
  52758. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  52759. * @param controllerId the controllerId to check
  52760. * @returns The mesh under pointer or null if no mesh is under the pointer
  52761. */
  52762. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  52763. /**
  52764. * Get the xr controller that correlates to the pointer id in the pointer event
  52765. *
  52766. * @param id the pointer id to search for
  52767. * @returns the controller that correlates to this id or null if not found
  52768. */
  52769. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  52770. private _identityMatrix;
  52771. private _screenCoordinatesRef;
  52772. private _viewportRef;
  52773. protected _onXRFrame(_xrFrame: XRFrame): void;
  52774. private _attachGazeMode;
  52775. private _attachScreenRayMode;
  52776. private _attachTrackedPointerRayMode;
  52777. private _convertNormalToDirectionOfRay;
  52778. private _detachController;
  52779. private _generateNewMeshPair;
  52780. private _pickingMoved;
  52781. private _updatePointerDistance;
  52782. /** @hidden */
  52783. get lasterPointerDefaultColor(): Color3;
  52784. }
  52785. }
  52786. declare module BABYLON {
  52787. /**
  52788. * Button which can be used to enter a different mode of XR
  52789. */
  52790. export class WebXREnterExitUIButton {
  52791. /** button element */
  52792. element: HTMLElement;
  52793. /** XR initialization options for the button */
  52794. sessionMode: XRSessionMode;
  52795. /** Reference space type */
  52796. referenceSpaceType: XRReferenceSpaceType;
  52797. /**
  52798. * Creates a WebXREnterExitUIButton
  52799. * @param element button element
  52800. * @param sessionMode XR initialization session mode
  52801. * @param referenceSpaceType the type of reference space to be used
  52802. */
  52803. constructor(
  52804. /** button element */
  52805. element: HTMLElement,
  52806. /** XR initialization options for the button */
  52807. sessionMode: XRSessionMode,
  52808. /** Reference space type */
  52809. referenceSpaceType: XRReferenceSpaceType);
  52810. /**
  52811. * Extendable function which can be used to update the button's visuals when the state changes
  52812. * @param activeButton the current active button in the UI
  52813. */
  52814. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52815. }
  52816. /**
  52817. * Options to create the webXR UI
  52818. */
  52819. export class WebXREnterExitUIOptions {
  52820. /**
  52821. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52822. */
  52823. customButtons?: Array<WebXREnterExitUIButton>;
  52824. /**
  52825. * A reference space type to use when creating the default button.
  52826. * Default is local-floor
  52827. */
  52828. referenceSpaceType?: XRReferenceSpaceType;
  52829. /**
  52830. * Context to enter xr with
  52831. */
  52832. renderTarget?: Nullable<WebXRRenderTarget>;
  52833. /**
  52834. * A session mode to use when creating the default button.
  52835. * Default is immersive-vr
  52836. */
  52837. sessionMode?: XRSessionMode;
  52838. /**
  52839. * A list of optional features to init the session with
  52840. */
  52841. optionalFeatures?: string[];
  52842. /**
  52843. * A list of optional features to init the session with
  52844. */
  52845. requiredFeatures?: string[];
  52846. /**
  52847. * If defined, this function will be executed if the UI encounters an error when entering XR
  52848. */
  52849. onError?: (error: any) => void;
  52850. }
  52851. /**
  52852. * UI to allow the user to enter/exit XR mode
  52853. */
  52854. export class WebXREnterExitUI implements IDisposable {
  52855. private scene;
  52856. /** version of the options passed to this UI */
  52857. options: WebXREnterExitUIOptions;
  52858. private _activeButton;
  52859. private _buttons;
  52860. /**
  52861. * The HTML Div Element to which buttons are added.
  52862. */
  52863. readonly overlay: HTMLDivElement;
  52864. /**
  52865. * Fired every time the active button is changed.
  52866. *
  52867. * When xr is entered via a button that launches xr that button will be the callback parameter
  52868. *
  52869. * When exiting xr the callback parameter will be null)
  52870. */
  52871. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52872. /**
  52873. *
  52874. * @param scene babylon scene object to use
  52875. * @param options (read-only) version of the options passed to this UI
  52876. */
  52877. private constructor();
  52878. /**
  52879. * Creates UI to allow the user to enter/exit XR mode
  52880. * @param scene the scene to add the ui to
  52881. * @param helper the xr experience helper to enter/exit xr with
  52882. * @param options options to configure the UI
  52883. * @returns the created ui
  52884. */
  52885. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52886. /**
  52887. * Disposes of the XR UI component
  52888. */
  52889. dispose(): void;
  52890. private _updateButtons;
  52891. }
  52892. }
  52893. declare module BABYLON {
  52894. /**
  52895. * Class containing static functions to help procedurally build meshes
  52896. */
  52897. export class LinesBuilder {
  52898. /**
  52899. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52900. * * 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
  52901. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52902. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52903. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52904. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52905. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52906. * * 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
  52907. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52910. * @param name defines the name of the new line system
  52911. * @param options defines the options used to create the line system
  52912. * @param scene defines the hosting scene
  52913. * @returns a new line system mesh
  52914. */
  52915. static CreateLineSystem(name: string, options: {
  52916. lines: Vector3[][];
  52917. updatable?: boolean;
  52918. instance?: Nullable<LinesMesh>;
  52919. colors?: Nullable<Color4[][]>;
  52920. useVertexAlpha?: boolean;
  52921. }, scene: Nullable<Scene>): LinesMesh;
  52922. /**
  52923. * Creates a line mesh
  52924. * 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
  52925. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52926. * * The parameter `points` is an array successive Vector3
  52927. * * 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
  52928. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52929. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52930. * * When updating an instance, remember that only point positions can change, not the number of points
  52931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52932. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52933. * @param name defines the name of the new line system
  52934. * @param options defines the options used to create the line system
  52935. * @param scene defines the hosting scene
  52936. * @returns a new line mesh
  52937. */
  52938. static CreateLines(name: string, options: {
  52939. points: Vector3[];
  52940. updatable?: boolean;
  52941. instance?: Nullable<LinesMesh>;
  52942. colors?: Color4[];
  52943. useVertexAlpha?: boolean;
  52944. }, scene?: Nullable<Scene>): LinesMesh;
  52945. /**
  52946. * Creates a dashed line mesh
  52947. * * 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
  52948. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52949. * * The parameter `points` is an array successive Vector3
  52950. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52951. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52952. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52953. * * 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
  52954. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52955. * * When updating an instance, remember that only point positions can change, not the number of points
  52956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52957. * @param name defines the name of the mesh
  52958. * @param options defines the options used to create the mesh
  52959. * @param scene defines the hosting scene
  52960. * @returns the dashed line mesh
  52961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52962. */
  52963. static CreateDashedLines(name: string, options: {
  52964. points: Vector3[];
  52965. dashSize?: number;
  52966. gapSize?: number;
  52967. dashNb?: number;
  52968. updatable?: boolean;
  52969. instance?: LinesMesh;
  52970. useVertexAlpha?: boolean;
  52971. }, scene?: Nullable<Scene>): LinesMesh;
  52972. }
  52973. }
  52974. declare module BABYLON {
  52975. /**
  52976. * Construction options for a timer
  52977. */
  52978. export interface ITimerOptions<T> {
  52979. /**
  52980. * Time-to-end
  52981. */
  52982. timeout: number;
  52983. /**
  52984. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52985. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52986. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52987. */
  52988. contextObservable: Observable<T>;
  52989. /**
  52990. * Optional parameters when adding an observer to the observable
  52991. */
  52992. observableParameters?: {
  52993. mask?: number;
  52994. insertFirst?: boolean;
  52995. scope?: any;
  52996. };
  52997. /**
  52998. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52999. */
  53000. breakCondition?: (data?: ITimerData<T>) => boolean;
  53001. /**
  53002. * Will be triggered when the time condition has met
  53003. */
  53004. onEnded?: (data: ITimerData<any>) => void;
  53005. /**
  53006. * Will be triggered when the break condition has met (prematurely ended)
  53007. */
  53008. onAborted?: (data: ITimerData<any>) => void;
  53009. /**
  53010. * Optional function to execute on each tick (or count)
  53011. */
  53012. onTick?: (data: ITimerData<any>) => void;
  53013. }
  53014. /**
  53015. * An interface defining the data sent by the timer
  53016. */
  53017. export interface ITimerData<T> {
  53018. /**
  53019. * When did it start
  53020. */
  53021. startTime: number;
  53022. /**
  53023. * Time now
  53024. */
  53025. currentTime: number;
  53026. /**
  53027. * Time passed since started
  53028. */
  53029. deltaTime: number;
  53030. /**
  53031. * How much is completed, in [0.0...1.0].
  53032. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  53033. */
  53034. completeRate: number;
  53035. /**
  53036. * What the registered observable sent in the last count
  53037. */
  53038. payload: T;
  53039. }
  53040. /**
  53041. * The current state of the timer
  53042. */
  53043. export enum TimerState {
  53044. /**
  53045. * Timer initialized, not yet started
  53046. */
  53047. INIT = 0,
  53048. /**
  53049. * Timer started and counting
  53050. */
  53051. STARTED = 1,
  53052. /**
  53053. * Timer ended (whether aborted or time reached)
  53054. */
  53055. ENDED = 2
  53056. }
  53057. /**
  53058. * A simple version of the timer. Will take options and start the timer immediately after calling it
  53059. *
  53060. * @param options options with which to initialize this timer
  53061. */
  53062. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  53063. /**
  53064. * An advanced implementation of a timer class
  53065. */
  53066. export class AdvancedTimer<T = any> implements IDisposable {
  53067. /**
  53068. * Will notify each time the timer calculates the remaining time
  53069. */
  53070. onEachCountObservable: Observable<ITimerData<T>>;
  53071. /**
  53072. * Will trigger when the timer was aborted due to the break condition
  53073. */
  53074. onTimerAbortedObservable: Observable<ITimerData<T>>;
  53075. /**
  53076. * Will trigger when the timer ended successfully
  53077. */
  53078. onTimerEndedObservable: Observable<ITimerData<T>>;
  53079. /**
  53080. * Will trigger when the timer state has changed
  53081. */
  53082. onStateChangedObservable: Observable<TimerState>;
  53083. private _observer;
  53084. private _contextObservable;
  53085. private _observableParameters;
  53086. private _startTime;
  53087. private _timer;
  53088. private _state;
  53089. private _breakCondition;
  53090. private _timeToEnd;
  53091. private _breakOnNextTick;
  53092. /**
  53093. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  53094. * @param options construction options for this advanced timer
  53095. */
  53096. constructor(options: ITimerOptions<T>);
  53097. /**
  53098. * set a breaking condition for this timer. Default is to never break during count
  53099. * @param predicate the new break condition. Returns true to break, false otherwise
  53100. */
  53101. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  53102. /**
  53103. * Reset ALL associated observables in this advanced timer
  53104. */
  53105. clearObservables(): void;
  53106. /**
  53107. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  53108. *
  53109. * @param timeToEnd how much time to measure until timer ended
  53110. */
  53111. start(timeToEnd?: number): void;
  53112. /**
  53113. * Will force a stop on the next tick.
  53114. */
  53115. stop(): void;
  53116. /**
  53117. * Dispose this timer, clearing all resources
  53118. */
  53119. dispose(): void;
  53120. private _setState;
  53121. private _tick;
  53122. private _stop;
  53123. }
  53124. }
  53125. declare module BABYLON {
  53126. /**
  53127. * The options container for the teleportation module
  53128. */
  53129. export interface IWebXRTeleportationOptions {
  53130. /**
  53131. * if provided, this scene will be used to render meshes.
  53132. */
  53133. customUtilityLayerScene?: Scene;
  53134. /**
  53135. * Values to configure the default target mesh
  53136. */
  53137. defaultTargetMeshOptions?: {
  53138. /**
  53139. * Fill color of the teleportation area
  53140. */
  53141. teleportationFillColor?: string;
  53142. /**
  53143. * Border color for the teleportation area
  53144. */
  53145. teleportationBorderColor?: string;
  53146. /**
  53147. * Disable the mesh's animation sequence
  53148. */
  53149. disableAnimation?: boolean;
  53150. /**
  53151. * Disable lighting on the material or the ring and arrow
  53152. */
  53153. disableLighting?: boolean;
  53154. /**
  53155. * Override the default material of the torus and arrow
  53156. */
  53157. torusArrowMaterial?: Material;
  53158. };
  53159. /**
  53160. * A list of meshes to use as floor meshes.
  53161. * Meshes can be added and removed after initializing the feature using the
  53162. * addFloorMesh and removeFloorMesh functions
  53163. * If empty, rotation will still work
  53164. */
  53165. floorMeshes?: AbstractMesh[];
  53166. /**
  53167. * use this rendering group id for the meshes (optional)
  53168. */
  53169. renderingGroupId?: number;
  53170. /**
  53171. * Should teleportation move only to snap points
  53172. */
  53173. snapPointsOnly?: boolean;
  53174. /**
  53175. * An array of points to which the teleportation will snap to.
  53176. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  53177. */
  53178. snapPositions?: Vector3[];
  53179. /**
  53180. * How close should the teleportation ray be in order to snap to position.
  53181. * Default to 0.8 units (meters)
  53182. */
  53183. snapToPositionRadius?: number;
  53184. /**
  53185. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  53186. * If you want to support rotation, make sure your mesh has a direction indicator.
  53187. *
  53188. * When left untouched, the default mesh will be initialized.
  53189. */
  53190. teleportationTargetMesh?: AbstractMesh;
  53191. /**
  53192. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  53193. */
  53194. timeToTeleport?: number;
  53195. /**
  53196. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  53197. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  53198. */
  53199. useMainComponentOnly?: boolean;
  53200. /**
  53201. * Should meshes created here be added to a utility layer or the main scene
  53202. */
  53203. useUtilityLayer?: boolean;
  53204. /**
  53205. * Babylon XR Input class for controller
  53206. */
  53207. xrInput: WebXRInput;
  53208. /**
  53209. * Meshes that the teleportation ray cannot go through
  53210. */
  53211. pickBlockerMeshes?: AbstractMesh[];
  53212. /**
  53213. * Should teleport work only on a specific hand?
  53214. */
  53215. forceHandedness?: XRHandedness;
  53216. /**
  53217. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  53218. */
  53219. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  53220. }
  53221. /**
  53222. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  53223. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  53224. * the input of the attached controllers.
  53225. */
  53226. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  53227. private _options;
  53228. private _controllers;
  53229. private _currentTeleportationControllerId;
  53230. private _floorMeshes;
  53231. private _quadraticBezierCurve;
  53232. private _selectionFeature;
  53233. private _snapToPositions;
  53234. private _snappedToPoint;
  53235. private _teleportationRingMaterial?;
  53236. private _tmpRay;
  53237. private _tmpVector;
  53238. private _tmpQuaternion;
  53239. /**
  53240. * The module's name
  53241. */
  53242. static readonly Name: string;
  53243. /**
  53244. * The (Babylon) version of this module.
  53245. * This is an integer representing the implementation version.
  53246. * This number does not correspond to the webxr specs version
  53247. */
  53248. static readonly Version: number;
  53249. /**
  53250. * Is movement backwards enabled
  53251. */
  53252. backwardsMovementEnabled: boolean;
  53253. /**
  53254. * Distance to travel when moving backwards
  53255. */
  53256. backwardsTeleportationDistance: number;
  53257. /**
  53258. * The distance from the user to the inspection point in the direction of the controller
  53259. * A higher number will allow the user to move further
  53260. * defaults to 5 (meters, in xr units)
  53261. */
  53262. parabolicCheckRadius: number;
  53263. /**
  53264. * Should the module support parabolic ray on top of direct ray
  53265. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  53266. * Very helpful when moving between floors / different heights
  53267. */
  53268. parabolicRayEnabled: boolean;
  53269. /**
  53270. * The second type of ray - straight line.
  53271. * Should it be enabled or should the parabolic line be the only one.
  53272. */
  53273. straightRayEnabled: boolean;
  53274. /**
  53275. * How much rotation should be applied when rotating right and left
  53276. */
  53277. rotationAngle: number;
  53278. private _rotationEnabled;
  53279. /**
  53280. * Is rotation enabled when moving forward?
  53281. * Disabling this feature will prevent the user from deciding the direction when teleporting
  53282. */
  53283. get rotationEnabled(): boolean;
  53284. /**
  53285. * Sets wether rotation is enabled or not
  53286. * @param enabled is rotation enabled when teleportation is shown
  53287. */
  53288. set rotationEnabled(enabled: boolean);
  53289. /**
  53290. * Exposes the currently set teleportation target mesh.
  53291. */
  53292. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  53293. /**
  53294. * constructs a new anchor system
  53295. * @param _xrSessionManager an instance of WebXRSessionManager
  53296. * @param _options configuration object for this feature
  53297. */
  53298. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  53299. /**
  53300. * Get the snapPointsOnly flag
  53301. */
  53302. get snapPointsOnly(): boolean;
  53303. /**
  53304. * Sets the snapPointsOnly flag
  53305. * @param snapToPoints should teleportation be exclusively to snap points
  53306. */
  53307. set snapPointsOnly(snapToPoints: boolean);
  53308. /**
  53309. * Add a new mesh to the floor meshes array
  53310. * @param mesh the mesh to use as floor mesh
  53311. */
  53312. addFloorMesh(mesh: AbstractMesh): void;
  53313. /**
  53314. * Add a new snap-to point to fix teleportation to this position
  53315. * @param newSnapPoint The new Snap-To point
  53316. */
  53317. addSnapPoint(newSnapPoint: Vector3): void;
  53318. attach(): boolean;
  53319. detach(): boolean;
  53320. dispose(): void;
  53321. /**
  53322. * Remove a mesh from the floor meshes array
  53323. * @param mesh the mesh to remove
  53324. */
  53325. removeFloorMesh(mesh: AbstractMesh): void;
  53326. /**
  53327. * Remove a mesh from the floor meshes array using its name
  53328. * @param name the mesh name to remove
  53329. */
  53330. removeFloorMeshByName(name: string): void;
  53331. /**
  53332. * 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
  53333. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  53334. * @returns was the point found and removed or not
  53335. */
  53336. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  53337. /**
  53338. * This function sets a selection feature that will be disabled when
  53339. * the forward ray is shown and will be reattached when hidden.
  53340. * This is used to remove the selection rays when moving.
  53341. * @param selectionFeature the feature to disable when forward movement is enabled
  53342. */
  53343. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  53344. protected _onXRFrame(_xrFrame: XRFrame): void;
  53345. private _attachController;
  53346. private _createDefaultTargetMesh;
  53347. private _detachController;
  53348. private _findClosestSnapPointWithRadius;
  53349. private _setTargetMeshPosition;
  53350. private _setTargetMeshVisibility;
  53351. private _showParabolicPath;
  53352. private _teleportForward;
  53353. }
  53354. }
  53355. declare module BABYLON {
  53356. /**
  53357. * Options for the default xr helper
  53358. */
  53359. export class WebXRDefaultExperienceOptions {
  53360. /**
  53361. * Enable or disable default UI to enter XR
  53362. */
  53363. disableDefaultUI?: boolean;
  53364. /**
  53365. * Should teleportation not initialize. defaults to false.
  53366. */
  53367. disableTeleportation?: boolean;
  53368. /**
  53369. * Floor meshes that will be used for teleport
  53370. */
  53371. floorMeshes?: Array<AbstractMesh>;
  53372. /**
  53373. * If set to true, the first frame will not be used to reset position
  53374. * The first frame is mainly used when copying transformation from the old camera
  53375. * Mainly used in AR
  53376. */
  53377. ignoreNativeCameraTransformation?: boolean;
  53378. /**
  53379. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  53380. */
  53381. inputOptions?: IWebXRInputOptions;
  53382. /**
  53383. * optional configuration for the output canvas
  53384. */
  53385. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  53386. /**
  53387. * optional UI options. This can be used among other to change session mode and reference space type
  53388. */
  53389. uiOptions?: WebXREnterExitUIOptions;
  53390. /**
  53391. * When loading teleportation and pointer select, use stable versions instead of latest.
  53392. */
  53393. useStablePlugins?: boolean;
  53394. /**
  53395. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  53396. */
  53397. renderingGroupId?: number;
  53398. /**
  53399. * A list of optional features to init the session with
  53400. * If set to true, all features we support will be added
  53401. */
  53402. optionalFeatures?: boolean | string[];
  53403. }
  53404. /**
  53405. * Default experience which provides a similar setup to the previous webVRExperience
  53406. */
  53407. export class WebXRDefaultExperience {
  53408. /**
  53409. * Base experience
  53410. */
  53411. baseExperience: WebXRExperienceHelper;
  53412. /**
  53413. * Enables ui for entering/exiting xr
  53414. */
  53415. enterExitUI: WebXREnterExitUI;
  53416. /**
  53417. * Input experience extension
  53418. */
  53419. input: WebXRInput;
  53420. /**
  53421. * Enables laser pointer and selection
  53422. */
  53423. pointerSelection: WebXRControllerPointerSelection;
  53424. /**
  53425. * Default target xr should render to
  53426. */
  53427. renderTarget: WebXRRenderTarget;
  53428. /**
  53429. * Enables teleportation
  53430. */
  53431. teleportation: WebXRMotionControllerTeleportation;
  53432. private constructor();
  53433. /**
  53434. * Creates the default xr experience
  53435. * @param scene scene
  53436. * @param options options for basic configuration
  53437. * @returns resulting WebXRDefaultExperience
  53438. */
  53439. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53440. /**
  53441. * DIsposes of the experience helper
  53442. */
  53443. dispose(): void;
  53444. }
  53445. }
  53446. declare module BABYLON {
  53447. /**
  53448. * Options to modify the vr teleportation behavior.
  53449. */
  53450. export interface VRTeleportationOptions {
  53451. /**
  53452. * The name of the mesh which should be used as the teleportation floor. (default: null)
  53453. */
  53454. floorMeshName?: string;
  53455. /**
  53456. * A list of meshes to be used as the teleportation floor. (default: empty)
  53457. */
  53458. floorMeshes?: Mesh[];
  53459. /**
  53460. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  53461. */
  53462. teleportationMode?: number;
  53463. /**
  53464. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  53465. */
  53466. teleportationTime?: number;
  53467. /**
  53468. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  53469. */
  53470. teleportationSpeed?: number;
  53471. /**
  53472. * The easing function used in the animation or null for Linear. (default CircleEase)
  53473. */
  53474. easingFunction?: EasingFunction;
  53475. }
  53476. /**
  53477. * Options to modify the vr experience helper's behavior.
  53478. */
  53479. export interface VRExperienceHelperOptions extends WebVROptions {
  53480. /**
  53481. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  53482. */
  53483. createDeviceOrientationCamera?: boolean;
  53484. /**
  53485. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  53486. */
  53487. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  53488. /**
  53489. * Uses the main button on the controller to toggle the laser casted. (default: true)
  53490. */
  53491. laserToggle?: boolean;
  53492. /**
  53493. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  53494. */
  53495. floorMeshes?: Mesh[];
  53496. /**
  53497. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  53498. */
  53499. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  53500. /**
  53501. * Defines if WebXR should be used instead of WebVR (if available)
  53502. */
  53503. useXR?: boolean;
  53504. }
  53505. /**
  53506. * Event containing information after VR has been entered
  53507. */
  53508. export class OnAfterEnteringVRObservableEvent {
  53509. /**
  53510. * If entering vr was successful
  53511. */
  53512. success: boolean;
  53513. }
  53514. /**
  53515. * Helps to quickly add VR support to an existing scene.
  53516. * See https://doc.babylonjs.com/how_to/webvr_helper
  53517. */
  53518. export class VRExperienceHelper {
  53519. /** Options to modify the vr experience helper's behavior. */
  53520. webVROptions: VRExperienceHelperOptions;
  53521. private _scene;
  53522. private _position;
  53523. private _btnVR;
  53524. private _btnVRDisplayed;
  53525. private _webVRsupported;
  53526. private _webVRready;
  53527. private _webVRrequesting;
  53528. private _webVRpresenting;
  53529. private _hasEnteredVR;
  53530. private _fullscreenVRpresenting;
  53531. private _inputElement;
  53532. private _webVRCamera;
  53533. private _vrDeviceOrientationCamera;
  53534. private _deviceOrientationCamera;
  53535. private _existingCamera;
  53536. private _onKeyDown;
  53537. private _onVrDisplayPresentChange;
  53538. private _onVRDisplayChanged;
  53539. private _onVRRequestPresentStart;
  53540. private _onVRRequestPresentComplete;
  53541. /**
  53542. * 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)
  53543. */
  53544. enableGazeEvenWhenNoPointerLock: boolean;
  53545. /**
  53546. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  53547. */
  53548. exitVROnDoubleTap: boolean;
  53549. /**
  53550. * Observable raised right before entering VR.
  53551. */
  53552. onEnteringVRObservable: Observable<VRExperienceHelper>;
  53553. /**
  53554. * Observable raised when entering VR has completed.
  53555. */
  53556. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  53557. /**
  53558. * Observable raised when exiting VR.
  53559. */
  53560. onExitingVRObservable: Observable<VRExperienceHelper>;
  53561. /**
  53562. * Observable raised when controller mesh is loaded.
  53563. */
  53564. onControllerMeshLoadedObservable: Observable<WebVRController>;
  53565. /** Return this.onEnteringVRObservable
  53566. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  53567. */
  53568. get onEnteringVR(): Observable<VRExperienceHelper>;
  53569. /** Return this.onExitingVRObservable
  53570. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  53571. */
  53572. get onExitingVR(): Observable<VRExperienceHelper>;
  53573. /** Return this.onControllerMeshLoadedObservable
  53574. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  53575. */
  53576. get onControllerMeshLoaded(): Observable<WebVRController>;
  53577. private _rayLength;
  53578. private _useCustomVRButton;
  53579. private _teleportationRequested;
  53580. private _teleportActive;
  53581. private _floorMeshName;
  53582. private _floorMeshesCollection;
  53583. private _teleportationMode;
  53584. private _teleportationTime;
  53585. private _teleportationSpeed;
  53586. private _teleportationEasing;
  53587. private _rotationAllowed;
  53588. private _teleportBackwardsVector;
  53589. private _teleportationTarget;
  53590. private _isDefaultTeleportationTarget;
  53591. private _postProcessMove;
  53592. private _teleportationFillColor;
  53593. private _teleportationBorderColor;
  53594. private _rotationAngle;
  53595. private _haloCenter;
  53596. private _cameraGazer;
  53597. private _padSensibilityUp;
  53598. private _padSensibilityDown;
  53599. private _leftController;
  53600. private _rightController;
  53601. private _gazeColor;
  53602. private _laserColor;
  53603. private _pickedLaserColor;
  53604. private _pickedGazeColor;
  53605. /**
  53606. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  53607. */
  53608. onNewMeshSelected: Observable<AbstractMesh>;
  53609. /**
  53610. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  53611. * This observable will provide the mesh and the controller used to select the mesh
  53612. */
  53613. onMeshSelectedWithController: Observable<{
  53614. mesh: AbstractMesh;
  53615. controller: WebVRController;
  53616. }>;
  53617. /**
  53618. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  53619. */
  53620. onNewMeshPicked: Observable<PickingInfo>;
  53621. private _circleEase;
  53622. /**
  53623. * Observable raised before camera teleportation
  53624. */
  53625. onBeforeCameraTeleport: Observable<Vector3>;
  53626. /**
  53627. * Observable raised after camera teleportation
  53628. */
  53629. onAfterCameraTeleport: Observable<Vector3>;
  53630. /**
  53631. * Observable raised when current selected mesh gets unselected
  53632. */
  53633. onSelectedMeshUnselected: Observable<AbstractMesh>;
  53634. private _raySelectionPredicate;
  53635. /**
  53636. * To be optionaly changed by user to define custom ray selection
  53637. */
  53638. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  53639. /**
  53640. * To be optionaly changed by user to define custom selection logic (after ray selection)
  53641. */
  53642. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53643. /**
  53644. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  53645. */
  53646. teleportationEnabled: boolean;
  53647. private _defaultHeight;
  53648. private _teleportationInitialized;
  53649. private _interactionsEnabled;
  53650. private _interactionsRequested;
  53651. private _displayGaze;
  53652. private _displayLaserPointer;
  53653. /**
  53654. * The mesh used to display where the user is going to teleport.
  53655. */
  53656. get teleportationTarget(): Mesh;
  53657. /**
  53658. * Sets the mesh to be used to display where the user is going to teleport.
  53659. */
  53660. set teleportationTarget(value: Mesh);
  53661. /**
  53662. * 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
  53663. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  53664. * See https://doc.babylonjs.com/resources/baking_transformations
  53665. */
  53666. get gazeTrackerMesh(): Mesh;
  53667. set gazeTrackerMesh(value: Mesh);
  53668. /**
  53669. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  53670. */
  53671. updateGazeTrackerScale: boolean;
  53672. /**
  53673. * If the gaze trackers color should be updated when selecting meshes
  53674. */
  53675. updateGazeTrackerColor: boolean;
  53676. /**
  53677. * If the controller laser color should be updated when selecting meshes
  53678. */
  53679. updateControllerLaserColor: boolean;
  53680. /**
  53681. * The gaze tracking mesh corresponding to the left controller
  53682. */
  53683. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  53684. /**
  53685. * The gaze tracking mesh corresponding to the right controller
  53686. */
  53687. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  53688. /**
  53689. * If the ray of the gaze should be displayed.
  53690. */
  53691. get displayGaze(): boolean;
  53692. /**
  53693. * Sets if the ray of the gaze should be displayed.
  53694. */
  53695. set displayGaze(value: boolean);
  53696. /**
  53697. * If the ray of the LaserPointer should be displayed.
  53698. */
  53699. get displayLaserPointer(): boolean;
  53700. /**
  53701. * Sets if the ray of the LaserPointer should be displayed.
  53702. */
  53703. set displayLaserPointer(value: boolean);
  53704. /**
  53705. * The deviceOrientationCamera used as the camera when not in VR.
  53706. */
  53707. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  53708. /**
  53709. * Based on the current WebVR support, returns the current VR camera used.
  53710. */
  53711. get currentVRCamera(): Nullable<Camera>;
  53712. /**
  53713. * The webVRCamera which is used when in VR.
  53714. */
  53715. get webVRCamera(): WebVRFreeCamera;
  53716. /**
  53717. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  53718. */
  53719. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  53720. /**
  53721. * The html button that is used to trigger entering into VR.
  53722. */
  53723. get vrButton(): Nullable<HTMLButtonElement>;
  53724. private get _teleportationRequestInitiated();
  53725. /**
  53726. * Defines whether or not Pointer lock should be requested when switching to
  53727. * full screen.
  53728. */
  53729. requestPointerLockOnFullScreen: boolean;
  53730. /**
  53731. * If asking to force XR, this will be populated with the default xr experience
  53732. */
  53733. xr: WebXRDefaultExperience;
  53734. /**
  53735. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  53736. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  53737. */
  53738. xrTestDone: boolean;
  53739. /**
  53740. * Instantiates a VRExperienceHelper.
  53741. * Helps to quickly add VR support to an existing scene.
  53742. * @param scene The scene the VRExperienceHelper belongs to.
  53743. * @param webVROptions Options to modify the vr experience helper's behavior.
  53744. */
  53745. constructor(scene: Scene,
  53746. /** Options to modify the vr experience helper's behavior. */
  53747. webVROptions?: VRExperienceHelperOptions);
  53748. private completeVRInit;
  53749. private _onDefaultMeshLoaded;
  53750. private _onResize;
  53751. private _onFullscreenChange;
  53752. /**
  53753. * Gets a value indicating if we are currently in VR mode.
  53754. */
  53755. get isInVRMode(): boolean;
  53756. private onVrDisplayPresentChange;
  53757. private onVRDisplayChanged;
  53758. private moveButtonToBottomRight;
  53759. private displayVRButton;
  53760. private updateButtonVisibility;
  53761. private _cachedAngularSensibility;
  53762. /**
  53763. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  53764. * Otherwise, will use the fullscreen API.
  53765. */
  53766. enterVR(): void;
  53767. /**
  53768. * Attempt to exit VR, or fullscreen.
  53769. */
  53770. exitVR(): void;
  53771. /**
  53772. * The position of the vr experience helper.
  53773. */
  53774. get position(): Vector3;
  53775. /**
  53776. * Sets the position of the vr experience helper.
  53777. */
  53778. set position(value: Vector3);
  53779. /**
  53780. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  53781. */
  53782. enableInteractions(): void;
  53783. private get _noControllerIsActive();
  53784. private beforeRender;
  53785. private _isTeleportationFloor;
  53786. /**
  53787. * Adds a floor mesh to be used for teleportation.
  53788. * @param floorMesh the mesh to be used for teleportation.
  53789. */
  53790. addFloorMesh(floorMesh: Mesh): void;
  53791. /**
  53792. * Removes a floor mesh from being used for teleportation.
  53793. * @param floorMesh the mesh to be removed.
  53794. */
  53795. removeFloorMesh(floorMesh: Mesh): void;
  53796. /**
  53797. * Enables interactions and teleportation using the VR controllers and gaze.
  53798. * @param vrTeleportationOptions options to modify teleportation behavior.
  53799. */
  53800. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  53801. private _onNewGamepadConnected;
  53802. private _tryEnableInteractionOnController;
  53803. private _onNewGamepadDisconnected;
  53804. private _enableInteractionOnController;
  53805. private _checkTeleportWithRay;
  53806. private _checkRotate;
  53807. private _checkTeleportBackwards;
  53808. private _enableTeleportationOnController;
  53809. private _createTeleportationCircles;
  53810. private _displayTeleportationTarget;
  53811. private _hideTeleportationTarget;
  53812. private _rotateCamera;
  53813. private _moveTeleportationSelectorTo;
  53814. private _workingVector;
  53815. private _workingQuaternion;
  53816. private _workingMatrix;
  53817. /**
  53818. * Time Constant Teleportation Mode
  53819. */
  53820. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  53821. /**
  53822. * Speed Constant Teleportation Mode
  53823. */
  53824. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  53825. /**
  53826. * Teleports the users feet to the desired location
  53827. * @param location The location where the user's feet should be placed
  53828. */
  53829. teleportCamera(location: Vector3): void;
  53830. private _convertNormalToDirectionOfRay;
  53831. private _castRayAndSelectObject;
  53832. private _notifySelectedMeshUnselected;
  53833. /**
  53834. * Permanently set new colors for the laser pointer
  53835. * @param color the new laser color
  53836. * @param pickedColor the new laser color when picked mesh detected
  53837. */
  53838. setLaserColor(color: Color3, pickedColor?: Color3): void;
  53839. /**
  53840. * Set lighting enabled / disabled on the laser pointer of both controllers
  53841. * @param enabled should the lighting be enabled on the laser pointer
  53842. */
  53843. setLaserLightingState(enabled?: boolean): void;
  53844. /**
  53845. * Permanently set new colors for the gaze pointer
  53846. * @param color the new gaze color
  53847. * @param pickedColor the new gaze color when picked mesh detected
  53848. */
  53849. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53850. /**
  53851. * Sets the color of the laser ray from the vr controllers.
  53852. * @param color new color for the ray.
  53853. */
  53854. changeLaserColor(color: Color3): void;
  53855. /**
  53856. * Sets the color of the ray from the vr headsets gaze.
  53857. * @param color new color for the ray.
  53858. */
  53859. changeGazeColor(color: Color3): void;
  53860. /**
  53861. * Exits VR and disposes of the vr experience helper
  53862. */
  53863. dispose(): void;
  53864. /**
  53865. * Gets the name of the VRExperienceHelper class
  53866. * @returns "VRExperienceHelper"
  53867. */
  53868. getClassName(): string;
  53869. }
  53870. }
  53871. declare module BABYLON {
  53872. /**
  53873. * Contains an array of blocks representing the octree
  53874. */
  53875. export interface IOctreeContainer<T> {
  53876. /**
  53877. * Blocks within the octree
  53878. */
  53879. blocks: Array<OctreeBlock<T>>;
  53880. }
  53881. /**
  53882. * Class used to store a cell in an octree
  53883. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53884. */
  53885. export class OctreeBlock<T> {
  53886. /**
  53887. * Gets the content of the current block
  53888. */
  53889. entries: T[];
  53890. /**
  53891. * Gets the list of block children
  53892. */
  53893. blocks: Array<OctreeBlock<T>>;
  53894. private _depth;
  53895. private _maxDepth;
  53896. private _capacity;
  53897. private _minPoint;
  53898. private _maxPoint;
  53899. private _boundingVectors;
  53900. private _creationFunc;
  53901. /**
  53902. * Creates a new block
  53903. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53904. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53905. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53906. * @param depth defines the current depth of this block in the octree
  53907. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53908. * @param creationFunc defines a callback to call when an element is added to the block
  53909. */
  53910. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53911. /**
  53912. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53913. */
  53914. get capacity(): number;
  53915. /**
  53916. * Gets the minimum vector (in world space) of the block's bounding box
  53917. */
  53918. get minPoint(): Vector3;
  53919. /**
  53920. * Gets the maximum vector (in world space) of the block's bounding box
  53921. */
  53922. get maxPoint(): Vector3;
  53923. /**
  53924. * Add a new element to this block
  53925. * @param entry defines the element to add
  53926. */
  53927. addEntry(entry: T): void;
  53928. /**
  53929. * Remove an element from this block
  53930. * @param entry defines the element to remove
  53931. */
  53932. removeEntry(entry: T): void;
  53933. /**
  53934. * Add an array of elements to this block
  53935. * @param entries defines the array of elements to add
  53936. */
  53937. addEntries(entries: T[]): void;
  53938. /**
  53939. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53940. * @param frustumPlanes defines the frustum planes to test
  53941. * @param selection defines the array to store current content if selection is positive
  53942. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53943. */
  53944. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53945. /**
  53946. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53947. * @param sphereCenter defines the bounding sphere center
  53948. * @param sphereRadius defines the bounding sphere radius
  53949. * @param selection defines the array to store current content if selection is positive
  53950. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53951. */
  53952. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53953. /**
  53954. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53955. * @param ray defines the ray to test with
  53956. * @param selection defines the array to store current content if selection is positive
  53957. */
  53958. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53959. /**
  53960. * Subdivide the content into child blocks (this block will then be empty)
  53961. */
  53962. createInnerBlocks(): void;
  53963. /**
  53964. * @hidden
  53965. */
  53966. 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;
  53967. }
  53968. }
  53969. declare module BABYLON {
  53970. /**
  53971. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53972. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53973. */
  53974. export class Octree<T> {
  53975. /** 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.) */
  53976. maxDepth: number;
  53977. /**
  53978. * Blocks within the octree containing objects
  53979. */
  53980. blocks: Array<OctreeBlock<T>>;
  53981. /**
  53982. * Content stored in the octree
  53983. */
  53984. dynamicContent: T[];
  53985. private _maxBlockCapacity;
  53986. private _selectionContent;
  53987. private _creationFunc;
  53988. /**
  53989. * Creates a octree
  53990. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53991. * @param creationFunc function to be used to instatiate the octree
  53992. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53993. * @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.)
  53994. */
  53995. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53996. /** 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.) */
  53997. maxDepth?: number);
  53998. /**
  53999. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  54000. * @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);
  54001. * @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);
  54002. * @param entries meshes to be added to the octree blocks
  54003. */
  54004. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  54005. /**
  54006. * Adds a mesh to the octree
  54007. * @param entry Mesh to add to the octree
  54008. */
  54009. addMesh(entry: T): void;
  54010. /**
  54011. * Remove an element from the octree
  54012. * @param entry defines the element to remove
  54013. */
  54014. removeMesh(entry: T): void;
  54015. /**
  54016. * Selects an array of meshes within the frustum
  54017. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  54018. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  54019. * @returns array of meshes within the frustum
  54020. */
  54021. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  54022. /**
  54023. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  54024. * @param sphereCenter defines the bounding sphere center
  54025. * @param sphereRadius defines the bounding sphere radius
  54026. * @param allowDuplicate defines if the selection array can contains duplicated entries
  54027. * @returns an array of objects that intersect the sphere
  54028. */
  54029. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  54030. /**
  54031. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  54032. * @param ray defines the ray to test with
  54033. * @returns array of intersected objects
  54034. */
  54035. intersectsRay(ray: Ray): SmartArray<T>;
  54036. /**
  54037. * Adds a mesh into the octree block if it intersects the block
  54038. */
  54039. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  54040. /**
  54041. * Adds a submesh into the octree block if it intersects the block
  54042. */
  54043. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  54044. }
  54045. }
  54046. declare module BABYLON {
  54047. interface Scene {
  54048. /**
  54049. * @hidden
  54050. * Backing Filed
  54051. */
  54052. _selectionOctree: Octree<AbstractMesh>;
  54053. /**
  54054. * Gets the octree used to boost mesh selection (picking)
  54055. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54056. */
  54057. selectionOctree: Octree<AbstractMesh>;
  54058. /**
  54059. * Creates or updates the octree used to boost selection (picking)
  54060. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54061. * @param maxCapacity defines the maximum capacity per leaf
  54062. * @param maxDepth defines the maximum depth of the octree
  54063. * @returns an octree of AbstractMesh
  54064. */
  54065. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  54066. }
  54067. interface AbstractMesh {
  54068. /**
  54069. * @hidden
  54070. * Backing Field
  54071. */
  54072. _submeshesOctree: Octree<SubMesh>;
  54073. /**
  54074. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  54075. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  54076. * @param maxCapacity defines the maximum size of each block (64 by default)
  54077. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  54078. * @returns the new octree
  54079. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  54080. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  54081. */
  54082. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  54083. }
  54084. /**
  54085. * Defines the octree scene component responsible to manage any octrees
  54086. * in a given scene.
  54087. */
  54088. export class OctreeSceneComponent {
  54089. /**
  54090. * The component name help to identify the component in the list of scene components.
  54091. */
  54092. readonly name: string;
  54093. /**
  54094. * The scene the component belongs to.
  54095. */
  54096. scene: Scene;
  54097. /**
  54098. * Indicates if the meshes have been checked to make sure they are isEnabled()
  54099. */
  54100. readonly checksIsEnabled: boolean;
  54101. /**
  54102. * Creates a new instance of the component for the given scene
  54103. * @param scene Defines the scene to register the component in
  54104. */
  54105. constructor(scene: Scene);
  54106. /**
  54107. * Registers the component in a given scene
  54108. */
  54109. register(): void;
  54110. /**
  54111. * Return the list of active meshes
  54112. * @returns the list of active meshes
  54113. */
  54114. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  54115. /**
  54116. * Return the list of active sub meshes
  54117. * @param mesh The mesh to get the candidates sub meshes from
  54118. * @returns the list of active sub meshes
  54119. */
  54120. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  54121. private _tempRay;
  54122. /**
  54123. * Return the list of sub meshes intersecting with a given local ray
  54124. * @param mesh defines the mesh to find the submesh for
  54125. * @param localRay defines the ray in local space
  54126. * @returns the list of intersecting sub meshes
  54127. */
  54128. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  54129. /**
  54130. * Return the list of sub meshes colliding with a collider
  54131. * @param mesh defines the mesh to find the submesh for
  54132. * @param collider defines the collider to evaluate the collision against
  54133. * @returns the list of colliding sub meshes
  54134. */
  54135. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  54136. /**
  54137. * Rebuilds the elements related to this component in case of
  54138. * context lost for instance.
  54139. */
  54140. rebuild(): void;
  54141. /**
  54142. * Disposes the component and the associated ressources.
  54143. */
  54144. dispose(): void;
  54145. }
  54146. }
  54147. declare module BABYLON {
  54148. /**
  54149. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  54150. */
  54151. export interface GizmoAxisCache {
  54152. /** Mesh used to runder the Gizmo */
  54153. gizmoMeshes: Mesh[];
  54154. /** Mesh used to detect user interaction with Gizmo */
  54155. colliderMeshes: Mesh[];
  54156. /** Material used to inicate color of gizmo mesh */
  54157. material: StandardMaterial;
  54158. /** Material used to inicate hover state of the Gizmo */
  54159. hoverMaterial: StandardMaterial;
  54160. /** Material used to inicate disabled state of the Gizmo */
  54161. disableMaterial: StandardMaterial;
  54162. /** Used to indicate Active state of the Gizmo */
  54163. active: boolean;
  54164. }
  54165. /**
  54166. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  54167. */
  54168. export class Gizmo implements IDisposable {
  54169. /** The utility layer the gizmo will be added to */
  54170. gizmoLayer: UtilityLayerRenderer;
  54171. /**
  54172. * The root mesh of the gizmo
  54173. */
  54174. _rootMesh: Mesh;
  54175. private _attachedMesh;
  54176. private _attachedNode;
  54177. /**
  54178. * Ratio for the scale of the gizmo (Default: 1)
  54179. */
  54180. protected _scaleRatio: number;
  54181. /**
  54182. * boolean updated by pointermove when a gizmo mesh is hovered
  54183. */
  54184. protected _isHovered: boolean;
  54185. /**
  54186. * Ratio for the scale of the gizmo (Default: 1)
  54187. */
  54188. set scaleRatio(value: number);
  54189. get scaleRatio(): number;
  54190. /**
  54191. * True when the mouse pointer is hovered a gizmo mesh
  54192. */
  54193. get isHovered(): boolean;
  54194. /**
  54195. * If a custom mesh has been set (Default: false)
  54196. */
  54197. protected _customMeshSet: boolean;
  54198. /**
  54199. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  54200. * * When set, interactions will be enabled
  54201. */
  54202. get attachedMesh(): Nullable<AbstractMesh>;
  54203. set attachedMesh(value: Nullable<AbstractMesh>);
  54204. /**
  54205. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  54206. * * When set, interactions will be enabled
  54207. */
  54208. get attachedNode(): Nullable<Node>;
  54209. set attachedNode(value: Nullable<Node>);
  54210. /**
  54211. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54212. * @param mesh The mesh to replace the default mesh of the gizmo
  54213. */
  54214. setCustomMesh(mesh: Mesh): void;
  54215. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  54216. /**
  54217. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  54218. */
  54219. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54220. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54221. /**
  54222. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  54223. */
  54224. updateGizmoPositionToMatchAttachedMesh: boolean;
  54225. /**
  54226. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  54227. */
  54228. updateScale: boolean;
  54229. protected _interactionsEnabled: boolean;
  54230. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54231. private _beforeRenderObserver;
  54232. private _tempQuaternion;
  54233. private _tempVector;
  54234. private _tempVector2;
  54235. private _tempMatrix1;
  54236. private _tempMatrix2;
  54237. private _rightHandtoLeftHandMatrix;
  54238. /**
  54239. * Creates a gizmo
  54240. * @param gizmoLayer The utility layer the gizmo will be added to
  54241. */
  54242. constructor(
  54243. /** The utility layer the gizmo will be added to */
  54244. gizmoLayer?: UtilityLayerRenderer);
  54245. /**
  54246. * Updates the gizmo to match the attached mesh's position/rotation
  54247. */
  54248. protected _update(): void;
  54249. /**
  54250. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  54251. * @param value Node, TransformNode or mesh
  54252. */
  54253. protected _matrixChanged(): void;
  54254. /**
  54255. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  54256. * @param gizmoLayer The utility layer the gizmo will be added to
  54257. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54258. * @returns {Observer<PointerInfo>} pointerObserver
  54259. */
  54260. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  54261. /**
  54262. * Disposes of the gizmo
  54263. */
  54264. dispose(): void;
  54265. }
  54266. }
  54267. declare module BABYLON {
  54268. /**
  54269. * Single plane drag gizmo
  54270. */
  54271. export class PlaneDragGizmo extends Gizmo {
  54272. /**
  54273. * Drag behavior responsible for the gizmos dragging interactions
  54274. */
  54275. dragBehavior: PointerDragBehavior;
  54276. private _pointerObserver;
  54277. /**
  54278. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54279. */
  54280. snapDistance: number;
  54281. /**
  54282. * Event that fires each time the gizmo snaps to a new location.
  54283. * * snapDistance is the the change in distance
  54284. */
  54285. onSnapObservable: Observable<{
  54286. snapDistance: number;
  54287. }>;
  54288. private _gizmoMesh;
  54289. private _coloredMaterial;
  54290. private _hoverMaterial;
  54291. private _disableMaterial;
  54292. private _isEnabled;
  54293. private _parent;
  54294. private _dragging;
  54295. /** @hidden */
  54296. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  54297. /**
  54298. * Creates a PlaneDragGizmo
  54299. * @param gizmoLayer The utility layer the gizmo will be added to
  54300. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  54301. * @param color The color of the gizmo
  54302. */
  54303. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  54304. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54305. /**
  54306. * If the gizmo is enabled
  54307. */
  54308. set isEnabled(value: boolean);
  54309. get isEnabled(): boolean;
  54310. /**
  54311. * Disposes of the gizmo
  54312. */
  54313. dispose(): void;
  54314. }
  54315. }
  54316. declare module BABYLON {
  54317. /**
  54318. * Single plane rotation gizmo
  54319. */
  54320. export class PlaneRotationGizmo extends Gizmo {
  54321. /**
  54322. * Drag behavior responsible for the gizmos dragging interactions
  54323. */
  54324. dragBehavior: PointerDragBehavior;
  54325. private _pointerObserver;
  54326. /**
  54327. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54328. */
  54329. snapDistance: number;
  54330. /**
  54331. * Event that fires each time the gizmo snaps to a new location.
  54332. * * snapDistance is the the change in distance
  54333. */
  54334. onSnapObservable: Observable<{
  54335. snapDistance: number;
  54336. }>;
  54337. private _isEnabled;
  54338. private _parent;
  54339. private _coloredMaterial;
  54340. private _hoverMaterial;
  54341. private _disableMaterial;
  54342. private _gizmoMesh;
  54343. private _rotationCircle;
  54344. private _dragging;
  54345. private static _CircleConstants;
  54346. /**
  54347. * Creates a PlaneRotationGizmo
  54348. * @param gizmoLayer The utility layer the gizmo will be added to
  54349. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54350. * @param color The color of the gizmo
  54351. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54352. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54353. * @param thickness display gizmo axis thickness
  54354. */
  54355. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54356. /** Create Geometry for Gizmo */
  54357. private _createGizmoMesh;
  54358. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54359. private setupRotationCircle;
  54360. private updateRotationPath;
  54361. private updateRotationCircle;
  54362. /**
  54363. * If the gizmo is enabled
  54364. */
  54365. set isEnabled(value: boolean);
  54366. get isEnabled(): boolean;
  54367. /**
  54368. * Disposes of the gizmo
  54369. */
  54370. dispose(): void;
  54371. }
  54372. }
  54373. declare module BABYLON {
  54374. /**
  54375. * Gizmo that enables rotating a mesh along 3 axis
  54376. */
  54377. export class RotationGizmo extends Gizmo {
  54378. /**
  54379. * Internal gizmo used for interactions on the x axis
  54380. */
  54381. xGizmo: PlaneRotationGizmo;
  54382. /**
  54383. * Internal gizmo used for interactions on the y axis
  54384. */
  54385. yGizmo: PlaneRotationGizmo;
  54386. /**
  54387. * Internal gizmo used for interactions on the z axis
  54388. */
  54389. zGizmo: PlaneRotationGizmo;
  54390. /** Fires an event when any of it's sub gizmos are dragged */
  54391. onDragStartObservable: Observable<unknown>;
  54392. /** Fires an event when any of it's sub gizmos are released from dragging */
  54393. onDragEndObservable: Observable<unknown>;
  54394. private _meshAttached;
  54395. private _nodeAttached;
  54396. private _observables;
  54397. /** Node Caching for quick lookup */
  54398. private _gizmoAxisCache;
  54399. get attachedMesh(): Nullable<AbstractMesh>;
  54400. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54401. get attachedNode(): Nullable<Node>;
  54402. set attachedNode(node: Nullable<Node>);
  54403. protected _checkBillboardTransform(): void;
  54404. /**
  54405. * True when the mouse pointer is hovering a gizmo mesh
  54406. */
  54407. get isHovered(): boolean;
  54408. /**
  54409. * Creates a RotationGizmo
  54410. * @param gizmoLayer The utility layer the gizmo will be added to
  54411. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54412. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54413. * @param thickness display gizmo axis thickness
  54414. */
  54415. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  54416. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54417. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54418. /**
  54419. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54420. */
  54421. set snapDistance(value: number);
  54422. get snapDistance(): number;
  54423. /**
  54424. * Ratio for the scale of the gizmo (Default: 1)
  54425. */
  54426. set scaleRatio(value: number);
  54427. get scaleRatio(): number;
  54428. /**
  54429. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54430. * @param mesh Axis gizmo mesh
  54431. * @param cache Gizmo axis definition used for reactive gizmo UI
  54432. */
  54433. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54434. /**
  54435. * Disposes of the gizmo
  54436. */
  54437. dispose(): void;
  54438. /**
  54439. * CustomMeshes are not supported by this gizmo
  54440. * @param mesh The mesh to replace the default mesh of the gizmo
  54441. */
  54442. setCustomMesh(mesh: Mesh): void;
  54443. }
  54444. }
  54445. declare module BABYLON {
  54446. /**
  54447. * Class containing static functions to help procedurally build meshes
  54448. */
  54449. export class PolyhedronBuilder {
  54450. /**
  54451. * Creates a polyhedron mesh
  54452. * * 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
  54453. * * The parameter `size` (positive float, default 1) sets the polygon size
  54454. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54455. * * 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`
  54456. * * 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
  54457. * * 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)`)
  54458. * * 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
  54459. * * 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
  54460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54461. * * 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
  54462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54463. * @param name defines the name of the mesh
  54464. * @param options defines the options used to create the mesh
  54465. * @param scene defines the hosting scene
  54466. * @returns the polyhedron mesh
  54467. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54468. */
  54469. static CreatePolyhedron(name: string, options: {
  54470. type?: number;
  54471. size?: number;
  54472. sizeX?: number;
  54473. sizeY?: number;
  54474. sizeZ?: number;
  54475. custom?: any;
  54476. faceUV?: Vector4[];
  54477. faceColors?: Color4[];
  54478. flat?: boolean;
  54479. updatable?: boolean;
  54480. sideOrientation?: number;
  54481. frontUVs?: Vector4;
  54482. backUVs?: Vector4;
  54483. }, scene?: Nullable<Scene>): Mesh;
  54484. }
  54485. }
  54486. declare module BABYLON {
  54487. /**
  54488. * Class containing static functions to help procedurally build meshes
  54489. */
  54490. export class BoxBuilder {
  54491. /**
  54492. * Creates a box mesh
  54493. * * The parameter `size` sets the size (float) of each box side (default 1)
  54494. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54495. * * 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)
  54496. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54498. * * 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
  54499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54500. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54501. * @param name defines the name of the mesh
  54502. * @param options defines the options used to create the mesh
  54503. * @param scene defines the hosting scene
  54504. * @returns the box mesh
  54505. */
  54506. static CreateBox(name: string, options: {
  54507. size?: number;
  54508. width?: number;
  54509. height?: number;
  54510. depth?: number;
  54511. faceUV?: Vector4[];
  54512. faceColors?: Color4[];
  54513. sideOrientation?: number;
  54514. frontUVs?: Vector4;
  54515. backUVs?: Vector4;
  54516. wrap?: boolean;
  54517. topBaseAt?: number;
  54518. bottomBaseAt?: number;
  54519. updatable?: boolean;
  54520. }, scene?: Nullable<Scene>): Mesh;
  54521. }
  54522. }
  54523. declare module BABYLON {
  54524. /**
  54525. * Single axis scale gizmo
  54526. */
  54527. export class AxisScaleGizmo extends Gizmo {
  54528. /**
  54529. * Drag behavior responsible for the gizmos dragging interactions
  54530. */
  54531. dragBehavior: PointerDragBehavior;
  54532. private _pointerObserver;
  54533. /**
  54534. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54535. */
  54536. snapDistance: number;
  54537. /**
  54538. * Event that fires each time the gizmo snaps to a new location.
  54539. * * snapDistance is the the change in distance
  54540. */
  54541. onSnapObservable: Observable<{
  54542. snapDistance: number;
  54543. }>;
  54544. /**
  54545. * If the scaling operation should be done on all axis (default: false)
  54546. */
  54547. uniformScaling: boolean;
  54548. /**
  54549. * Custom sensitivity value for the drag strength
  54550. */
  54551. sensitivity: number;
  54552. private _isEnabled;
  54553. private _parent;
  54554. private _gizmoMesh;
  54555. private _coloredMaterial;
  54556. private _hoverMaterial;
  54557. private _disableMaterial;
  54558. private _dragging;
  54559. private _tmpVector;
  54560. private _tmpMatrix;
  54561. private _tmpMatrix2;
  54562. /**
  54563. * Creates an AxisScaleGizmo
  54564. * @param gizmoLayer The utility layer the gizmo will be added to
  54565. * @param dragAxis The axis which the gizmo will be able to scale on
  54566. * @param color The color of the gizmo
  54567. * @param thickness display gizmo axis thickness
  54568. */
  54569. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  54570. /** Create Geometry for Gizmo */
  54571. private _createGizmoMesh;
  54572. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54573. /**
  54574. * If the gizmo is enabled
  54575. */
  54576. set isEnabled(value: boolean);
  54577. get isEnabled(): boolean;
  54578. /**
  54579. * Disposes of the gizmo
  54580. */
  54581. dispose(): void;
  54582. /**
  54583. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54584. * @param mesh The mesh to replace the default mesh of the gizmo
  54585. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54586. */
  54587. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54588. }
  54589. }
  54590. declare module BABYLON {
  54591. /**
  54592. * Gizmo that enables scaling a mesh along 3 axis
  54593. */
  54594. export class ScaleGizmo extends Gizmo {
  54595. /**
  54596. * Internal gizmo used for interactions on the x axis
  54597. */
  54598. xGizmo: AxisScaleGizmo;
  54599. /**
  54600. * Internal gizmo used for interactions on the y axis
  54601. */
  54602. yGizmo: AxisScaleGizmo;
  54603. /**
  54604. * Internal gizmo used for interactions on the z axis
  54605. */
  54606. zGizmo: AxisScaleGizmo;
  54607. /**
  54608. * Internal gizmo used to scale all axis equally
  54609. */
  54610. uniformScaleGizmo: AxisScaleGizmo;
  54611. private _meshAttached;
  54612. private _nodeAttached;
  54613. private _snapDistance;
  54614. private _uniformScalingMesh;
  54615. private _octahedron;
  54616. private _sensitivity;
  54617. private _coloredMaterial;
  54618. private _hoverMaterial;
  54619. private _disableMaterial;
  54620. private _observables;
  54621. /** Node Caching for quick lookup */
  54622. private _gizmoAxisCache;
  54623. /** Fires an event when any of it's sub gizmos are dragged */
  54624. onDragStartObservable: Observable<unknown>;
  54625. /** Fires an event when any of it's sub gizmos are released from dragging */
  54626. onDragEndObservable: Observable<unknown>;
  54627. get attachedMesh(): Nullable<AbstractMesh>;
  54628. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54629. get attachedNode(): Nullable<Node>;
  54630. set attachedNode(node: Nullable<Node>);
  54631. /**
  54632. * True when the mouse pointer is hovering a gizmo mesh
  54633. */
  54634. get isHovered(): boolean;
  54635. /**
  54636. * Creates a ScaleGizmo
  54637. * @param gizmoLayer The utility layer the gizmo will be added to
  54638. * @param thickness display gizmo axis thickness
  54639. */
  54640. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54641. /** Create Geometry for Gizmo */
  54642. private _createUniformScaleMesh;
  54643. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54644. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54645. /**
  54646. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54647. */
  54648. set snapDistance(value: number);
  54649. get snapDistance(): number;
  54650. /**
  54651. * Ratio for the scale of the gizmo (Default: 1)
  54652. */
  54653. set scaleRatio(value: number);
  54654. get scaleRatio(): number;
  54655. /**
  54656. * Sensitivity factor for dragging (Default: 1)
  54657. */
  54658. set sensitivity(value: number);
  54659. get sensitivity(): number;
  54660. /**
  54661. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54662. * @param mesh Axis gizmo mesh
  54663. * @param cache Gizmo axis definition used for reactive gizmo UI
  54664. */
  54665. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54666. /**
  54667. * Disposes of the gizmo
  54668. */
  54669. dispose(): void;
  54670. }
  54671. }
  54672. declare module BABYLON {
  54673. /**
  54674. * Bounding box gizmo
  54675. */
  54676. export class BoundingBoxGizmo extends Gizmo {
  54677. private _lineBoundingBox;
  54678. private _rotateSpheresParent;
  54679. private _scaleBoxesParent;
  54680. private _boundingDimensions;
  54681. private _renderObserver;
  54682. private _pointerObserver;
  54683. private _scaleDragSpeed;
  54684. private _tmpQuaternion;
  54685. private _tmpVector;
  54686. private _tmpRotationMatrix;
  54687. /**
  54688. * 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)
  54689. */
  54690. ignoreChildren: boolean;
  54691. /**
  54692. * 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)
  54693. */
  54694. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54695. /**
  54696. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54697. */
  54698. rotationSphereSize: number;
  54699. /**
  54700. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54701. */
  54702. scaleBoxSize: number;
  54703. /**
  54704. * 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)
  54705. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54706. */
  54707. fixedDragMeshScreenSize: boolean;
  54708. /**
  54709. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  54710. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  54711. */
  54712. fixedDragMeshBoundsSize: boolean;
  54713. /**
  54714. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54715. */
  54716. fixedDragMeshScreenSizeDistanceFactor: number;
  54717. /**
  54718. * Fired when a rotation sphere or scale box is dragged
  54719. */
  54720. onDragStartObservable: Observable<{}>;
  54721. /**
  54722. * Fired when a scale box is dragged
  54723. */
  54724. onScaleBoxDragObservable: Observable<{}>;
  54725. /**
  54726. * Fired when a scale box drag is ended
  54727. */
  54728. onScaleBoxDragEndObservable: Observable<{}>;
  54729. /**
  54730. * Fired when a rotation sphere is dragged
  54731. */
  54732. onRotationSphereDragObservable: Observable<{}>;
  54733. /**
  54734. * Fired when a rotation sphere drag is ended
  54735. */
  54736. onRotationSphereDragEndObservable: Observable<{}>;
  54737. /**
  54738. * 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)
  54739. */
  54740. scalePivot: Nullable<Vector3>;
  54741. /**
  54742. * Mesh used as a pivot to rotate the attached node
  54743. */
  54744. private _anchorMesh;
  54745. private _existingMeshScale;
  54746. private _dragMesh;
  54747. private pointerDragBehavior;
  54748. private coloredMaterial;
  54749. private hoverColoredMaterial;
  54750. /**
  54751. * Sets the color of the bounding box gizmo
  54752. * @param color the color to set
  54753. */
  54754. setColor(color: Color3): void;
  54755. /**
  54756. * Creates an BoundingBoxGizmo
  54757. * @param gizmoLayer The utility layer the gizmo will be added to
  54758. * @param color The color of the gizmo
  54759. */
  54760. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54761. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  54762. private _selectNode;
  54763. /**
  54764. * Updates the bounding box information for the Gizmo
  54765. */
  54766. updateBoundingBox(): void;
  54767. private _updateRotationSpheres;
  54768. private _updateScaleBoxes;
  54769. /**
  54770. * Enables rotation on the specified axis and disables rotation on the others
  54771. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54772. */
  54773. setEnabledRotationAxis(axis: string): void;
  54774. /**
  54775. * Enables/disables scaling
  54776. * @param enable if scaling should be enabled
  54777. * @param homogeneousScaling defines if scaling should only be homogeneous
  54778. */
  54779. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54780. private _updateDummy;
  54781. /**
  54782. * Enables a pointer drag behavior on the bounding box of the gizmo
  54783. */
  54784. enableDragBehavior(): void;
  54785. /**
  54786. * Disposes of the gizmo
  54787. */
  54788. dispose(): void;
  54789. /**
  54790. * 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)
  54791. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54792. * @returns the bounding box mesh with the passed in mesh as a child
  54793. */
  54794. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54795. /**
  54796. * CustomMeshes are not supported by this gizmo
  54797. * @param mesh The mesh to replace the default mesh of the gizmo
  54798. */
  54799. setCustomMesh(mesh: Mesh): void;
  54800. }
  54801. }
  54802. declare module BABYLON {
  54803. /**
  54804. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54805. */
  54806. export class GizmoManager implements IDisposable {
  54807. private scene;
  54808. /**
  54809. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54810. */
  54811. gizmos: {
  54812. positionGizmo: Nullable<PositionGizmo>;
  54813. rotationGizmo: Nullable<RotationGizmo>;
  54814. scaleGizmo: Nullable<ScaleGizmo>;
  54815. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54816. };
  54817. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54818. clearGizmoOnEmptyPointerEvent: boolean;
  54819. /** Fires an event when the manager is attached to a mesh */
  54820. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54821. /** Fires an event when the manager is attached to a node */
  54822. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54823. private _gizmosEnabled;
  54824. private _pointerObservers;
  54825. private _attachedMesh;
  54826. private _attachedNode;
  54827. private _boundingBoxColor;
  54828. private _defaultUtilityLayer;
  54829. private _defaultKeepDepthUtilityLayer;
  54830. private _thickness;
  54831. /** Node Caching for quick lookup */
  54832. private _gizmoAxisCache;
  54833. /**
  54834. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54835. */
  54836. boundingBoxDragBehavior: SixDofDragBehavior;
  54837. /**
  54838. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54839. */
  54840. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54841. /**
  54842. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54843. */
  54844. attachableNodes: Nullable<Array<Node>>;
  54845. /**
  54846. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54847. */
  54848. usePointerToAttachGizmos: boolean;
  54849. /**
  54850. * Utility layer that the bounding box gizmo belongs to
  54851. */
  54852. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54853. /**
  54854. * Utility layer that all gizmos besides bounding box belong to
  54855. */
  54856. get utilityLayer(): UtilityLayerRenderer;
  54857. /**
  54858. * True when the mouse pointer is hovering a gizmo mesh
  54859. */
  54860. get isHovered(): boolean;
  54861. /**
  54862. * Instatiates a gizmo manager
  54863. * @param scene the scene to overlay the gizmos on top of
  54864. * @param thickness display gizmo axis thickness
  54865. * @param utilityLayer the layer where gizmos are rendered
  54866. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  54867. */
  54868. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  54869. /**
  54870. * Subscribes to pointer down events, for attaching and detaching mesh
  54871. * @param scene The sceme layer the observer will be added to
  54872. */
  54873. private _attachToMeshPointerObserver;
  54874. /**
  54875. * Attaches a set of gizmos to the specified mesh
  54876. * @param mesh The mesh the gizmo's should be attached to
  54877. */
  54878. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54879. /**
  54880. * Attaches a set of gizmos to the specified node
  54881. * @param node The node the gizmo's should be attached to
  54882. */
  54883. attachToNode(node: Nullable<Node>): void;
  54884. /**
  54885. * If the position gizmo is enabled
  54886. */
  54887. set positionGizmoEnabled(value: boolean);
  54888. get positionGizmoEnabled(): boolean;
  54889. /**
  54890. * If the rotation gizmo is enabled
  54891. */
  54892. set rotationGizmoEnabled(value: boolean);
  54893. get rotationGizmoEnabled(): boolean;
  54894. /**
  54895. * If the scale gizmo is enabled
  54896. */
  54897. set scaleGizmoEnabled(value: boolean);
  54898. get scaleGizmoEnabled(): boolean;
  54899. /**
  54900. * If the boundingBox gizmo is enabled
  54901. */
  54902. set boundingBoxGizmoEnabled(value: boolean);
  54903. get boundingBoxGizmoEnabled(): boolean;
  54904. /**
  54905. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54906. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  54907. */
  54908. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  54909. /**
  54910. * Disposes of the gizmo manager
  54911. */
  54912. dispose(): void;
  54913. }
  54914. }
  54915. declare module BABYLON {
  54916. /**
  54917. * Gizmo that enables dragging a mesh along 3 axis
  54918. */
  54919. export class PositionGizmo extends Gizmo {
  54920. /**
  54921. * Internal gizmo used for interactions on the x axis
  54922. */
  54923. xGizmo: AxisDragGizmo;
  54924. /**
  54925. * Internal gizmo used for interactions on the y axis
  54926. */
  54927. yGizmo: AxisDragGizmo;
  54928. /**
  54929. * Internal gizmo used for interactions on the z axis
  54930. */
  54931. zGizmo: AxisDragGizmo;
  54932. /**
  54933. * Internal gizmo used for interactions on the yz plane
  54934. */
  54935. xPlaneGizmo: PlaneDragGizmo;
  54936. /**
  54937. * Internal gizmo used for interactions on the xz plane
  54938. */
  54939. yPlaneGizmo: PlaneDragGizmo;
  54940. /**
  54941. * Internal gizmo used for interactions on the xy plane
  54942. */
  54943. zPlaneGizmo: PlaneDragGizmo;
  54944. /**
  54945. * private variables
  54946. */
  54947. private _meshAttached;
  54948. private _nodeAttached;
  54949. private _snapDistance;
  54950. private _observables;
  54951. /** Node Caching for quick lookup */
  54952. private _gizmoAxisCache;
  54953. /** Fires an event when any of it's sub gizmos are dragged */
  54954. onDragStartObservable: Observable<unknown>;
  54955. /** Fires an event when any of it's sub gizmos are released from dragging */
  54956. onDragEndObservable: Observable<unknown>;
  54957. /**
  54958. * If set to true, planar drag is enabled
  54959. */
  54960. private _planarGizmoEnabled;
  54961. get attachedMesh(): Nullable<AbstractMesh>;
  54962. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54963. get attachedNode(): Nullable<Node>;
  54964. set attachedNode(node: Nullable<Node>);
  54965. /**
  54966. * True when the mouse pointer is hovering a gizmo mesh
  54967. */
  54968. get isHovered(): boolean;
  54969. /**
  54970. * Creates a PositionGizmo
  54971. * @param gizmoLayer The utility layer the gizmo will be added to
  54972. @param thickness display gizmo axis thickness
  54973. */
  54974. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  54975. /**
  54976. * If the planar drag gizmo is enabled
  54977. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  54978. */
  54979. set planarGizmoEnabled(value: boolean);
  54980. get planarGizmoEnabled(): boolean;
  54981. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54982. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54983. /**
  54984. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54985. */
  54986. set snapDistance(value: number);
  54987. get snapDistance(): number;
  54988. /**
  54989. * Ratio for the scale of the gizmo (Default: 1)
  54990. */
  54991. set scaleRatio(value: number);
  54992. get scaleRatio(): number;
  54993. /**
  54994. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  54995. * @param mesh Axis gizmo mesh
  54996. * @param cache Gizmo axis definition used for reactive gizmo UI
  54997. */
  54998. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  54999. /**
  55000. * Disposes of the gizmo
  55001. */
  55002. dispose(): void;
  55003. /**
  55004. * CustomMeshes are not supported by this gizmo
  55005. * @param mesh The mesh to replace the default mesh of the gizmo
  55006. */
  55007. setCustomMesh(mesh: Mesh): void;
  55008. }
  55009. }
  55010. declare module BABYLON {
  55011. /**
  55012. * Single axis drag gizmo
  55013. */
  55014. export class AxisDragGizmo extends Gizmo {
  55015. /**
  55016. * Drag behavior responsible for the gizmos dragging interactions
  55017. */
  55018. dragBehavior: PointerDragBehavior;
  55019. private _pointerObserver;
  55020. /**
  55021. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55022. */
  55023. snapDistance: number;
  55024. /**
  55025. * Event that fires each time the gizmo snaps to a new location.
  55026. * * snapDistance is the the change in distance
  55027. */
  55028. onSnapObservable: Observable<{
  55029. snapDistance: number;
  55030. }>;
  55031. private _isEnabled;
  55032. private _parent;
  55033. private _gizmoMesh;
  55034. private _coloredMaterial;
  55035. private _hoverMaterial;
  55036. private _disableMaterial;
  55037. private _dragging;
  55038. /** @hidden */
  55039. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  55040. /** @hidden */
  55041. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  55042. /**
  55043. * Creates an AxisDragGizmo
  55044. * @param gizmoLayer The utility layer the gizmo will be added to
  55045. * @param dragAxis The axis which the gizmo will be able to drag on
  55046. * @param color The color of the gizmo
  55047. * @param thickness display gizmo axis thickness
  55048. */
  55049. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  55050. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55051. /**
  55052. * If the gizmo is enabled
  55053. */
  55054. set isEnabled(value: boolean);
  55055. get isEnabled(): boolean;
  55056. /**
  55057. * Disposes of the gizmo
  55058. */
  55059. dispose(): void;
  55060. }
  55061. }
  55062. declare module BABYLON.Debug {
  55063. /**
  55064. * The Axes viewer will show 3 axes in a specific point in space
  55065. */
  55066. export class AxesViewer {
  55067. private _xAxis;
  55068. private _yAxis;
  55069. private _zAxis;
  55070. private _scaleLinesFactor;
  55071. private _instanced;
  55072. /**
  55073. * Gets the hosting scene
  55074. */
  55075. scene: Nullable<Scene>;
  55076. /**
  55077. * Gets or sets a number used to scale line length
  55078. */
  55079. scaleLines: number;
  55080. /** Gets the node hierarchy used to render x-axis */
  55081. get xAxis(): TransformNode;
  55082. /** Gets the node hierarchy used to render y-axis */
  55083. get yAxis(): TransformNode;
  55084. /** Gets the node hierarchy used to render z-axis */
  55085. get zAxis(): TransformNode;
  55086. /**
  55087. * Creates a new AxesViewer
  55088. * @param scene defines the hosting scene
  55089. * @param scaleLines defines a number used to scale line length (1 by default)
  55090. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  55091. * @param xAxis defines the node hierarchy used to render the x-axis
  55092. * @param yAxis defines the node hierarchy used to render the y-axis
  55093. * @param zAxis defines the node hierarchy used to render the z-axis
  55094. */
  55095. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  55096. /**
  55097. * Force the viewer to update
  55098. * @param position defines the position of the viewer
  55099. * @param xaxis defines the x axis of the viewer
  55100. * @param yaxis defines the y axis of the viewer
  55101. * @param zaxis defines the z axis of the viewer
  55102. */
  55103. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  55104. /**
  55105. * Creates an instance of this axes viewer.
  55106. * @returns a new axes viewer with instanced meshes
  55107. */
  55108. createInstance(): AxesViewer;
  55109. /** Releases resources */
  55110. dispose(): void;
  55111. private static _SetRenderingGroupId;
  55112. }
  55113. }
  55114. declare module BABYLON.Debug {
  55115. /**
  55116. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  55117. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  55118. */
  55119. export class BoneAxesViewer extends AxesViewer {
  55120. /**
  55121. * Gets or sets the target mesh where to display the axes viewer
  55122. */
  55123. mesh: Nullable<Mesh>;
  55124. /**
  55125. * Gets or sets the target bone where to display the axes viewer
  55126. */
  55127. bone: Nullable<Bone>;
  55128. /** Gets current position */
  55129. pos: Vector3;
  55130. /** Gets direction of X axis */
  55131. xaxis: Vector3;
  55132. /** Gets direction of Y axis */
  55133. yaxis: Vector3;
  55134. /** Gets direction of Z axis */
  55135. zaxis: Vector3;
  55136. /**
  55137. * Creates a new BoneAxesViewer
  55138. * @param scene defines the hosting scene
  55139. * @param bone defines the target bone
  55140. * @param mesh defines the target mesh
  55141. * @param scaleLines defines a scaling factor for line length (1 by default)
  55142. */
  55143. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  55144. /**
  55145. * Force the viewer to update
  55146. */
  55147. update(): void;
  55148. /** Releases resources */
  55149. dispose(): void;
  55150. }
  55151. }
  55152. declare module BABYLON {
  55153. /**
  55154. * Interface used to define scene explorer extensibility option
  55155. */
  55156. export interface IExplorerExtensibilityOption {
  55157. /**
  55158. * Define the option label
  55159. */
  55160. label: string;
  55161. /**
  55162. * Defines the action to execute on click
  55163. */
  55164. action: (entity: any) => void;
  55165. }
  55166. /**
  55167. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  55168. */
  55169. export interface IExplorerExtensibilityGroup {
  55170. /**
  55171. * Defines a predicate to test if a given type mut be extended
  55172. */
  55173. predicate: (entity: any) => boolean;
  55174. /**
  55175. * Gets the list of options added to a type
  55176. */
  55177. entries: IExplorerExtensibilityOption[];
  55178. }
  55179. /**
  55180. * Interface used to define the options to use to create the Inspector
  55181. */
  55182. export interface IInspectorOptions {
  55183. /**
  55184. * Display in overlay mode (default: false)
  55185. */
  55186. overlay?: boolean;
  55187. /**
  55188. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  55189. */
  55190. globalRoot?: HTMLElement;
  55191. /**
  55192. * Display the Scene explorer
  55193. */
  55194. showExplorer?: boolean;
  55195. /**
  55196. * Display the property inspector
  55197. */
  55198. showInspector?: boolean;
  55199. /**
  55200. * Display in embed mode (both panes on the right)
  55201. */
  55202. embedMode?: boolean;
  55203. /**
  55204. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  55205. */
  55206. handleResize?: boolean;
  55207. /**
  55208. * Allow the panes to popup (default: true)
  55209. */
  55210. enablePopup?: boolean;
  55211. /**
  55212. * Allow the panes to be closed by users (default: true)
  55213. */
  55214. enableClose?: boolean;
  55215. /**
  55216. * Optional list of extensibility entries
  55217. */
  55218. explorerExtensibility?: IExplorerExtensibilityGroup[];
  55219. /**
  55220. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  55221. */
  55222. inspectorURL?: string;
  55223. /**
  55224. * Optional initial tab (default to DebugLayerTab.Properties)
  55225. */
  55226. initialTab?: DebugLayerTab;
  55227. }
  55228. interface Scene {
  55229. /**
  55230. * @hidden
  55231. * Backing field
  55232. */
  55233. _debugLayer: DebugLayer;
  55234. /**
  55235. * Gets the debug layer (aka Inspector) associated with the scene
  55236. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55237. */
  55238. debugLayer: DebugLayer;
  55239. }
  55240. /**
  55241. * Enum of inspector action tab
  55242. */
  55243. export enum DebugLayerTab {
  55244. /**
  55245. * Properties tag (default)
  55246. */
  55247. Properties = 0,
  55248. /**
  55249. * Debug tab
  55250. */
  55251. Debug = 1,
  55252. /**
  55253. * Statistics tab
  55254. */
  55255. Statistics = 2,
  55256. /**
  55257. * Tools tab
  55258. */
  55259. Tools = 3,
  55260. /**
  55261. * Settings tab
  55262. */
  55263. Settings = 4
  55264. }
  55265. /**
  55266. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55267. * what is happening in your scene
  55268. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55269. */
  55270. export class DebugLayer {
  55271. /**
  55272. * Define the url to get the inspector script from.
  55273. * By default it uses the babylonjs CDN.
  55274. * @ignoreNaming
  55275. */
  55276. static InspectorURL: string;
  55277. private _scene;
  55278. private BJSINSPECTOR;
  55279. private _onPropertyChangedObservable?;
  55280. /**
  55281. * Observable triggered when a property is changed through the inspector.
  55282. */
  55283. get onPropertyChangedObservable(): any;
  55284. /**
  55285. * Instantiates a new debug layer.
  55286. * The debug layer (aka Inspector) is the go to tool in order to better understand
  55287. * what is happening in your scene
  55288. * @see https://doc.babylonjs.com/features/playground_debuglayer
  55289. * @param scene Defines the scene to inspect
  55290. */
  55291. constructor(scene: Scene);
  55292. /** Creates the inspector window. */
  55293. private _createInspector;
  55294. /**
  55295. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  55296. * @param entity defines the entity to select
  55297. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  55298. */
  55299. select(entity: any, lineContainerTitles?: string | string[]): void;
  55300. /** Get the inspector from bundle or global */
  55301. private _getGlobalInspector;
  55302. /**
  55303. * Get if the inspector is visible or not.
  55304. * @returns true if visible otherwise, false
  55305. */
  55306. isVisible(): boolean;
  55307. /**
  55308. * Hide the inspector and close its window.
  55309. */
  55310. hide(): void;
  55311. /**
  55312. * Update the scene in the inspector
  55313. */
  55314. setAsActiveScene(): void;
  55315. /**
  55316. * Launch the debugLayer.
  55317. * @param config Define the configuration of the inspector
  55318. * @return a promise fulfilled when the debug layer is visible
  55319. */
  55320. show(config?: IInspectorOptions): Promise<DebugLayer>;
  55321. }
  55322. }
  55323. declare module BABYLON.Debug {
  55324. /**
  55325. * Used to show the physics impostor around the specific mesh
  55326. */
  55327. export class PhysicsViewer {
  55328. /** @hidden */
  55329. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  55330. /** @hidden */
  55331. protected _meshes: Array<Nullable<AbstractMesh>>;
  55332. /** @hidden */
  55333. protected _scene: Nullable<Scene>;
  55334. /** @hidden */
  55335. protected _numMeshes: number;
  55336. /** @hidden */
  55337. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  55338. private _renderFunction;
  55339. private _utilityLayer;
  55340. private _debugBoxMesh;
  55341. private _debugSphereMesh;
  55342. private _debugCylinderMesh;
  55343. private _debugMaterial;
  55344. private _debugMeshMeshes;
  55345. /**
  55346. * Creates a new PhysicsViewer
  55347. * @param scene defines the hosting scene
  55348. */
  55349. constructor(scene: Scene);
  55350. /** @hidden */
  55351. protected _updateDebugMeshes(): void;
  55352. /**
  55353. * Renders a specified physic impostor
  55354. * @param impostor defines the impostor to render
  55355. * @param targetMesh defines the mesh represented by the impostor
  55356. * @returns the new debug mesh used to render the impostor
  55357. */
  55358. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  55359. /**
  55360. * Hides a specified physic impostor
  55361. * @param impostor defines the impostor to hide
  55362. */
  55363. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  55364. private _getDebugMaterial;
  55365. private _getDebugBoxMesh;
  55366. private _getDebugSphereMesh;
  55367. private _getDebugCylinderMesh;
  55368. private _getDebugMeshMesh;
  55369. private _getDebugMesh;
  55370. /** Releases all resources */
  55371. dispose(): void;
  55372. }
  55373. }
  55374. declare module BABYLON {
  55375. /**
  55376. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55377. * in order to better appreciate the issue one might have.
  55378. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55379. */
  55380. export class RayHelper {
  55381. /**
  55382. * Defines the ray we are currently tryin to visualize.
  55383. */
  55384. ray: Nullable<Ray>;
  55385. private _renderPoints;
  55386. private _renderLine;
  55387. private _renderFunction;
  55388. private _scene;
  55389. private _onAfterRenderObserver;
  55390. private _onAfterStepObserver;
  55391. private _attachedToMesh;
  55392. private _meshSpaceDirection;
  55393. private _meshSpaceOrigin;
  55394. /**
  55395. * Helper function to create a colored helper in a scene in one line.
  55396. * @param ray Defines the ray we are currently tryin to visualize
  55397. * @param scene Defines the scene the ray is used in
  55398. * @param color Defines the color we want to see the ray in
  55399. * @returns The newly created ray helper.
  55400. */
  55401. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  55402. /**
  55403. * Instantiate a new ray helper.
  55404. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  55405. * in order to better appreciate the issue one might have.
  55406. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  55407. * @param ray Defines the ray we are currently tryin to visualize
  55408. */
  55409. constructor(ray: Ray);
  55410. /**
  55411. * Shows the ray we are willing to debug.
  55412. * @param scene Defines the scene the ray needs to be rendered in
  55413. * @param color Defines the color the ray needs to be rendered in
  55414. */
  55415. show(scene: Scene, color?: Color3): void;
  55416. /**
  55417. * Hides the ray we are debugging.
  55418. */
  55419. hide(): void;
  55420. private _render;
  55421. /**
  55422. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  55423. * @param mesh Defines the mesh we want the helper attached to
  55424. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  55425. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  55426. * @param length Defines the length of the ray
  55427. */
  55428. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  55429. /**
  55430. * Detach the ray helper from the mesh it has previously been attached to.
  55431. */
  55432. detachFromMesh(): void;
  55433. private _updateToMesh;
  55434. /**
  55435. * Dispose the helper and release its associated resources.
  55436. */
  55437. dispose(): void;
  55438. }
  55439. }
  55440. declare module BABYLON {
  55441. /**
  55442. * Defines the options associated with the creation of a SkeletonViewer.
  55443. */
  55444. export interface ISkeletonViewerOptions {
  55445. /** Should the system pause animations before building the Viewer? */
  55446. pauseAnimations: boolean;
  55447. /** Should the system return the skeleton to rest before building? */
  55448. returnToRest: boolean;
  55449. /** public Display Mode of the Viewer */
  55450. displayMode: number;
  55451. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55452. displayOptions: ISkeletonViewerDisplayOptions;
  55453. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  55454. computeBonesUsingShaders: boolean;
  55455. /** Flag ignore non weighted bones */
  55456. useAllBones: boolean;
  55457. }
  55458. /**
  55459. * Defines how to display the various bone meshes for the viewer.
  55460. */
  55461. export interface ISkeletonViewerDisplayOptions {
  55462. /** How far down to start tapering the bone spurs */
  55463. midStep?: number;
  55464. /** How big is the midStep? */
  55465. midStepFactor?: number;
  55466. /** Base for the Sphere Size */
  55467. sphereBaseSize?: number;
  55468. /** The ratio of the sphere to the longest bone in units */
  55469. sphereScaleUnit?: number;
  55470. /** Ratio for the Sphere Size */
  55471. sphereFactor?: number;
  55472. /** Whether a spur should attach its far end to the child bone position */
  55473. spurFollowsChild?: boolean;
  55474. /** Whether to show local axes or not */
  55475. showLocalAxes?: boolean;
  55476. /** Length of each local axis */
  55477. localAxesSize?: number;
  55478. }
  55479. /**
  55480. * Defines the constructor options for the BoneWeight Shader.
  55481. */
  55482. export interface IBoneWeightShaderOptions {
  55483. /** Skeleton to Map */
  55484. skeleton: Skeleton;
  55485. /** Colors for Uninfluenced bones */
  55486. colorBase?: Color3;
  55487. /** Colors for 0.0-0.25 Weight bones */
  55488. colorZero?: Color3;
  55489. /** Color for 0.25-0.5 Weight Influence */
  55490. colorQuarter?: Color3;
  55491. /** Color for 0.5-0.75 Weight Influence */
  55492. colorHalf?: Color3;
  55493. /** Color for 0.75-1 Weight Influence */
  55494. colorFull?: Color3;
  55495. /** Color for Zero Weight Influence */
  55496. targetBoneIndex?: number;
  55497. }
  55498. /**
  55499. * Simple structure of the gradient steps for the Color Map.
  55500. */
  55501. export interface ISkeletonMapShaderColorMapKnot {
  55502. /** Color of the Knot */
  55503. color: Color3;
  55504. /** Location of the Knot */
  55505. location: number;
  55506. }
  55507. /**
  55508. * Defines the constructor options for the SkeletonMap Shader.
  55509. */
  55510. export interface ISkeletonMapShaderOptions {
  55511. /** Skeleton to Map */
  55512. skeleton: Skeleton;
  55513. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  55514. colorMap?: ISkeletonMapShaderColorMapKnot[];
  55515. }
  55516. }
  55517. declare module BABYLON {
  55518. /**
  55519. * Class containing static functions to help procedurally build meshes
  55520. */
  55521. export class RibbonBuilder {
  55522. /**
  55523. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55524. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55525. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55526. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55527. * * 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
  55528. * * 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
  55529. * * 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
  55530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55531. * * 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
  55532. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55533. * * 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
  55534. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55535. * * 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
  55536. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55538. * @param name defines the name of the mesh
  55539. * @param options defines the options used to create the mesh
  55540. * @param scene defines the hosting scene
  55541. * @returns the ribbon mesh
  55542. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55543. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55544. */
  55545. static CreateRibbon(name: string, options: {
  55546. pathArray: Vector3[][];
  55547. closeArray?: boolean;
  55548. closePath?: boolean;
  55549. offset?: number;
  55550. updatable?: boolean;
  55551. sideOrientation?: number;
  55552. frontUVs?: Vector4;
  55553. backUVs?: Vector4;
  55554. instance?: Mesh;
  55555. invertUV?: boolean;
  55556. uvs?: Vector2[];
  55557. colors?: Color4[];
  55558. }, scene?: Nullable<Scene>): Mesh;
  55559. }
  55560. }
  55561. declare module BABYLON {
  55562. /**
  55563. * Class containing static functions to help procedurally build meshes
  55564. */
  55565. export class ShapeBuilder {
  55566. /**
  55567. * 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.
  55568. * * 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.
  55569. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55570. * * 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.
  55571. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55572. * * 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
  55573. * * 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
  55574. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55576. * * 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
  55577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55579. * @param name defines the name of the mesh
  55580. * @param options defines the options used to create the mesh
  55581. * @param scene defines the hosting scene
  55582. * @returns the extruded shape mesh
  55583. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55584. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55585. */
  55586. static ExtrudeShape(name: string, options: {
  55587. shape: Vector3[];
  55588. path: Vector3[];
  55589. scale?: number;
  55590. rotation?: number;
  55591. cap?: number;
  55592. updatable?: boolean;
  55593. sideOrientation?: number;
  55594. frontUVs?: Vector4;
  55595. backUVs?: Vector4;
  55596. instance?: Mesh;
  55597. invertUV?: boolean;
  55598. }, scene?: Nullable<Scene>): Mesh;
  55599. /**
  55600. * Creates an custom extruded shape mesh.
  55601. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55602. * * 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.
  55603. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55604. * * 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
  55605. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55606. * * 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
  55607. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55608. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55609. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55610. * * 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
  55611. * * 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
  55612. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55614. * * 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
  55615. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55617. * @param name defines the name of the mesh
  55618. * @param options defines the options used to create the mesh
  55619. * @param scene defines the hosting scene
  55620. * @returns the custom extruded shape mesh
  55621. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55622. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55623. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55624. */
  55625. static ExtrudeShapeCustom(name: string, options: {
  55626. shape: Vector3[];
  55627. path: Vector3[];
  55628. scaleFunction?: any;
  55629. rotationFunction?: any;
  55630. ribbonCloseArray?: boolean;
  55631. ribbonClosePath?: boolean;
  55632. cap?: number;
  55633. updatable?: boolean;
  55634. sideOrientation?: number;
  55635. frontUVs?: Vector4;
  55636. backUVs?: Vector4;
  55637. instance?: Mesh;
  55638. invertUV?: boolean;
  55639. }, scene?: Nullable<Scene>): Mesh;
  55640. private static _ExtrudeShapeGeneric;
  55641. }
  55642. }
  55643. declare module BABYLON.Debug {
  55644. /**
  55645. * Class used to render a debug view of a given skeleton
  55646. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  55647. */
  55648. export class SkeletonViewer {
  55649. /** defines the skeleton to render */
  55650. skeleton: Skeleton;
  55651. /** defines the mesh attached to the skeleton */
  55652. mesh: AbstractMesh;
  55653. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55654. autoUpdateBonesMatrices: boolean;
  55655. /** defines the rendering group id to use with the viewer */
  55656. renderingGroupId: number;
  55657. /** is the options for the viewer */
  55658. options: Partial<ISkeletonViewerOptions>;
  55659. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  55660. static readonly DISPLAY_LINES: number;
  55661. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  55662. static readonly DISPLAY_SPHERES: number;
  55663. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  55664. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  55665. /** public static method to create a BoneWeight Shader
  55666. * @param options The constructor options
  55667. * @param scene The scene that the shader is scoped to
  55668. * @returns The created ShaderMaterial
  55669. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  55670. */
  55671. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  55672. /** public static method to create a BoneWeight Shader
  55673. * @param options The constructor options
  55674. * @param scene The scene that the shader is scoped to
  55675. * @returns The created ShaderMaterial
  55676. */
  55677. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  55678. /** private static method to create a BoneWeight Shader
  55679. * @param size The size of the buffer to create (usually the bone count)
  55680. * @param colorMap The gradient data to generate
  55681. * @param scene The scene that the shader is scoped to
  55682. * @returns an Array of floats from the color gradient values
  55683. */
  55684. private static _CreateBoneMapColorBuffer;
  55685. /** If SkeletonViewer scene scope. */
  55686. private _scene;
  55687. /** Gets or sets the color used to render the skeleton */
  55688. color: Color3;
  55689. /** Array of the points of the skeleton fo the line view. */
  55690. private _debugLines;
  55691. /** The SkeletonViewers Mesh. */
  55692. private _debugMesh;
  55693. /** The local axes Meshes. */
  55694. private _localAxes;
  55695. /** If SkeletonViewer is enabled. */
  55696. private _isEnabled;
  55697. /** If SkeletonViewer is ready. */
  55698. private _ready;
  55699. /** SkeletonViewer render observable. */
  55700. private _obs;
  55701. /** The Utility Layer to render the gizmos in. */
  55702. private _utilityLayer;
  55703. private _boneIndices;
  55704. /** Gets the Scene. */
  55705. get scene(): Scene;
  55706. /** Gets the utilityLayer. */
  55707. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  55708. /** Checks Ready Status. */
  55709. get isReady(): Boolean;
  55710. /** Sets Ready Status. */
  55711. set ready(value: boolean);
  55712. /** Gets the debugMesh */
  55713. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  55714. /** Sets the debugMesh */
  55715. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  55716. /** Gets the displayMode */
  55717. get displayMode(): number;
  55718. /** Sets the displayMode */
  55719. set displayMode(value: number);
  55720. /**
  55721. * Creates a new SkeletonViewer
  55722. * @param skeleton defines the skeleton to render
  55723. * @param mesh defines the mesh attached to the skeleton
  55724. * @param scene defines the hosting scene
  55725. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  55726. * @param renderingGroupId defines the rendering group id to use with the viewer
  55727. * @param options All of the extra constructor options for the SkeletonViewer
  55728. */
  55729. constructor(
  55730. /** defines the skeleton to render */
  55731. skeleton: Skeleton,
  55732. /** defines the mesh attached to the skeleton */
  55733. mesh: AbstractMesh,
  55734. /** The Scene scope*/
  55735. scene: Scene,
  55736. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  55737. autoUpdateBonesMatrices?: boolean,
  55738. /** defines the rendering group id to use with the viewer */
  55739. renderingGroupId?: number,
  55740. /** is the options for the viewer */
  55741. options?: Partial<ISkeletonViewerOptions>);
  55742. /** The Dynamic bindings for the update functions */
  55743. private _bindObs;
  55744. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  55745. update(): void;
  55746. /** Gets or sets a boolean indicating if the viewer is enabled */
  55747. set isEnabled(value: boolean);
  55748. get isEnabled(): boolean;
  55749. private _getBonePosition;
  55750. private _getLinesForBonesWithLength;
  55751. private _getLinesForBonesNoLength;
  55752. /** function to revert the mesh and scene back to the initial state. */
  55753. private _revert;
  55754. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  55755. private _getAbsoluteBindPoseToRef;
  55756. /** function to build and bind sphere joint points and spur bone representations. */
  55757. private _buildSpheresAndSpurs;
  55758. private _buildLocalAxes;
  55759. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  55760. private _displayLinesUpdate;
  55761. /** Changes the displayMode of the skeleton viewer
  55762. * @param mode The displayMode numerical value
  55763. */
  55764. changeDisplayMode(mode: number): void;
  55765. /** Sets a display option of the skeleton viewer
  55766. *
  55767. * | Option | Type | Default | Description |
  55768. * | ---------------- | ------- | ------- | ----------- |
  55769. * | 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`. |
  55770. * | 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`. |
  55771. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  55772. * | 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`. |
  55773. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  55774. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  55775. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  55776. *
  55777. * @param option String of the option name
  55778. * @param value The numerical option value
  55779. */
  55780. changeDisplayOptions(option: string, value: number): void;
  55781. /** Release associated resources */
  55782. dispose(): void;
  55783. }
  55784. }
  55785. declare module BABYLON {
  55786. /**
  55787. * Enum for Device Types
  55788. */
  55789. export enum DeviceType {
  55790. /** Generic */
  55791. Generic = 0,
  55792. /** Keyboard */
  55793. Keyboard = 1,
  55794. /** Mouse */
  55795. Mouse = 2,
  55796. /** Touch Pointers */
  55797. Touch = 3,
  55798. /** PS4 Dual Shock */
  55799. DualShock = 4,
  55800. /** Xbox */
  55801. Xbox = 5,
  55802. /** Switch Controller */
  55803. Switch = 6
  55804. }
  55805. /**
  55806. * Enum for All Pointers (Touch/Mouse)
  55807. */
  55808. export enum PointerInput {
  55809. /** Horizontal Axis */
  55810. Horizontal = 0,
  55811. /** Vertical Axis */
  55812. Vertical = 1,
  55813. /** Left Click or Touch */
  55814. LeftClick = 2,
  55815. /** Middle Click */
  55816. MiddleClick = 3,
  55817. /** Right Click */
  55818. RightClick = 4,
  55819. /** Browser Back */
  55820. BrowserBack = 5,
  55821. /** Browser Forward */
  55822. BrowserForward = 6
  55823. }
  55824. /**
  55825. * Enum for Dual Shock Gamepad
  55826. */
  55827. export enum DualShockInput {
  55828. /** Cross */
  55829. Cross = 0,
  55830. /** Circle */
  55831. Circle = 1,
  55832. /** Square */
  55833. Square = 2,
  55834. /** Triangle */
  55835. Triangle = 3,
  55836. /** L1 */
  55837. L1 = 4,
  55838. /** R1 */
  55839. R1 = 5,
  55840. /** L2 */
  55841. L2 = 6,
  55842. /** R2 */
  55843. R2 = 7,
  55844. /** Share */
  55845. Share = 8,
  55846. /** Options */
  55847. Options = 9,
  55848. /** L3 */
  55849. L3 = 10,
  55850. /** R3 */
  55851. R3 = 11,
  55852. /** DPadUp */
  55853. DPadUp = 12,
  55854. /** DPadDown */
  55855. DPadDown = 13,
  55856. /** DPadLeft */
  55857. DPadLeft = 14,
  55858. /** DRight */
  55859. DPadRight = 15,
  55860. /** Home */
  55861. Home = 16,
  55862. /** TouchPad */
  55863. TouchPad = 17,
  55864. /** LStickXAxis */
  55865. LStickXAxis = 18,
  55866. /** LStickYAxis */
  55867. LStickYAxis = 19,
  55868. /** RStickXAxis */
  55869. RStickXAxis = 20,
  55870. /** RStickYAxis */
  55871. RStickYAxis = 21
  55872. }
  55873. /**
  55874. * Enum for Xbox Gamepad
  55875. */
  55876. export enum XboxInput {
  55877. /** A */
  55878. A = 0,
  55879. /** B */
  55880. B = 1,
  55881. /** X */
  55882. X = 2,
  55883. /** Y */
  55884. Y = 3,
  55885. /** LB */
  55886. LB = 4,
  55887. /** RB */
  55888. RB = 5,
  55889. /** LT */
  55890. LT = 6,
  55891. /** RT */
  55892. RT = 7,
  55893. /** Back */
  55894. Back = 8,
  55895. /** Start */
  55896. Start = 9,
  55897. /** LS */
  55898. LS = 10,
  55899. /** RS */
  55900. RS = 11,
  55901. /** DPadUp */
  55902. DPadUp = 12,
  55903. /** DPadDown */
  55904. DPadDown = 13,
  55905. /** DPadLeft */
  55906. DPadLeft = 14,
  55907. /** DRight */
  55908. DPadRight = 15,
  55909. /** Home */
  55910. Home = 16,
  55911. /** LStickXAxis */
  55912. LStickXAxis = 17,
  55913. /** LStickYAxis */
  55914. LStickYAxis = 18,
  55915. /** RStickXAxis */
  55916. RStickXAxis = 19,
  55917. /** RStickYAxis */
  55918. RStickYAxis = 20
  55919. }
  55920. /**
  55921. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  55922. */
  55923. export enum SwitchInput {
  55924. /** B */
  55925. B = 0,
  55926. /** A */
  55927. A = 1,
  55928. /** Y */
  55929. Y = 2,
  55930. /** X */
  55931. X = 3,
  55932. /** L */
  55933. L = 4,
  55934. /** R */
  55935. R = 5,
  55936. /** ZL */
  55937. ZL = 6,
  55938. /** ZR */
  55939. ZR = 7,
  55940. /** Minus */
  55941. Minus = 8,
  55942. /** Plus */
  55943. Plus = 9,
  55944. /** LS */
  55945. LS = 10,
  55946. /** RS */
  55947. RS = 11,
  55948. /** DPadUp */
  55949. DPadUp = 12,
  55950. /** DPadDown */
  55951. DPadDown = 13,
  55952. /** DPadLeft */
  55953. DPadLeft = 14,
  55954. /** DRight */
  55955. DPadRight = 15,
  55956. /** Home */
  55957. Home = 16,
  55958. /** Capture */
  55959. Capture = 17,
  55960. /** LStickXAxis */
  55961. LStickXAxis = 18,
  55962. /** LStickYAxis */
  55963. LStickYAxis = 19,
  55964. /** RStickXAxis */
  55965. RStickXAxis = 20,
  55966. /** RStickYAxis */
  55967. RStickYAxis = 21
  55968. }
  55969. }
  55970. declare module BABYLON {
  55971. /**
  55972. * This class will take all inputs from Keyboard, Pointer, and
  55973. * any Gamepads and provide a polling system that all devices
  55974. * will use. This class assumes that there will only be one
  55975. * pointer device and one keyboard.
  55976. */
  55977. export class DeviceInputSystem implements IDisposable {
  55978. /**
  55979. * Returns onDeviceConnected callback property
  55980. * @returns Callback with function to execute when a device is connected
  55981. */
  55982. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  55983. /**
  55984. * Sets callback function when a device is connected and executes against all connected devices
  55985. * @param callback Function to execute when a device is connected
  55986. */
  55987. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  55988. /**
  55989. * Callback to be triggered when a device is disconnected
  55990. */
  55991. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  55992. /**
  55993. * Callback to be triggered when event driven input is updated
  55994. */
  55995. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  55996. private _inputs;
  55997. private _gamepads;
  55998. private _keyboardActive;
  55999. private _pointerActive;
  56000. private _elementToAttachTo;
  56001. private _keyboardDownEvent;
  56002. private _keyboardUpEvent;
  56003. private _pointerMoveEvent;
  56004. private _pointerDownEvent;
  56005. private _pointerUpEvent;
  56006. private _gamepadConnectedEvent;
  56007. private _gamepadDisconnectedEvent;
  56008. private _onDeviceConnected;
  56009. private static _MAX_KEYCODES;
  56010. private static _MAX_POINTER_INPUTS;
  56011. private constructor();
  56012. /**
  56013. * Creates a new DeviceInputSystem instance
  56014. * @param engine Engine to pull input element from
  56015. * @returns The new instance
  56016. */
  56017. static Create(engine: Engine): DeviceInputSystem;
  56018. /**
  56019. * Checks for current device input value, given an id and input index
  56020. * @param deviceName Id of connected device
  56021. * @param inputIndex Index of device input
  56022. * @returns Current value of input
  56023. */
  56024. /**
  56025. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  56026. * @param deviceType Enum specifiying device type
  56027. * @param deviceSlot "Slot" or index that device is referenced in
  56028. * @param inputIndex Id of input to be checked
  56029. * @returns Current value of input
  56030. */
  56031. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  56032. /**
  56033. * Dispose of all the eventlisteners
  56034. */
  56035. dispose(): void;
  56036. /**
  56037. * Checks for existing connections to devices and register them, if necessary
  56038. * Currently handles gamepads and mouse
  56039. */
  56040. private _checkForConnectedDevices;
  56041. /**
  56042. * Add a gamepad to the DeviceInputSystem
  56043. * @param gamepad A single DOM Gamepad object
  56044. */
  56045. private _addGamePad;
  56046. /**
  56047. * Add pointer device to DeviceInputSystem
  56048. * @param deviceType Type of Pointer to add
  56049. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  56050. * @param currentX Current X at point of adding
  56051. * @param currentY Current Y at point of adding
  56052. */
  56053. private _addPointerDevice;
  56054. /**
  56055. * Add device and inputs to device array
  56056. * @param deviceType Enum specifiying device type
  56057. * @param deviceSlot "Slot" or index that device is referenced in
  56058. * @param numberOfInputs Number of input entries to create for given device
  56059. */
  56060. private _registerDevice;
  56061. /**
  56062. * Given a specific device name, remove that device from the device map
  56063. * @param deviceType Enum specifiying device type
  56064. * @param deviceSlot "Slot" or index that device is referenced in
  56065. */
  56066. private _unregisterDevice;
  56067. /**
  56068. * Handle all actions that come from keyboard interaction
  56069. */
  56070. private _handleKeyActions;
  56071. /**
  56072. * Handle all actions that come from pointer interaction
  56073. */
  56074. private _handlePointerActions;
  56075. /**
  56076. * Handle all actions that come from gamepad interaction
  56077. */
  56078. private _handleGamepadActions;
  56079. /**
  56080. * Update all non-event based devices with each frame
  56081. * @param deviceType Enum specifiying device type
  56082. * @param deviceSlot "Slot" or index that device is referenced in
  56083. * @param inputIndex Id of input to be checked
  56084. */
  56085. private _updateDevice;
  56086. /**
  56087. * Gets DeviceType from the device name
  56088. * @param deviceName Name of Device from DeviceInputSystem
  56089. * @returns DeviceType enum value
  56090. */
  56091. private _getGamepadDeviceType;
  56092. }
  56093. }
  56094. declare module BABYLON {
  56095. /**
  56096. * Type to handle enforcement of inputs
  56097. */
  56098. 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;
  56099. }
  56100. declare module BABYLON {
  56101. /**
  56102. * Class that handles all input for a specific device
  56103. */
  56104. export class DeviceSource<T extends DeviceType> {
  56105. /** Type of device */
  56106. readonly deviceType: DeviceType;
  56107. /** "Slot" or index that device is referenced in */
  56108. readonly deviceSlot: number;
  56109. /**
  56110. * Observable to handle device input changes per device
  56111. */
  56112. readonly onInputChangedObservable: Observable<{
  56113. inputIndex: DeviceInput<T>;
  56114. previousState: Nullable<number>;
  56115. currentState: Nullable<number>;
  56116. }>;
  56117. private readonly _deviceInputSystem;
  56118. /**
  56119. * Default Constructor
  56120. * @param deviceInputSystem Reference to DeviceInputSystem
  56121. * @param deviceType Type of device
  56122. * @param deviceSlot "Slot" or index that device is referenced in
  56123. */
  56124. constructor(deviceInputSystem: DeviceInputSystem,
  56125. /** Type of device */
  56126. deviceType: DeviceType,
  56127. /** "Slot" or index that device is referenced in */
  56128. deviceSlot?: number);
  56129. /**
  56130. * Get input for specific input
  56131. * @param inputIndex index of specific input on device
  56132. * @returns Input value from DeviceInputSystem
  56133. */
  56134. getInput(inputIndex: DeviceInput<T>): number;
  56135. }
  56136. /**
  56137. * Class to keep track of devices
  56138. */
  56139. export class DeviceSourceManager implements IDisposable {
  56140. /**
  56141. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  56142. */
  56143. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  56144. /**
  56145. * Observable to be triggered when after a device is disconnected
  56146. */
  56147. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  56148. private readonly _devices;
  56149. private readonly _firstDevice;
  56150. private readonly _deviceInputSystem;
  56151. /**
  56152. * Default Constructor
  56153. * @param engine engine to pull input element from
  56154. */
  56155. constructor(engine: Engine);
  56156. /**
  56157. * Gets a DeviceSource, given a type and slot
  56158. * @param deviceType Enum specifying device type
  56159. * @param deviceSlot "Slot" or index that device is referenced in
  56160. * @returns DeviceSource object
  56161. */
  56162. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  56163. /**
  56164. * Gets an array of DeviceSource objects for a given device type
  56165. * @param deviceType Enum specifying device type
  56166. * @returns Array of DeviceSource objects
  56167. */
  56168. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  56169. /**
  56170. * Returns a read-only list of all available devices
  56171. * @returns Read-only array with active devices
  56172. */
  56173. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  56174. /**
  56175. * Dispose of DeviceInputSystem and other parts
  56176. */
  56177. dispose(): void;
  56178. /**
  56179. * Function to add device name to device list
  56180. * @param deviceType Enum specifying device type
  56181. * @param deviceSlot "Slot" or index that device is referenced in
  56182. */
  56183. private _addDevice;
  56184. /**
  56185. * Function to remove device name to device list
  56186. * @param deviceType Enum specifying device type
  56187. * @param deviceSlot "Slot" or index that device is referenced in
  56188. */
  56189. private _removeDevice;
  56190. /**
  56191. * Updates array storing first connected device of each type
  56192. * @param type Type of Device
  56193. */
  56194. private _updateFirstDevices;
  56195. }
  56196. }
  56197. declare module BABYLON {
  56198. /**
  56199. * Options to create the null engine
  56200. */
  56201. export class NullEngineOptions {
  56202. /**
  56203. * Render width (Default: 512)
  56204. */
  56205. renderWidth: number;
  56206. /**
  56207. * Render height (Default: 256)
  56208. */
  56209. renderHeight: number;
  56210. /**
  56211. * Texture size (Default: 512)
  56212. */
  56213. textureSize: number;
  56214. /**
  56215. * If delta time between frames should be constant
  56216. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56217. */
  56218. deterministicLockstep: boolean;
  56219. /**
  56220. * Maximum about of steps between frames (Default: 4)
  56221. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56222. */
  56223. lockstepMaxSteps: number;
  56224. /**
  56225. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  56226. */
  56227. useHighPrecisionMatrix?: boolean;
  56228. }
  56229. /**
  56230. * The null engine class provides support for headless version of babylon.js.
  56231. * This can be used in server side scenario or for testing purposes
  56232. */
  56233. export class NullEngine extends Engine {
  56234. private _options;
  56235. /**
  56236. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  56237. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56238. * @returns true if engine is in deterministic lock step mode
  56239. */
  56240. isDeterministicLockStep(): boolean;
  56241. /**
  56242. * Gets the max steps when engine is running in deterministic lock step
  56243. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  56244. * @returns the max steps
  56245. */
  56246. getLockstepMaxSteps(): number;
  56247. /**
  56248. * Gets the current hardware scaling level.
  56249. * By default the hardware scaling level is computed from the window device ratio.
  56250. * 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.
  56251. * @returns a number indicating the current hardware scaling level
  56252. */
  56253. getHardwareScalingLevel(): number;
  56254. constructor(options?: NullEngineOptions);
  56255. /**
  56256. * Creates a vertex buffer
  56257. * @param vertices the data for the vertex buffer
  56258. * @returns the new WebGL static buffer
  56259. */
  56260. createVertexBuffer(vertices: FloatArray): DataBuffer;
  56261. /**
  56262. * Creates a new index buffer
  56263. * @param indices defines the content of the index buffer
  56264. * @param updatable defines if the index buffer must be updatable
  56265. * @returns a new webGL buffer
  56266. */
  56267. createIndexBuffer(indices: IndicesArray): DataBuffer;
  56268. /**
  56269. * Clear the current render buffer or the current render target (if any is set up)
  56270. * @param color defines the color to use
  56271. * @param backBuffer defines if the back buffer must be cleared
  56272. * @param depth defines if the depth buffer must be cleared
  56273. * @param stencil defines if the stencil buffer must be cleared
  56274. */
  56275. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  56276. /**
  56277. * Gets the current render width
  56278. * @param useScreen defines if screen size must be used (or the current render target if any)
  56279. * @returns a number defining the current render width
  56280. */
  56281. getRenderWidth(useScreen?: boolean): number;
  56282. /**
  56283. * Gets the current render height
  56284. * @param useScreen defines if screen size must be used (or the current render target if any)
  56285. * @returns a number defining the current render height
  56286. */
  56287. getRenderHeight(useScreen?: boolean): number;
  56288. /**
  56289. * Set the WebGL's viewport
  56290. * @param viewport defines the viewport element to be used
  56291. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  56292. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  56293. */
  56294. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  56295. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  56296. /**
  56297. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  56298. * @param pipelineContext defines the pipeline context to use
  56299. * @param uniformsNames defines the list of uniform names
  56300. * @returns an array of webGL uniform locations
  56301. */
  56302. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  56303. /**
  56304. * Gets the lsit of active attributes for a given webGL program
  56305. * @param pipelineContext defines the pipeline context to use
  56306. * @param attributesNames defines the list of attribute names to get
  56307. * @returns an array of indices indicating the offset of each attribute
  56308. */
  56309. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  56310. /**
  56311. * Binds an effect to the webGL context
  56312. * @param effect defines the effect to bind
  56313. */
  56314. bindSamplers(effect: Effect): void;
  56315. /**
  56316. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  56317. * @param effect defines the effect to activate
  56318. */
  56319. enableEffect(effect: Effect): void;
  56320. /**
  56321. * Set various states to the webGL context
  56322. * @param culling defines backface culling state
  56323. * @param zOffset defines the value to apply to zOffset (0 by default)
  56324. * @param force defines if states must be applied even if cache is up to date
  56325. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  56326. */
  56327. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  56328. /**
  56329. * Set the value of an uniform to an array of int32
  56330. * @param uniform defines the webGL uniform location where to store the value
  56331. * @param array defines the array of int32 to store
  56332. * @returns true if value was set
  56333. */
  56334. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56335. /**
  56336. * Set the value of an uniform to an array of int32 (stored as vec2)
  56337. * @param uniform defines the webGL uniform location where to store the value
  56338. * @param array defines the array of int32 to store
  56339. * @returns true if value was set
  56340. */
  56341. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56342. /**
  56343. * Set the value of an uniform to an array of int32 (stored as vec3)
  56344. * @param uniform defines the webGL uniform location where to store the value
  56345. * @param array defines the array of int32 to store
  56346. * @returns true if value was set
  56347. */
  56348. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56349. /**
  56350. * Set the value of an uniform to an array of int32 (stored as vec4)
  56351. * @param uniform defines the webGL uniform location where to store the value
  56352. * @param array defines the array of int32 to store
  56353. * @returns true if value was set
  56354. */
  56355. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  56356. /**
  56357. * Set the value of an uniform to an array of float32
  56358. * @param uniform defines the webGL uniform location where to store the value
  56359. * @param array defines the array of float32 to store
  56360. * @returns true if value was set
  56361. */
  56362. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56363. /**
  56364. * Set the value of an uniform to an array of float32 (stored as vec2)
  56365. * @param uniform defines the webGL uniform location where to store the value
  56366. * @param array defines the array of float32 to store
  56367. * @returns true if value was set
  56368. */
  56369. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56370. /**
  56371. * Set the value of an uniform to an array of float32 (stored as vec3)
  56372. * @param uniform defines the webGL uniform location where to store the value
  56373. * @param array defines the array of float32 to store
  56374. * @returns true if value was set
  56375. */
  56376. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56377. /**
  56378. * Set the value of an uniform to an array of float32 (stored as vec4)
  56379. * @param uniform defines the webGL uniform location where to store the value
  56380. * @param array defines the array of float32 to store
  56381. * @returns true if value was set
  56382. */
  56383. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  56384. /**
  56385. * Set the value of an uniform to an array of number
  56386. * @param uniform defines the webGL uniform location where to store the value
  56387. * @param array defines the array of number to store
  56388. * @returns true if value was set
  56389. */
  56390. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  56391. /**
  56392. * Set the value of an uniform to an array of number (stored as vec2)
  56393. * @param uniform defines the webGL uniform location where to store the value
  56394. * @param array defines the array of number to store
  56395. * @returns true if value was set
  56396. */
  56397. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  56398. /**
  56399. * Set the value of an uniform to an array of number (stored as vec3)
  56400. * @param uniform defines the webGL uniform location where to store the value
  56401. * @param array defines the array of number to store
  56402. * @returns true if value was set
  56403. */
  56404. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  56405. /**
  56406. * Set the value of an uniform to an array of number (stored as vec4)
  56407. * @param uniform defines the webGL uniform location where to store the value
  56408. * @param array defines the array of number to store
  56409. * @returns true if value was set
  56410. */
  56411. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  56412. /**
  56413. * Set the value of an uniform to an array of float32 (stored as matrices)
  56414. * @param uniform defines the webGL uniform location where to store the value
  56415. * @param matrices defines the array of float32 to store
  56416. * @returns true if value was set
  56417. */
  56418. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  56419. /**
  56420. * Set the value of an uniform to a matrix (3x3)
  56421. * @param uniform defines the webGL uniform location where to store the value
  56422. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  56423. * @returns true if value was set
  56424. */
  56425. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56426. /**
  56427. * Set the value of an uniform to a matrix (2x2)
  56428. * @param uniform defines the webGL uniform location where to store the value
  56429. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  56430. * @returns true if value was set
  56431. */
  56432. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  56433. /**
  56434. * Set the value of an uniform to a number (float)
  56435. * @param uniform defines the webGL uniform location where to store the value
  56436. * @param value defines the float number to store
  56437. * @returns true if value was set
  56438. */
  56439. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  56440. /**
  56441. * Set the value of an uniform to a vec2
  56442. * @param uniform defines the webGL uniform location where to store the value
  56443. * @param x defines the 1st component of the value
  56444. * @param y defines the 2nd component of the value
  56445. * @returns true if value was set
  56446. */
  56447. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  56448. /**
  56449. * Set the value of an uniform to a vec3
  56450. * @param uniform defines the webGL uniform location where to store the value
  56451. * @param x defines the 1st component of the value
  56452. * @param y defines the 2nd component of the value
  56453. * @param z defines the 3rd component of the value
  56454. * @returns true if value was set
  56455. */
  56456. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  56457. /**
  56458. * Set the value of an uniform to a boolean
  56459. * @param uniform defines the webGL uniform location where to store the value
  56460. * @param bool defines the boolean to store
  56461. * @returns true if value was set
  56462. */
  56463. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  56464. /**
  56465. * Set the value of an uniform to a vec4
  56466. * @param uniform defines the webGL uniform location where to store the value
  56467. * @param x defines the 1st component of the value
  56468. * @param y defines the 2nd component of the value
  56469. * @param z defines the 3rd component of the value
  56470. * @param w defines the 4th component of the value
  56471. * @returns true if value was set
  56472. */
  56473. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  56474. /**
  56475. * Sets the current alpha mode
  56476. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  56477. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  56478. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  56479. */
  56480. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  56481. /**
  56482. * Bind webGl buffers directly to the webGL context
  56483. * @param vertexBuffers defines the vertex buffer to bind
  56484. * @param indexBuffer defines the index buffer to bind
  56485. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  56486. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  56487. * @param effect defines the effect associated with the vertex buffer
  56488. */
  56489. bindBuffers(vertexBuffers: {
  56490. [key: string]: VertexBuffer;
  56491. }, indexBuffer: DataBuffer, effect: Effect): void;
  56492. /**
  56493. * Force the entire cache to be cleared
  56494. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  56495. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  56496. */
  56497. wipeCaches(bruteForce?: boolean): void;
  56498. /**
  56499. * Send a draw order
  56500. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  56501. * @param indexStart defines the starting index
  56502. * @param indexCount defines the number of index to draw
  56503. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56504. */
  56505. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  56506. /**
  56507. * Draw a list of indexed primitives
  56508. * @param fillMode defines the primitive to use
  56509. * @param indexStart defines the starting index
  56510. * @param indexCount defines the number of index to draw
  56511. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56512. */
  56513. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  56514. /**
  56515. * Draw a list of unindexed primitives
  56516. * @param fillMode defines the primitive to use
  56517. * @param verticesStart defines the index of first vertex to draw
  56518. * @param verticesCount defines the count of vertices to draw
  56519. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  56520. */
  56521. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  56522. /** @hidden */
  56523. _createTexture(): WebGLTexture;
  56524. /** @hidden */
  56525. _releaseTexture(texture: InternalTexture): void;
  56526. /**
  56527. * Usually called from Texture.ts.
  56528. * Passed information to create a WebGLTexture
  56529. * @param urlArg defines a value which contains one of the following:
  56530. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  56531. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  56532. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  56533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  56534. * @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)
  56535. * @param scene needed for loading to the correct scene
  56536. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  56537. * @param onLoad optional callback to be called upon successful completion
  56538. * @param onError optional callback to be called upon failure
  56539. * @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
  56540. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  56541. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  56542. * @param forcedExtension defines the extension to use to pick the right loader
  56543. * @param mimeType defines an optional mime type
  56544. * @returns a InternalTexture for assignment back into BABYLON.Texture
  56545. */
  56546. 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;
  56547. /**
  56548. * Creates a new render target texture
  56549. * @param size defines the size of the texture
  56550. * @param options defines the options used to create the texture
  56551. * @returns a new render target texture stored in an InternalTexture
  56552. */
  56553. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  56554. /**
  56555. * Update the sampling mode of a given texture
  56556. * @param samplingMode defines the required sampling mode
  56557. * @param texture defines the texture to update
  56558. */
  56559. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  56560. /**
  56561. * Binds the frame buffer to the specified texture.
  56562. * @param texture The texture to render to or null for the default canvas
  56563. * @param faceIndex The face of the texture to render to in case of cube texture
  56564. * @param requiredWidth The width of the target to render to
  56565. * @param requiredHeight The height of the target to render to
  56566. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  56567. * @param lodLevel defines le lod level to bind to the frame buffer
  56568. */
  56569. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  56570. /**
  56571. * Unbind the current render target texture from the webGL context
  56572. * @param texture defines the render target texture to unbind
  56573. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  56574. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  56575. */
  56576. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  56577. /**
  56578. * Creates a dynamic vertex buffer
  56579. * @param vertices the data for the dynamic vertex buffer
  56580. * @returns the new WebGL dynamic buffer
  56581. */
  56582. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  56583. /**
  56584. * Update the content of a dynamic texture
  56585. * @param texture defines the texture to update
  56586. * @param canvas defines the canvas containing the source
  56587. * @param invertY defines if data must be stored with Y axis inverted
  56588. * @param premulAlpha defines if alpha is stored as premultiplied
  56589. * @param format defines the format of the data
  56590. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  56591. */
  56592. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  56593. /**
  56594. * Gets a boolean indicating if all created effects are ready
  56595. * @returns true if all effects are ready
  56596. */
  56597. areAllEffectsReady(): boolean;
  56598. /**
  56599. * @hidden
  56600. * Get the current error code of the webGL context
  56601. * @returns the error code
  56602. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  56603. */
  56604. getError(): number;
  56605. /** @hidden */
  56606. _getUnpackAlignement(): number;
  56607. /** @hidden */
  56608. _unpackFlipY(value: boolean): void;
  56609. /**
  56610. * Update a dynamic index buffer
  56611. * @param indexBuffer defines the target index buffer
  56612. * @param indices defines the data to update
  56613. * @param offset defines the offset in the target index buffer where update should start
  56614. */
  56615. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  56616. /**
  56617. * Updates a dynamic vertex buffer.
  56618. * @param vertexBuffer the vertex buffer to update
  56619. * @param vertices the data used to update the vertex buffer
  56620. * @param byteOffset the byte offset of the data (optional)
  56621. * @param byteLength the byte length of the data (optional)
  56622. */
  56623. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  56624. /** @hidden */
  56625. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  56626. /** @hidden */
  56627. _bindTexture(channel: number, texture: InternalTexture): void;
  56628. protected _deleteBuffer(buffer: WebGLBuffer): void;
  56629. /**
  56630. * 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
  56631. */
  56632. releaseEffects(): void;
  56633. displayLoadingUI(): void;
  56634. hideLoadingUI(): void;
  56635. /** @hidden */
  56636. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56637. /** @hidden */
  56638. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56639. /** @hidden */
  56640. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  56641. /** @hidden */
  56642. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  56643. }
  56644. }
  56645. declare module BABYLON {
  56646. /**
  56647. * @hidden
  56648. **/
  56649. export class _TimeToken {
  56650. _startTimeQuery: Nullable<WebGLQuery>;
  56651. _endTimeQuery: Nullable<WebGLQuery>;
  56652. _timeElapsedQuery: Nullable<WebGLQuery>;
  56653. _timeElapsedQueryEnded: boolean;
  56654. }
  56655. }
  56656. declare module BABYLON {
  56657. /** @hidden */
  56658. export class _OcclusionDataStorage {
  56659. /** @hidden */
  56660. occlusionInternalRetryCounter: number;
  56661. /** @hidden */
  56662. isOcclusionQueryInProgress: boolean;
  56663. /** @hidden */
  56664. isOccluded: boolean;
  56665. /** @hidden */
  56666. occlusionRetryCount: number;
  56667. /** @hidden */
  56668. occlusionType: number;
  56669. /** @hidden */
  56670. occlusionQueryAlgorithmType: number;
  56671. }
  56672. interface Engine {
  56673. /**
  56674. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  56675. * @return the new query
  56676. */
  56677. createQuery(): WebGLQuery;
  56678. /**
  56679. * Delete and release a webGL query
  56680. * @param query defines the query to delete
  56681. * @return the current engine
  56682. */
  56683. deleteQuery(query: WebGLQuery): Engine;
  56684. /**
  56685. * Check if a given query has resolved and got its value
  56686. * @param query defines the query to check
  56687. * @returns true if the query got its value
  56688. */
  56689. isQueryResultAvailable(query: WebGLQuery): boolean;
  56690. /**
  56691. * Gets the value of a given query
  56692. * @param query defines the query to check
  56693. * @returns the value of the query
  56694. */
  56695. getQueryResult(query: WebGLQuery): number;
  56696. /**
  56697. * Initiates an occlusion query
  56698. * @param algorithmType defines the algorithm to use
  56699. * @param query defines the query to use
  56700. * @returns the current engine
  56701. * @see https://doc.babylonjs.com/features/occlusionquery
  56702. */
  56703. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  56704. /**
  56705. * Ends an occlusion query
  56706. * @see https://doc.babylonjs.com/features/occlusionquery
  56707. * @param algorithmType defines the algorithm to use
  56708. * @returns the current engine
  56709. */
  56710. endOcclusionQuery(algorithmType: number): Engine;
  56711. /**
  56712. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  56713. * Please note that only one query can be issued at a time
  56714. * @returns a time token used to track the time span
  56715. */
  56716. startTimeQuery(): Nullable<_TimeToken>;
  56717. /**
  56718. * Ends a time query
  56719. * @param token defines the token used to measure the time span
  56720. * @returns the time spent (in ns)
  56721. */
  56722. endTimeQuery(token: _TimeToken): int;
  56723. /** @hidden */
  56724. _currentNonTimestampToken: Nullable<_TimeToken>;
  56725. /** @hidden */
  56726. _createTimeQuery(): WebGLQuery;
  56727. /** @hidden */
  56728. _deleteTimeQuery(query: WebGLQuery): void;
  56729. /** @hidden */
  56730. _getGlAlgorithmType(algorithmType: number): number;
  56731. /** @hidden */
  56732. _getTimeQueryResult(query: WebGLQuery): any;
  56733. /** @hidden */
  56734. _getTimeQueryAvailability(query: WebGLQuery): any;
  56735. }
  56736. interface AbstractMesh {
  56737. /**
  56738. * Backing filed
  56739. * @hidden
  56740. */
  56741. __occlusionDataStorage: _OcclusionDataStorage;
  56742. /**
  56743. * Access property
  56744. * @hidden
  56745. */
  56746. _occlusionDataStorage: _OcclusionDataStorage;
  56747. /**
  56748. * 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.
  56749. * The default value is -1 which means don't break the query and wait till the result
  56750. * @see https://doc.babylonjs.com/features/occlusionquery
  56751. */
  56752. occlusionRetryCount: number;
  56753. /**
  56754. * 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:
  56755. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  56756. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  56757. * * 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.
  56758. * @see https://doc.babylonjs.com/features/occlusionquery
  56759. */
  56760. occlusionType: number;
  56761. /**
  56762. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  56763. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  56764. * * 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.
  56765. * @see https://doc.babylonjs.com/features/occlusionquery
  56766. */
  56767. occlusionQueryAlgorithmType: number;
  56768. /**
  56769. * 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
  56770. * @see https://doc.babylonjs.com/features/occlusionquery
  56771. */
  56772. isOccluded: boolean;
  56773. /**
  56774. * Flag to check the progress status of the query
  56775. * @see https://doc.babylonjs.com/features/occlusionquery
  56776. */
  56777. isOcclusionQueryInProgress: boolean;
  56778. }
  56779. }
  56780. declare module BABYLON {
  56781. /** @hidden */
  56782. export var _forceTransformFeedbackToBundle: boolean;
  56783. interface Engine {
  56784. /**
  56785. * Creates a webGL transform feedback object
  56786. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  56787. * @returns the webGL transform feedback object
  56788. */
  56789. createTransformFeedback(): WebGLTransformFeedback;
  56790. /**
  56791. * Delete a webGL transform feedback object
  56792. * @param value defines the webGL transform feedback object to delete
  56793. */
  56794. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  56795. /**
  56796. * Bind a webGL transform feedback object to the webgl context
  56797. * @param value defines the webGL transform feedback object to bind
  56798. */
  56799. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  56800. /**
  56801. * Begins a transform feedback operation
  56802. * @param usePoints defines if points or triangles must be used
  56803. */
  56804. beginTransformFeedback(usePoints: boolean): void;
  56805. /**
  56806. * Ends a transform feedback operation
  56807. */
  56808. endTransformFeedback(): void;
  56809. /**
  56810. * Specify the varyings to use with transform feedback
  56811. * @param program defines the associated webGL program
  56812. * @param value defines the list of strings representing the varying names
  56813. */
  56814. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  56815. /**
  56816. * Bind a webGL buffer for a transform feedback operation
  56817. * @param value defines the webGL buffer to bind
  56818. */
  56819. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  56820. }
  56821. }
  56822. declare module BABYLON {
  56823. /**
  56824. * Class used to define an additional view for the engine
  56825. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56826. */
  56827. export class EngineView {
  56828. /** Defines the canvas where to render the view */
  56829. target: HTMLCanvasElement;
  56830. /** Defines an optional camera used to render the view (will use active camera else) */
  56831. camera?: Camera;
  56832. }
  56833. interface Engine {
  56834. /**
  56835. * Gets or sets the HTML element to use for attaching events
  56836. */
  56837. inputElement: Nullable<HTMLElement>;
  56838. /**
  56839. * Gets the current engine view
  56840. * @see https://doc.babylonjs.com/how_to/multi_canvases
  56841. */
  56842. activeView: Nullable<EngineView>;
  56843. /** Gets or sets the list of views */
  56844. views: EngineView[];
  56845. /**
  56846. * Register a new child canvas
  56847. * @param canvas defines the canvas to register
  56848. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  56849. * @returns the associated view
  56850. */
  56851. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  56852. /**
  56853. * Remove a registered child canvas
  56854. * @param canvas defines the canvas to remove
  56855. * @returns the current engine
  56856. */
  56857. unRegisterView(canvas: HTMLCanvasElement): Engine;
  56858. }
  56859. }
  56860. declare module BABYLON {
  56861. interface Engine {
  56862. /** @hidden */
  56863. _excludedCompressedTextures: string[];
  56864. /** @hidden */
  56865. _textureFormatInUse: string;
  56866. /**
  56867. * Gets the list of texture formats supported
  56868. */
  56869. readonly texturesSupported: Array<string>;
  56870. /**
  56871. * Gets the texture format in use
  56872. */
  56873. readonly textureFormatInUse: Nullable<string>;
  56874. /**
  56875. * Set the compressed texture extensions or file names to skip.
  56876. *
  56877. * @param skippedFiles defines the list of those texture files you want to skip
  56878. * Example: [".dds", ".env", "myfile.png"]
  56879. */
  56880. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  56881. /**
  56882. * Set the compressed texture format to use, based on the formats you have, and the formats
  56883. * supported by the hardware / browser.
  56884. *
  56885. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  56886. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  56887. * to API arguments needed to compressed textures. This puts the burden on the container
  56888. * generator to house the arcane code for determining these for current & future formats.
  56889. *
  56890. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56891. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56892. *
  56893. * Note: The result of this call is not taken into account when a texture is base64.
  56894. *
  56895. * @param formatsAvailable defines the list of those format families you have created
  56896. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  56897. *
  56898. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  56899. * @returns The extension selected.
  56900. */
  56901. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  56902. }
  56903. }
  56904. declare module BABYLON {
  56905. /** @hidden */
  56906. export var rgbdEncodePixelShader: {
  56907. name: string;
  56908. shader: string;
  56909. };
  56910. }
  56911. declare module BABYLON {
  56912. /**
  56913. * Raw texture data and descriptor sufficient for WebGL texture upload
  56914. */
  56915. export interface EnvironmentTextureInfo {
  56916. /**
  56917. * Version of the environment map
  56918. */
  56919. version: number;
  56920. /**
  56921. * Width of image
  56922. */
  56923. width: number;
  56924. /**
  56925. * Irradiance information stored in the file.
  56926. */
  56927. irradiance: any;
  56928. /**
  56929. * Specular information stored in the file.
  56930. */
  56931. specular: any;
  56932. }
  56933. /**
  56934. * Defines One Image in the file. It requires only the position in the file
  56935. * as well as the length.
  56936. */
  56937. interface BufferImageData {
  56938. /**
  56939. * Length of the image data.
  56940. */
  56941. length: number;
  56942. /**
  56943. * Position of the data from the null terminator delimiting the end of the JSON.
  56944. */
  56945. position: number;
  56946. }
  56947. /**
  56948. * Defines the specular data enclosed in the file.
  56949. * This corresponds to the version 1 of the data.
  56950. */
  56951. export interface EnvironmentTextureSpecularInfoV1 {
  56952. /**
  56953. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  56954. */
  56955. specularDataPosition?: number;
  56956. /**
  56957. * This contains all the images data needed to reconstruct the cubemap.
  56958. */
  56959. mipmaps: Array<BufferImageData>;
  56960. /**
  56961. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  56962. */
  56963. lodGenerationScale: number;
  56964. }
  56965. /**
  56966. * Sets of helpers addressing the serialization and deserialization of environment texture
  56967. * stored in a BabylonJS env file.
  56968. * Those files are usually stored as .env files.
  56969. */
  56970. export class EnvironmentTextureTools {
  56971. /**
  56972. * Magic number identifying the env file.
  56973. */
  56974. private static _MagicBytes;
  56975. /**
  56976. * Gets the environment info from an env file.
  56977. * @param data The array buffer containing the .env bytes.
  56978. * @returns the environment file info (the json header) if successfully parsed.
  56979. */
  56980. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  56981. /**
  56982. * Creates an environment texture from a loaded cube texture.
  56983. * @param texture defines the cube texture to convert in env file
  56984. * @return a promise containing the environment data if succesfull.
  56985. */
  56986. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  56987. /**
  56988. * Creates a JSON representation of the spherical data.
  56989. * @param texture defines the texture containing the polynomials
  56990. * @return the JSON representation of the spherical info
  56991. */
  56992. private static _CreateEnvTextureIrradiance;
  56993. /**
  56994. * Creates the ArrayBufferViews used for initializing environment texture image data.
  56995. * @param data the image data
  56996. * @param info parameters that determine what views will be created for accessing the underlying buffer
  56997. * @return the views described by info providing access to the underlying buffer
  56998. */
  56999. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  57000. /**
  57001. * Uploads the texture info contained in the env file to the GPU.
  57002. * @param texture defines the internal texture to upload to
  57003. * @param data defines the data to load
  57004. * @param info defines the texture info retrieved through the GetEnvInfo method
  57005. * @returns a promise
  57006. */
  57007. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  57008. private static _OnImageReadyAsync;
  57009. /**
  57010. * Uploads the levels of image data to the GPU.
  57011. * @param texture defines the internal texture to upload to
  57012. * @param imageData defines the array buffer views of image data [mipmap][face]
  57013. * @returns a promise
  57014. */
  57015. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  57016. /**
  57017. * Uploads spherical polynomials information to the texture.
  57018. * @param texture defines the texture we are trying to upload the information to
  57019. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  57020. */
  57021. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  57022. /** @hidden */
  57023. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57024. }
  57025. }
  57026. declare module BABYLON {
  57027. /**
  57028. * Class used to inline functions in shader code
  57029. */
  57030. export class ShaderCodeInliner {
  57031. private static readonly _RegexpFindFunctionNameAndType;
  57032. private _sourceCode;
  57033. private _functionDescr;
  57034. private _numMaxIterations;
  57035. /** Gets or sets the token used to mark the functions to inline */
  57036. inlineToken: string;
  57037. /** Gets or sets the debug mode */
  57038. debug: boolean;
  57039. /** Gets the code after the inlining process */
  57040. get code(): string;
  57041. /**
  57042. * Initializes the inliner
  57043. * @param sourceCode shader code source to inline
  57044. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  57045. */
  57046. constructor(sourceCode: string, numMaxIterations?: number);
  57047. /**
  57048. * Start the processing of the shader code
  57049. */
  57050. processCode(): void;
  57051. private _collectFunctions;
  57052. private _processInlining;
  57053. private _extractBetweenMarkers;
  57054. private _skipWhitespaces;
  57055. private _removeComments;
  57056. private _replaceFunctionCallsByCode;
  57057. private _findBackward;
  57058. private _escapeRegExp;
  57059. private _replaceNames;
  57060. }
  57061. }
  57062. declare module BABYLON {
  57063. /**
  57064. * Container for accessors for natively-stored mesh data buffers.
  57065. */
  57066. class NativeDataBuffer extends DataBuffer {
  57067. /**
  57068. * Accessor value used to identify/retrieve a natively-stored index buffer.
  57069. */
  57070. nativeIndexBuffer?: any;
  57071. /**
  57072. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  57073. */
  57074. nativeVertexBuffer?: any;
  57075. }
  57076. /** @hidden */
  57077. class NativeTexture extends InternalTexture {
  57078. getInternalTexture(): InternalTexture;
  57079. getViewCount(): number;
  57080. }
  57081. /** @hidden */
  57082. export class NativeEngine extends Engine {
  57083. private readonly _native;
  57084. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  57085. private readonly INVALID_HANDLE;
  57086. private _boundBuffersVertexArray;
  57087. private _currentDepthTest;
  57088. getHardwareScalingLevel(): number;
  57089. constructor();
  57090. dispose(): void;
  57091. /**
  57092. * Can be used to override the current requestAnimationFrame requester.
  57093. * @hidden
  57094. */
  57095. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  57096. /**
  57097. * Override default engine behavior.
  57098. * @param color
  57099. * @param backBuffer
  57100. * @param depth
  57101. * @param stencil
  57102. */
  57103. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  57104. /**
  57105. * Gets host document
  57106. * @returns the host document object
  57107. */
  57108. getHostDocument(): Nullable<Document>;
  57109. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57110. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  57111. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  57112. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  57113. [key: string]: VertexBuffer;
  57114. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57115. bindBuffers(vertexBuffers: {
  57116. [key: string]: VertexBuffer;
  57117. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  57118. recordVertexArrayObject(vertexBuffers: {
  57119. [key: string]: VertexBuffer;
  57120. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  57121. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57122. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  57123. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57124. /**
  57125. * Draw a list of indexed primitives
  57126. * @param fillMode defines the primitive to use
  57127. * @param indexStart defines the starting index
  57128. * @param indexCount defines the number of index to draw
  57129. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57130. */
  57131. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57132. /**
  57133. * Draw a list of unindexed primitives
  57134. * @param fillMode defines the primitive to use
  57135. * @param verticesStart defines the index of first vertex to draw
  57136. * @param verticesCount defines the count of vertices to draw
  57137. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57138. */
  57139. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57140. createPipelineContext(): IPipelineContext;
  57141. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  57142. /** @hidden */
  57143. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  57144. /** @hidden */
  57145. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  57146. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57147. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  57148. protected _setProgram(program: WebGLProgram): void;
  57149. _releaseEffect(effect: Effect): void;
  57150. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  57151. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  57152. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  57153. bindSamplers(effect: Effect): void;
  57154. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  57155. getRenderWidth(useScreen?: boolean): number;
  57156. getRenderHeight(useScreen?: boolean): number;
  57157. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  57158. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57159. /**
  57160. * Set the z offset to apply to current rendering
  57161. * @param value defines the offset to apply
  57162. */
  57163. setZOffset(value: number): void;
  57164. /**
  57165. * Gets the current value of the zOffset
  57166. * @returns the current zOffset state
  57167. */
  57168. getZOffset(): number;
  57169. /**
  57170. * Enable or disable depth buffering
  57171. * @param enable defines the state to set
  57172. */
  57173. setDepthBuffer(enable: boolean): void;
  57174. /**
  57175. * Gets a boolean indicating if depth writing is enabled
  57176. * @returns the current depth writing state
  57177. */
  57178. getDepthWrite(): boolean;
  57179. setDepthFunctionToGreater(): void;
  57180. setDepthFunctionToGreaterOrEqual(): void;
  57181. setDepthFunctionToLess(): void;
  57182. setDepthFunctionToLessOrEqual(): void;
  57183. /**
  57184. * Enable or disable depth writing
  57185. * @param enable defines the state to set
  57186. */
  57187. setDepthWrite(enable: boolean): void;
  57188. /**
  57189. * Enable or disable color writing
  57190. * @param enable defines the state to set
  57191. */
  57192. setColorWrite(enable: boolean): void;
  57193. /**
  57194. * Gets a boolean indicating if color writing is enabled
  57195. * @returns the current color writing state
  57196. */
  57197. getColorWrite(): boolean;
  57198. /**
  57199. * Sets alpha constants used by some alpha blending modes
  57200. * @param r defines the red component
  57201. * @param g defines the green component
  57202. * @param b defines the blue component
  57203. * @param a defines the alpha component
  57204. */
  57205. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  57206. /**
  57207. * Sets the current alpha mode
  57208. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  57209. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57210. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57211. */
  57212. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57213. /**
  57214. * Gets the current alpha mode
  57215. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57216. * @returns the current alpha mode
  57217. */
  57218. getAlphaMode(): number;
  57219. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  57220. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57221. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57222. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57223. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57224. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57225. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57226. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57227. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57228. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57229. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57230. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57231. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57232. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57233. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57234. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57235. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57236. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57237. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57238. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57239. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  57240. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  57241. wipeCaches(bruteForce?: boolean): void;
  57242. _createTexture(): WebGLTexture;
  57243. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  57244. /**
  57245. * Update the content of a dynamic texture
  57246. * @param texture defines the texture to update
  57247. * @param canvas defines the canvas containing the source
  57248. * @param invertY defines if data must be stored with Y axis inverted
  57249. * @param premulAlpha defines if alpha is stored as premultiplied
  57250. * @param format defines the format of the data
  57251. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57252. */
  57253. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57254. /**
  57255. * Usually called from Texture.ts.
  57256. * Passed information to create a WebGLTexture
  57257. * @param url defines a value which contains one of the following:
  57258. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57259. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57260. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57261. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57262. * @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)
  57263. * @param scene needed for loading to the correct scene
  57264. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57265. * @param onLoad optional callback to be called upon successful completion
  57266. * @param onError optional callback to be called upon failure
  57267. * @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
  57268. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57269. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57270. * @param forcedExtension defines the extension to use to pick the right loader
  57271. * @param mimeType defines an optional mime type
  57272. * @param loaderOptions options to be passed to the loader
  57273. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57274. */
  57275. 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;
  57276. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  57277. _releaseFramebufferObjects(texture: InternalTexture): void;
  57278. /**
  57279. * Creates a cube texture
  57280. * @param rootUrl defines the url where the files to load is located
  57281. * @param scene defines the current scene
  57282. * @param files defines the list of files to load (1 per face)
  57283. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  57284. * @param onLoad defines an optional callback raised when the texture is loaded
  57285. * @param onError defines an optional callback raised if there is an issue to load the texture
  57286. * @param format defines the format of the data
  57287. * @param forcedExtension defines the extension to use to pick the right loader
  57288. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  57289. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57290. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57291. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  57292. * @returns the cube texture as an InternalTexture
  57293. */
  57294. 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;
  57295. createRenderTargetTexture(size: number | {
  57296. width: number;
  57297. height: number;
  57298. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  57299. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57300. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57301. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57302. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  57303. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  57304. /**
  57305. * Updates a dynamic vertex buffer.
  57306. * @param vertexBuffer the vertex buffer to update
  57307. * @param data the data used to update the vertex buffer
  57308. * @param byteOffset the byte offset of the data (optional)
  57309. * @param byteLength the byte length of the data (optional)
  57310. */
  57311. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  57312. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  57313. private _updateAnisotropicLevel;
  57314. private _getAddressMode;
  57315. /** @hidden */
  57316. _bindTexture(channel: number, texture: InternalTexture): void;
  57317. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  57318. releaseEffects(): void;
  57319. /** @hidden */
  57320. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57321. /** @hidden */
  57322. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57323. /** @hidden */
  57324. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57325. /** @hidden */
  57326. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57327. private _getNativeSamplingMode;
  57328. private _getNativeTextureFormat;
  57329. private _getNativeAlphaMode;
  57330. private _getNativeAttribType;
  57331. }
  57332. }
  57333. declare module BABYLON {
  57334. /**
  57335. * Gather the list of clipboard event types as constants.
  57336. */
  57337. export class ClipboardEventTypes {
  57338. /**
  57339. * The clipboard event is fired when a copy command is active (pressed).
  57340. */
  57341. static readonly COPY: number;
  57342. /**
  57343. * The clipboard event is fired when a cut command is active (pressed).
  57344. */
  57345. static readonly CUT: number;
  57346. /**
  57347. * The clipboard event is fired when a paste command is active (pressed).
  57348. */
  57349. static readonly PASTE: number;
  57350. }
  57351. /**
  57352. * This class is used to store clipboard related info for the onClipboardObservable event.
  57353. */
  57354. export class ClipboardInfo {
  57355. /**
  57356. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57357. */
  57358. type: number;
  57359. /**
  57360. * Defines the related dom event
  57361. */
  57362. event: ClipboardEvent;
  57363. /**
  57364. *Creates an instance of ClipboardInfo.
  57365. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  57366. * @param event Defines the related dom event
  57367. */
  57368. constructor(
  57369. /**
  57370. * Defines the type of event (BABYLON.ClipboardEventTypes)
  57371. */
  57372. type: number,
  57373. /**
  57374. * Defines the related dom event
  57375. */
  57376. event: ClipboardEvent);
  57377. /**
  57378. * Get the clipboard event's type from the keycode.
  57379. * @param keyCode Defines the keyCode for the current keyboard event.
  57380. * @return {number}
  57381. */
  57382. static GetTypeFromCharacter(keyCode: number): number;
  57383. }
  57384. }
  57385. declare module BABYLON {
  57386. /**
  57387. * Google Daydream controller
  57388. */
  57389. export class DaydreamController extends WebVRController {
  57390. /**
  57391. * Base Url for the controller model.
  57392. */
  57393. static MODEL_BASE_URL: string;
  57394. /**
  57395. * File name for the controller model.
  57396. */
  57397. static MODEL_FILENAME: string;
  57398. /**
  57399. * Gamepad Id prefix used to identify Daydream Controller.
  57400. */
  57401. static readonly GAMEPAD_ID_PREFIX: string;
  57402. /**
  57403. * Creates a new DaydreamController from a gamepad
  57404. * @param vrGamepad the gamepad that the controller should be created from
  57405. */
  57406. constructor(vrGamepad: any);
  57407. /**
  57408. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57409. * @param scene scene in which to add meshes
  57410. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57411. */
  57412. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57413. /**
  57414. * Called once for each button that changed state since the last frame
  57415. * @param buttonIdx Which button index changed
  57416. * @param state New state of the button
  57417. * @param changes Which properties on the state changed since last frame
  57418. */
  57419. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57420. }
  57421. }
  57422. declare module BABYLON {
  57423. /**
  57424. * Gear VR Controller
  57425. */
  57426. export class GearVRController extends WebVRController {
  57427. /**
  57428. * Base Url for the controller model.
  57429. */
  57430. static MODEL_BASE_URL: string;
  57431. /**
  57432. * File name for the controller model.
  57433. */
  57434. static MODEL_FILENAME: string;
  57435. /**
  57436. * Gamepad Id prefix used to identify this controller.
  57437. */
  57438. static readonly GAMEPAD_ID_PREFIX: string;
  57439. private readonly _buttonIndexToObservableNameMap;
  57440. /**
  57441. * Creates a new GearVRController from a gamepad
  57442. * @param vrGamepad the gamepad that the controller should be created from
  57443. */
  57444. constructor(vrGamepad: any);
  57445. /**
  57446. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57447. * @param scene scene in which to add meshes
  57448. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57449. */
  57450. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57451. /**
  57452. * Called once for each button that changed state since the last frame
  57453. * @param buttonIdx Which button index changed
  57454. * @param state New state of the button
  57455. * @param changes Which properties on the state changed since last frame
  57456. */
  57457. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57458. }
  57459. }
  57460. declare module BABYLON {
  57461. /**
  57462. * Generic Controller
  57463. */
  57464. export class GenericController extends WebVRController {
  57465. /**
  57466. * Base Url for the controller model.
  57467. */
  57468. static readonly MODEL_BASE_URL: string;
  57469. /**
  57470. * File name for the controller model.
  57471. */
  57472. static readonly MODEL_FILENAME: string;
  57473. /**
  57474. * Creates a new GenericController from a gamepad
  57475. * @param vrGamepad the gamepad that the controller should be created from
  57476. */
  57477. constructor(vrGamepad: any);
  57478. /**
  57479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57480. * @param scene scene in which to add meshes
  57481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57482. */
  57483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57484. /**
  57485. * Called once for each button that changed state since the last frame
  57486. * @param buttonIdx Which button index changed
  57487. * @param state New state of the button
  57488. * @param changes Which properties on the state changed since last frame
  57489. */
  57490. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57491. }
  57492. }
  57493. declare module BABYLON {
  57494. /**
  57495. * Oculus Touch Controller
  57496. */
  57497. export class OculusTouchController extends WebVRController {
  57498. /**
  57499. * Base Url for the controller model.
  57500. */
  57501. static MODEL_BASE_URL: string;
  57502. /**
  57503. * File name for the left controller model.
  57504. */
  57505. static MODEL_LEFT_FILENAME: string;
  57506. /**
  57507. * File name for the right controller model.
  57508. */
  57509. static MODEL_RIGHT_FILENAME: string;
  57510. /**
  57511. * Base Url for the Quest controller model.
  57512. */
  57513. static QUEST_MODEL_BASE_URL: string;
  57514. /**
  57515. * @hidden
  57516. * If the controllers are running on a device that needs the updated Quest controller models
  57517. */
  57518. static _IsQuest: boolean;
  57519. /**
  57520. * Fired when the secondary trigger on this controller is modified
  57521. */
  57522. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  57523. /**
  57524. * Fired when the thumb rest on this controller is modified
  57525. */
  57526. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  57527. /**
  57528. * Creates a new OculusTouchController from a gamepad
  57529. * @param vrGamepad the gamepad that the controller should be created from
  57530. */
  57531. constructor(vrGamepad: any);
  57532. /**
  57533. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57534. * @param scene scene in which to add meshes
  57535. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57536. */
  57537. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57538. /**
  57539. * Fired when the A button on this controller is modified
  57540. */
  57541. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57542. /**
  57543. * Fired when the B button on this controller is modified
  57544. */
  57545. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57546. /**
  57547. * Fired when the X button on this controller is modified
  57548. */
  57549. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57550. /**
  57551. * Fired when the Y button on this controller is modified
  57552. */
  57553. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57554. /**
  57555. * Called once for each button that changed state since the last frame
  57556. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  57557. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  57558. * 2) secondary trigger (same)
  57559. * 3) A (right) X (left), touch, pressed = value
  57560. * 4) B / Y
  57561. * 5) thumb rest
  57562. * @param buttonIdx Which button index changed
  57563. * @param state New state of the button
  57564. * @param changes Which properties on the state changed since last frame
  57565. */
  57566. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57567. }
  57568. }
  57569. declare module BABYLON {
  57570. /**
  57571. * Vive Controller
  57572. */
  57573. export class ViveController extends WebVRController {
  57574. /**
  57575. * Base Url for the controller model.
  57576. */
  57577. static MODEL_BASE_URL: string;
  57578. /**
  57579. * File name for the controller model.
  57580. */
  57581. static MODEL_FILENAME: string;
  57582. /**
  57583. * Creates a new ViveController from a gamepad
  57584. * @param vrGamepad the gamepad that the controller should be created from
  57585. */
  57586. constructor(vrGamepad: any);
  57587. /**
  57588. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57589. * @param scene scene in which to add meshes
  57590. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57591. */
  57592. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  57593. /**
  57594. * Fired when the left button on this controller is modified
  57595. */
  57596. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57597. /**
  57598. * Fired when the right button on this controller is modified
  57599. */
  57600. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57601. /**
  57602. * Fired when the menu button on this controller is modified
  57603. */
  57604. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57605. /**
  57606. * Called once for each button that changed state since the last frame
  57607. * Vive mapping:
  57608. * 0: touchpad
  57609. * 1: trigger
  57610. * 2: left AND right buttons
  57611. * 3: menu button
  57612. * @param buttonIdx Which button index changed
  57613. * @param state New state of the button
  57614. * @param changes Which properties on the state changed since last frame
  57615. */
  57616. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57617. }
  57618. }
  57619. declare module BABYLON {
  57620. /**
  57621. * Defines the WindowsMotionController object that the state of the windows motion controller
  57622. */
  57623. export class WindowsMotionController extends WebVRController {
  57624. /**
  57625. * The base url used to load the left and right controller models
  57626. */
  57627. static MODEL_BASE_URL: string;
  57628. /**
  57629. * The name of the left controller model file
  57630. */
  57631. static MODEL_LEFT_FILENAME: string;
  57632. /**
  57633. * The name of the right controller model file
  57634. */
  57635. static MODEL_RIGHT_FILENAME: string;
  57636. /**
  57637. * The controller name prefix for this controller type
  57638. */
  57639. static readonly GAMEPAD_ID_PREFIX: string;
  57640. /**
  57641. * The controller id pattern for this controller type
  57642. */
  57643. private static readonly GAMEPAD_ID_PATTERN;
  57644. private _loadedMeshInfo;
  57645. protected readonly _mapping: {
  57646. buttons: string[];
  57647. buttonMeshNames: {
  57648. trigger: string;
  57649. menu: string;
  57650. grip: string;
  57651. thumbstick: string;
  57652. trackpad: string;
  57653. };
  57654. buttonObservableNames: {
  57655. trigger: string;
  57656. menu: string;
  57657. grip: string;
  57658. thumbstick: string;
  57659. trackpad: string;
  57660. };
  57661. axisMeshNames: string[];
  57662. pointingPoseMeshName: string;
  57663. };
  57664. /**
  57665. * Fired when the trackpad on this controller is clicked
  57666. */
  57667. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57668. /**
  57669. * Fired when the trackpad on this controller is modified
  57670. */
  57671. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57672. /**
  57673. * The current x and y values of this controller's trackpad
  57674. */
  57675. trackpad: StickValues;
  57676. /**
  57677. * Creates a new WindowsMotionController from a gamepad
  57678. * @param vrGamepad the gamepad that the controller should be created from
  57679. */
  57680. constructor(vrGamepad: any);
  57681. /**
  57682. * Fired when the trigger on this controller is modified
  57683. */
  57684. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57685. /**
  57686. * Fired when the menu button on this controller is modified
  57687. */
  57688. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57689. /**
  57690. * Fired when the grip button on this controller is modified
  57691. */
  57692. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57693. /**
  57694. * Fired when the thumbstick button on this controller is modified
  57695. */
  57696. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57697. /**
  57698. * Fired when the touchpad button on this controller is modified
  57699. */
  57700. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57701. /**
  57702. * Fired when the touchpad values on this controller are modified
  57703. */
  57704. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  57705. protected _updateTrackpad(): void;
  57706. /**
  57707. * Called once per frame by the engine.
  57708. */
  57709. update(): void;
  57710. /**
  57711. * Called once for each button that changed state since the last frame
  57712. * @param buttonIdx Which button index changed
  57713. * @param state New state of the button
  57714. * @param changes Which properties on the state changed since last frame
  57715. */
  57716. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  57717. /**
  57718. * Moves the buttons on the controller mesh based on their current state
  57719. * @param buttonName the name of the button to move
  57720. * @param buttonValue the value of the button which determines the buttons new position
  57721. */
  57722. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  57723. /**
  57724. * Moves the axis on the controller mesh based on its current state
  57725. * @param axis the index of the axis
  57726. * @param axisValue the value of the axis which determines the meshes new position
  57727. * @hidden
  57728. */
  57729. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  57730. /**
  57731. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  57732. * @param scene scene in which to add meshes
  57733. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  57734. */
  57735. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  57736. /**
  57737. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  57738. * can be transformed by button presses and axes values, based on this._mapping.
  57739. *
  57740. * @param scene scene in which the meshes exist
  57741. * @param meshes list of meshes that make up the controller model to process
  57742. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  57743. */
  57744. private processModel;
  57745. private createMeshInfo;
  57746. /**
  57747. * Gets the ray of the controller in the direction the controller is pointing
  57748. * @param length the length the resulting ray should be
  57749. * @returns a ray in the direction the controller is pointing
  57750. */
  57751. getForwardRay(length?: number): Ray;
  57752. /**
  57753. * Disposes of the controller
  57754. */
  57755. dispose(): void;
  57756. }
  57757. /**
  57758. * This class represents a new windows motion controller in XR.
  57759. */
  57760. export class XRWindowsMotionController extends WindowsMotionController {
  57761. /**
  57762. * Changing the original WIndowsMotionController mapping to fir the new mapping
  57763. */
  57764. protected readonly _mapping: {
  57765. buttons: string[];
  57766. buttonMeshNames: {
  57767. trigger: string;
  57768. menu: string;
  57769. grip: string;
  57770. thumbstick: string;
  57771. trackpad: string;
  57772. };
  57773. buttonObservableNames: {
  57774. trigger: string;
  57775. menu: string;
  57776. grip: string;
  57777. thumbstick: string;
  57778. trackpad: string;
  57779. };
  57780. axisMeshNames: string[];
  57781. pointingPoseMeshName: string;
  57782. };
  57783. /**
  57784. * Construct a new XR-Based windows motion controller
  57785. *
  57786. * @param gamepadInfo the gamepad object from the browser
  57787. */
  57788. constructor(gamepadInfo: any);
  57789. /**
  57790. * holds the thumbstick values (X,Y)
  57791. */
  57792. thumbstickValues: StickValues;
  57793. /**
  57794. * Fired when the thumbstick on this controller is clicked
  57795. */
  57796. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  57797. /**
  57798. * Fired when the thumbstick on this controller is modified
  57799. */
  57800. onThumbstickValuesChangedObservable: Observable<StickValues>;
  57801. /**
  57802. * Fired when the touchpad button on this controller is modified
  57803. */
  57804. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  57805. /**
  57806. * Fired when the touchpad values on this controller are modified
  57807. */
  57808. onTrackpadValuesChangedObservable: Observable<StickValues>;
  57809. /**
  57810. * Fired when the thumbstick button on this controller is modified
  57811. * here to prevent breaking changes
  57812. */
  57813. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  57814. /**
  57815. * updating the thumbstick(!) and not the trackpad.
  57816. * This is named this way due to the difference between WebVR and XR and to avoid
  57817. * changing the parent class.
  57818. */
  57819. protected _updateTrackpad(): void;
  57820. /**
  57821. * Disposes the class with joy
  57822. */
  57823. dispose(): void;
  57824. }
  57825. }
  57826. declare module BABYLON {
  57827. /**
  57828. * A directional light is defined by a direction (what a surprise!).
  57829. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  57830. * 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.
  57831. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57832. */
  57833. export class DirectionalLight extends ShadowLight {
  57834. private _shadowFrustumSize;
  57835. /**
  57836. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  57837. */
  57838. get shadowFrustumSize(): number;
  57839. /**
  57840. * Specifies a fix frustum size for the shadow generation.
  57841. */
  57842. set shadowFrustumSize(value: number);
  57843. private _shadowOrthoScale;
  57844. /**
  57845. * Gets the shadow projection scale against the optimal computed one.
  57846. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57847. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57848. */
  57849. get shadowOrthoScale(): number;
  57850. /**
  57851. * Sets the shadow projection scale against the optimal computed one.
  57852. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  57853. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  57854. */
  57855. set shadowOrthoScale(value: number);
  57856. /**
  57857. * Automatically compute the projection matrix to best fit (including all the casters)
  57858. * on each frame.
  57859. */
  57860. autoUpdateExtends: boolean;
  57861. /**
  57862. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  57863. * on each frame. autoUpdateExtends must be set to true for this to work
  57864. */
  57865. autoCalcShadowZBounds: boolean;
  57866. private _orthoLeft;
  57867. private _orthoRight;
  57868. private _orthoTop;
  57869. private _orthoBottom;
  57870. /**
  57871. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  57872. * The directional light is emitted from everywhere in the given direction.
  57873. * It can cast shadows.
  57874. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57875. * @param name The friendly name of the light
  57876. * @param direction The direction of the light
  57877. * @param scene The scene the light belongs to
  57878. */
  57879. constructor(name: string, direction: Vector3, scene: Scene);
  57880. /**
  57881. * Returns the string "DirectionalLight".
  57882. * @return The class name
  57883. */
  57884. getClassName(): string;
  57885. /**
  57886. * Returns the integer 1.
  57887. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57888. */
  57889. getTypeID(): number;
  57890. /**
  57891. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  57892. * Returns the DirectionalLight Shadow projection matrix.
  57893. */
  57894. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57895. /**
  57896. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  57897. * Returns the DirectionalLight Shadow projection matrix.
  57898. */
  57899. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  57900. /**
  57901. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  57902. * Returns the DirectionalLight Shadow projection matrix.
  57903. */
  57904. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57905. protected _buildUniformLayout(): void;
  57906. /**
  57907. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  57908. * @param effect The effect to update
  57909. * @param lightIndex The index of the light in the effect to update
  57910. * @returns The directional light
  57911. */
  57912. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  57913. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  57914. /**
  57915. * Gets the minZ 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 min for
  57920. * @returns the depth min z
  57921. */
  57922. getDepthMinZ(activeCamera: Camera): number;
  57923. /**
  57924. * Gets the maxZ used for shadow according to both the scene and the light.
  57925. *
  57926. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  57927. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  57928. * @param activeCamera The camera we are returning the max for
  57929. * @returns the depth max z
  57930. */
  57931. getDepthMaxZ(activeCamera: Camera): number;
  57932. /**
  57933. * Prepares the list of defines specific to the light type.
  57934. * @param defines the list of defines
  57935. * @param lightIndex defines the index of the light for the effect
  57936. */
  57937. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57938. }
  57939. }
  57940. declare module BABYLON {
  57941. /**
  57942. * Class containing static functions to help procedurally build meshes
  57943. */
  57944. export class HemisphereBuilder {
  57945. /**
  57946. * Creates a hemisphere mesh
  57947. * @param name defines the name of the mesh
  57948. * @param options defines the options used to create the mesh
  57949. * @param scene defines the hosting scene
  57950. * @returns the hemisphere mesh
  57951. */
  57952. static CreateHemisphere(name: string, options: {
  57953. segments?: number;
  57954. diameter?: number;
  57955. sideOrientation?: number;
  57956. }, scene: any): Mesh;
  57957. }
  57958. }
  57959. declare module BABYLON {
  57960. /**
  57961. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57962. * These values define a cone of light starting from the position, emitting toward the direction.
  57963. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57964. * and the exponent defines the speed of the decay of the light with distance (reach).
  57965. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57966. */
  57967. export class SpotLight extends ShadowLight {
  57968. private _angle;
  57969. private _innerAngle;
  57970. private _cosHalfAngle;
  57971. private _lightAngleScale;
  57972. private _lightAngleOffset;
  57973. /**
  57974. * Gets the cone angle of the spot light in Radians.
  57975. */
  57976. get angle(): number;
  57977. /**
  57978. * Sets the cone angle of the spot light in Radians.
  57979. */
  57980. set angle(value: number);
  57981. /**
  57982. * Only used in gltf falloff mode, this defines the angle where
  57983. * the directional falloff will start before cutting at angle which could be seen
  57984. * as outer angle.
  57985. */
  57986. get innerAngle(): number;
  57987. /**
  57988. * Only used in gltf falloff mode, this defines the angle where
  57989. * the directional falloff will start before cutting at angle which could be seen
  57990. * as outer angle.
  57991. */
  57992. set innerAngle(value: number);
  57993. private _shadowAngleScale;
  57994. /**
  57995. * Allows scaling the angle of the light for shadow generation only.
  57996. */
  57997. get shadowAngleScale(): number;
  57998. /**
  57999. * Allows scaling the angle of the light for shadow generation only.
  58000. */
  58001. set shadowAngleScale(value: number);
  58002. /**
  58003. * The light decay speed with the distance from the emission spot.
  58004. */
  58005. exponent: number;
  58006. private _projectionTextureMatrix;
  58007. /**
  58008. * Allows reading the projecton texture
  58009. */
  58010. get projectionTextureMatrix(): Matrix;
  58011. protected _projectionTextureLightNear: number;
  58012. /**
  58013. * Gets the near clip of the Spotlight for texture projection.
  58014. */
  58015. get projectionTextureLightNear(): number;
  58016. /**
  58017. * Sets the near clip of the Spotlight for texture projection.
  58018. */
  58019. set projectionTextureLightNear(value: number);
  58020. protected _projectionTextureLightFar: number;
  58021. /**
  58022. * Gets the far clip of the Spotlight for texture projection.
  58023. */
  58024. get projectionTextureLightFar(): number;
  58025. /**
  58026. * Sets the far clip of the Spotlight for texture projection.
  58027. */
  58028. set projectionTextureLightFar(value: number);
  58029. protected _projectionTextureUpDirection: Vector3;
  58030. /**
  58031. * Gets the Up vector of the Spotlight for texture projection.
  58032. */
  58033. get projectionTextureUpDirection(): Vector3;
  58034. /**
  58035. * Sets the Up vector of the Spotlight for texture projection.
  58036. */
  58037. set projectionTextureUpDirection(value: Vector3);
  58038. private _projectionTexture;
  58039. /**
  58040. * Gets the projection texture of the light.
  58041. */
  58042. get projectionTexture(): Nullable<BaseTexture>;
  58043. /**
  58044. * Sets the projection texture of the light.
  58045. */
  58046. set projectionTexture(value: Nullable<BaseTexture>);
  58047. private static _IsProceduralTexture;
  58048. private static _IsTexture;
  58049. private _projectionTextureViewLightDirty;
  58050. private _projectionTextureProjectionLightDirty;
  58051. private _projectionTextureDirty;
  58052. private _projectionTextureViewTargetVector;
  58053. private _projectionTextureViewLightMatrix;
  58054. private _projectionTextureProjectionLightMatrix;
  58055. private _projectionTextureScalingMatrix;
  58056. /**
  58057. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  58058. * It can cast shadows.
  58059. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58060. * @param name The light friendly name
  58061. * @param position The position of the spot light in the scene
  58062. * @param direction The direction of the light in the scene
  58063. * @param angle The cone angle of the light in Radians
  58064. * @param exponent The light decay speed with the distance from the emission spot
  58065. * @param scene The scene the lights belongs to
  58066. */
  58067. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  58068. /**
  58069. * Returns the string "SpotLight".
  58070. * @returns the class name
  58071. */
  58072. getClassName(): string;
  58073. /**
  58074. * Returns the integer 2.
  58075. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58076. */
  58077. getTypeID(): number;
  58078. /**
  58079. * Overrides the direction setter to recompute the projection texture view light Matrix.
  58080. */
  58081. protected _setDirection(value: Vector3): void;
  58082. /**
  58083. * Overrides the position setter to recompute the projection texture view light Matrix.
  58084. */
  58085. protected _setPosition(value: Vector3): void;
  58086. /**
  58087. * 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.
  58088. * Returns the SpotLight.
  58089. */
  58090. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58091. protected _computeProjectionTextureViewLightMatrix(): void;
  58092. protected _computeProjectionTextureProjectionLightMatrix(): void;
  58093. /**
  58094. * Main function for light texture projection matrix computing.
  58095. */
  58096. protected _computeProjectionTextureMatrix(): void;
  58097. protected _buildUniformLayout(): void;
  58098. private _computeAngleValues;
  58099. /**
  58100. * Sets the passed Effect "effect" with the Light textures.
  58101. * @param effect The effect to update
  58102. * @param lightIndex The index of the light in the effect to update
  58103. * @returns The light
  58104. */
  58105. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  58106. /**
  58107. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  58108. * @param effect The effect to update
  58109. * @param lightIndex The index of the light in the effect to update
  58110. * @returns The spot light
  58111. */
  58112. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  58113. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58114. /**
  58115. * Disposes the light and the associated resources.
  58116. */
  58117. dispose(): void;
  58118. /**
  58119. * Prepares the list of defines specific to the light type.
  58120. * @param defines the list of defines
  58121. * @param lightIndex defines the index of the light for the effect
  58122. */
  58123. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  58124. }
  58125. }
  58126. declare module BABYLON {
  58127. /**
  58128. * Gizmo that enables viewing a light
  58129. */
  58130. export class LightGizmo extends Gizmo {
  58131. private _lightMesh;
  58132. private _material;
  58133. private _cachedPosition;
  58134. private _cachedForward;
  58135. private _attachedMeshParent;
  58136. private _pointerObserver;
  58137. /**
  58138. * Event that fires each time the gizmo is clicked
  58139. */
  58140. onClickedObservable: Observable<Light>;
  58141. /**
  58142. * Creates a LightGizmo
  58143. * @param gizmoLayer The utility layer the gizmo will be added to
  58144. */
  58145. constructor(gizmoLayer?: UtilityLayerRenderer);
  58146. private _light;
  58147. /**
  58148. * The light that the gizmo is attached to
  58149. */
  58150. set light(light: Nullable<Light>);
  58151. get light(): Nullable<Light>;
  58152. /**
  58153. * Gets the material used to render the light gizmo
  58154. */
  58155. get material(): StandardMaterial;
  58156. /**
  58157. * @hidden
  58158. * Updates the gizmo to match the attached mesh's position/rotation
  58159. */
  58160. protected _update(): void;
  58161. private static _Scale;
  58162. /**
  58163. * Creates the lines for a light mesh
  58164. */
  58165. private static _CreateLightLines;
  58166. /**
  58167. * Disposes of the light gizmo
  58168. */
  58169. dispose(): void;
  58170. private static _CreateHemisphericLightMesh;
  58171. private static _CreatePointLightMesh;
  58172. private static _CreateSpotLightMesh;
  58173. private static _CreateDirectionalLightMesh;
  58174. }
  58175. }
  58176. declare module BABYLON {
  58177. /**
  58178. * Gizmo that enables viewing a camera
  58179. */
  58180. export class CameraGizmo extends Gizmo {
  58181. private _cameraMesh;
  58182. private _cameraLinesMesh;
  58183. private _material;
  58184. private _pointerObserver;
  58185. /**
  58186. * Event that fires each time the gizmo is clicked
  58187. */
  58188. onClickedObservable: Observable<Camera>;
  58189. /**
  58190. * Creates a CameraGizmo
  58191. * @param gizmoLayer The utility layer the gizmo will be added to
  58192. */
  58193. constructor(gizmoLayer?: UtilityLayerRenderer);
  58194. private _camera;
  58195. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  58196. get displayFrustum(): boolean;
  58197. set displayFrustum(value: boolean);
  58198. /**
  58199. * The camera that the gizmo is attached to
  58200. */
  58201. set camera(camera: Nullable<Camera>);
  58202. get camera(): Nullable<Camera>;
  58203. /**
  58204. * Gets the material used to render the camera gizmo
  58205. */
  58206. get material(): StandardMaterial;
  58207. /**
  58208. * @hidden
  58209. * Updates the gizmo to match the attached mesh's position/rotation
  58210. */
  58211. protected _update(): void;
  58212. private static _Scale;
  58213. private _invProjection;
  58214. /**
  58215. * Disposes of the camera gizmo
  58216. */
  58217. dispose(): void;
  58218. private static _CreateCameraMesh;
  58219. private static _CreateCameraFrustum;
  58220. }
  58221. }
  58222. declare module BABYLON {
  58223. /** @hidden */
  58224. export var backgroundFragmentDeclaration: {
  58225. name: string;
  58226. shader: string;
  58227. };
  58228. }
  58229. declare module BABYLON {
  58230. /** @hidden */
  58231. export var backgroundUboDeclaration: {
  58232. name: string;
  58233. shader: string;
  58234. };
  58235. }
  58236. declare module BABYLON {
  58237. /** @hidden */
  58238. export var backgroundPixelShader: {
  58239. name: string;
  58240. shader: string;
  58241. };
  58242. }
  58243. declare module BABYLON {
  58244. /** @hidden */
  58245. export var backgroundVertexDeclaration: {
  58246. name: string;
  58247. shader: string;
  58248. };
  58249. }
  58250. declare module BABYLON {
  58251. /** @hidden */
  58252. export var backgroundVertexShader: {
  58253. name: string;
  58254. shader: string;
  58255. };
  58256. }
  58257. declare module BABYLON {
  58258. /**
  58259. * Background material used to create an efficient environement around your scene.
  58260. */
  58261. export class BackgroundMaterial extends PushMaterial {
  58262. /**
  58263. * Standard reflectance value at parallel view angle.
  58264. */
  58265. static StandardReflectance0: number;
  58266. /**
  58267. * Standard reflectance value at grazing angle.
  58268. */
  58269. static StandardReflectance90: number;
  58270. protected _primaryColor: Color3;
  58271. /**
  58272. * Key light Color (multiply against the environement texture)
  58273. */
  58274. primaryColor: Color3;
  58275. protected __perceptualColor: Nullable<Color3>;
  58276. /**
  58277. * Experimental Internal Use Only.
  58278. *
  58279. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  58280. * This acts as a helper to set the primary color to a more "human friendly" value.
  58281. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  58282. * output color as close as possible from the chosen value.
  58283. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  58284. * part of lighting setup.)
  58285. */
  58286. get _perceptualColor(): Nullable<Color3>;
  58287. set _perceptualColor(value: Nullable<Color3>);
  58288. protected _primaryColorShadowLevel: float;
  58289. /**
  58290. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  58291. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  58292. */
  58293. get primaryColorShadowLevel(): float;
  58294. set primaryColorShadowLevel(value: float);
  58295. protected _primaryColorHighlightLevel: float;
  58296. /**
  58297. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  58298. * The primary color is used at the level chosen to define what the white area would look.
  58299. */
  58300. get primaryColorHighlightLevel(): float;
  58301. set primaryColorHighlightLevel(value: float);
  58302. protected _reflectionTexture: Nullable<BaseTexture>;
  58303. /**
  58304. * Reflection Texture used in the material.
  58305. * Should be author in a specific way for the best result (refer to the documentation).
  58306. */
  58307. reflectionTexture: Nullable<BaseTexture>;
  58308. protected _reflectionBlur: float;
  58309. /**
  58310. * Reflection Texture level of blur.
  58311. *
  58312. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  58313. * texture twice.
  58314. */
  58315. reflectionBlur: float;
  58316. protected _diffuseTexture: Nullable<BaseTexture>;
  58317. /**
  58318. * Diffuse Texture used in the material.
  58319. * Should be author in a specific way for the best result (refer to the documentation).
  58320. */
  58321. diffuseTexture: Nullable<BaseTexture>;
  58322. protected _shadowLights: Nullable<IShadowLight[]>;
  58323. /**
  58324. * Specify the list of lights casting shadow on the material.
  58325. * All scene shadow lights will be included if null.
  58326. */
  58327. shadowLights: Nullable<IShadowLight[]>;
  58328. protected _shadowLevel: float;
  58329. /**
  58330. * Helps adjusting the shadow to a softer level if required.
  58331. * 0 means black shadows and 1 means no shadows.
  58332. */
  58333. shadowLevel: float;
  58334. protected _sceneCenter: Vector3;
  58335. /**
  58336. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  58337. * It is usually zero but might be interesting to modify according to your setup.
  58338. */
  58339. sceneCenter: Vector3;
  58340. protected _opacityFresnel: boolean;
  58341. /**
  58342. * This helps specifying that the material is falling off to the sky box at grazing angle.
  58343. * This helps ensuring a nice transition when the camera goes under the ground.
  58344. */
  58345. opacityFresnel: boolean;
  58346. protected _reflectionFresnel: boolean;
  58347. /**
  58348. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  58349. * This helps adding a mirror texture on the ground.
  58350. */
  58351. reflectionFresnel: boolean;
  58352. protected _reflectionFalloffDistance: number;
  58353. /**
  58354. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  58355. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  58356. */
  58357. reflectionFalloffDistance: number;
  58358. protected _reflectionAmount: number;
  58359. /**
  58360. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  58361. */
  58362. reflectionAmount: number;
  58363. protected _reflectionReflectance0: number;
  58364. /**
  58365. * This specifies the weight of the reflection at grazing angle.
  58366. */
  58367. reflectionReflectance0: number;
  58368. protected _reflectionReflectance90: number;
  58369. /**
  58370. * This specifies the weight of the reflection at a perpendicular point of view.
  58371. */
  58372. reflectionReflectance90: number;
  58373. /**
  58374. * Sets the reflection reflectance fresnel values according to the default standard
  58375. * empirically know to work well :-)
  58376. */
  58377. set reflectionStandardFresnelWeight(value: number);
  58378. protected _useRGBColor: boolean;
  58379. /**
  58380. * Helps to directly use the maps channels instead of their level.
  58381. */
  58382. useRGBColor: boolean;
  58383. protected _enableNoise: boolean;
  58384. /**
  58385. * This helps reducing the banding effect that could occur on the background.
  58386. */
  58387. enableNoise: boolean;
  58388. /**
  58389. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58390. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  58391. * Recommended to be keep at 1.0 except for special cases.
  58392. */
  58393. get fovMultiplier(): number;
  58394. set fovMultiplier(value: number);
  58395. private _fovMultiplier;
  58396. /**
  58397. * Enable the FOV adjustment feature controlled by fovMultiplier.
  58398. */
  58399. useEquirectangularFOV: boolean;
  58400. private _maxSimultaneousLights;
  58401. /**
  58402. * Number of Simultaneous lights allowed on the material.
  58403. */
  58404. maxSimultaneousLights: int;
  58405. private _shadowOnly;
  58406. /**
  58407. * Make the material only render shadows
  58408. */
  58409. shadowOnly: boolean;
  58410. /**
  58411. * Default configuration related to image processing available in the Background Material.
  58412. */
  58413. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58414. /**
  58415. * Keep track of the image processing observer to allow dispose and replace.
  58416. */
  58417. private _imageProcessingObserver;
  58418. /**
  58419. * Attaches a new image processing configuration to the PBR Material.
  58420. * @param configuration (if null the scene configuration will be use)
  58421. */
  58422. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58423. /**
  58424. * Gets the image processing configuration used either in this material.
  58425. */
  58426. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  58427. /**
  58428. * Sets the Default image processing configuration used either in the this material.
  58429. *
  58430. * If sets to null, the scene one is in use.
  58431. */
  58432. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  58433. /**
  58434. * Gets wether the color curves effect is enabled.
  58435. */
  58436. get cameraColorCurvesEnabled(): boolean;
  58437. /**
  58438. * Sets wether the color curves effect is enabled.
  58439. */
  58440. set cameraColorCurvesEnabled(value: boolean);
  58441. /**
  58442. * Gets wether the color grading effect is enabled.
  58443. */
  58444. get cameraColorGradingEnabled(): boolean;
  58445. /**
  58446. * Gets wether the color grading effect is enabled.
  58447. */
  58448. set cameraColorGradingEnabled(value: boolean);
  58449. /**
  58450. * Gets wether tonemapping is enabled or not.
  58451. */
  58452. get cameraToneMappingEnabled(): boolean;
  58453. /**
  58454. * Sets wether tonemapping is enabled or not
  58455. */
  58456. set cameraToneMappingEnabled(value: boolean);
  58457. /**
  58458. * The camera exposure used on this material.
  58459. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58460. * This corresponds to a photographic exposure.
  58461. */
  58462. get cameraExposure(): float;
  58463. /**
  58464. * The camera exposure used on this material.
  58465. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58466. * This corresponds to a photographic exposure.
  58467. */
  58468. set cameraExposure(value: float);
  58469. /**
  58470. * Gets The camera contrast used on this material.
  58471. */
  58472. get cameraContrast(): float;
  58473. /**
  58474. * Sets The camera contrast used on this material.
  58475. */
  58476. set cameraContrast(value: float);
  58477. /**
  58478. * Gets the Color Grading 2D Lookup Texture.
  58479. */
  58480. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58481. /**
  58482. * Sets the Color Grading 2D Lookup Texture.
  58483. */
  58484. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58485. /**
  58486. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58487. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58488. * 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;
  58489. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58490. */
  58491. get cameraColorCurves(): Nullable<ColorCurves>;
  58492. /**
  58493. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58494. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58495. * 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;
  58496. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58497. */
  58498. set cameraColorCurves(value: Nullable<ColorCurves>);
  58499. /**
  58500. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  58501. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  58502. */
  58503. switchToBGR: boolean;
  58504. private _renderTargets;
  58505. private _reflectionControls;
  58506. private _white;
  58507. private _primaryShadowColor;
  58508. private _primaryHighlightColor;
  58509. /**
  58510. * Instantiates a Background Material in the given scene
  58511. * @param name The friendly name of the material
  58512. * @param scene The scene to add the material to
  58513. */
  58514. constructor(name: string, scene: Scene);
  58515. /**
  58516. * Gets a boolean indicating that current material needs to register RTT
  58517. */
  58518. get hasRenderTargetTextures(): boolean;
  58519. /**
  58520. * The entire material has been created in order to prevent overdraw.
  58521. * @returns false
  58522. */
  58523. needAlphaTesting(): boolean;
  58524. /**
  58525. * The entire material has been created in order to prevent overdraw.
  58526. * @returns true if blending is enable
  58527. */
  58528. needAlphaBlending(): boolean;
  58529. /**
  58530. * Checks wether the material is ready to be rendered for a given mesh.
  58531. * @param mesh The mesh to render
  58532. * @param subMesh The submesh to check against
  58533. * @param useInstances Specify wether or not the material is used with instances
  58534. * @returns true if all the dependencies are ready (Textures, Effects...)
  58535. */
  58536. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58537. /**
  58538. * Compute the primary color according to the chosen perceptual color.
  58539. */
  58540. private _computePrimaryColorFromPerceptualColor;
  58541. /**
  58542. * Compute the highlights and shadow colors according to their chosen levels.
  58543. */
  58544. private _computePrimaryColors;
  58545. /**
  58546. * Build the uniform buffer used in the material.
  58547. */
  58548. buildUniformLayout(): void;
  58549. /**
  58550. * Unbind the material.
  58551. */
  58552. unbind(): void;
  58553. /**
  58554. * Bind only the world matrix to the material.
  58555. * @param world The world matrix to bind.
  58556. */
  58557. bindOnlyWorldMatrix(world: Matrix): void;
  58558. /**
  58559. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  58560. * @param world The world matrix to bind.
  58561. * @param subMesh The submesh to bind for.
  58562. */
  58563. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58564. /**
  58565. * Checks to see if a texture is used in the material.
  58566. * @param texture - Base texture to use.
  58567. * @returns - Boolean specifying if a texture is used in the material.
  58568. */
  58569. hasTexture(texture: BaseTexture): boolean;
  58570. /**
  58571. * Dispose the material.
  58572. * @param forceDisposeEffect Force disposal of the associated effect.
  58573. * @param forceDisposeTextures Force disposal of the associated textures.
  58574. */
  58575. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58576. /**
  58577. * Clones the material.
  58578. * @param name The cloned name.
  58579. * @returns The cloned material.
  58580. */
  58581. clone(name: string): BackgroundMaterial;
  58582. /**
  58583. * Serializes the current material to its JSON representation.
  58584. * @returns The JSON representation.
  58585. */
  58586. serialize(): any;
  58587. /**
  58588. * Gets the class name of the material
  58589. * @returns "BackgroundMaterial"
  58590. */
  58591. getClassName(): string;
  58592. /**
  58593. * Parse a JSON input to create back a background material.
  58594. * @param source The JSON data to parse
  58595. * @param scene The scene to create the parsed material in
  58596. * @param rootUrl The root url of the assets the material depends upon
  58597. * @returns the instantiated BackgroundMaterial.
  58598. */
  58599. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  58600. }
  58601. }
  58602. declare module BABYLON {
  58603. /**
  58604. * Represents the different options available during the creation of
  58605. * a Environment helper.
  58606. *
  58607. * This can control the default ground, skybox and image processing setup of your scene.
  58608. */
  58609. export interface IEnvironmentHelperOptions {
  58610. /**
  58611. * Specifies whether or not to create a ground.
  58612. * True by default.
  58613. */
  58614. createGround: boolean;
  58615. /**
  58616. * Specifies the ground size.
  58617. * 15 by default.
  58618. */
  58619. groundSize: number;
  58620. /**
  58621. * The texture used on the ground for the main color.
  58622. * Comes from the BabylonJS CDN by default.
  58623. *
  58624. * Remarks: Can be either a texture or a url.
  58625. */
  58626. groundTexture: string | BaseTexture;
  58627. /**
  58628. * The color mixed in the ground texture by default.
  58629. * BabylonJS clearColor by default.
  58630. */
  58631. groundColor: Color3;
  58632. /**
  58633. * Specifies the ground opacity.
  58634. * 1 by default.
  58635. */
  58636. groundOpacity: number;
  58637. /**
  58638. * Enables the ground to receive shadows.
  58639. * True by default.
  58640. */
  58641. enableGroundShadow: boolean;
  58642. /**
  58643. * Helps preventing the shadow to be fully black on the ground.
  58644. * 0.5 by default.
  58645. */
  58646. groundShadowLevel: number;
  58647. /**
  58648. * Creates a mirror texture attach to the ground.
  58649. * false by default.
  58650. */
  58651. enableGroundMirror: boolean;
  58652. /**
  58653. * Specifies the ground mirror size ratio.
  58654. * 0.3 by default as the default kernel is 64.
  58655. */
  58656. groundMirrorSizeRatio: number;
  58657. /**
  58658. * Specifies the ground mirror blur kernel size.
  58659. * 64 by default.
  58660. */
  58661. groundMirrorBlurKernel: number;
  58662. /**
  58663. * Specifies the ground mirror visibility amount.
  58664. * 1 by default
  58665. */
  58666. groundMirrorAmount: number;
  58667. /**
  58668. * Specifies the ground mirror reflectance weight.
  58669. * This uses the standard weight of the background material to setup the fresnel effect
  58670. * of the mirror.
  58671. * 1 by default.
  58672. */
  58673. groundMirrorFresnelWeight: number;
  58674. /**
  58675. * Specifies the ground mirror Falloff distance.
  58676. * This can helps reducing the size of the reflection.
  58677. * 0 by Default.
  58678. */
  58679. groundMirrorFallOffDistance: number;
  58680. /**
  58681. * Specifies the ground mirror texture type.
  58682. * Unsigned Int by Default.
  58683. */
  58684. groundMirrorTextureType: number;
  58685. /**
  58686. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  58687. * the shown objects.
  58688. */
  58689. groundYBias: number;
  58690. /**
  58691. * Specifies whether or not to create a skybox.
  58692. * True by default.
  58693. */
  58694. createSkybox: boolean;
  58695. /**
  58696. * Specifies the skybox size.
  58697. * 20 by default.
  58698. */
  58699. skyboxSize: number;
  58700. /**
  58701. * The texture used on the skybox for the main color.
  58702. * Comes from the BabylonJS CDN by default.
  58703. *
  58704. * Remarks: Can be either a texture or a url.
  58705. */
  58706. skyboxTexture: string | BaseTexture;
  58707. /**
  58708. * The color mixed in the skybox texture by default.
  58709. * BabylonJS clearColor by default.
  58710. */
  58711. skyboxColor: Color3;
  58712. /**
  58713. * The background rotation around the Y axis of the scene.
  58714. * This helps aligning the key lights of your scene with the background.
  58715. * 0 by default.
  58716. */
  58717. backgroundYRotation: number;
  58718. /**
  58719. * Compute automatically the size of the elements to best fit with the scene.
  58720. */
  58721. sizeAuto: boolean;
  58722. /**
  58723. * Default position of the rootMesh if autoSize is not true.
  58724. */
  58725. rootPosition: Vector3;
  58726. /**
  58727. * Sets up the image processing in the scene.
  58728. * true by default.
  58729. */
  58730. setupImageProcessing: boolean;
  58731. /**
  58732. * The texture used as your environment texture in the scene.
  58733. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  58734. *
  58735. * Remarks: Can be either a texture or a url.
  58736. */
  58737. environmentTexture: string | BaseTexture;
  58738. /**
  58739. * The value of the exposure to apply to the scene.
  58740. * 0.6 by default if setupImageProcessing is true.
  58741. */
  58742. cameraExposure: number;
  58743. /**
  58744. * The value of the contrast to apply to the scene.
  58745. * 1.6 by default if setupImageProcessing is true.
  58746. */
  58747. cameraContrast: number;
  58748. /**
  58749. * Specifies whether or not tonemapping should be enabled in the scene.
  58750. * true by default if setupImageProcessing is true.
  58751. */
  58752. toneMappingEnabled: boolean;
  58753. }
  58754. /**
  58755. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  58756. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  58757. * It also helps with the default setup of your imageProcessing configuration.
  58758. */
  58759. export class EnvironmentHelper {
  58760. /**
  58761. * Default ground texture URL.
  58762. */
  58763. private static _groundTextureCDNUrl;
  58764. /**
  58765. * Default skybox texture URL.
  58766. */
  58767. private static _skyboxTextureCDNUrl;
  58768. /**
  58769. * Default environment texture URL.
  58770. */
  58771. private static _environmentTextureCDNUrl;
  58772. /**
  58773. * Creates the default options for the helper.
  58774. */
  58775. private static _getDefaultOptions;
  58776. private _rootMesh;
  58777. /**
  58778. * Gets the root mesh created by the helper.
  58779. */
  58780. get rootMesh(): Mesh;
  58781. private _skybox;
  58782. /**
  58783. * Gets the skybox created by the helper.
  58784. */
  58785. get skybox(): Nullable<Mesh>;
  58786. private _skyboxTexture;
  58787. /**
  58788. * Gets the skybox texture created by the helper.
  58789. */
  58790. get skyboxTexture(): Nullable<BaseTexture>;
  58791. private _skyboxMaterial;
  58792. /**
  58793. * Gets the skybox material created by the helper.
  58794. */
  58795. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  58796. private _ground;
  58797. /**
  58798. * Gets the ground mesh created by the helper.
  58799. */
  58800. get ground(): Nullable<Mesh>;
  58801. private _groundTexture;
  58802. /**
  58803. * Gets the ground texture created by the helper.
  58804. */
  58805. get groundTexture(): Nullable<BaseTexture>;
  58806. private _groundMirror;
  58807. /**
  58808. * Gets the ground mirror created by the helper.
  58809. */
  58810. get groundMirror(): Nullable<MirrorTexture>;
  58811. /**
  58812. * Gets the ground mirror render list to helps pushing the meshes
  58813. * you wish in the ground reflection.
  58814. */
  58815. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  58816. private _groundMaterial;
  58817. /**
  58818. * Gets the ground material created by the helper.
  58819. */
  58820. get groundMaterial(): Nullable<BackgroundMaterial>;
  58821. /**
  58822. * Stores the creation options.
  58823. */
  58824. private readonly _scene;
  58825. private _options;
  58826. /**
  58827. * This observable will be notified with any error during the creation of the environment,
  58828. * mainly texture creation errors.
  58829. */
  58830. onErrorObservable: Observable<{
  58831. message?: string;
  58832. exception?: any;
  58833. }>;
  58834. /**
  58835. * constructor
  58836. * @param options Defines the options we want to customize the helper
  58837. * @param scene The scene to add the material to
  58838. */
  58839. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  58840. /**
  58841. * Updates the background according to the new options
  58842. * @param options
  58843. */
  58844. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  58845. /**
  58846. * Sets the primary color of all the available elements.
  58847. * @param color the main color to affect to the ground and the background
  58848. */
  58849. setMainColor(color: Color3): void;
  58850. /**
  58851. * Setup the image processing according to the specified options.
  58852. */
  58853. private _setupImageProcessing;
  58854. /**
  58855. * Setup the environment texture according to the specified options.
  58856. */
  58857. private _setupEnvironmentTexture;
  58858. /**
  58859. * Setup the background according to the specified options.
  58860. */
  58861. private _setupBackground;
  58862. /**
  58863. * Get the scene sizes according to the setup.
  58864. */
  58865. private _getSceneSize;
  58866. /**
  58867. * Setup the ground according to the specified options.
  58868. */
  58869. private _setupGround;
  58870. /**
  58871. * Setup the ground material according to the specified options.
  58872. */
  58873. private _setupGroundMaterial;
  58874. /**
  58875. * Setup the ground diffuse texture according to the specified options.
  58876. */
  58877. private _setupGroundDiffuseTexture;
  58878. /**
  58879. * Setup the ground mirror texture according to the specified options.
  58880. */
  58881. private _setupGroundMirrorTexture;
  58882. /**
  58883. * Setup the ground to receive the mirror texture.
  58884. */
  58885. private _setupMirrorInGroundMaterial;
  58886. /**
  58887. * Setup the skybox according to the specified options.
  58888. */
  58889. private _setupSkybox;
  58890. /**
  58891. * Setup the skybox material according to the specified options.
  58892. */
  58893. private _setupSkyboxMaterial;
  58894. /**
  58895. * Setup the skybox reflection texture according to the specified options.
  58896. */
  58897. private _setupSkyboxReflectionTexture;
  58898. private _errorHandler;
  58899. /**
  58900. * Dispose all the elements created by the Helper.
  58901. */
  58902. dispose(): void;
  58903. }
  58904. }
  58905. declare module BABYLON {
  58906. /**
  58907. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  58908. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  58909. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58910. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58911. */
  58912. export abstract class TextureDome<T extends Texture> extends TransformNode {
  58913. protected onError: Nullable<(message?: string, exception?: any) => void>;
  58914. /**
  58915. * Define the source as a Monoscopic panoramic 360/180.
  58916. */
  58917. static readonly MODE_MONOSCOPIC: number;
  58918. /**
  58919. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  58920. */
  58921. static readonly MODE_TOPBOTTOM: number;
  58922. /**
  58923. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  58924. */
  58925. static readonly MODE_SIDEBYSIDE: number;
  58926. private _halfDome;
  58927. private _crossEye;
  58928. protected _useDirectMapping: boolean;
  58929. /**
  58930. * The texture being displayed on the sphere
  58931. */
  58932. protected _texture: T;
  58933. /**
  58934. * Gets the texture being displayed on the sphere
  58935. */
  58936. get texture(): T;
  58937. /**
  58938. * Sets the texture being displayed on the sphere
  58939. */
  58940. set texture(newTexture: T);
  58941. /**
  58942. * The skybox material
  58943. */
  58944. protected _material: BackgroundMaterial;
  58945. /**
  58946. * The surface used for the dome
  58947. */
  58948. protected _mesh: Mesh;
  58949. /**
  58950. * Gets the mesh used for the dome.
  58951. */
  58952. get mesh(): Mesh;
  58953. /**
  58954. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58955. */
  58956. private _halfDomeMask;
  58957. /**
  58958. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58959. * Also see the options.resolution property.
  58960. */
  58961. get fovMultiplier(): number;
  58962. set fovMultiplier(value: number);
  58963. protected _textureMode: number;
  58964. /**
  58965. * Gets or set the current texture mode for the texture. It can be:
  58966. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58967. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58968. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58969. */
  58970. get textureMode(): number;
  58971. /**
  58972. * Sets the current texture mode for the texture. It can be:
  58973. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58974. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58975. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58976. */
  58977. set textureMode(value: number);
  58978. /**
  58979. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58980. */
  58981. get halfDome(): boolean;
  58982. /**
  58983. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58984. */
  58985. set halfDome(enabled: boolean);
  58986. /**
  58987. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58988. */
  58989. set crossEye(enabled: boolean);
  58990. /**
  58991. * Is it a cross-eye texture?
  58992. */
  58993. get crossEye(): boolean;
  58994. /**
  58995. * The background material of this dome.
  58996. */
  58997. get material(): BackgroundMaterial;
  58998. /**
  58999. * Oberserver used in Stereoscopic VR Mode.
  59000. */
  59001. private _onBeforeCameraRenderObserver;
  59002. /**
  59003. * Observable raised when an error occured while loading the 360 image
  59004. */
  59005. onLoadErrorObservable: Observable<string>;
  59006. /**
  59007. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  59008. * @param name Element's name, child elements will append suffixes for their own names.
  59009. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  59010. * @param options An object containing optional or exposed sub element properties
  59011. */
  59012. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  59013. resolution?: number;
  59014. clickToPlay?: boolean;
  59015. autoPlay?: boolean;
  59016. loop?: boolean;
  59017. size?: number;
  59018. poster?: string;
  59019. faceForward?: boolean;
  59020. useDirectMapping?: boolean;
  59021. halfDomeMode?: boolean;
  59022. crossEyeMode?: boolean;
  59023. generateMipMaps?: boolean;
  59024. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  59025. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  59026. protected _changeTextureMode(value: number): void;
  59027. /**
  59028. * Releases resources associated with this node.
  59029. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59030. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59031. */
  59032. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59033. }
  59034. }
  59035. declare module BABYLON {
  59036. /**
  59037. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  59038. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  59039. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  59040. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59041. */
  59042. export class PhotoDome extends TextureDome<Texture> {
  59043. /**
  59044. * Define the image as a Monoscopic panoramic 360 image.
  59045. */
  59046. static readonly MODE_MONOSCOPIC: number;
  59047. /**
  59048. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  59049. */
  59050. static readonly MODE_TOPBOTTOM: number;
  59051. /**
  59052. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  59053. */
  59054. static readonly MODE_SIDEBYSIDE: number;
  59055. /**
  59056. * Gets or sets the texture being displayed on the sphere
  59057. */
  59058. get photoTexture(): Texture;
  59059. /**
  59060. * sets the texture being displayed on the sphere
  59061. */
  59062. set photoTexture(value: Texture);
  59063. /**
  59064. * Gets the current video mode for the video. It can be:
  59065. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59066. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59067. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59068. */
  59069. get imageMode(): number;
  59070. /**
  59071. * Sets the current video mode for the video. It can be:
  59072. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  59073. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  59074. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  59075. */
  59076. set imageMode(value: number);
  59077. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  59078. }
  59079. }
  59080. declare module BABYLON {
  59081. /**
  59082. * Direct draw surface info
  59083. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  59084. */
  59085. export interface DDSInfo {
  59086. /**
  59087. * Width of the texture
  59088. */
  59089. width: number;
  59090. /**
  59091. * Width of the texture
  59092. */
  59093. height: number;
  59094. /**
  59095. * Number of Mipmaps for the texture
  59096. * @see https://en.wikipedia.org/wiki/Mipmap
  59097. */
  59098. mipmapCount: number;
  59099. /**
  59100. * If the textures format is a known fourCC format
  59101. * @see https://www.fourcc.org/
  59102. */
  59103. isFourCC: boolean;
  59104. /**
  59105. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  59106. */
  59107. isRGB: boolean;
  59108. /**
  59109. * If the texture is a lumincance format
  59110. */
  59111. isLuminance: boolean;
  59112. /**
  59113. * If this is a cube texture
  59114. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  59115. */
  59116. isCube: boolean;
  59117. /**
  59118. * If the texture is a compressed format eg. FOURCC_DXT1
  59119. */
  59120. isCompressed: boolean;
  59121. /**
  59122. * The dxgiFormat of the texture
  59123. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  59124. */
  59125. dxgiFormat: number;
  59126. /**
  59127. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  59128. */
  59129. textureType: number;
  59130. /**
  59131. * Sphericle polynomial created for the dds texture
  59132. */
  59133. sphericalPolynomial?: SphericalPolynomial;
  59134. }
  59135. /**
  59136. * Class used to provide DDS decompression tools
  59137. */
  59138. export class DDSTools {
  59139. /**
  59140. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  59141. */
  59142. static StoreLODInAlphaChannel: boolean;
  59143. /**
  59144. * Gets DDS information from an array buffer
  59145. * @param data defines the array buffer view to read data from
  59146. * @returns the DDS information
  59147. */
  59148. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  59149. private static _FloatView;
  59150. private static _Int32View;
  59151. private static _ToHalfFloat;
  59152. private static _FromHalfFloat;
  59153. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  59154. private static _GetHalfFloatRGBAArrayBuffer;
  59155. private static _GetFloatRGBAArrayBuffer;
  59156. private static _GetFloatAsUIntRGBAArrayBuffer;
  59157. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  59158. private static _GetRGBAArrayBuffer;
  59159. private static _ExtractLongWordOrder;
  59160. private static _GetRGBArrayBuffer;
  59161. private static _GetLuminanceArrayBuffer;
  59162. /**
  59163. * Uploads DDS Levels to a Babylon Texture
  59164. * @hidden
  59165. */
  59166. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  59167. }
  59168. interface ThinEngine {
  59169. /**
  59170. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  59171. * @param rootUrl defines the url where the file to load is located
  59172. * @param scene defines the current scene
  59173. * @param lodScale defines scale to apply to the mip map selection
  59174. * @param lodOffset defines offset to apply to the mip map selection
  59175. * @param onLoad defines an optional callback raised when the texture is loaded
  59176. * @param onError defines an optional callback raised if there is an issue to load the texture
  59177. * @param format defines the format of the data
  59178. * @param forcedExtension defines the extension to use to pick the right loader
  59179. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  59180. * @returns the cube texture as an InternalTexture
  59181. */
  59182. 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;
  59183. }
  59184. }
  59185. declare module BABYLON {
  59186. /**
  59187. * Implementation of the DDS Texture Loader.
  59188. * @hidden
  59189. */
  59190. export class _DDSTextureLoader implements IInternalTextureLoader {
  59191. /**
  59192. * Defines wether the loader supports cascade loading the different faces.
  59193. */
  59194. readonly supportCascades: boolean;
  59195. /**
  59196. * This returns if the loader support the current file information.
  59197. * @param extension defines the file extension of the file being loaded
  59198. * @returns true if the loader can load the specified file
  59199. */
  59200. canLoad(extension: string): boolean;
  59201. /**
  59202. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59203. * @param data contains the texture data
  59204. * @param texture defines the BabylonJS internal texture
  59205. * @param createPolynomials will be true if polynomials have been requested
  59206. * @param onLoad defines the callback to trigger once the texture is ready
  59207. * @param onError defines the callback to trigger in case of error
  59208. */
  59209. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59210. /**
  59211. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59212. * @param data contains the texture data
  59213. * @param texture defines the BabylonJS internal texture
  59214. * @param callback defines the method to call once ready to upload
  59215. */
  59216. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59217. }
  59218. }
  59219. declare module BABYLON {
  59220. /**
  59221. * Implementation of the ENV Texture Loader.
  59222. * @hidden
  59223. */
  59224. export class _ENVTextureLoader implements IInternalTextureLoader {
  59225. /**
  59226. * Defines wether the loader supports cascade loading the different faces.
  59227. */
  59228. readonly supportCascades: boolean;
  59229. /**
  59230. * This returns if the loader support the current file information.
  59231. * @param extension defines the file extension of the file being loaded
  59232. * @returns true if the loader can load the specified file
  59233. */
  59234. canLoad(extension: string): boolean;
  59235. /**
  59236. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59237. * @param data contains the texture data
  59238. * @param texture defines the BabylonJS internal texture
  59239. * @param createPolynomials will be true if polynomials have been requested
  59240. * @param onLoad defines the callback to trigger once the texture is ready
  59241. * @param onError defines the callback to trigger in case of error
  59242. */
  59243. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59244. /**
  59245. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59246. * @param data contains the texture data
  59247. * @param texture defines the BabylonJS internal texture
  59248. * @param callback defines the method to call once ready to upload
  59249. */
  59250. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59251. }
  59252. }
  59253. declare module BABYLON {
  59254. /**
  59255. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59256. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59257. */
  59258. export class KhronosTextureContainer {
  59259. /** contents of the KTX container file */
  59260. data: ArrayBufferView;
  59261. private static HEADER_LEN;
  59262. private static COMPRESSED_2D;
  59263. private static COMPRESSED_3D;
  59264. private static TEX_2D;
  59265. private static TEX_3D;
  59266. /**
  59267. * Gets the openGL type
  59268. */
  59269. glType: number;
  59270. /**
  59271. * Gets the openGL type size
  59272. */
  59273. glTypeSize: number;
  59274. /**
  59275. * Gets the openGL format
  59276. */
  59277. glFormat: number;
  59278. /**
  59279. * Gets the openGL internal format
  59280. */
  59281. glInternalFormat: number;
  59282. /**
  59283. * Gets the base internal format
  59284. */
  59285. glBaseInternalFormat: number;
  59286. /**
  59287. * Gets image width in pixel
  59288. */
  59289. pixelWidth: number;
  59290. /**
  59291. * Gets image height in pixel
  59292. */
  59293. pixelHeight: number;
  59294. /**
  59295. * Gets image depth in pixels
  59296. */
  59297. pixelDepth: number;
  59298. /**
  59299. * Gets the number of array elements
  59300. */
  59301. numberOfArrayElements: number;
  59302. /**
  59303. * Gets the number of faces
  59304. */
  59305. numberOfFaces: number;
  59306. /**
  59307. * Gets the number of mipmap levels
  59308. */
  59309. numberOfMipmapLevels: number;
  59310. /**
  59311. * Gets the bytes of key value data
  59312. */
  59313. bytesOfKeyValueData: number;
  59314. /**
  59315. * Gets the load type
  59316. */
  59317. loadType: number;
  59318. /**
  59319. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59320. */
  59321. isInvalid: boolean;
  59322. /**
  59323. * Creates a new KhronosTextureContainer
  59324. * @param data contents of the KTX container file
  59325. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59326. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59327. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59328. */
  59329. constructor(
  59330. /** contents of the KTX container file */
  59331. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59332. /**
  59333. * Uploads KTX content to a Babylon Texture.
  59334. * It is assumed that the texture has already been created & is currently bound
  59335. * @hidden
  59336. */
  59337. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59338. private _upload2DCompressedLevels;
  59339. /**
  59340. * Checks if the given data starts with a KTX file identifier.
  59341. * @param data the data to check
  59342. * @returns true if the data is a KTX file or false otherwise
  59343. */
  59344. static IsValid(data: ArrayBufferView): boolean;
  59345. }
  59346. }
  59347. declare module BABYLON {
  59348. /**
  59349. * Helper class to push actions to a pool of workers.
  59350. */
  59351. export class WorkerPool implements IDisposable {
  59352. private _workerInfos;
  59353. private _pendingActions;
  59354. /**
  59355. * Constructor
  59356. * @param workers Array of workers to use for actions
  59357. */
  59358. constructor(workers: Array<Worker>);
  59359. /**
  59360. * Terminates all workers and clears any pending actions.
  59361. */
  59362. dispose(): void;
  59363. /**
  59364. * Pushes an action to the worker pool. If all the workers are active, the action will be
  59365. * pended until a worker has completed its action.
  59366. * @param action The action to perform. Call onComplete when the action is complete.
  59367. */
  59368. push(action: (worker: Worker, onComplete: () => void) => void): void;
  59369. private _execute;
  59370. }
  59371. }
  59372. declare module BABYLON {
  59373. /**
  59374. * Class for loading KTX2 files
  59375. */
  59376. export class KhronosTextureContainer2 {
  59377. private static _WorkerPoolPromise?;
  59378. private static _Initialized;
  59379. private static _Ktx2Decoder;
  59380. /**
  59381. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  59382. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  59383. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  59384. * Urls you can change:
  59385. * URLConfig.jsDecoderModule
  59386. * URLConfig.wasmUASTCToASTC
  59387. * URLConfig.wasmUASTCToBC7
  59388. * URLConfig.wasmUASTCToRGBA_UNORM
  59389. * URLConfig.wasmUASTCToRGBA_SRGB
  59390. * URLConfig.jsMSCTranscoder
  59391. * URLConfig.wasmMSCTranscoder
  59392. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  59393. */
  59394. static URLConfig: {
  59395. jsDecoderModule: string;
  59396. wasmUASTCToASTC: null;
  59397. wasmUASTCToBC7: null;
  59398. wasmUASTCToRGBA_UNORM: null;
  59399. wasmUASTCToRGBA_SRGB: null;
  59400. jsMSCTranscoder: null;
  59401. wasmMSCTranscoder: null;
  59402. };
  59403. /**
  59404. * Default number of workers used to handle data decoding
  59405. */
  59406. static DefaultNumWorkers: number;
  59407. private static GetDefaultNumWorkers;
  59408. private _engine;
  59409. private static _CreateWorkerPool;
  59410. /**
  59411. * Constructor
  59412. * @param engine The engine to use
  59413. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  59414. */
  59415. constructor(engine: ThinEngine, numWorkers?: number);
  59416. /** @hidden */
  59417. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  59418. /**
  59419. * Stop all async operations and release resources.
  59420. */
  59421. dispose(): void;
  59422. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  59423. /**
  59424. * Checks if the given data starts with a KTX2 file identifier.
  59425. * @param data the data to check
  59426. * @returns true if the data is a KTX2 file or false otherwise
  59427. */
  59428. static IsValid(data: ArrayBufferView): boolean;
  59429. }
  59430. }
  59431. declare module BABYLON {
  59432. /**
  59433. * Implementation of the KTX Texture Loader.
  59434. * @hidden
  59435. */
  59436. export class _KTXTextureLoader implements IInternalTextureLoader {
  59437. /**
  59438. * Defines wether the loader supports cascade loading the different faces.
  59439. */
  59440. readonly supportCascades: boolean;
  59441. /**
  59442. * This returns if the loader support the current file information.
  59443. * @param extension defines the file extension of the file being loaded
  59444. * @param mimeType defines the optional mime type of the file being loaded
  59445. * @returns true if the loader can load the specified file
  59446. */
  59447. canLoad(extension: string, mimeType?: string): boolean;
  59448. /**
  59449. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59450. * @param data contains the texture data
  59451. * @param texture defines the BabylonJS internal texture
  59452. * @param createPolynomials will be true if polynomials have been requested
  59453. * @param onLoad defines the callback to trigger once the texture is ready
  59454. * @param onError defines the callback to trigger in case of error
  59455. */
  59456. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59457. /**
  59458. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59459. * @param data contains the texture data
  59460. * @param texture defines the BabylonJS internal texture
  59461. * @param callback defines the method to call once ready to upload
  59462. */
  59463. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  59464. }
  59465. }
  59466. declare module BABYLON {
  59467. /** @hidden */
  59468. export var _forceSceneHelpersToBundle: boolean;
  59469. interface Scene {
  59470. /**
  59471. * Creates a default light for the scene.
  59472. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59473. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59474. */
  59475. createDefaultLight(replace?: boolean): void;
  59476. /**
  59477. * Creates a default camera for the scene.
  59478. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59479. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59480. * @param replace has default false, when true replaces the active camera in the scene
  59481. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59482. */
  59483. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59484. /**
  59485. * Creates a default camera and a default light.
  59486. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59487. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59488. * @param replace has the default false, when true replaces the active camera/light in the scene
  59489. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59490. */
  59491. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59492. /**
  59493. * Creates a new sky box
  59494. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59495. * @param environmentTexture defines the texture to use as environment texture
  59496. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59497. * @param scale defines the overall scale of the skybox
  59498. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59499. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59500. * @returns a new mesh holding the sky box
  59501. */
  59502. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59503. /**
  59504. * Creates a new environment
  59505. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59506. * @param options defines the options you can use to configure the environment
  59507. * @returns the new EnvironmentHelper
  59508. */
  59509. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59510. /**
  59511. * Creates a new VREXperienceHelper
  59512. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59513. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59514. * @returns a new VREXperienceHelper
  59515. */
  59516. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59517. /**
  59518. * Creates a new WebXRDefaultExperience
  59519. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59520. * @param options experience options
  59521. * @returns a promise for a new WebXRDefaultExperience
  59522. */
  59523. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59524. }
  59525. }
  59526. declare module BABYLON {
  59527. /**
  59528. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59529. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59530. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59531. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59532. */
  59533. export class VideoDome extends TextureDome<VideoTexture> {
  59534. /**
  59535. * Define the video source as a Monoscopic panoramic 360 video.
  59536. */
  59537. static readonly MODE_MONOSCOPIC: number;
  59538. /**
  59539. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59540. */
  59541. static readonly MODE_TOPBOTTOM: number;
  59542. /**
  59543. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59544. */
  59545. static readonly MODE_SIDEBYSIDE: number;
  59546. /**
  59547. * Get the video texture associated with this video dome
  59548. */
  59549. get videoTexture(): VideoTexture;
  59550. /**
  59551. * Get the video mode of this dome
  59552. */
  59553. get videoMode(): number;
  59554. /**
  59555. * Set the video mode of this dome.
  59556. * @see textureMode
  59557. */
  59558. set videoMode(value: number);
  59559. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  59560. }
  59561. }
  59562. declare module BABYLON {
  59563. /**
  59564. * This class can be used to get instrumentation data from a Babylon engine
  59565. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59566. */
  59567. export class EngineInstrumentation implements IDisposable {
  59568. /**
  59569. * Define the instrumented engine.
  59570. */
  59571. engine: Engine;
  59572. private _captureGPUFrameTime;
  59573. private _gpuFrameTimeToken;
  59574. private _gpuFrameTime;
  59575. private _captureShaderCompilationTime;
  59576. private _shaderCompilationTime;
  59577. private _onBeginFrameObserver;
  59578. private _onEndFrameObserver;
  59579. private _onBeforeShaderCompilationObserver;
  59580. private _onAfterShaderCompilationObserver;
  59581. /**
  59582. * Gets the perf counter used for GPU frame time
  59583. */
  59584. get gpuFrameTimeCounter(): PerfCounter;
  59585. /**
  59586. * Gets the GPU frame time capture status
  59587. */
  59588. get captureGPUFrameTime(): boolean;
  59589. /**
  59590. * Enable or disable the GPU frame time capture
  59591. */
  59592. set captureGPUFrameTime(value: boolean);
  59593. /**
  59594. * Gets the perf counter used for shader compilation time
  59595. */
  59596. get shaderCompilationTimeCounter(): PerfCounter;
  59597. /**
  59598. * Gets the shader compilation time capture status
  59599. */
  59600. get captureShaderCompilationTime(): boolean;
  59601. /**
  59602. * Enable or disable the shader compilation time capture
  59603. */
  59604. set captureShaderCompilationTime(value: boolean);
  59605. /**
  59606. * Instantiates a new engine instrumentation.
  59607. * This class can be used to get instrumentation data from a Babylon engine
  59608. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59609. * @param engine Defines the engine to instrument
  59610. */
  59611. constructor(
  59612. /**
  59613. * Define the instrumented engine.
  59614. */
  59615. engine: Engine);
  59616. /**
  59617. * Dispose and release associated resources.
  59618. */
  59619. dispose(): void;
  59620. }
  59621. }
  59622. declare module BABYLON {
  59623. /**
  59624. * This class can be used to get instrumentation data from a Babylon engine
  59625. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59626. */
  59627. export class SceneInstrumentation implements IDisposable {
  59628. /**
  59629. * Defines the scene to instrument
  59630. */
  59631. scene: Scene;
  59632. private _captureActiveMeshesEvaluationTime;
  59633. private _activeMeshesEvaluationTime;
  59634. private _captureRenderTargetsRenderTime;
  59635. private _renderTargetsRenderTime;
  59636. private _captureFrameTime;
  59637. private _frameTime;
  59638. private _captureRenderTime;
  59639. private _renderTime;
  59640. private _captureInterFrameTime;
  59641. private _interFrameTime;
  59642. private _captureParticlesRenderTime;
  59643. private _particlesRenderTime;
  59644. private _captureSpritesRenderTime;
  59645. private _spritesRenderTime;
  59646. private _capturePhysicsTime;
  59647. private _physicsTime;
  59648. private _captureAnimationsTime;
  59649. private _animationsTime;
  59650. private _captureCameraRenderTime;
  59651. private _cameraRenderTime;
  59652. private _onBeforeActiveMeshesEvaluationObserver;
  59653. private _onAfterActiveMeshesEvaluationObserver;
  59654. private _onBeforeRenderTargetsRenderObserver;
  59655. private _onAfterRenderTargetsRenderObserver;
  59656. private _onAfterRenderObserver;
  59657. private _onBeforeDrawPhaseObserver;
  59658. private _onAfterDrawPhaseObserver;
  59659. private _onBeforeAnimationsObserver;
  59660. private _onBeforeParticlesRenderingObserver;
  59661. private _onAfterParticlesRenderingObserver;
  59662. private _onBeforeSpritesRenderingObserver;
  59663. private _onAfterSpritesRenderingObserver;
  59664. private _onBeforePhysicsObserver;
  59665. private _onAfterPhysicsObserver;
  59666. private _onAfterAnimationsObserver;
  59667. private _onBeforeCameraRenderObserver;
  59668. private _onAfterCameraRenderObserver;
  59669. /**
  59670. * Gets the perf counter used for active meshes evaluation time
  59671. */
  59672. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59673. /**
  59674. * Gets the active meshes evaluation time capture status
  59675. */
  59676. get captureActiveMeshesEvaluationTime(): boolean;
  59677. /**
  59678. * Enable or disable the active meshes evaluation time capture
  59679. */
  59680. set captureActiveMeshesEvaluationTime(value: boolean);
  59681. /**
  59682. * Gets the perf counter used for render targets render time
  59683. */
  59684. get renderTargetsRenderTimeCounter(): PerfCounter;
  59685. /**
  59686. * Gets the render targets render time capture status
  59687. */
  59688. get captureRenderTargetsRenderTime(): boolean;
  59689. /**
  59690. * Enable or disable the render targets render time capture
  59691. */
  59692. set captureRenderTargetsRenderTime(value: boolean);
  59693. /**
  59694. * Gets the perf counter used for particles render time
  59695. */
  59696. get particlesRenderTimeCounter(): PerfCounter;
  59697. /**
  59698. * Gets the particles render time capture status
  59699. */
  59700. get captureParticlesRenderTime(): boolean;
  59701. /**
  59702. * Enable or disable the particles render time capture
  59703. */
  59704. set captureParticlesRenderTime(value: boolean);
  59705. /**
  59706. * Gets the perf counter used for sprites render time
  59707. */
  59708. get spritesRenderTimeCounter(): PerfCounter;
  59709. /**
  59710. * Gets the sprites render time capture status
  59711. */
  59712. get captureSpritesRenderTime(): boolean;
  59713. /**
  59714. * Enable or disable the sprites render time capture
  59715. */
  59716. set captureSpritesRenderTime(value: boolean);
  59717. /**
  59718. * Gets the perf counter used for physics time
  59719. */
  59720. get physicsTimeCounter(): PerfCounter;
  59721. /**
  59722. * Gets the physics time capture status
  59723. */
  59724. get capturePhysicsTime(): boolean;
  59725. /**
  59726. * Enable or disable the physics time capture
  59727. */
  59728. set capturePhysicsTime(value: boolean);
  59729. /**
  59730. * Gets the perf counter used for animations time
  59731. */
  59732. get animationsTimeCounter(): PerfCounter;
  59733. /**
  59734. * Gets the animations time capture status
  59735. */
  59736. get captureAnimationsTime(): boolean;
  59737. /**
  59738. * Enable or disable the animations time capture
  59739. */
  59740. set captureAnimationsTime(value: boolean);
  59741. /**
  59742. * Gets the perf counter used for frame time capture
  59743. */
  59744. get frameTimeCounter(): PerfCounter;
  59745. /**
  59746. * Gets the frame time capture status
  59747. */
  59748. get captureFrameTime(): boolean;
  59749. /**
  59750. * Enable or disable the frame time capture
  59751. */
  59752. set captureFrameTime(value: boolean);
  59753. /**
  59754. * Gets the perf counter used for inter-frames time capture
  59755. */
  59756. get interFrameTimeCounter(): PerfCounter;
  59757. /**
  59758. * Gets the inter-frames time capture status
  59759. */
  59760. get captureInterFrameTime(): boolean;
  59761. /**
  59762. * Enable or disable the inter-frames time capture
  59763. */
  59764. set captureInterFrameTime(value: boolean);
  59765. /**
  59766. * Gets the perf counter used for render time capture
  59767. */
  59768. get renderTimeCounter(): PerfCounter;
  59769. /**
  59770. * Gets the render time capture status
  59771. */
  59772. get captureRenderTime(): boolean;
  59773. /**
  59774. * Enable or disable the render time capture
  59775. */
  59776. set captureRenderTime(value: boolean);
  59777. /**
  59778. * Gets the perf counter used for camera render time capture
  59779. */
  59780. get cameraRenderTimeCounter(): PerfCounter;
  59781. /**
  59782. * Gets the camera render time capture status
  59783. */
  59784. get captureCameraRenderTime(): boolean;
  59785. /**
  59786. * Enable or disable the camera render time capture
  59787. */
  59788. set captureCameraRenderTime(value: boolean);
  59789. /**
  59790. * Gets the perf counter used for draw calls
  59791. */
  59792. get drawCallsCounter(): PerfCounter;
  59793. /**
  59794. * Instantiates a new scene instrumentation.
  59795. * This class can be used to get instrumentation data from a Babylon engine
  59796. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59797. * @param scene Defines the scene to instrument
  59798. */
  59799. constructor(
  59800. /**
  59801. * Defines the scene to instrument
  59802. */
  59803. scene: Scene);
  59804. /**
  59805. * Dispose and release associated resources.
  59806. */
  59807. dispose(): void;
  59808. }
  59809. }
  59810. declare module BABYLON {
  59811. /** @hidden */
  59812. export var glowMapGenerationPixelShader: {
  59813. name: string;
  59814. shader: string;
  59815. };
  59816. }
  59817. declare module BABYLON {
  59818. /** @hidden */
  59819. export var glowMapGenerationVertexShader: {
  59820. name: string;
  59821. shader: string;
  59822. };
  59823. }
  59824. declare module BABYLON {
  59825. /**
  59826. * Effect layer options. This helps customizing the behaviour
  59827. * of the effect layer.
  59828. */
  59829. export interface IEffectLayerOptions {
  59830. /**
  59831. * Multiplication factor apply to the canvas size to compute the render target size
  59832. * used to generated the objects (the smaller the faster).
  59833. */
  59834. mainTextureRatio: number;
  59835. /**
  59836. * Enforces a fixed size texture to ensure effect stability across devices.
  59837. */
  59838. mainTextureFixedSize?: number;
  59839. /**
  59840. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59841. */
  59842. alphaBlendingMode: number;
  59843. /**
  59844. * The camera attached to the layer.
  59845. */
  59846. camera: Nullable<Camera>;
  59847. /**
  59848. * The rendering group to draw the layer in.
  59849. */
  59850. renderingGroupId: number;
  59851. }
  59852. /**
  59853. * The effect layer Helps adding post process effect blended with the main pass.
  59854. *
  59855. * This can be for instance use to generate glow or higlight effects on the scene.
  59856. *
  59857. * The effect layer class can not be used directly and is intented to inherited from to be
  59858. * customized per effects.
  59859. */
  59860. export abstract class EffectLayer {
  59861. private _vertexBuffers;
  59862. private _indexBuffer;
  59863. private _cachedDefines;
  59864. private _effectLayerMapGenerationEffect;
  59865. private _effectLayerOptions;
  59866. private _mergeEffect;
  59867. protected _scene: Scene;
  59868. protected _engine: Engine;
  59869. protected _maxSize: number;
  59870. protected _mainTextureDesiredSize: ISize;
  59871. protected _mainTexture: RenderTargetTexture;
  59872. protected _shouldRender: boolean;
  59873. protected _postProcesses: PostProcess[];
  59874. protected _textures: BaseTexture[];
  59875. protected _emissiveTextureAndColor: {
  59876. texture: Nullable<BaseTexture>;
  59877. color: Color4;
  59878. };
  59879. /**
  59880. * The name of the layer
  59881. */
  59882. name: string;
  59883. /**
  59884. * The clear color of the texture used to generate the glow map.
  59885. */
  59886. neutralColor: Color4;
  59887. /**
  59888. * Specifies whether the highlight layer is enabled or not.
  59889. */
  59890. isEnabled: boolean;
  59891. /**
  59892. * Gets the camera attached to the layer.
  59893. */
  59894. get camera(): Nullable<Camera>;
  59895. /**
  59896. * Gets the rendering group id the layer should render in.
  59897. */
  59898. get renderingGroupId(): number;
  59899. set renderingGroupId(renderingGroupId: number);
  59900. /**
  59901. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  59902. */
  59903. disableBoundingBoxesFromEffectLayer: boolean;
  59904. /**
  59905. * An event triggered when the effect layer has been disposed.
  59906. */
  59907. onDisposeObservable: Observable<EffectLayer>;
  59908. /**
  59909. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59910. */
  59911. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59912. /**
  59913. * An event triggered when the generated texture is being merged in the scene.
  59914. */
  59915. onBeforeComposeObservable: Observable<EffectLayer>;
  59916. /**
  59917. * An event triggered when the mesh is rendered into the effect render target.
  59918. */
  59919. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59920. /**
  59921. * An event triggered after the mesh has been rendered into the effect render target.
  59922. */
  59923. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59924. /**
  59925. * An event triggered when the generated texture has been merged in the scene.
  59926. */
  59927. onAfterComposeObservable: Observable<EffectLayer>;
  59928. /**
  59929. * An event triggered when the efffect layer changes its size.
  59930. */
  59931. onSizeChangedObservable: Observable<EffectLayer>;
  59932. /** @hidden */
  59933. static _SceneComponentInitialization: (scene: Scene) => void;
  59934. /**
  59935. * Instantiates a new effect Layer and references it in the scene.
  59936. * @param name The name of the layer
  59937. * @param scene The scene to use the layer in
  59938. */
  59939. constructor(
  59940. /** The Friendly of the effect in the scene */
  59941. name: string, scene: Scene);
  59942. /**
  59943. * Get the effect name of the layer.
  59944. * @return The effect name
  59945. */
  59946. abstract getEffectName(): string;
  59947. /**
  59948. * Checks for the readiness of the element composing the layer.
  59949. * @param subMesh the mesh to check for
  59950. * @param useInstances specify whether or not to use instances to render the mesh
  59951. * @return true if ready otherwise, false
  59952. */
  59953. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59954. /**
  59955. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59956. * @returns true if the effect requires stencil during the main canvas render pass.
  59957. */
  59958. abstract needStencil(): boolean;
  59959. /**
  59960. * Create the merge effect. This is the shader use to blit the information back
  59961. * to the main canvas at the end of the scene rendering.
  59962. * @returns The effect containing the shader used to merge the effect on the main canvas
  59963. */
  59964. protected abstract _createMergeEffect(): Effect;
  59965. /**
  59966. * Creates the render target textures and post processes used in the effect layer.
  59967. */
  59968. protected abstract _createTextureAndPostProcesses(): void;
  59969. /**
  59970. * Implementation specific of rendering the generating effect on the main canvas.
  59971. * @param effect The effect used to render through
  59972. */
  59973. protected abstract _internalRender(effect: Effect): void;
  59974. /**
  59975. * Sets the required values for both the emissive texture and and the main color.
  59976. */
  59977. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59978. /**
  59979. * Free any resources and references associated to a mesh.
  59980. * Internal use
  59981. * @param mesh The mesh to free.
  59982. */
  59983. abstract _disposeMesh(mesh: Mesh): void;
  59984. /**
  59985. * Serializes this layer (Glow or Highlight for example)
  59986. * @returns a serialized layer object
  59987. */
  59988. abstract serialize?(): any;
  59989. /**
  59990. * Initializes the effect layer with the required options.
  59991. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59992. */
  59993. protected _init(options: Partial<IEffectLayerOptions>): void;
  59994. /**
  59995. * Generates the index buffer of the full screen quad blending to the main canvas.
  59996. */
  59997. private _generateIndexBuffer;
  59998. /**
  59999. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  60000. */
  60001. private _generateVertexBuffer;
  60002. /**
  60003. * Sets the main texture desired size which is the closest power of two
  60004. * of the engine canvas size.
  60005. */
  60006. private _setMainTextureSize;
  60007. /**
  60008. * Creates the main texture for the effect layer.
  60009. */
  60010. protected _createMainTexture(): void;
  60011. /**
  60012. * Adds specific effects defines.
  60013. * @param defines The defines to add specifics to.
  60014. */
  60015. protected _addCustomEffectDefines(defines: string[]): void;
  60016. /**
  60017. * Checks for the readiness of the element composing the layer.
  60018. * @param subMesh the mesh to check for
  60019. * @param useInstances specify whether or not to use instances to render the mesh
  60020. * @param emissiveTexture the associated emissive texture used to generate the glow
  60021. * @return true if ready otherwise, false
  60022. */
  60023. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  60024. /**
  60025. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  60026. */
  60027. render(): void;
  60028. /**
  60029. * Determine if a given mesh will be used in the current effect.
  60030. * @param mesh mesh to test
  60031. * @returns true if the mesh will be used
  60032. */
  60033. hasMesh(mesh: AbstractMesh): boolean;
  60034. /**
  60035. * Returns true if the layer contains information to display, otherwise false.
  60036. * @returns true if the glow layer should be rendered
  60037. */
  60038. shouldRender(): boolean;
  60039. /**
  60040. * Returns true if the mesh should render, otherwise false.
  60041. * @param mesh The mesh to render
  60042. * @returns true if it should render otherwise false
  60043. */
  60044. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  60045. /**
  60046. * Returns true if the mesh can be rendered, otherwise false.
  60047. * @param mesh The mesh to render
  60048. * @param material The material used on the mesh
  60049. * @returns true if it can be rendered otherwise false
  60050. */
  60051. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60052. /**
  60053. * Returns true if the mesh should render, otherwise false.
  60054. * @param mesh The mesh to render
  60055. * @returns true if it should render otherwise false
  60056. */
  60057. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  60058. /**
  60059. * Renders the submesh passed in parameter to the generation map.
  60060. */
  60061. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  60062. /**
  60063. * Defines whether the current material of the mesh should be use to render the effect.
  60064. * @param mesh defines the current mesh to render
  60065. */
  60066. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60067. /**
  60068. * Rebuild the required buffers.
  60069. * @hidden Internal use only.
  60070. */
  60071. _rebuild(): void;
  60072. /**
  60073. * Dispose only the render target textures and post process.
  60074. */
  60075. private _disposeTextureAndPostProcesses;
  60076. /**
  60077. * Dispose the highlight layer and free resources.
  60078. */
  60079. dispose(): void;
  60080. /**
  60081. * Gets the class name of the effect layer
  60082. * @returns the string with the class name of the effect layer
  60083. */
  60084. getClassName(): string;
  60085. /**
  60086. * Creates an effect layer from parsed effect layer data
  60087. * @param parsedEffectLayer defines effect layer data
  60088. * @param scene defines the current scene
  60089. * @param rootUrl defines the root URL containing the effect layer information
  60090. * @returns a parsed effect Layer
  60091. */
  60092. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  60093. }
  60094. }
  60095. declare module BABYLON {
  60096. interface AbstractScene {
  60097. /**
  60098. * The list of effect layers (highlights/glow) added to the scene
  60099. * @see https://doc.babylonjs.com/how_to/highlight_layer
  60100. * @see https://doc.babylonjs.com/how_to/glow_layer
  60101. */
  60102. effectLayers: Array<EffectLayer>;
  60103. /**
  60104. * Removes the given effect layer from this scene.
  60105. * @param toRemove defines the effect layer to remove
  60106. * @returns the index of the removed effect layer
  60107. */
  60108. removeEffectLayer(toRemove: EffectLayer): number;
  60109. /**
  60110. * Adds the given effect layer to this scene
  60111. * @param newEffectLayer defines the effect layer to add
  60112. */
  60113. addEffectLayer(newEffectLayer: EffectLayer): void;
  60114. }
  60115. /**
  60116. * Defines the layer scene component responsible to manage any effect layers
  60117. * in a given scene.
  60118. */
  60119. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  60120. /**
  60121. * The component name helpfull to identify the component in the list of scene components.
  60122. */
  60123. readonly name: string;
  60124. /**
  60125. * The scene the component belongs to.
  60126. */
  60127. scene: Scene;
  60128. private _engine;
  60129. private _renderEffects;
  60130. private _needStencil;
  60131. private _previousStencilState;
  60132. /**
  60133. * Creates a new instance of the component for the given scene
  60134. * @param scene Defines the scene to register the component in
  60135. */
  60136. constructor(scene: Scene);
  60137. /**
  60138. * Registers the component in a given scene
  60139. */
  60140. register(): void;
  60141. /**
  60142. * Rebuilds the elements related to this component in case of
  60143. * context lost for instance.
  60144. */
  60145. rebuild(): void;
  60146. /**
  60147. * Serializes the component data to the specified json object
  60148. * @param serializationObject The object to serialize to
  60149. */
  60150. serialize(serializationObject: any): void;
  60151. /**
  60152. * Adds all the elements from the container to the scene
  60153. * @param container the container holding the elements
  60154. */
  60155. addFromContainer(container: AbstractScene): void;
  60156. /**
  60157. * Removes all the elements in the container from the scene
  60158. * @param container contains the elements to remove
  60159. * @param dispose if the removed element should be disposed (default: false)
  60160. */
  60161. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60162. /**
  60163. * Disposes the component and the associated ressources.
  60164. */
  60165. dispose(): void;
  60166. private _isReadyForMesh;
  60167. private _renderMainTexture;
  60168. private _setStencil;
  60169. private _setStencilBack;
  60170. private _draw;
  60171. private _drawCamera;
  60172. private _drawRenderingGroup;
  60173. }
  60174. }
  60175. declare module BABYLON {
  60176. /** @hidden */
  60177. export var glowMapMergePixelShader: {
  60178. name: string;
  60179. shader: string;
  60180. };
  60181. }
  60182. declare module BABYLON {
  60183. /** @hidden */
  60184. export var glowMapMergeVertexShader: {
  60185. name: string;
  60186. shader: string;
  60187. };
  60188. }
  60189. declare module BABYLON {
  60190. interface AbstractScene {
  60191. /**
  60192. * Return a the first highlight layer of the scene with a given name.
  60193. * @param name The name of the highlight layer to look for.
  60194. * @return The highlight layer if found otherwise null.
  60195. */
  60196. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60197. }
  60198. /**
  60199. * Glow layer options. This helps customizing the behaviour
  60200. * of the glow layer.
  60201. */
  60202. export interface IGlowLayerOptions {
  60203. /**
  60204. * Multiplication factor apply to the canvas size to compute the render target size
  60205. * used to generated the glowing objects (the smaller the faster).
  60206. */
  60207. mainTextureRatio: number;
  60208. /**
  60209. * Enforces a fixed size texture to ensure resize independant blur.
  60210. */
  60211. mainTextureFixedSize?: number;
  60212. /**
  60213. * How big is the kernel of the blur texture.
  60214. */
  60215. blurKernelSize: number;
  60216. /**
  60217. * The camera attached to the layer.
  60218. */
  60219. camera: Nullable<Camera>;
  60220. /**
  60221. * Enable MSAA by chosing the number of samples.
  60222. */
  60223. mainTextureSamples?: number;
  60224. /**
  60225. * The rendering group to draw the layer in.
  60226. */
  60227. renderingGroupId: number;
  60228. }
  60229. /**
  60230. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60231. *
  60232. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60233. *
  60234. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60235. */
  60236. export class GlowLayer extends EffectLayer {
  60237. /**
  60238. * Effect Name of the layer.
  60239. */
  60240. static readonly EffectName: string;
  60241. /**
  60242. * The default blur kernel size used for the glow.
  60243. */
  60244. static DefaultBlurKernelSize: number;
  60245. /**
  60246. * The default texture size ratio used for the glow.
  60247. */
  60248. static DefaultTextureRatio: number;
  60249. /**
  60250. * Sets the kernel size of the blur.
  60251. */
  60252. set blurKernelSize(value: number);
  60253. /**
  60254. * Gets the kernel size of the blur.
  60255. */
  60256. get blurKernelSize(): number;
  60257. /**
  60258. * Sets the glow intensity.
  60259. */
  60260. set intensity(value: number);
  60261. /**
  60262. * Gets the glow intensity.
  60263. */
  60264. get intensity(): number;
  60265. private _options;
  60266. private _intensity;
  60267. private _horizontalBlurPostprocess1;
  60268. private _verticalBlurPostprocess1;
  60269. private _horizontalBlurPostprocess2;
  60270. private _verticalBlurPostprocess2;
  60271. private _blurTexture1;
  60272. private _blurTexture2;
  60273. private _postProcesses1;
  60274. private _postProcesses2;
  60275. private _includedOnlyMeshes;
  60276. private _excludedMeshes;
  60277. private _meshesUsingTheirOwnMaterials;
  60278. /**
  60279. * Callback used to let the user override the color selection on a per mesh basis
  60280. */
  60281. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60282. /**
  60283. * Callback used to let the user override the texture selection on a per mesh basis
  60284. */
  60285. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60286. /**
  60287. * Instantiates a new glow Layer and references it to the scene.
  60288. * @param name The name of the layer
  60289. * @param scene The scene to use the layer in
  60290. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60291. */
  60292. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60293. /**
  60294. * Get the effect name of the layer.
  60295. * @return The effect name
  60296. */
  60297. getEffectName(): string;
  60298. /**
  60299. * Create the merge effect. This is the shader use to blit the information back
  60300. * to the main canvas at the end of the scene rendering.
  60301. */
  60302. protected _createMergeEffect(): Effect;
  60303. /**
  60304. * Creates the render target textures and post processes used in the glow layer.
  60305. */
  60306. protected _createTextureAndPostProcesses(): void;
  60307. /**
  60308. * Checks for the readiness of the element composing the layer.
  60309. * @param subMesh the mesh to check for
  60310. * @param useInstances specify wether or not to use instances to render the mesh
  60311. * @param emissiveTexture the associated emissive texture used to generate the glow
  60312. * @return true if ready otherwise, false
  60313. */
  60314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60315. /**
  60316. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60317. */
  60318. needStencil(): boolean;
  60319. /**
  60320. * Returns true if the mesh can be rendered, otherwise false.
  60321. * @param mesh The mesh to render
  60322. * @param material The material used on the mesh
  60323. * @returns true if it can be rendered otherwise false
  60324. */
  60325. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60326. /**
  60327. * Implementation specific of rendering the generating effect on the main canvas.
  60328. * @param effect The effect used to render through
  60329. */
  60330. protected _internalRender(effect: Effect): void;
  60331. /**
  60332. * Sets the required values for both the emissive texture and and the main color.
  60333. */
  60334. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60335. /**
  60336. * Returns true if the mesh should render, otherwise false.
  60337. * @param mesh The mesh to render
  60338. * @returns true if it should render otherwise false
  60339. */
  60340. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60341. /**
  60342. * Adds specific effects defines.
  60343. * @param defines The defines to add specifics to.
  60344. */
  60345. protected _addCustomEffectDefines(defines: string[]): void;
  60346. /**
  60347. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60348. * @param mesh The mesh to exclude from the glow layer
  60349. */
  60350. addExcludedMesh(mesh: Mesh): void;
  60351. /**
  60352. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60353. * @param mesh The mesh to remove
  60354. */
  60355. removeExcludedMesh(mesh: Mesh): void;
  60356. /**
  60357. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60358. * @param mesh The mesh to include in the glow layer
  60359. */
  60360. addIncludedOnlyMesh(mesh: Mesh): void;
  60361. /**
  60362. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60363. * @param mesh The mesh to remove
  60364. */
  60365. removeIncludedOnlyMesh(mesh: Mesh): void;
  60366. /**
  60367. * Determine if a given mesh will be used in the glow layer
  60368. * @param mesh The mesh to test
  60369. * @returns true if the mesh will be highlighted by the current glow layer
  60370. */
  60371. hasMesh(mesh: AbstractMesh): boolean;
  60372. /**
  60373. * Defines whether the current material of the mesh should be use to render the effect.
  60374. * @param mesh defines the current mesh to render
  60375. */
  60376. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60377. /**
  60378. * Add a mesh to be rendered through its own material and not with emissive only.
  60379. * @param mesh The mesh for which we need to use its material
  60380. */
  60381. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60382. /**
  60383. * Remove a mesh from being rendered through its own material and not with emissive only.
  60384. * @param mesh The mesh for which we need to not use its material
  60385. */
  60386. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60387. /**
  60388. * Free any resources and references associated to a mesh.
  60389. * Internal use
  60390. * @param mesh The mesh to free.
  60391. * @hidden
  60392. */
  60393. _disposeMesh(mesh: Mesh): void;
  60394. /**
  60395. * Gets the class name of the effect layer
  60396. * @returns the string with the class name of the effect layer
  60397. */
  60398. getClassName(): string;
  60399. /**
  60400. * Serializes this glow layer
  60401. * @returns a serialized glow layer object
  60402. */
  60403. serialize(): any;
  60404. /**
  60405. * Creates a Glow Layer from parsed glow layer data
  60406. * @param parsedGlowLayer defines glow layer data
  60407. * @param scene defines the current scene
  60408. * @param rootUrl defines the root URL containing the glow layer information
  60409. * @returns a parsed Glow Layer
  60410. */
  60411. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60412. }
  60413. }
  60414. declare module BABYLON {
  60415. /** @hidden */
  60416. export var glowBlurPostProcessPixelShader: {
  60417. name: string;
  60418. shader: string;
  60419. };
  60420. }
  60421. declare module BABYLON {
  60422. interface AbstractScene {
  60423. /**
  60424. * Return a the first highlight layer of the scene with a given name.
  60425. * @param name The name of the highlight layer to look for.
  60426. * @return The highlight layer if found otherwise null.
  60427. */
  60428. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60429. }
  60430. /**
  60431. * Highlight layer options. This helps customizing the behaviour
  60432. * of the highlight layer.
  60433. */
  60434. export interface IHighlightLayerOptions {
  60435. /**
  60436. * Multiplication factor apply to the canvas size to compute the render target size
  60437. * used to generated the glowing objects (the smaller the faster).
  60438. */
  60439. mainTextureRatio: number;
  60440. /**
  60441. * Enforces a fixed size texture to ensure resize independant blur.
  60442. */
  60443. mainTextureFixedSize?: number;
  60444. /**
  60445. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60446. * of the picture to blur (the smaller the faster).
  60447. */
  60448. blurTextureSizeRatio: number;
  60449. /**
  60450. * How big in texel of the blur texture is the vertical blur.
  60451. */
  60452. blurVerticalSize: number;
  60453. /**
  60454. * How big in texel of the blur texture is the horizontal blur.
  60455. */
  60456. blurHorizontalSize: number;
  60457. /**
  60458. * Alpha blending mode used to apply the blur. Default is combine.
  60459. */
  60460. alphaBlendingMode: number;
  60461. /**
  60462. * The camera attached to the layer.
  60463. */
  60464. camera: Nullable<Camera>;
  60465. /**
  60466. * Should we display highlight as a solid stroke?
  60467. */
  60468. isStroke?: boolean;
  60469. /**
  60470. * The rendering group to draw the layer in.
  60471. */
  60472. renderingGroupId: number;
  60473. }
  60474. /**
  60475. * The highlight layer Helps adding a glow effect around a mesh.
  60476. *
  60477. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60478. * glowy meshes to your scene.
  60479. *
  60480. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60481. */
  60482. export class HighlightLayer extends EffectLayer {
  60483. name: string;
  60484. /**
  60485. * Effect Name of the highlight layer.
  60486. */
  60487. static readonly EffectName: string;
  60488. /**
  60489. * The neutral color used during the preparation of the glow effect.
  60490. * This is black by default as the blend operation is a blend operation.
  60491. */
  60492. static NeutralColor: Color4;
  60493. /**
  60494. * Stencil value used for glowing meshes.
  60495. */
  60496. static GlowingMeshStencilReference: number;
  60497. /**
  60498. * Stencil value used for the other meshes in the scene.
  60499. */
  60500. static NormalMeshStencilReference: number;
  60501. /**
  60502. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60503. */
  60504. innerGlow: boolean;
  60505. /**
  60506. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60507. */
  60508. outerGlow: boolean;
  60509. /**
  60510. * Specifies the horizontal size of the blur.
  60511. */
  60512. set blurHorizontalSize(value: number);
  60513. /**
  60514. * Specifies the vertical size of the blur.
  60515. */
  60516. set blurVerticalSize(value: number);
  60517. /**
  60518. * Gets the horizontal size of the blur.
  60519. */
  60520. get blurHorizontalSize(): number;
  60521. /**
  60522. * Gets the vertical size of the blur.
  60523. */
  60524. get blurVerticalSize(): number;
  60525. /**
  60526. * An event triggered when the highlight layer is being blurred.
  60527. */
  60528. onBeforeBlurObservable: Observable<HighlightLayer>;
  60529. /**
  60530. * An event triggered when the highlight layer has been blurred.
  60531. */
  60532. onAfterBlurObservable: Observable<HighlightLayer>;
  60533. private _instanceGlowingMeshStencilReference;
  60534. private _options;
  60535. private _downSamplePostprocess;
  60536. private _horizontalBlurPostprocess;
  60537. private _verticalBlurPostprocess;
  60538. private _blurTexture;
  60539. private _meshes;
  60540. private _excludedMeshes;
  60541. /**
  60542. * Instantiates a new highlight Layer and references it to the scene..
  60543. * @param name The name of the layer
  60544. * @param scene The scene to use the layer in
  60545. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60546. */
  60547. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60548. /**
  60549. * Get the effect name of the layer.
  60550. * @return The effect name
  60551. */
  60552. getEffectName(): string;
  60553. /**
  60554. * Create the merge effect. This is the shader use to blit the information back
  60555. * to the main canvas at the end of the scene rendering.
  60556. */
  60557. protected _createMergeEffect(): Effect;
  60558. /**
  60559. * Creates the render target textures and post processes used in the highlight layer.
  60560. */
  60561. protected _createTextureAndPostProcesses(): void;
  60562. /**
  60563. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60564. */
  60565. needStencil(): boolean;
  60566. /**
  60567. * Checks for the readiness of the element composing the layer.
  60568. * @param subMesh the mesh to check for
  60569. * @param useInstances specify wether or not to use instances to render the mesh
  60570. * @param emissiveTexture the associated emissive texture used to generate the glow
  60571. * @return true if ready otherwise, false
  60572. */
  60573. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60574. /**
  60575. * Implementation specific of rendering the generating effect on the main canvas.
  60576. * @param effect The effect used to render through
  60577. */
  60578. protected _internalRender(effect: Effect): void;
  60579. /**
  60580. * Returns true if the layer contains information to display, otherwise false.
  60581. */
  60582. shouldRender(): boolean;
  60583. /**
  60584. * Returns true if the mesh should render, otherwise false.
  60585. * @param mesh The mesh to render
  60586. * @returns true if it should render otherwise false
  60587. */
  60588. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60589. /**
  60590. * Returns true if the mesh can be rendered, otherwise false.
  60591. * @param mesh The mesh to render
  60592. * @param material The material used on the mesh
  60593. * @returns true if it can be rendered otherwise false
  60594. */
  60595. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60596. /**
  60597. * Adds specific effects defines.
  60598. * @param defines The defines to add specifics to.
  60599. */
  60600. protected _addCustomEffectDefines(defines: string[]): void;
  60601. /**
  60602. * Sets the required values for both the emissive texture and and the main color.
  60603. */
  60604. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60605. /**
  60606. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60607. * @param mesh The mesh to exclude from the highlight layer
  60608. */
  60609. addExcludedMesh(mesh: Mesh): void;
  60610. /**
  60611. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60612. * @param mesh The mesh to highlight
  60613. */
  60614. removeExcludedMesh(mesh: Mesh): void;
  60615. /**
  60616. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60617. * @param mesh mesh to test
  60618. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60619. */
  60620. hasMesh(mesh: AbstractMesh): boolean;
  60621. /**
  60622. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60623. * @param mesh The mesh to highlight
  60624. * @param color The color of the highlight
  60625. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60626. */
  60627. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60628. /**
  60629. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60630. * @param mesh The mesh to highlight
  60631. */
  60632. removeMesh(mesh: Mesh): void;
  60633. /**
  60634. * Remove all the meshes currently referenced in the highlight layer
  60635. */
  60636. removeAllMeshes(): void;
  60637. /**
  60638. * Force the stencil to the normal expected value for none glowing parts
  60639. */
  60640. private _defaultStencilReference;
  60641. /**
  60642. * Free any resources and references associated to a mesh.
  60643. * Internal use
  60644. * @param mesh The mesh to free.
  60645. * @hidden
  60646. */
  60647. _disposeMesh(mesh: Mesh): void;
  60648. /**
  60649. * Dispose the highlight layer and free resources.
  60650. */
  60651. dispose(): void;
  60652. /**
  60653. * Gets the class name of the effect layer
  60654. * @returns the string with the class name of the effect layer
  60655. */
  60656. getClassName(): string;
  60657. /**
  60658. * Serializes this Highlight layer
  60659. * @returns a serialized Highlight layer object
  60660. */
  60661. serialize(): any;
  60662. /**
  60663. * Creates a Highlight layer from parsed Highlight layer data
  60664. * @param parsedHightlightLayer defines the Highlight layer data
  60665. * @param scene defines the current scene
  60666. * @param rootUrl defines the root URL containing the Highlight layer information
  60667. * @returns a parsed Highlight layer
  60668. */
  60669. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60670. }
  60671. }
  60672. declare module BABYLON {
  60673. interface AbstractScene {
  60674. /**
  60675. * The list of layers (background and foreground) of the scene
  60676. */
  60677. layers: Array<Layer>;
  60678. }
  60679. /**
  60680. * Defines the layer scene component responsible to manage any layers
  60681. * in a given scene.
  60682. */
  60683. export class LayerSceneComponent implements ISceneComponent {
  60684. /**
  60685. * The component name helpfull to identify the component in the list of scene components.
  60686. */
  60687. readonly name: string;
  60688. /**
  60689. * The scene the component belongs to.
  60690. */
  60691. scene: Scene;
  60692. private _engine;
  60693. /**
  60694. * Creates a new instance of the component for the given scene
  60695. * @param scene Defines the scene to register the component in
  60696. */
  60697. constructor(scene: Scene);
  60698. /**
  60699. * Registers the component in a given scene
  60700. */
  60701. register(): void;
  60702. /**
  60703. * Rebuilds the elements related to this component in case of
  60704. * context lost for instance.
  60705. */
  60706. rebuild(): void;
  60707. /**
  60708. * Disposes the component and the associated ressources.
  60709. */
  60710. dispose(): void;
  60711. private _draw;
  60712. private _drawCameraPredicate;
  60713. private _drawCameraBackground;
  60714. private _drawCameraForeground;
  60715. private _drawRenderTargetPredicate;
  60716. private _drawRenderTargetBackground;
  60717. private _drawRenderTargetForeground;
  60718. /**
  60719. * Adds all the elements from the container to the scene
  60720. * @param container the container holding the elements
  60721. */
  60722. addFromContainer(container: AbstractScene): void;
  60723. /**
  60724. * Removes all the elements in the container from the scene
  60725. * @param container contains the elements to remove
  60726. * @param dispose if the removed element should be disposed (default: false)
  60727. */
  60728. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60729. }
  60730. }
  60731. declare module BABYLON {
  60732. /** @hidden */
  60733. export var layerPixelShader: {
  60734. name: string;
  60735. shader: string;
  60736. };
  60737. }
  60738. declare module BABYLON {
  60739. /** @hidden */
  60740. export var layerVertexShader: {
  60741. name: string;
  60742. shader: string;
  60743. };
  60744. }
  60745. declare module BABYLON {
  60746. /**
  60747. * This represents a full screen 2d layer.
  60748. * This can be useful to display a picture in the background of your scene for instance.
  60749. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60750. */
  60751. export class Layer {
  60752. /**
  60753. * Define the name of the layer.
  60754. */
  60755. name: string;
  60756. /**
  60757. * Define the texture the layer should display.
  60758. */
  60759. texture: Nullable<Texture>;
  60760. /**
  60761. * Is the layer in background or foreground.
  60762. */
  60763. isBackground: boolean;
  60764. /**
  60765. * Define the color of the layer (instead of texture).
  60766. */
  60767. color: Color4;
  60768. /**
  60769. * Define the scale of the layer in order to zoom in out of the texture.
  60770. */
  60771. scale: Vector2;
  60772. /**
  60773. * Define an offset for the layer in order to shift the texture.
  60774. */
  60775. offset: Vector2;
  60776. /**
  60777. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60778. */
  60779. alphaBlendingMode: number;
  60780. /**
  60781. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60782. * Alpha test will not mix with the background color in case of transparency.
  60783. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60784. */
  60785. alphaTest: boolean;
  60786. /**
  60787. * Define a mask to restrict the layer to only some of the scene cameras.
  60788. */
  60789. layerMask: number;
  60790. /**
  60791. * Define the list of render target the layer is visible into.
  60792. */
  60793. renderTargetTextures: RenderTargetTexture[];
  60794. /**
  60795. * Define if the layer is only used in renderTarget or if it also
  60796. * renders in the main frame buffer of the canvas.
  60797. */
  60798. renderOnlyInRenderTargetTextures: boolean;
  60799. private _scene;
  60800. private _vertexBuffers;
  60801. private _indexBuffer;
  60802. private _effect;
  60803. private _previousDefines;
  60804. /**
  60805. * An event triggered when the layer is disposed.
  60806. */
  60807. onDisposeObservable: Observable<Layer>;
  60808. private _onDisposeObserver;
  60809. /**
  60810. * Back compatibility with callback before the onDisposeObservable existed.
  60811. * The set callback will be triggered when the layer has been disposed.
  60812. */
  60813. set onDispose(callback: () => void);
  60814. /**
  60815. * An event triggered before rendering the scene
  60816. */
  60817. onBeforeRenderObservable: Observable<Layer>;
  60818. private _onBeforeRenderObserver;
  60819. /**
  60820. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60821. * The set callback will be triggered just before rendering the layer.
  60822. */
  60823. set onBeforeRender(callback: () => void);
  60824. /**
  60825. * An event triggered after rendering the scene
  60826. */
  60827. onAfterRenderObservable: Observable<Layer>;
  60828. private _onAfterRenderObserver;
  60829. /**
  60830. * Back compatibility with callback before the onAfterRenderObservable existed.
  60831. * The set callback will be triggered just after rendering the layer.
  60832. */
  60833. set onAfterRender(callback: () => void);
  60834. /**
  60835. * Instantiates a new layer.
  60836. * This represents a full screen 2d layer.
  60837. * This can be useful to display a picture in the background of your scene for instance.
  60838. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60839. * @param name Define the name of the layer in the scene
  60840. * @param imgUrl Define the url of the texture to display in the layer
  60841. * @param scene Define the scene the layer belongs to
  60842. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60843. * @param color Defines a color for the layer
  60844. */
  60845. constructor(
  60846. /**
  60847. * Define the name of the layer.
  60848. */
  60849. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60850. private _createIndexBuffer;
  60851. /** @hidden */
  60852. _rebuild(): void;
  60853. /**
  60854. * Renders the layer in the scene.
  60855. */
  60856. render(): void;
  60857. /**
  60858. * Disposes and releases the associated ressources.
  60859. */
  60860. dispose(): void;
  60861. }
  60862. }
  60863. declare module BABYLON {
  60864. /** @hidden */
  60865. export var lensFlarePixelShader: {
  60866. name: string;
  60867. shader: string;
  60868. };
  60869. }
  60870. declare module BABYLON {
  60871. /** @hidden */
  60872. export var lensFlareVertexShader: {
  60873. name: string;
  60874. shader: string;
  60875. };
  60876. }
  60877. declare module BABYLON {
  60878. /**
  60879. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60880. * It is usually composed of several `lensFlare`.
  60881. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60882. */
  60883. export class LensFlareSystem {
  60884. /**
  60885. * Define the name of the lens flare system
  60886. */
  60887. name: string;
  60888. /**
  60889. * List of lens flares used in this system.
  60890. */
  60891. lensFlares: LensFlare[];
  60892. /**
  60893. * Define a limit from the border the lens flare can be visible.
  60894. */
  60895. borderLimit: number;
  60896. /**
  60897. * Define a viewport border we do not want to see the lens flare in.
  60898. */
  60899. viewportBorder: number;
  60900. /**
  60901. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60902. */
  60903. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60904. /**
  60905. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60906. */
  60907. layerMask: number;
  60908. /**
  60909. * Define the id of the lens flare system in the scene.
  60910. * (equal to name by default)
  60911. */
  60912. id: string;
  60913. private _scene;
  60914. private _emitter;
  60915. private _vertexBuffers;
  60916. private _indexBuffer;
  60917. private _effect;
  60918. private _positionX;
  60919. private _positionY;
  60920. private _isEnabled;
  60921. /** @hidden */
  60922. static _SceneComponentInitialization: (scene: Scene) => void;
  60923. /**
  60924. * Instantiates a lens flare system.
  60925. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60926. * It is usually composed of several `lensFlare`.
  60927. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60928. * @param name Define the name of the lens flare system in the scene
  60929. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60930. * @param scene Define the scene the lens flare system belongs to
  60931. */
  60932. constructor(
  60933. /**
  60934. * Define the name of the lens flare system
  60935. */
  60936. name: string, emitter: any, scene: Scene);
  60937. /**
  60938. * Define if the lens flare system is enabled.
  60939. */
  60940. get isEnabled(): boolean;
  60941. set isEnabled(value: boolean);
  60942. /**
  60943. * Get the scene the effects belongs to.
  60944. * @returns the scene holding the lens flare system
  60945. */
  60946. getScene(): Scene;
  60947. /**
  60948. * Get the emitter of the lens flare system.
  60949. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60950. * @returns the emitter of the lens flare system
  60951. */
  60952. getEmitter(): any;
  60953. /**
  60954. * Set the emitter of the lens flare system.
  60955. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60956. * @param newEmitter Define the new emitter of the system
  60957. */
  60958. setEmitter(newEmitter: any): void;
  60959. /**
  60960. * Get the lens flare system emitter position.
  60961. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60962. * @returns the position
  60963. */
  60964. getEmitterPosition(): Vector3;
  60965. /**
  60966. * @hidden
  60967. */
  60968. computeEffectivePosition(globalViewport: Viewport): boolean;
  60969. /** @hidden */
  60970. _isVisible(): boolean;
  60971. /**
  60972. * @hidden
  60973. */
  60974. render(): boolean;
  60975. /**
  60976. * Dispose and release the lens flare with its associated resources.
  60977. */
  60978. dispose(): void;
  60979. /**
  60980. * Parse a lens flare system from a JSON repressentation
  60981. * @param parsedLensFlareSystem Define the JSON to parse
  60982. * @param scene Define the scene the parsed system should be instantiated in
  60983. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60984. * @returns the parsed system
  60985. */
  60986. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60987. /**
  60988. * Serialize the current Lens Flare System into a JSON representation.
  60989. * @returns the serialized JSON
  60990. */
  60991. serialize(): any;
  60992. }
  60993. }
  60994. declare module BABYLON {
  60995. /**
  60996. * This represents one of the lens effect in a `lensFlareSystem`.
  60997. * It controls one of the indiviual texture used in the effect.
  60998. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60999. */
  61000. export class LensFlare {
  61001. /**
  61002. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61003. */
  61004. size: number;
  61005. /**
  61006. * 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.
  61007. */
  61008. position: number;
  61009. /**
  61010. * Define the lens color.
  61011. */
  61012. color: Color3;
  61013. /**
  61014. * Define the lens texture.
  61015. */
  61016. texture: Nullable<Texture>;
  61017. /**
  61018. * Define the alpha mode to render this particular lens.
  61019. */
  61020. alphaMode: number;
  61021. private _system;
  61022. /**
  61023. * Creates a new Lens Flare.
  61024. * This represents one of the lens effect in a `lensFlareSystem`.
  61025. * It controls one of the indiviual texture used in the effect.
  61026. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61027. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  61028. * @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.
  61029. * @param color Define the lens color
  61030. * @param imgUrl Define the lens texture url
  61031. * @param system Define the `lensFlareSystem` this flare is part of
  61032. * @returns The newly created Lens Flare
  61033. */
  61034. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  61035. /**
  61036. * Instantiates a new Lens Flare.
  61037. * This represents one of the lens effect in a `lensFlareSystem`.
  61038. * It controls one of the indiviual texture used in the effect.
  61039. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61040. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  61041. * @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.
  61042. * @param color Define the lens color
  61043. * @param imgUrl Define the lens texture url
  61044. * @param system Define the `lensFlareSystem` this flare is part of
  61045. */
  61046. constructor(
  61047. /**
  61048. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  61049. */
  61050. size: number,
  61051. /**
  61052. * 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.
  61053. */
  61054. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  61055. /**
  61056. * Dispose and release the lens flare with its associated resources.
  61057. */
  61058. dispose(): void;
  61059. }
  61060. }
  61061. declare module BABYLON {
  61062. interface AbstractScene {
  61063. /**
  61064. * The list of lens flare system added to the scene
  61065. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  61066. */
  61067. lensFlareSystems: Array<LensFlareSystem>;
  61068. /**
  61069. * Removes the given lens flare system from this scene.
  61070. * @param toRemove The lens flare system to remove
  61071. * @returns The index of the removed lens flare system
  61072. */
  61073. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  61074. /**
  61075. * Adds the given lens flare system to this scene
  61076. * @param newLensFlareSystem The lens flare system to add
  61077. */
  61078. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  61079. /**
  61080. * Gets a lens flare system using its name
  61081. * @param name defines the name to look for
  61082. * @returns the lens flare system or null if not found
  61083. */
  61084. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  61085. /**
  61086. * Gets a lens flare system using its id
  61087. * @param id defines the id to look for
  61088. * @returns the lens flare system or null if not found
  61089. */
  61090. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  61091. }
  61092. /**
  61093. * Defines the lens flare scene component responsible to manage any lens flares
  61094. * in a given scene.
  61095. */
  61096. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  61097. /**
  61098. * The component name helpfull to identify the component in the list of scene components.
  61099. */
  61100. readonly name: string;
  61101. /**
  61102. * The scene the component belongs to.
  61103. */
  61104. scene: Scene;
  61105. /**
  61106. * Creates a new instance of the component for the given scene
  61107. * @param scene Defines the scene to register the component in
  61108. */
  61109. constructor(scene: Scene);
  61110. /**
  61111. * Registers the component in a given scene
  61112. */
  61113. register(): void;
  61114. /**
  61115. * Rebuilds the elements related to this component in case of
  61116. * context lost for instance.
  61117. */
  61118. rebuild(): void;
  61119. /**
  61120. * Adds all the elements from the container to the scene
  61121. * @param container the container holding the elements
  61122. */
  61123. addFromContainer(container: AbstractScene): void;
  61124. /**
  61125. * Removes all the elements in the container from the scene
  61126. * @param container contains the elements to remove
  61127. * @param dispose if the removed element should be disposed (default: false)
  61128. */
  61129. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61130. /**
  61131. * Serializes the component data to the specified json object
  61132. * @param serializationObject The object to serialize to
  61133. */
  61134. serialize(serializationObject: any): void;
  61135. /**
  61136. * Disposes the component and the associated ressources.
  61137. */
  61138. dispose(): void;
  61139. private _draw;
  61140. }
  61141. }
  61142. declare module BABYLON {
  61143. /** @hidden */
  61144. export var depthPixelShader: {
  61145. name: string;
  61146. shader: string;
  61147. };
  61148. }
  61149. declare module BABYLON {
  61150. /** @hidden */
  61151. export var depthVertexShader: {
  61152. name: string;
  61153. shader: string;
  61154. };
  61155. }
  61156. declare module BABYLON {
  61157. /**
  61158. * This represents a depth renderer in Babylon.
  61159. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61160. */
  61161. export class DepthRenderer {
  61162. private _scene;
  61163. private _depthMap;
  61164. private _effect;
  61165. private readonly _storeNonLinearDepth;
  61166. private readonly _clearColor;
  61167. /** Get if the depth renderer is using packed depth or not */
  61168. readonly isPacked: boolean;
  61169. private _cachedDefines;
  61170. private _camera;
  61171. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61172. enabled: boolean;
  61173. /**
  61174. * Specifiess that the depth renderer will only be used within
  61175. * the camera it is created for.
  61176. * This can help forcing its rendering during the camera processing.
  61177. */
  61178. useOnlyInActiveCamera: boolean;
  61179. /** @hidden */
  61180. static _SceneComponentInitialization: (scene: Scene) => void;
  61181. /**
  61182. * Instantiates a depth renderer
  61183. * @param scene The scene the renderer belongs to
  61184. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61185. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61186. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61187. */
  61188. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61189. /**
  61190. * Creates the depth rendering effect and checks if the effect is ready.
  61191. * @param subMesh The submesh to be used to render the depth map of
  61192. * @param useInstances If multiple world instances should be used
  61193. * @returns if the depth renderer is ready to render the depth map
  61194. */
  61195. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61196. /**
  61197. * Gets the texture which the depth map will be written to.
  61198. * @returns The depth map texture
  61199. */
  61200. getDepthMap(): RenderTargetTexture;
  61201. /**
  61202. * Disposes of the depth renderer.
  61203. */
  61204. dispose(): void;
  61205. }
  61206. }
  61207. declare module BABYLON {
  61208. /** @hidden */
  61209. export var minmaxReduxPixelShader: {
  61210. name: string;
  61211. shader: string;
  61212. };
  61213. }
  61214. declare module BABYLON {
  61215. /**
  61216. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61217. * and maximum values from all values of the texture.
  61218. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61219. * The source values are read from the red channel of the texture.
  61220. */
  61221. export class MinMaxReducer {
  61222. /**
  61223. * Observable triggered when the computation has been performed
  61224. */
  61225. onAfterReductionPerformed: Observable<{
  61226. min: number;
  61227. max: number;
  61228. }>;
  61229. protected _camera: Camera;
  61230. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61231. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61232. protected _postProcessManager: PostProcessManager;
  61233. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61234. protected _forceFullscreenViewport: boolean;
  61235. /**
  61236. * Creates a min/max reducer
  61237. * @param camera The camera to use for the post processes
  61238. */
  61239. constructor(camera: Camera);
  61240. /**
  61241. * Gets the texture used to read the values from.
  61242. */
  61243. get sourceTexture(): Nullable<RenderTargetTexture>;
  61244. /**
  61245. * Sets the source texture to read the values from.
  61246. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61247. * because in such textures '1' value must not be taken into account to compute the maximum
  61248. * as this value is used to clear the texture.
  61249. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61250. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61251. * @param depthRedux Indicates if the texture is a depth texture or not
  61252. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61253. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61254. */
  61255. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61256. /**
  61257. * Defines the refresh rate of the computation.
  61258. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61259. */
  61260. get refreshRate(): number;
  61261. set refreshRate(value: number);
  61262. protected _activated: boolean;
  61263. /**
  61264. * Gets the activation status of the reducer
  61265. */
  61266. get activated(): boolean;
  61267. /**
  61268. * Activates the reduction computation.
  61269. * When activated, the observers registered in onAfterReductionPerformed are
  61270. * called after the compuation is performed
  61271. */
  61272. activate(): void;
  61273. /**
  61274. * Deactivates the reduction computation.
  61275. */
  61276. deactivate(): void;
  61277. /**
  61278. * Disposes the min/max reducer
  61279. * @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.
  61280. */
  61281. dispose(disposeAll?: boolean): void;
  61282. }
  61283. }
  61284. declare module BABYLON {
  61285. /**
  61286. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61287. */
  61288. export class DepthReducer extends MinMaxReducer {
  61289. private _depthRenderer;
  61290. private _depthRendererId;
  61291. /**
  61292. * Gets the depth renderer used for the computation.
  61293. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61294. */
  61295. get depthRenderer(): Nullable<DepthRenderer>;
  61296. /**
  61297. * Creates a depth reducer
  61298. * @param camera The camera used to render the depth texture
  61299. */
  61300. constructor(camera: Camera);
  61301. /**
  61302. * Sets the depth renderer to use to generate the depth map
  61303. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61304. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61305. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61306. */
  61307. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61308. /** @hidden */
  61309. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61310. /**
  61311. * Activates the reduction computation.
  61312. * When activated, the observers registered in onAfterReductionPerformed are
  61313. * called after the compuation is performed
  61314. */
  61315. activate(): void;
  61316. /**
  61317. * Deactivates the reduction computation.
  61318. */
  61319. deactivate(): void;
  61320. /**
  61321. * Disposes the depth reducer
  61322. * @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.
  61323. */
  61324. dispose(disposeAll?: boolean): void;
  61325. }
  61326. }
  61327. declare module BABYLON {
  61328. /**
  61329. * A CSM implementation allowing casting shadows on large scenes.
  61330. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61331. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61332. */
  61333. export class CascadedShadowGenerator extends ShadowGenerator {
  61334. private static readonly frustumCornersNDCSpace;
  61335. /**
  61336. * Name of the CSM class
  61337. */
  61338. static CLASSNAME: string;
  61339. /**
  61340. * Defines the default number of cascades used by the CSM.
  61341. */
  61342. static readonly DEFAULT_CASCADES_COUNT: number;
  61343. /**
  61344. * Defines the minimum number of cascades used by the CSM.
  61345. */
  61346. static readonly MIN_CASCADES_COUNT: number;
  61347. /**
  61348. * Defines the maximum number of cascades used by the CSM.
  61349. */
  61350. static readonly MAX_CASCADES_COUNT: number;
  61351. protected _validateFilter(filter: number): number;
  61352. /**
  61353. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61354. */
  61355. penumbraDarkness: number;
  61356. private _numCascades;
  61357. /**
  61358. * Gets or set the number of cascades used by the CSM.
  61359. */
  61360. get numCascades(): number;
  61361. set numCascades(value: number);
  61362. /**
  61363. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61364. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61365. */
  61366. stabilizeCascades: boolean;
  61367. private _freezeShadowCastersBoundingInfo;
  61368. private _freezeShadowCastersBoundingInfoObservable;
  61369. /**
  61370. * Enables or disables the shadow casters bounding info computation.
  61371. * If your shadow casters don't move, you can disable this feature.
  61372. * If it is enabled, the bounding box computation is done every frame.
  61373. */
  61374. get freezeShadowCastersBoundingInfo(): boolean;
  61375. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61376. private _scbiMin;
  61377. private _scbiMax;
  61378. protected _computeShadowCastersBoundingInfo(): void;
  61379. protected _shadowCastersBoundingInfo: BoundingInfo;
  61380. /**
  61381. * Gets or sets the shadow casters bounding info.
  61382. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61383. * so that the system won't overwrite the bounds you provide
  61384. */
  61385. get shadowCastersBoundingInfo(): BoundingInfo;
  61386. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61387. protected _breaksAreDirty: boolean;
  61388. protected _minDistance: number;
  61389. protected _maxDistance: number;
  61390. /**
  61391. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61392. *
  61393. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61394. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61395. * @param min minimal distance for the breaks (default to 0.)
  61396. * @param max maximal distance for the breaks (default to 1.)
  61397. */
  61398. setMinMaxDistance(min: number, max: number): void;
  61399. /** Gets the minimal distance used in the cascade break computation */
  61400. get minDistance(): number;
  61401. /** Gets the maximal distance used in the cascade break computation */
  61402. get maxDistance(): number;
  61403. /**
  61404. * Gets the class name of that object
  61405. * @returns "CascadedShadowGenerator"
  61406. */
  61407. getClassName(): string;
  61408. private _cascadeMinExtents;
  61409. private _cascadeMaxExtents;
  61410. /**
  61411. * Gets a cascade minimum extents
  61412. * @param cascadeIndex index of the cascade
  61413. * @returns the minimum cascade extents
  61414. */
  61415. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61416. /**
  61417. * Gets a cascade maximum extents
  61418. * @param cascadeIndex index of the cascade
  61419. * @returns the maximum cascade extents
  61420. */
  61421. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61422. private _cascades;
  61423. private _currentLayer;
  61424. private _viewSpaceFrustumsZ;
  61425. private _viewMatrices;
  61426. private _projectionMatrices;
  61427. private _transformMatrices;
  61428. private _transformMatricesAsArray;
  61429. private _frustumLengths;
  61430. private _lightSizeUVCorrection;
  61431. private _depthCorrection;
  61432. private _frustumCornersWorldSpace;
  61433. private _frustumCenter;
  61434. private _shadowCameraPos;
  61435. private _shadowMaxZ;
  61436. /**
  61437. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61438. * It defaults to camera.maxZ
  61439. */
  61440. get shadowMaxZ(): number;
  61441. /**
  61442. * Sets the shadow max z distance.
  61443. */
  61444. set shadowMaxZ(value: number);
  61445. protected _debug: boolean;
  61446. /**
  61447. * Gets or sets the debug flag.
  61448. * When enabled, the cascades are materialized by different colors on the screen.
  61449. */
  61450. get debug(): boolean;
  61451. set debug(dbg: boolean);
  61452. private _depthClamp;
  61453. /**
  61454. * Gets or sets the depth clamping value.
  61455. *
  61456. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61457. * to account for the shadow casters far away.
  61458. *
  61459. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61460. */
  61461. get depthClamp(): boolean;
  61462. set depthClamp(value: boolean);
  61463. private _cascadeBlendPercentage;
  61464. /**
  61465. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61466. * It defaults to 0.1 (10% blending).
  61467. */
  61468. get cascadeBlendPercentage(): number;
  61469. set cascadeBlendPercentage(value: number);
  61470. private _lambda;
  61471. /**
  61472. * Gets or set the lambda parameter.
  61473. * This parameter is used to split the camera frustum and create the cascades.
  61474. * 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.
  61475. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61476. */
  61477. get lambda(): number;
  61478. set lambda(value: number);
  61479. /**
  61480. * Gets the view matrix corresponding to a given cascade
  61481. * @param cascadeNum cascade to retrieve the view matrix from
  61482. * @returns the cascade view matrix
  61483. */
  61484. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61485. /**
  61486. * Gets the projection matrix corresponding to a given cascade
  61487. * @param cascadeNum cascade to retrieve the projection matrix from
  61488. * @returns the cascade projection matrix
  61489. */
  61490. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61491. /**
  61492. * Gets the transformation matrix corresponding to a given cascade
  61493. * @param cascadeNum cascade to retrieve the transformation matrix from
  61494. * @returns the cascade transformation matrix
  61495. */
  61496. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61497. private _depthRenderer;
  61498. /**
  61499. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61500. *
  61501. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61502. *
  61503. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61504. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61505. * @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
  61506. */
  61507. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61508. private _depthReducer;
  61509. private _autoCalcDepthBounds;
  61510. /**
  61511. * Gets or sets the autoCalcDepthBounds property.
  61512. *
  61513. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61514. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61515. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61516. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61517. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61518. */
  61519. get autoCalcDepthBounds(): boolean;
  61520. set autoCalcDepthBounds(value: boolean);
  61521. /**
  61522. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61523. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61524. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61525. * for setting the refresh rate on the renderer yourself!
  61526. */
  61527. get autoCalcDepthBoundsRefreshRate(): number;
  61528. set autoCalcDepthBoundsRefreshRate(value: number);
  61529. /**
  61530. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61531. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61532. * you change the camera near/far planes!
  61533. */
  61534. splitFrustum(): void;
  61535. private _splitFrustum;
  61536. private _computeMatrices;
  61537. private _computeFrustumInWorldSpace;
  61538. private _computeCascadeFrustum;
  61539. /**
  61540. * Support test.
  61541. */
  61542. static get IsSupported(): boolean;
  61543. /** @hidden */
  61544. static _SceneComponentInitialization: (scene: Scene) => void;
  61545. /**
  61546. * Creates a Cascaded Shadow Generator object.
  61547. * A ShadowGenerator is the required tool to use the shadows.
  61548. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61549. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61550. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61551. * @param light The directional light object generating the shadows.
  61552. * @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.
  61553. */
  61554. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61555. protected _initializeGenerator(): void;
  61556. protected _createTargetRenderTexture(): void;
  61557. protected _initializeShadowMap(): void;
  61558. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61559. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61560. /**
  61561. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61562. * @param defines Defines of the material we want to update
  61563. * @param lightIndex Index of the light in the enabled light list of the material
  61564. */
  61565. prepareDefines(defines: any, lightIndex: number): void;
  61566. /**
  61567. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61568. * defined in the generator but impacting the effect).
  61569. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61570. * @param effect The effect we are binfing the information for
  61571. */
  61572. bindShadowLight(lightIndex: string, effect: Effect): void;
  61573. /**
  61574. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61575. * (eq to view projection * shadow projection matrices)
  61576. * @returns The transform matrix used to create the shadow map
  61577. */
  61578. getTransformMatrix(): Matrix;
  61579. /**
  61580. * Disposes the ShadowGenerator.
  61581. * Returns nothing.
  61582. */
  61583. dispose(): void;
  61584. /**
  61585. * Serializes the shadow generator setup to a json object.
  61586. * @returns The serialized JSON object
  61587. */
  61588. serialize(): any;
  61589. /**
  61590. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61591. * @param parsedShadowGenerator The JSON object to parse
  61592. * @param scene The scene to create the shadow map for
  61593. * @returns The parsed shadow generator
  61594. */
  61595. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61596. }
  61597. }
  61598. declare module BABYLON {
  61599. /**
  61600. * Defines the shadow generator component responsible to manage any shadow generators
  61601. * in a given scene.
  61602. */
  61603. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61604. /**
  61605. * The component name helpfull to identify the component in the list of scene components.
  61606. */
  61607. readonly name: string;
  61608. /**
  61609. * The scene the component belongs to.
  61610. */
  61611. scene: Scene;
  61612. /**
  61613. * Creates a new instance of the component for the given scene
  61614. * @param scene Defines the scene to register the component in
  61615. */
  61616. constructor(scene: Scene);
  61617. /**
  61618. * Registers the component in a given scene
  61619. */
  61620. register(): void;
  61621. /**
  61622. * Rebuilds the elements related to this component in case of
  61623. * context lost for instance.
  61624. */
  61625. rebuild(): void;
  61626. /**
  61627. * Serializes the component data to the specified json object
  61628. * @param serializationObject The object to serialize to
  61629. */
  61630. serialize(serializationObject: any): void;
  61631. /**
  61632. * Adds all the elements from the container to the scene
  61633. * @param container the container holding the elements
  61634. */
  61635. addFromContainer(container: AbstractScene): void;
  61636. /**
  61637. * Removes all the elements in the container from the scene
  61638. * @param container contains the elements to remove
  61639. * @param dispose if the removed element should be disposed (default: false)
  61640. */
  61641. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61642. /**
  61643. * Rebuilds the elements related to this component in case of
  61644. * context lost for instance.
  61645. */
  61646. dispose(): void;
  61647. private _gatherRenderTargets;
  61648. }
  61649. }
  61650. declare module BABYLON {
  61651. /**
  61652. * A point light is a light defined by an unique point in world space.
  61653. * The light is emitted in every direction from this point.
  61654. * A good example of a point light is a standard light bulb.
  61655. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61656. */
  61657. export class PointLight extends ShadowLight {
  61658. private _shadowAngle;
  61659. /**
  61660. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61661. * This specifies what angle the shadow will use to be created.
  61662. *
  61663. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61664. */
  61665. get shadowAngle(): number;
  61666. /**
  61667. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61668. * This specifies what angle the shadow will use to be created.
  61669. *
  61670. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61671. */
  61672. set shadowAngle(value: number);
  61673. /**
  61674. * Gets the direction if it has been set.
  61675. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61676. */
  61677. get direction(): Vector3;
  61678. /**
  61679. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61680. */
  61681. set direction(value: Vector3);
  61682. /**
  61683. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61684. * A PointLight emits the light in every direction.
  61685. * It can cast shadows.
  61686. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61687. * ```javascript
  61688. * var pointLight = new PointLight("pl", camera.position, scene);
  61689. * ```
  61690. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61691. * @param name The light friendly name
  61692. * @param position The position of the point light in the scene
  61693. * @param scene The scene the lights belongs to
  61694. */
  61695. constructor(name: string, position: Vector3, scene: Scene);
  61696. /**
  61697. * Returns the string "PointLight"
  61698. * @returns the class name
  61699. */
  61700. getClassName(): string;
  61701. /**
  61702. * Returns the integer 0.
  61703. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61704. */
  61705. getTypeID(): number;
  61706. /**
  61707. * Specifies wether or not the shadowmap should be a cube texture.
  61708. * @returns true if the shadowmap needs to be a cube texture.
  61709. */
  61710. needCube(): boolean;
  61711. /**
  61712. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61713. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61714. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61715. */
  61716. getShadowDirection(faceIndex?: number): Vector3;
  61717. /**
  61718. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61719. * - fov = PI / 2
  61720. * - aspect ratio : 1.0
  61721. * - z-near and far equal to the active camera minZ and maxZ.
  61722. * Returns the PointLight.
  61723. */
  61724. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61725. protected _buildUniformLayout(): void;
  61726. /**
  61727. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61728. * @param effect The effect to update
  61729. * @param lightIndex The index of the light in the effect to update
  61730. * @returns The point light
  61731. */
  61732. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61733. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61734. /**
  61735. * Prepares the list of defines specific to the light type.
  61736. * @param defines the list of defines
  61737. * @param lightIndex defines the index of the light for the effect
  61738. */
  61739. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61740. }
  61741. }
  61742. declare module BABYLON {
  61743. /**
  61744. * Header information of HDR texture files.
  61745. */
  61746. export interface HDRInfo {
  61747. /**
  61748. * The height of the texture in pixels.
  61749. */
  61750. height: number;
  61751. /**
  61752. * The width of the texture in pixels.
  61753. */
  61754. width: number;
  61755. /**
  61756. * The index of the beginning of the data in the binary file.
  61757. */
  61758. dataPosition: number;
  61759. }
  61760. /**
  61761. * This groups tools to convert HDR texture to native colors array.
  61762. */
  61763. export class HDRTools {
  61764. private static Ldexp;
  61765. private static Rgbe2float;
  61766. private static readStringLine;
  61767. /**
  61768. * Reads header information from an RGBE texture stored in a native array.
  61769. * More information on this format are available here:
  61770. * https://en.wikipedia.org/wiki/RGBE_image_format
  61771. *
  61772. * @param uint8array The binary file stored in native array.
  61773. * @return The header information.
  61774. */
  61775. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61776. /**
  61777. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61778. * This RGBE texture needs to store the information as a panorama.
  61779. *
  61780. * More information on this format are available here:
  61781. * https://en.wikipedia.org/wiki/RGBE_image_format
  61782. *
  61783. * @param buffer The binary file stored in an array buffer.
  61784. * @param size The expected size of the extracted cubemap.
  61785. * @return The Cube Map information.
  61786. */
  61787. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61788. /**
  61789. * Returns the pixels data extracted from an RGBE texture.
  61790. * This pixels will be stored left to right up to down in the R G B order in one array.
  61791. *
  61792. * More information on this format are available here:
  61793. * https://en.wikipedia.org/wiki/RGBE_image_format
  61794. *
  61795. * @param uint8array The binary file stored in an array buffer.
  61796. * @param hdrInfo The header information of the file.
  61797. * @return The pixels data in RGB right to left up to down order.
  61798. */
  61799. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61800. private static RGBE_ReadPixels_RLE;
  61801. private static RGBE_ReadPixels_NOT_RLE;
  61802. }
  61803. }
  61804. declare module BABYLON {
  61805. /**
  61806. * Effect Render Options
  61807. */
  61808. export interface IEffectRendererOptions {
  61809. /**
  61810. * Defines the vertices positions.
  61811. */
  61812. positions?: number[];
  61813. /**
  61814. * Defines the indices.
  61815. */
  61816. indices?: number[];
  61817. }
  61818. /**
  61819. * Helper class to render one or more effects.
  61820. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61821. */
  61822. export class EffectRenderer {
  61823. private engine;
  61824. private static _DefaultOptions;
  61825. private _vertexBuffers;
  61826. private _indexBuffer;
  61827. private _fullscreenViewport;
  61828. /**
  61829. * Creates an effect renderer
  61830. * @param engine the engine to use for rendering
  61831. * @param options defines the options of the effect renderer
  61832. */
  61833. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61834. /**
  61835. * Sets the current viewport in normalized coordinates 0-1
  61836. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61837. */
  61838. setViewport(viewport?: Viewport): void;
  61839. /**
  61840. * Binds the embedded attributes buffer to the effect.
  61841. * @param effect Defines the effect to bind the attributes for
  61842. */
  61843. bindBuffers(effect: Effect): void;
  61844. /**
  61845. * Sets the current effect wrapper to use during draw.
  61846. * The effect needs to be ready before calling this api.
  61847. * This also sets the default full screen position attribute.
  61848. * @param effectWrapper Defines the effect to draw with
  61849. */
  61850. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61851. /**
  61852. * Restores engine states
  61853. */
  61854. restoreStates(): void;
  61855. /**
  61856. * Draws a full screen quad.
  61857. */
  61858. draw(): void;
  61859. private isRenderTargetTexture;
  61860. /**
  61861. * renders one or more effects to a specified texture
  61862. * @param effectWrapper the effect to renderer
  61863. * @param outputTexture texture to draw to, if null it will render to the screen.
  61864. */
  61865. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61866. /**
  61867. * Disposes of the effect renderer
  61868. */
  61869. dispose(): void;
  61870. }
  61871. /**
  61872. * Options to create an EffectWrapper
  61873. */
  61874. interface EffectWrapperCreationOptions {
  61875. /**
  61876. * Engine to use to create the effect
  61877. */
  61878. engine: ThinEngine;
  61879. /**
  61880. * Fragment shader for the effect
  61881. */
  61882. fragmentShader: string;
  61883. /**
  61884. * Use the shader store instead of direct source code
  61885. */
  61886. useShaderStore?: boolean;
  61887. /**
  61888. * Vertex shader for the effect
  61889. */
  61890. vertexShader?: string;
  61891. /**
  61892. * Attributes to use in the shader
  61893. */
  61894. attributeNames?: Array<string>;
  61895. /**
  61896. * Uniforms to use in the shader
  61897. */
  61898. uniformNames?: Array<string>;
  61899. /**
  61900. * Texture sampler names to use in the shader
  61901. */
  61902. samplerNames?: Array<string>;
  61903. /**
  61904. * Defines to use in the shader
  61905. */
  61906. defines?: Array<string>;
  61907. /**
  61908. * Callback when effect is compiled
  61909. */
  61910. onCompiled?: Nullable<(effect: Effect) => void>;
  61911. /**
  61912. * The friendly name of the effect displayed in Spector.
  61913. */
  61914. name?: string;
  61915. }
  61916. /**
  61917. * Wraps an effect to be used for rendering
  61918. */
  61919. export class EffectWrapper {
  61920. /**
  61921. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61922. */
  61923. onApplyObservable: Observable<{}>;
  61924. /**
  61925. * The underlying effect
  61926. */
  61927. effect: Effect;
  61928. /**
  61929. * Creates an effect to be renderer
  61930. * @param creationOptions options to create the effect
  61931. */
  61932. constructor(creationOptions: EffectWrapperCreationOptions);
  61933. /**
  61934. * Disposes of the effect wrapper
  61935. */
  61936. dispose(): void;
  61937. }
  61938. }
  61939. declare module BABYLON {
  61940. /** @hidden */
  61941. export var hdrFilteringVertexShader: {
  61942. name: string;
  61943. shader: string;
  61944. };
  61945. }
  61946. declare module BABYLON {
  61947. /** @hidden */
  61948. export var hdrFilteringPixelShader: {
  61949. name: string;
  61950. shader: string;
  61951. };
  61952. }
  61953. declare module BABYLON {
  61954. /**
  61955. * Options for texture filtering
  61956. */
  61957. interface IHDRFilteringOptions {
  61958. /**
  61959. * Scales pixel intensity for the input HDR map.
  61960. */
  61961. hdrScale?: number;
  61962. /**
  61963. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61964. */
  61965. quality?: number;
  61966. }
  61967. /**
  61968. * Filters HDR maps to get correct renderings of PBR reflections
  61969. */
  61970. export class HDRFiltering {
  61971. private _engine;
  61972. private _effectRenderer;
  61973. private _effectWrapper;
  61974. private _lodGenerationOffset;
  61975. private _lodGenerationScale;
  61976. /**
  61977. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61978. * you care about baking speed.
  61979. */
  61980. quality: number;
  61981. /**
  61982. * Scales pixel intensity for the input HDR map.
  61983. */
  61984. hdrScale: number;
  61985. /**
  61986. * Instantiates HDR filter for reflection maps
  61987. *
  61988. * @param engine Thin engine
  61989. * @param options Options
  61990. */
  61991. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61992. private _createRenderTarget;
  61993. private _prefilterInternal;
  61994. private _createEffect;
  61995. /**
  61996. * Get a value indicating if the filter is ready to be used
  61997. * @param texture Texture to filter
  61998. * @returns true if the filter is ready
  61999. */
  62000. isReady(texture: BaseTexture): boolean;
  62001. /**
  62002. * Prefilters a cube texture to have mipmap levels representing roughness values.
  62003. * Prefiltering will be invoked at the end of next rendering pass.
  62004. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  62005. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  62006. * @param texture Texture to filter
  62007. * @param onFinished Callback when filtering is done
  62008. * @return Promise called when prefiltering is done
  62009. */
  62010. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  62011. }
  62012. }
  62013. declare module BABYLON {
  62014. /**
  62015. * This represents a texture coming from an HDR input.
  62016. *
  62017. * The only supported format is currently panorama picture stored in RGBE format.
  62018. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62019. */
  62020. export class HDRCubeTexture extends BaseTexture {
  62021. private static _facesMapping;
  62022. private _generateHarmonics;
  62023. private _noMipmap;
  62024. private _prefilterOnLoad;
  62025. private _textureMatrix;
  62026. private _size;
  62027. private _onLoad;
  62028. private _onError;
  62029. /**
  62030. * The texture URL.
  62031. */
  62032. url: string;
  62033. protected _isBlocking: boolean;
  62034. /**
  62035. * Sets wether or not the texture is blocking during loading.
  62036. */
  62037. set isBlocking(value: boolean);
  62038. /**
  62039. * Gets wether or not the texture is blocking during loading.
  62040. */
  62041. get isBlocking(): boolean;
  62042. protected _rotationY: number;
  62043. /**
  62044. * Sets texture matrix rotation angle around Y axis in radians.
  62045. */
  62046. set rotationY(value: number);
  62047. /**
  62048. * Gets texture matrix rotation angle around Y axis radians.
  62049. */
  62050. get rotationY(): number;
  62051. /**
  62052. * Gets or sets the center of the bounding box associated with the cube texture
  62053. * It must define where the camera used to render the texture was set
  62054. */
  62055. boundingBoxPosition: Vector3;
  62056. private _boundingBoxSize;
  62057. /**
  62058. * Gets or sets the size of the bounding box associated with the cube texture
  62059. * When defined, the cubemap will switch to local mode
  62060. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62061. * @example https://www.babylonjs-playground.com/#RNASML
  62062. */
  62063. set boundingBoxSize(value: Vector3);
  62064. get boundingBoxSize(): Vector3;
  62065. /**
  62066. * Instantiates an HDRTexture from the following parameters.
  62067. *
  62068. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62069. * @param sceneOrEngine The scene or engine the texture will be used in
  62070. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62071. * @param noMipmap Forces to not generate the mipmap if true
  62072. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62073. * @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)
  62074. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62075. */
  62076. 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>);
  62077. /**
  62078. * Get the current class name of the texture useful for serialization or dynamic coding.
  62079. * @returns "HDRCubeTexture"
  62080. */
  62081. getClassName(): string;
  62082. /**
  62083. * Occurs when the file is raw .hdr file.
  62084. */
  62085. private loadTexture;
  62086. clone(): HDRCubeTexture;
  62087. delayLoad(): void;
  62088. /**
  62089. * Get the texture reflection matrix used to rotate/transform the reflection.
  62090. * @returns the reflection matrix
  62091. */
  62092. getReflectionTextureMatrix(): Matrix;
  62093. /**
  62094. * Set the texture reflection matrix used to rotate/transform the reflection.
  62095. * @param value Define the reflection matrix to set
  62096. */
  62097. setReflectionTextureMatrix(value: Matrix): void;
  62098. /**
  62099. * Parses a JSON representation of an HDR Texture in order to create the texture
  62100. * @param parsedTexture Define the JSON representation
  62101. * @param scene Define the scene the texture should be created in
  62102. * @param rootUrl Define the root url in case we need to load relative dependencies
  62103. * @returns the newly created texture after parsing
  62104. */
  62105. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62106. serialize(): any;
  62107. }
  62108. }
  62109. declare module BABYLON {
  62110. /**
  62111. * Class used to control physics engine
  62112. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62113. */
  62114. export class PhysicsEngine implements IPhysicsEngine {
  62115. private _physicsPlugin;
  62116. /**
  62117. * Global value used to control the smallest number supported by the simulation
  62118. */
  62119. static Epsilon: number;
  62120. private _impostors;
  62121. private _joints;
  62122. private _subTimeStep;
  62123. /**
  62124. * Gets the gravity vector used by the simulation
  62125. */
  62126. gravity: Vector3;
  62127. /**
  62128. * Factory used to create the default physics plugin.
  62129. * @returns The default physics plugin
  62130. */
  62131. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62132. /**
  62133. * Creates a new Physics Engine
  62134. * @param gravity defines the gravity vector used by the simulation
  62135. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62136. */
  62137. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62138. /**
  62139. * Sets the gravity vector used by the simulation
  62140. * @param gravity defines the gravity vector to use
  62141. */
  62142. setGravity(gravity: Vector3): void;
  62143. /**
  62144. * Set the time step of the physics engine.
  62145. * Default is 1/60.
  62146. * To slow it down, enter 1/600 for example.
  62147. * To speed it up, 1/30
  62148. * @param newTimeStep defines the new timestep to apply to this world.
  62149. */
  62150. setTimeStep(newTimeStep?: number): void;
  62151. /**
  62152. * Get the time step of the physics engine.
  62153. * @returns the current time step
  62154. */
  62155. getTimeStep(): number;
  62156. /**
  62157. * Set the sub time step of the physics engine.
  62158. * Default is 0 meaning there is no sub steps
  62159. * To increase physics resolution precision, set a small value (like 1 ms)
  62160. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62161. */
  62162. setSubTimeStep(subTimeStep?: number): void;
  62163. /**
  62164. * Get the sub time step of the physics engine.
  62165. * @returns the current sub time step
  62166. */
  62167. getSubTimeStep(): number;
  62168. /**
  62169. * Release all resources
  62170. */
  62171. dispose(): void;
  62172. /**
  62173. * Gets the name of the current physics plugin
  62174. * @returns the name of the plugin
  62175. */
  62176. getPhysicsPluginName(): string;
  62177. /**
  62178. * Adding a new impostor for the impostor tracking.
  62179. * This will be done by the impostor itself.
  62180. * @param impostor the impostor to add
  62181. */
  62182. addImpostor(impostor: PhysicsImpostor): void;
  62183. /**
  62184. * Remove an impostor from the engine.
  62185. * This impostor and its mesh will not longer be updated by the physics engine.
  62186. * @param impostor the impostor to remove
  62187. */
  62188. removeImpostor(impostor: PhysicsImpostor): void;
  62189. /**
  62190. * Add a joint to the physics engine
  62191. * @param mainImpostor defines the main impostor to which the joint is added.
  62192. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62193. * @param joint defines the joint that will connect both impostors.
  62194. */
  62195. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62196. /**
  62197. * Removes a joint from the simulation
  62198. * @param mainImpostor defines the impostor used with the joint
  62199. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62200. * @param joint defines the joint to remove
  62201. */
  62202. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62203. /**
  62204. * Called by the scene. No need to call it.
  62205. * @param delta defines the timespam between frames
  62206. */
  62207. _step(delta: number): void;
  62208. /**
  62209. * Gets the current plugin used to run the simulation
  62210. * @returns current plugin
  62211. */
  62212. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62213. /**
  62214. * Gets the list of physic impostors
  62215. * @returns an array of PhysicsImpostor
  62216. */
  62217. getImpostors(): Array<PhysicsImpostor>;
  62218. /**
  62219. * Gets the impostor for a physics enabled object
  62220. * @param object defines the object impersonated by the impostor
  62221. * @returns the PhysicsImpostor or null if not found
  62222. */
  62223. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62224. /**
  62225. * Gets the impostor for a physics body object
  62226. * @param body defines physics body used by the impostor
  62227. * @returns the PhysicsImpostor or null if not found
  62228. */
  62229. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62230. /**
  62231. * Does a raycast in the physics world
  62232. * @param from when should the ray start?
  62233. * @param to when should the ray end?
  62234. * @returns PhysicsRaycastResult
  62235. */
  62236. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62237. }
  62238. }
  62239. declare module BABYLON {
  62240. /** @hidden */
  62241. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62242. private _useDeltaForWorldStep;
  62243. world: any;
  62244. name: string;
  62245. private _physicsMaterials;
  62246. private _fixedTimeStep;
  62247. private _cannonRaycastResult;
  62248. private _raycastResult;
  62249. private _physicsBodysToRemoveAfterStep;
  62250. private _firstFrame;
  62251. BJSCANNON: any;
  62252. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62253. setGravity(gravity: Vector3): void;
  62254. setTimeStep(timeStep: number): void;
  62255. getTimeStep(): number;
  62256. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62257. private _removeMarkedPhysicsBodiesFromWorld;
  62258. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62259. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62260. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62261. private _processChildMeshes;
  62262. removePhysicsBody(impostor: PhysicsImpostor): void;
  62263. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62264. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62265. private _addMaterial;
  62266. private _checkWithEpsilon;
  62267. private _createShape;
  62268. private _createHeightmap;
  62269. private _minus90X;
  62270. private _plus90X;
  62271. private _tmpPosition;
  62272. private _tmpDeltaPosition;
  62273. private _tmpUnityRotation;
  62274. private _updatePhysicsBodyTransformation;
  62275. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62276. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62277. isSupported(): boolean;
  62278. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62279. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62280. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62281. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62282. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62283. getBodyMass(impostor: PhysicsImpostor): number;
  62284. getBodyFriction(impostor: PhysicsImpostor): number;
  62285. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62286. getBodyRestitution(impostor: PhysicsImpostor): number;
  62287. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62288. sleepBody(impostor: PhysicsImpostor): void;
  62289. wakeUpBody(impostor: PhysicsImpostor): void;
  62290. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62291. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62292. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62293. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62294. getRadius(impostor: PhysicsImpostor): number;
  62295. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62296. dispose(): void;
  62297. private _extendNamespace;
  62298. /**
  62299. * Does a raycast in the physics world
  62300. * @param from when should the ray start?
  62301. * @param to when should the ray end?
  62302. * @returns PhysicsRaycastResult
  62303. */
  62304. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62305. }
  62306. }
  62307. declare module BABYLON {
  62308. /** @hidden */
  62309. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62310. private _useDeltaForWorldStep;
  62311. world: any;
  62312. name: string;
  62313. BJSOIMO: any;
  62314. private _raycastResult;
  62315. private _fixedTimeStep;
  62316. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62317. setGravity(gravity: Vector3): void;
  62318. setTimeStep(timeStep: number): void;
  62319. getTimeStep(): number;
  62320. private _tmpImpostorsArray;
  62321. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62322. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62323. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62324. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62325. private _tmpPositionVector;
  62326. removePhysicsBody(impostor: PhysicsImpostor): void;
  62327. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62328. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62329. isSupported(): boolean;
  62330. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62331. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62332. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62333. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62334. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62335. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62336. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62337. getBodyMass(impostor: PhysicsImpostor): number;
  62338. getBodyFriction(impostor: PhysicsImpostor): number;
  62339. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62340. getBodyRestitution(impostor: PhysicsImpostor): number;
  62341. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62342. sleepBody(impostor: PhysicsImpostor): void;
  62343. wakeUpBody(impostor: PhysicsImpostor): void;
  62344. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62345. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62346. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62347. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62348. getRadius(impostor: PhysicsImpostor): number;
  62349. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62350. dispose(): void;
  62351. /**
  62352. * Does a raycast in the physics world
  62353. * @param from when should the ray start?
  62354. * @param to when should the ray end?
  62355. * @returns PhysicsRaycastResult
  62356. */
  62357. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62358. }
  62359. }
  62360. declare module BABYLON {
  62361. /**
  62362. * AmmoJS Physics plugin
  62363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62364. * @see https://github.com/kripken/ammo.js/
  62365. */
  62366. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62367. private _useDeltaForWorldStep;
  62368. /**
  62369. * Reference to the Ammo library
  62370. */
  62371. bjsAMMO: any;
  62372. /**
  62373. * Created ammoJS world which physics bodies are added to
  62374. */
  62375. world: any;
  62376. /**
  62377. * Name of the plugin
  62378. */
  62379. name: string;
  62380. private _timeStep;
  62381. private _fixedTimeStep;
  62382. private _maxSteps;
  62383. private _tmpQuaternion;
  62384. private _tmpAmmoTransform;
  62385. private _tmpAmmoQuaternion;
  62386. private _tmpAmmoConcreteContactResultCallback;
  62387. private _collisionConfiguration;
  62388. private _dispatcher;
  62389. private _overlappingPairCache;
  62390. private _solver;
  62391. private _softBodySolver;
  62392. private _tmpAmmoVectorA;
  62393. private _tmpAmmoVectorB;
  62394. private _tmpAmmoVectorC;
  62395. private _tmpAmmoVectorD;
  62396. private _tmpContactCallbackResult;
  62397. private _tmpAmmoVectorRCA;
  62398. private _tmpAmmoVectorRCB;
  62399. private _raycastResult;
  62400. private _tmpContactPoint;
  62401. private static readonly DISABLE_COLLISION_FLAG;
  62402. private static readonly KINEMATIC_FLAG;
  62403. private static readonly DISABLE_DEACTIVATION_FLAG;
  62404. /**
  62405. * Initializes the ammoJS plugin
  62406. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62407. * @param ammoInjection can be used to inject your own ammo reference
  62408. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62409. */
  62410. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62411. /**
  62412. * Sets the gravity of the physics world (m/(s^2))
  62413. * @param gravity Gravity to set
  62414. */
  62415. setGravity(gravity: Vector3): void;
  62416. /**
  62417. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62418. * @param timeStep timestep to use in seconds
  62419. */
  62420. setTimeStep(timeStep: number): void;
  62421. /**
  62422. * 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)
  62423. * @param fixedTimeStep fixedTimeStep to use in seconds
  62424. */
  62425. setFixedTimeStep(fixedTimeStep: number): void;
  62426. /**
  62427. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62428. * @param maxSteps the maximum number of steps by the physics engine per frame
  62429. */
  62430. setMaxSteps(maxSteps: number): void;
  62431. /**
  62432. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62433. * @returns the current timestep in seconds
  62434. */
  62435. getTimeStep(): number;
  62436. /**
  62437. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62438. */
  62439. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62440. private _isImpostorInContact;
  62441. private _isImpostorPairInContact;
  62442. private _stepSimulation;
  62443. /**
  62444. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62445. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62446. * After the step the babylon meshes are set to the position of the physics imposters
  62447. * @param delta amount of time to step forward
  62448. * @param impostors array of imposters to update before/after the step
  62449. */
  62450. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62451. /**
  62452. * Update babylon mesh to match physics world object
  62453. * @param impostor imposter to match
  62454. */
  62455. private _afterSoftStep;
  62456. /**
  62457. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62458. * @param impostor imposter to match
  62459. */
  62460. private _ropeStep;
  62461. /**
  62462. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62463. * @param impostor imposter to match
  62464. */
  62465. private _softbodyOrClothStep;
  62466. private _tmpMatrix;
  62467. /**
  62468. * Applies an impulse on the imposter
  62469. * @param impostor imposter to apply impulse to
  62470. * @param force amount of force to be applied to the imposter
  62471. * @param contactPoint the location to apply the impulse on the imposter
  62472. */
  62473. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62474. /**
  62475. * Applies a force on the imposter
  62476. * @param impostor imposter to apply force
  62477. * @param force amount of force to be applied to the imposter
  62478. * @param contactPoint the location to apply the force on the imposter
  62479. */
  62480. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62481. /**
  62482. * Creates a physics body using the plugin
  62483. * @param impostor the imposter to create the physics body on
  62484. */
  62485. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62486. /**
  62487. * Removes the physics body from the imposter and disposes of the body's memory
  62488. * @param impostor imposter to remove the physics body from
  62489. */
  62490. removePhysicsBody(impostor: PhysicsImpostor): void;
  62491. /**
  62492. * Generates a joint
  62493. * @param impostorJoint the imposter joint to create the joint with
  62494. */
  62495. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62496. /**
  62497. * Removes a joint
  62498. * @param impostorJoint the imposter joint to remove the joint from
  62499. */
  62500. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62501. private _addMeshVerts;
  62502. /**
  62503. * Initialise the soft body vertices to match its object's (mesh) vertices
  62504. * Softbody vertices (nodes) are in world space and to match this
  62505. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62506. * @param impostor to create the softbody for
  62507. */
  62508. private _softVertexData;
  62509. /**
  62510. * Create an impostor's soft body
  62511. * @param impostor to create the softbody for
  62512. */
  62513. private _createSoftbody;
  62514. /**
  62515. * Create cloth for an impostor
  62516. * @param impostor to create the softbody for
  62517. */
  62518. private _createCloth;
  62519. /**
  62520. * Create rope for an impostor
  62521. * @param impostor to create the softbody for
  62522. */
  62523. private _createRope;
  62524. /**
  62525. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62526. * @param impostor to create the custom physics shape for
  62527. */
  62528. private _createCustom;
  62529. private _addHullVerts;
  62530. private _createShape;
  62531. /**
  62532. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62533. * @param impostor imposter containing the physics body and babylon object
  62534. */
  62535. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62536. /**
  62537. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62538. * @param impostor imposter containing the physics body and babylon object
  62539. * @param newPosition new position
  62540. * @param newRotation new rotation
  62541. */
  62542. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62543. /**
  62544. * If this plugin is supported
  62545. * @returns true if its supported
  62546. */
  62547. isSupported(): boolean;
  62548. /**
  62549. * Sets the linear velocity of the physics body
  62550. * @param impostor imposter to set the velocity on
  62551. * @param velocity velocity to set
  62552. */
  62553. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62554. /**
  62555. * Sets the angular velocity of the physics body
  62556. * @param impostor imposter to set the velocity on
  62557. * @param velocity velocity to set
  62558. */
  62559. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62560. /**
  62561. * gets the linear velocity
  62562. * @param impostor imposter to get linear velocity from
  62563. * @returns linear velocity
  62564. */
  62565. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62566. /**
  62567. * gets the angular velocity
  62568. * @param impostor imposter to get angular velocity from
  62569. * @returns angular velocity
  62570. */
  62571. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62572. /**
  62573. * Sets the mass of physics body
  62574. * @param impostor imposter to set the mass on
  62575. * @param mass mass to set
  62576. */
  62577. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62578. /**
  62579. * Gets the mass of the physics body
  62580. * @param impostor imposter to get the mass from
  62581. * @returns mass
  62582. */
  62583. getBodyMass(impostor: PhysicsImpostor): number;
  62584. /**
  62585. * Gets friction of the impostor
  62586. * @param impostor impostor to get friction from
  62587. * @returns friction value
  62588. */
  62589. getBodyFriction(impostor: PhysicsImpostor): number;
  62590. /**
  62591. * Sets friction of the impostor
  62592. * @param impostor impostor to set friction on
  62593. * @param friction friction value
  62594. */
  62595. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62596. /**
  62597. * Gets restitution of the impostor
  62598. * @param impostor impostor to get restitution from
  62599. * @returns restitution value
  62600. */
  62601. getBodyRestitution(impostor: PhysicsImpostor): number;
  62602. /**
  62603. * Sets resitution of the impostor
  62604. * @param impostor impostor to set resitution on
  62605. * @param restitution resitution value
  62606. */
  62607. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62608. /**
  62609. * Gets pressure inside the impostor
  62610. * @param impostor impostor to get pressure from
  62611. * @returns pressure value
  62612. */
  62613. getBodyPressure(impostor: PhysicsImpostor): number;
  62614. /**
  62615. * Sets pressure inside a soft body impostor
  62616. * Cloth and rope must remain 0 pressure
  62617. * @param impostor impostor to set pressure on
  62618. * @param pressure pressure value
  62619. */
  62620. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62621. /**
  62622. * Gets stiffness of the impostor
  62623. * @param impostor impostor to get stiffness from
  62624. * @returns pressure value
  62625. */
  62626. getBodyStiffness(impostor: PhysicsImpostor): number;
  62627. /**
  62628. * Sets stiffness of the impostor
  62629. * @param impostor impostor to set stiffness on
  62630. * @param stiffness stiffness value from 0 to 1
  62631. */
  62632. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62633. /**
  62634. * Gets velocityIterations of the impostor
  62635. * @param impostor impostor to get velocity iterations from
  62636. * @returns velocityIterations value
  62637. */
  62638. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62639. /**
  62640. * Sets velocityIterations of the impostor
  62641. * @param impostor impostor to set velocity iterations on
  62642. * @param velocityIterations velocityIterations value
  62643. */
  62644. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62645. /**
  62646. * Gets positionIterations of the impostor
  62647. * @param impostor impostor to get position iterations from
  62648. * @returns positionIterations value
  62649. */
  62650. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62651. /**
  62652. * Sets positionIterations of the impostor
  62653. * @param impostor impostor to set position on
  62654. * @param positionIterations positionIterations value
  62655. */
  62656. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62657. /**
  62658. * Append an anchor to a cloth object
  62659. * @param impostor is the cloth impostor to add anchor to
  62660. * @param otherImpostor is the rigid impostor to anchor to
  62661. * @param width ratio across width from 0 to 1
  62662. * @param height ratio up height from 0 to 1
  62663. * @param influence the elasticity between cloth 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. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62667. /**
  62668. * Append an hook to a rope object
  62669. * @param impostor is the rope impostor to add hook to
  62670. * @param otherImpostor is the rigid impostor to hook to
  62671. * @param length ratio along the rope from 0 to 1
  62672. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62673. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62674. */
  62675. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62676. /**
  62677. * Sleeps the physics body and stops it from being active
  62678. * @param impostor impostor to sleep
  62679. */
  62680. sleepBody(impostor: PhysicsImpostor): void;
  62681. /**
  62682. * Activates the physics body
  62683. * @param impostor impostor to activate
  62684. */
  62685. wakeUpBody(impostor: PhysicsImpostor): void;
  62686. /**
  62687. * Updates the distance parameters of the joint
  62688. * @param joint joint to update
  62689. * @param maxDistance maximum distance of the joint
  62690. * @param minDistance minimum distance of the joint
  62691. */
  62692. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62693. /**
  62694. * Sets a motor on the joint
  62695. * @param joint joint to set motor on
  62696. * @param speed speed of the motor
  62697. * @param maxForce maximum force of the motor
  62698. * @param motorIndex index of the motor
  62699. */
  62700. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62701. /**
  62702. * Sets the motors limit
  62703. * @param joint joint to set limit on
  62704. * @param upperLimit upper limit
  62705. * @param lowerLimit lower limit
  62706. */
  62707. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62708. /**
  62709. * Syncs the position and rotation of a mesh with the impostor
  62710. * @param mesh mesh to sync
  62711. * @param impostor impostor to update the mesh with
  62712. */
  62713. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62714. /**
  62715. * Gets the radius of the impostor
  62716. * @param impostor impostor to get radius from
  62717. * @returns the radius
  62718. */
  62719. getRadius(impostor: PhysicsImpostor): number;
  62720. /**
  62721. * Gets the box size of the impostor
  62722. * @param impostor impostor to get box size from
  62723. * @param result the resulting box size
  62724. */
  62725. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62726. /**
  62727. * Disposes of the impostor
  62728. */
  62729. dispose(): void;
  62730. /**
  62731. * Does a raycast in the physics world
  62732. * @param from when should the ray start?
  62733. * @param to when should the ray end?
  62734. * @returns PhysicsRaycastResult
  62735. */
  62736. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62737. }
  62738. }
  62739. declare module BABYLON {
  62740. interface AbstractScene {
  62741. /**
  62742. * The list of reflection probes added to the scene
  62743. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62744. */
  62745. reflectionProbes: Array<ReflectionProbe>;
  62746. /**
  62747. * Removes the given reflection probe from this scene.
  62748. * @param toRemove The reflection probe to remove
  62749. * @returns The index of the removed reflection probe
  62750. */
  62751. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62752. /**
  62753. * Adds the given reflection probe to this scene.
  62754. * @param newReflectionProbe The reflection probe to add
  62755. */
  62756. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62757. }
  62758. /**
  62759. * Class used to generate realtime reflection / refraction cube textures
  62760. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62761. */
  62762. export class ReflectionProbe {
  62763. /** defines the name of the probe */
  62764. name: string;
  62765. private _scene;
  62766. private _renderTargetTexture;
  62767. private _projectionMatrix;
  62768. private _viewMatrix;
  62769. private _target;
  62770. private _add;
  62771. private _attachedMesh;
  62772. private _invertYAxis;
  62773. /** Gets or sets probe position (center of the cube map) */
  62774. position: Vector3;
  62775. /**
  62776. * Creates a new reflection probe
  62777. * @param name defines the name of the probe
  62778. * @param size defines the texture resolution (for each face)
  62779. * @param scene defines the hosting scene
  62780. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62781. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62782. */
  62783. constructor(
  62784. /** defines the name of the probe */
  62785. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62786. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62787. get samples(): number;
  62788. set samples(value: number);
  62789. /** Gets or sets the refresh rate to use (on every frame by default) */
  62790. get refreshRate(): number;
  62791. set refreshRate(value: number);
  62792. /**
  62793. * Gets the hosting scene
  62794. * @returns a Scene
  62795. */
  62796. getScene(): Scene;
  62797. /** Gets the internal CubeTexture used to render to */
  62798. get cubeTexture(): RenderTargetTexture;
  62799. /** Gets the list of meshes to render */
  62800. get renderList(): Nullable<AbstractMesh[]>;
  62801. /**
  62802. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62803. * @param mesh defines the mesh to attach to
  62804. */
  62805. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62806. /**
  62807. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62808. * @param renderingGroupId The rendering group id corresponding to its index
  62809. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62810. */
  62811. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62812. /**
  62813. * Clean all associated resources
  62814. */
  62815. dispose(): void;
  62816. /**
  62817. * Converts the reflection probe information to a readable string for debug purpose.
  62818. * @param fullDetails Supports for multiple levels of logging within scene loading
  62819. * @returns the human readable reflection probe info
  62820. */
  62821. toString(fullDetails?: boolean): string;
  62822. /**
  62823. * Get the class name of the relfection probe.
  62824. * @returns "ReflectionProbe"
  62825. */
  62826. getClassName(): string;
  62827. /**
  62828. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62829. * @returns The JSON representation of the texture
  62830. */
  62831. serialize(): any;
  62832. /**
  62833. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62834. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62835. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62836. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62837. * @returns The parsed reflection probe if successful
  62838. */
  62839. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  62840. }
  62841. }
  62842. declare module BABYLON {
  62843. /** @hidden */
  62844. export var _BabylonLoaderRegistered: boolean;
  62845. /**
  62846. * Helps setting up some configuration for the babylon file loader.
  62847. */
  62848. export class BabylonFileLoaderConfiguration {
  62849. /**
  62850. * The loader does not allow injecting custom physix engine into the plugins.
  62851. * Unfortunately in ES6, we need to manually inject them into the plugin.
  62852. * So you could set this variable to your engine import to make it work.
  62853. */
  62854. static LoaderInjectedPhysicsEngine: any;
  62855. }
  62856. }
  62857. declare module BABYLON {
  62858. /**
  62859. * A material to use for fast depth-only rendering.
  62860. */
  62861. export class OcclusionMaterial extends ShaderMaterial {
  62862. constructor(name: string, scene: Scene);
  62863. }
  62864. }
  62865. declare module BABYLON {
  62866. /**
  62867. * The Physically based simple base material of BJS.
  62868. *
  62869. * This enables better naming and convention enforcements on top of the pbrMaterial.
  62870. * It is used as the base class for both the specGloss and metalRough conventions.
  62871. */
  62872. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  62873. /**
  62874. * Number of Simultaneous lights allowed on the material.
  62875. */
  62876. maxSimultaneousLights: number;
  62877. /**
  62878. * If sets to true, disables all the lights affecting the material.
  62879. */
  62880. disableLighting: boolean;
  62881. /**
  62882. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  62883. */
  62884. environmentTexture: BaseTexture;
  62885. /**
  62886. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  62887. */
  62888. invertNormalMapX: boolean;
  62889. /**
  62890. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  62891. */
  62892. invertNormalMapY: boolean;
  62893. /**
  62894. * Normal map used in the model.
  62895. */
  62896. normalTexture: BaseTexture;
  62897. /**
  62898. * Emissivie color used to self-illuminate the model.
  62899. */
  62900. emissiveColor: Color3;
  62901. /**
  62902. * Emissivie texture used to self-illuminate the model.
  62903. */
  62904. emissiveTexture: BaseTexture;
  62905. /**
  62906. * Occlusion Channel Strenght.
  62907. */
  62908. occlusionStrength: number;
  62909. /**
  62910. * Occlusion Texture of the material (adding extra occlusion effects).
  62911. */
  62912. occlusionTexture: BaseTexture;
  62913. /**
  62914. * Defines the alpha limits in alpha test mode.
  62915. */
  62916. alphaCutOff: number;
  62917. /**
  62918. * Gets the current double sided mode.
  62919. */
  62920. get doubleSided(): boolean;
  62921. /**
  62922. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  62923. */
  62924. set doubleSided(value: boolean);
  62925. /**
  62926. * Stores the pre-calculated light information of a mesh in a texture.
  62927. */
  62928. lightmapTexture: BaseTexture;
  62929. /**
  62930. * If true, the light map contains occlusion information instead of lighting info.
  62931. */
  62932. useLightmapAsShadowmap: boolean;
  62933. /**
  62934. * Instantiates a new PBRMaterial instance.
  62935. *
  62936. * @param name The material name
  62937. * @param scene The scene the material will be use in.
  62938. */
  62939. constructor(name: string, scene: Scene);
  62940. getClassName(): string;
  62941. }
  62942. }
  62943. declare module BABYLON {
  62944. /**
  62945. * The PBR material of BJS following the metal roughness convention.
  62946. *
  62947. * This fits to the PBR convention in the GLTF definition:
  62948. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  62949. */
  62950. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  62951. /**
  62952. * The base color has two different interpretations depending on the value of metalness.
  62953. * When the material is a metal, the base color is the specific measured reflectance value
  62954. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  62955. * of the material.
  62956. */
  62957. baseColor: Color3;
  62958. /**
  62959. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  62960. * well as opacity information in the alpha channel.
  62961. */
  62962. baseTexture: BaseTexture;
  62963. /**
  62964. * Specifies the metallic scalar value of the material.
  62965. * Can also be used to scale the metalness values of the metallic texture.
  62966. */
  62967. metallic: number;
  62968. /**
  62969. * Specifies the roughness scalar value of the material.
  62970. * Can also be used to scale the roughness values of the metallic texture.
  62971. */
  62972. roughness: number;
  62973. /**
  62974. * Texture containing both the metallic value in the B channel and the
  62975. * roughness value in the G channel to keep better precision.
  62976. */
  62977. metallicRoughnessTexture: BaseTexture;
  62978. /**
  62979. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62980. *
  62981. * @param name The material name
  62982. * @param scene The scene the material will be use in.
  62983. */
  62984. constructor(name: string, scene: Scene);
  62985. /**
  62986. * Return the currrent class name of the material.
  62987. */
  62988. getClassName(): string;
  62989. /**
  62990. * Makes a duplicate of the current material.
  62991. * @param name - name to use for the new material.
  62992. */
  62993. clone(name: string): PBRMetallicRoughnessMaterial;
  62994. /**
  62995. * Serialize the material to a parsable JSON object.
  62996. */
  62997. serialize(): any;
  62998. /**
  62999. * Parses a JSON object correponding to the serialize function.
  63000. */
  63001. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63002. }
  63003. }
  63004. declare module BABYLON {
  63005. /**
  63006. * The PBR material of BJS following the specular glossiness convention.
  63007. *
  63008. * This fits to the PBR convention in the GLTF definition:
  63009. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63010. */
  63011. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63012. /**
  63013. * Specifies the diffuse color of the material.
  63014. */
  63015. diffuseColor: Color3;
  63016. /**
  63017. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63018. * channel.
  63019. */
  63020. diffuseTexture: BaseTexture;
  63021. /**
  63022. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63023. */
  63024. specularColor: Color3;
  63025. /**
  63026. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63027. */
  63028. glossiness: number;
  63029. /**
  63030. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63031. */
  63032. specularGlossinessTexture: BaseTexture;
  63033. /**
  63034. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63035. *
  63036. * @param name The material name
  63037. * @param scene The scene the material will be use in.
  63038. */
  63039. constructor(name: string, scene: Scene);
  63040. /**
  63041. * Return the currrent class name of the material.
  63042. */
  63043. getClassName(): string;
  63044. /**
  63045. * Makes a duplicate of the current material.
  63046. * @param name - name to use for the new material.
  63047. */
  63048. clone(name: string): PBRSpecularGlossinessMaterial;
  63049. /**
  63050. * Serialize the material to a parsable JSON object.
  63051. */
  63052. serialize(): any;
  63053. /**
  63054. * Parses a JSON object correponding to the serialize function.
  63055. */
  63056. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63057. }
  63058. }
  63059. declare module BABYLON {
  63060. /**
  63061. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63062. * It can help converting any input color in a desired output one. This can then be used to create effects
  63063. * from sepia, black and white to sixties or futuristic rendering...
  63064. *
  63065. * The only supported format is currently 3dl.
  63066. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63067. */
  63068. export class ColorGradingTexture extends BaseTexture {
  63069. /**
  63070. * The texture URL.
  63071. */
  63072. url: string;
  63073. /**
  63074. * Empty line regex stored for GC.
  63075. */
  63076. private static _noneEmptyLineRegex;
  63077. private _textureMatrix;
  63078. private _onLoad;
  63079. /**
  63080. * Instantiates a ColorGradingTexture from the following parameters.
  63081. *
  63082. * @param url The location of the color gradind data (currently only supporting 3dl)
  63083. * @param sceneOrEngine The scene or engine the texture will be used in
  63084. * @param onLoad defines a callback triggered when the texture has been loaded
  63085. */
  63086. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63087. /**
  63088. * Fires the onload event from the constructor if requested.
  63089. */
  63090. private _triggerOnLoad;
  63091. /**
  63092. * Returns the texture matrix used in most of the material.
  63093. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63094. */
  63095. getTextureMatrix(): Matrix;
  63096. /**
  63097. * Occurs when the file being loaded is a .3dl LUT file.
  63098. */
  63099. private load3dlTexture;
  63100. /**
  63101. * Starts the loading process of the texture.
  63102. */
  63103. private loadTexture;
  63104. /**
  63105. * Clones the color gradind texture.
  63106. */
  63107. clone(): ColorGradingTexture;
  63108. /**
  63109. * Called during delayed load for textures.
  63110. */
  63111. delayLoad(): void;
  63112. /**
  63113. * Parses a color grading texture serialized by Babylon.
  63114. * @param parsedTexture The texture information being parsedTexture
  63115. * @param scene The scene to load the texture in
  63116. * @param rootUrl The root url of the data assets to load
  63117. * @return A color gradind texture
  63118. */
  63119. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63120. /**
  63121. * Serializes the LUT texture to json format.
  63122. */
  63123. serialize(): any;
  63124. }
  63125. }
  63126. declare module BABYLON {
  63127. /**
  63128. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63129. */
  63130. export class EquiRectangularCubeTexture extends BaseTexture {
  63131. /** The six faces of the cube. */
  63132. private static _FacesMapping;
  63133. private _noMipmap;
  63134. private _onLoad;
  63135. private _onError;
  63136. /** The size of the cubemap. */
  63137. private _size;
  63138. /** The buffer of the image. */
  63139. private _buffer;
  63140. /** The width of the input image. */
  63141. private _width;
  63142. /** The height of the input image. */
  63143. private _height;
  63144. /** The URL to the image. */
  63145. url: string;
  63146. /**
  63147. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63148. * @param url The location of the image
  63149. * @param scene The scene the texture will be used in
  63150. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63151. * @param noMipmap Forces to not generate the mipmap if true
  63152. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63153. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63154. * @param onLoad — defines a callback called when texture is loaded
  63155. * @param onError — defines a callback called if there is an error
  63156. */
  63157. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63158. /**
  63159. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63160. */
  63161. private loadImage;
  63162. /**
  63163. * Convert the image buffer into a cubemap and create a CubeTexture.
  63164. */
  63165. private loadTexture;
  63166. /**
  63167. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63168. * @param buffer The ArrayBuffer that should be converted.
  63169. * @returns The buffer as Float32Array.
  63170. */
  63171. private getFloat32ArrayFromArrayBuffer;
  63172. /**
  63173. * Get the current class name of the texture useful for serialization or dynamic coding.
  63174. * @returns "EquiRectangularCubeTexture"
  63175. */
  63176. getClassName(): string;
  63177. /**
  63178. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63179. * @returns A clone of the current EquiRectangularCubeTexture.
  63180. */
  63181. clone(): EquiRectangularCubeTexture;
  63182. }
  63183. }
  63184. declare module BABYLON {
  63185. /**
  63186. * Defines the options related to the creation of an HtmlElementTexture
  63187. */
  63188. export interface IHtmlElementTextureOptions {
  63189. /**
  63190. * Defines wether mip maps should be created or not.
  63191. */
  63192. generateMipMaps?: boolean;
  63193. /**
  63194. * Defines the sampling mode of the texture.
  63195. */
  63196. samplingMode?: number;
  63197. /**
  63198. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63199. */
  63200. engine: Nullable<ThinEngine>;
  63201. /**
  63202. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63203. */
  63204. scene: Nullable<Scene>;
  63205. }
  63206. /**
  63207. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63208. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63209. * is automatically managed.
  63210. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63211. * in your application.
  63212. *
  63213. * As the update is not automatic, you need to call them manually.
  63214. */
  63215. export class HtmlElementTexture extends BaseTexture {
  63216. /**
  63217. * The texture URL.
  63218. */
  63219. element: HTMLVideoElement | HTMLCanvasElement;
  63220. private static readonly DefaultOptions;
  63221. private _textureMatrix;
  63222. private _isVideo;
  63223. private _generateMipMaps;
  63224. private _samplingMode;
  63225. /**
  63226. * Instantiates a HtmlElementTexture from the following parameters.
  63227. *
  63228. * @param name Defines the name of the texture
  63229. * @param element Defines the video or canvas the texture is filled with
  63230. * @param options Defines the other none mandatory texture creation options
  63231. */
  63232. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63233. private _createInternalTexture;
  63234. /**
  63235. * Returns the texture matrix used in most of the material.
  63236. */
  63237. getTextureMatrix(): Matrix;
  63238. /**
  63239. * Updates the content of the texture.
  63240. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63241. */
  63242. update(invertY?: Nullable<boolean>): void;
  63243. }
  63244. }
  63245. declare module BABYLON {
  63246. /**
  63247. * Based on jsTGALoader - Javascript loader for TGA file
  63248. * By Vincent Thibault
  63249. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63250. */
  63251. export class TGATools {
  63252. private static _TYPE_INDEXED;
  63253. private static _TYPE_RGB;
  63254. private static _TYPE_GREY;
  63255. private static _TYPE_RLE_INDEXED;
  63256. private static _TYPE_RLE_RGB;
  63257. private static _TYPE_RLE_GREY;
  63258. private static _ORIGIN_MASK;
  63259. private static _ORIGIN_SHIFT;
  63260. private static _ORIGIN_BL;
  63261. private static _ORIGIN_BR;
  63262. private static _ORIGIN_UL;
  63263. private static _ORIGIN_UR;
  63264. /**
  63265. * Gets the header of a TGA file
  63266. * @param data defines the TGA data
  63267. * @returns the header
  63268. */
  63269. static GetTGAHeader(data: Uint8Array): any;
  63270. /**
  63271. * Uploads TGA content to a Babylon Texture
  63272. * @hidden
  63273. */
  63274. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63275. /** @hidden */
  63276. 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;
  63277. /** @hidden */
  63278. 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;
  63279. /** @hidden */
  63280. 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;
  63281. /** @hidden */
  63282. 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;
  63283. /** @hidden */
  63284. 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;
  63285. /** @hidden */
  63286. 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;
  63287. }
  63288. }
  63289. declare module BABYLON {
  63290. /**
  63291. * Implementation of the TGA Texture Loader.
  63292. * @hidden
  63293. */
  63294. export class _TGATextureLoader implements IInternalTextureLoader {
  63295. /**
  63296. * Defines wether the loader supports cascade loading the different faces.
  63297. */
  63298. readonly supportCascades: boolean;
  63299. /**
  63300. * This returns if the loader support the current file information.
  63301. * @param extension defines the file extension of the file being loaded
  63302. * @returns true if the loader can load the specified file
  63303. */
  63304. canLoad(extension: string): boolean;
  63305. /**
  63306. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63307. * @param data contains the texture data
  63308. * @param texture defines the BabylonJS internal texture
  63309. * @param createPolynomials will be true if polynomials have been requested
  63310. * @param onLoad defines the callback to trigger once the texture is ready
  63311. * @param onError defines the callback to trigger in case of error
  63312. */
  63313. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63314. /**
  63315. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63316. * @param data contains the texture data
  63317. * @param texture defines the BabylonJS internal texture
  63318. * @param callback defines the method to call once ready to upload
  63319. */
  63320. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63321. }
  63322. }
  63323. declare module BABYLON {
  63324. /**
  63325. * Info about the .basis files
  63326. */
  63327. class BasisFileInfo {
  63328. /**
  63329. * If the file has alpha
  63330. */
  63331. hasAlpha: boolean;
  63332. /**
  63333. * Info about each image of the basis file
  63334. */
  63335. images: Array<{
  63336. levels: Array<{
  63337. width: number;
  63338. height: number;
  63339. transcodedPixels: ArrayBufferView;
  63340. }>;
  63341. }>;
  63342. }
  63343. /**
  63344. * Result of transcoding a basis file
  63345. */
  63346. class TranscodeResult {
  63347. /**
  63348. * Info about the .basis file
  63349. */
  63350. fileInfo: BasisFileInfo;
  63351. /**
  63352. * Format to use when loading the file
  63353. */
  63354. format: number;
  63355. }
  63356. /**
  63357. * Configuration options for the Basis transcoder
  63358. */
  63359. export class BasisTranscodeConfiguration {
  63360. /**
  63361. * Supported compression formats used to determine the supported output format of the transcoder
  63362. */
  63363. supportedCompressionFormats?: {
  63364. /**
  63365. * etc1 compression format
  63366. */
  63367. etc1?: boolean;
  63368. /**
  63369. * s3tc compression format
  63370. */
  63371. s3tc?: boolean;
  63372. /**
  63373. * pvrtc compression format
  63374. */
  63375. pvrtc?: boolean;
  63376. /**
  63377. * etc2 compression format
  63378. */
  63379. etc2?: boolean;
  63380. };
  63381. /**
  63382. * If mipmap levels should be loaded for transcoded images (Default: true)
  63383. */
  63384. loadMipmapLevels?: boolean;
  63385. /**
  63386. * Index of a single image to load (Default: all images)
  63387. */
  63388. loadSingleImage?: number;
  63389. }
  63390. /**
  63391. * Used to load .Basis files
  63392. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63393. */
  63394. export class BasisTools {
  63395. private static _IgnoreSupportedFormats;
  63396. /**
  63397. * URL to use when loading the basis transcoder
  63398. */
  63399. static JSModuleURL: string;
  63400. /**
  63401. * URL to use when loading the wasm module for the transcoder
  63402. */
  63403. static WasmModuleURL: string;
  63404. /**
  63405. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63406. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63407. * @returns internal format corresponding to the Basis format
  63408. */
  63409. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63410. private static _WorkerPromise;
  63411. private static _Worker;
  63412. private static _actionId;
  63413. private static _CreateWorkerAsync;
  63414. /**
  63415. * Transcodes a loaded image file to compressed pixel data
  63416. * @param data image data to transcode
  63417. * @param config configuration options for the transcoding
  63418. * @returns a promise resulting in the transcoded image
  63419. */
  63420. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63421. /**
  63422. * Loads a texture from the transcode result
  63423. * @param texture texture load to
  63424. * @param transcodeResult the result of transcoding the basis file to load from
  63425. */
  63426. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63427. }
  63428. }
  63429. declare module BABYLON {
  63430. /**
  63431. * Loader for .basis file format
  63432. */
  63433. export class _BasisTextureLoader implements IInternalTextureLoader {
  63434. /**
  63435. * Defines whether the loader supports cascade loading the different faces.
  63436. */
  63437. readonly supportCascades: boolean;
  63438. /**
  63439. * This returns if the loader support the current file information.
  63440. * @param extension defines the file extension of the file being loaded
  63441. * @returns true if the loader can load the specified file
  63442. */
  63443. canLoad(extension: string): boolean;
  63444. /**
  63445. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63446. * @param data contains the texture data
  63447. * @param texture defines the BabylonJS internal texture
  63448. * @param createPolynomials will be true if polynomials have been requested
  63449. * @param onLoad defines the callback to trigger once the texture is ready
  63450. * @param onError defines the callback to trigger in case of error
  63451. */
  63452. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63453. /**
  63454. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63455. * @param data contains the texture data
  63456. * @param texture defines the BabylonJS internal texture
  63457. * @param callback defines the method to call once ready to upload
  63458. */
  63459. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63460. }
  63461. }
  63462. declare module BABYLON {
  63463. /**
  63464. * Defines the basic options interface of a TexturePacker Frame
  63465. */
  63466. export interface ITexturePackerFrame {
  63467. /**
  63468. * The frame ID
  63469. */
  63470. id: number;
  63471. /**
  63472. * The frames Scale
  63473. */
  63474. scale: Vector2;
  63475. /**
  63476. * The Frames offset
  63477. */
  63478. offset: Vector2;
  63479. }
  63480. /**
  63481. * This is a support class for frame Data on texture packer sets.
  63482. */
  63483. export class TexturePackerFrame implements ITexturePackerFrame {
  63484. /**
  63485. * The frame ID
  63486. */
  63487. id: number;
  63488. /**
  63489. * The frames Scale
  63490. */
  63491. scale: Vector2;
  63492. /**
  63493. * The Frames offset
  63494. */
  63495. offset: Vector2;
  63496. /**
  63497. * Initializes a texture package frame.
  63498. * @param id The numerical frame identifier
  63499. * @param scale Scalar Vector2 for UV frame
  63500. * @param offset Vector2 for the frame position in UV units.
  63501. * @returns TexturePackerFrame
  63502. */
  63503. constructor(id: number, scale: Vector2, offset: Vector2);
  63504. }
  63505. }
  63506. declare module BABYLON {
  63507. /**
  63508. * Defines the basic options interface of a TexturePacker
  63509. */
  63510. export interface ITexturePackerOptions {
  63511. /**
  63512. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63513. */
  63514. map?: string[];
  63515. /**
  63516. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63517. */
  63518. uvsIn?: string;
  63519. /**
  63520. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63521. */
  63522. uvsOut?: string;
  63523. /**
  63524. * number representing the layout style. Defaults to LAYOUT_STRIP
  63525. */
  63526. layout?: number;
  63527. /**
  63528. * number of columns if using custom column count layout(2). This defaults to 4.
  63529. */
  63530. colnum?: number;
  63531. /**
  63532. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63533. */
  63534. updateInputMeshes?: boolean;
  63535. /**
  63536. * boolean flag to dispose all the source textures. Defaults to true.
  63537. */
  63538. disposeSources?: boolean;
  63539. /**
  63540. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63541. */
  63542. fillBlanks?: boolean;
  63543. /**
  63544. * string value representing the context fill style color. Defaults to 'black'.
  63545. */
  63546. customFillColor?: string;
  63547. /**
  63548. * Width and Height Value of each Frame in the TexturePacker Sets
  63549. */
  63550. frameSize?: number;
  63551. /**
  63552. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63553. */
  63554. paddingRatio?: number;
  63555. /**
  63556. * Number that declares the fill method for the padding gutter.
  63557. */
  63558. paddingMode?: number;
  63559. /**
  63560. * If in SUBUV_COLOR padding mode what color to use.
  63561. */
  63562. paddingColor?: Color3 | Color4;
  63563. }
  63564. /**
  63565. * Defines the basic interface of a TexturePacker JSON File
  63566. */
  63567. export interface ITexturePackerJSON {
  63568. /**
  63569. * The frame ID
  63570. */
  63571. name: string;
  63572. /**
  63573. * The base64 channel data
  63574. */
  63575. sets: any;
  63576. /**
  63577. * The options of the Packer
  63578. */
  63579. options: ITexturePackerOptions;
  63580. /**
  63581. * The frame data of the Packer
  63582. */
  63583. frames: Array<number>;
  63584. }
  63585. /**
  63586. * This is a support class that generates a series of packed texture sets.
  63587. * @see https://doc.babylonjs.com/babylon101/materials
  63588. */
  63589. export class TexturePacker {
  63590. /** Packer Layout Constant 0 */
  63591. static readonly LAYOUT_STRIP: number;
  63592. /** Packer Layout Constant 1 */
  63593. static readonly LAYOUT_POWER2: number;
  63594. /** Packer Layout Constant 2 */
  63595. static readonly LAYOUT_COLNUM: number;
  63596. /** Packer Layout Constant 0 */
  63597. static readonly SUBUV_WRAP: number;
  63598. /** Packer Layout Constant 1 */
  63599. static readonly SUBUV_EXTEND: number;
  63600. /** Packer Layout Constant 2 */
  63601. static readonly SUBUV_COLOR: number;
  63602. /** The Name of the Texture Package */
  63603. name: string;
  63604. /** The scene scope of the TexturePacker */
  63605. scene: Scene;
  63606. /** The Meshes to target */
  63607. meshes: AbstractMesh[];
  63608. /** Arguments passed with the Constructor */
  63609. options: ITexturePackerOptions;
  63610. /** The promise that is started upon initialization */
  63611. promise: Nullable<Promise<TexturePacker | string>>;
  63612. /** The Container object for the channel sets that are generated */
  63613. sets: object;
  63614. /** The Container array for the frames that are generated */
  63615. frames: TexturePackerFrame[];
  63616. /** The expected number of textures the system is parsing. */
  63617. private _expecting;
  63618. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63619. private _paddingValue;
  63620. /**
  63621. * Initializes a texture package series from an array of meshes or a single mesh.
  63622. * @param name The name of the package
  63623. * @param meshes The target meshes to compose the package from
  63624. * @param options The arguments that texture packer should follow while building.
  63625. * @param scene The scene which the textures are scoped to.
  63626. * @returns TexturePacker
  63627. */
  63628. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63629. /**
  63630. * Starts the package process
  63631. * @param resolve The promises resolution function
  63632. * @returns TexturePacker
  63633. */
  63634. private _createFrames;
  63635. /**
  63636. * Calculates the Size of the Channel Sets
  63637. * @returns Vector2
  63638. */
  63639. private _calculateSize;
  63640. /**
  63641. * Calculates the UV data for the frames.
  63642. * @param baseSize the base frameSize
  63643. * @param padding the base frame padding
  63644. * @param dtSize size of the Dynamic Texture for that channel
  63645. * @param dtUnits is 1/dtSize
  63646. * @param update flag to update the input meshes
  63647. */
  63648. private _calculateMeshUVFrames;
  63649. /**
  63650. * Calculates the frames Offset.
  63651. * @param index of the frame
  63652. * @returns Vector2
  63653. */
  63654. private _getFrameOffset;
  63655. /**
  63656. * Updates a Mesh to the frame data
  63657. * @param mesh that is the target
  63658. * @param frameID or the frame index
  63659. */
  63660. private _updateMeshUV;
  63661. /**
  63662. * Updates a Meshes materials to use the texture packer channels
  63663. * @param m is the mesh to target
  63664. * @param force all channels on the packer to be set.
  63665. */
  63666. private _updateTextureReferences;
  63667. /**
  63668. * Public method to set a Mesh to a frame
  63669. * @param m that is the target
  63670. * @param frameID or the frame index
  63671. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63672. */
  63673. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63674. /**
  63675. * Starts the async promise to compile the texture packer.
  63676. * @returns Promise<void>
  63677. */
  63678. processAsync(): Promise<void>;
  63679. /**
  63680. * Disposes all textures associated with this packer
  63681. */
  63682. dispose(): void;
  63683. /**
  63684. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63685. * @param imageType is the image type to use.
  63686. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63687. */
  63688. download(imageType?: string, quality?: number): void;
  63689. /**
  63690. * Public method to load a texturePacker JSON file.
  63691. * @param data of the JSON file in string format.
  63692. */
  63693. updateFromJSON(data: string): void;
  63694. }
  63695. }
  63696. declare module BABYLON {
  63697. /**
  63698. * 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.
  63699. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63700. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63701. */
  63702. export class CustomProceduralTexture extends ProceduralTexture {
  63703. private _animate;
  63704. private _time;
  63705. private _config;
  63706. private _texturePath;
  63707. /**
  63708. * Instantiates a new Custom Procedural Texture.
  63709. * 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.
  63710. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63711. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63712. * @param name Define the name of the texture
  63713. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63714. * @param size Define the size of the texture to create
  63715. * @param scene Define the scene the texture belongs to
  63716. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63717. * @param generateMipMaps Define if the texture should creates mip maps or not
  63718. */
  63719. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63720. private _loadJson;
  63721. /**
  63722. * Is the texture ready to be used ? (rendered at least once)
  63723. * @returns true if ready, otherwise, false.
  63724. */
  63725. isReady(): boolean;
  63726. /**
  63727. * Render the texture to its associated render target.
  63728. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63729. */
  63730. render(useCameraPostProcess?: boolean): void;
  63731. /**
  63732. * Update the list of dependant textures samplers in the shader.
  63733. */
  63734. updateTextures(): void;
  63735. /**
  63736. * Update the uniform values of the procedural texture in the shader.
  63737. */
  63738. updateShaderUniforms(): void;
  63739. /**
  63740. * Define if the texture animates or not.
  63741. */
  63742. get animate(): boolean;
  63743. set animate(value: boolean);
  63744. }
  63745. }
  63746. declare module BABYLON {
  63747. /** @hidden */
  63748. export var noisePixelShader: {
  63749. name: string;
  63750. shader: string;
  63751. };
  63752. }
  63753. declare module BABYLON {
  63754. /**
  63755. * Class used to generate noise procedural textures
  63756. */
  63757. export class NoiseProceduralTexture extends ProceduralTexture {
  63758. /** Gets or sets the start time (default is 0) */
  63759. time: number;
  63760. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63761. brightness: number;
  63762. /** Defines the number of octaves to process */
  63763. octaves: number;
  63764. /** Defines the level of persistence (0.8 by default) */
  63765. persistence: number;
  63766. /** Gets or sets animation speed factor (default is 1) */
  63767. animationSpeedFactor: number;
  63768. /**
  63769. * Creates a new NoiseProceduralTexture
  63770. * @param name defines the name fo the texture
  63771. * @param size defines the size of the texture (default is 256)
  63772. * @param scene defines the hosting scene
  63773. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  63774. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  63775. */
  63776. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63777. private _updateShaderUniforms;
  63778. protected _getDefines(): string;
  63779. /** Generate the current state of the procedural texture */
  63780. render(useCameraPostProcess?: boolean): void;
  63781. /**
  63782. * Serializes this noise procedural texture
  63783. * @returns a serialized noise procedural texture object
  63784. */
  63785. serialize(): any;
  63786. /**
  63787. * Clone the texture.
  63788. * @returns the cloned texture
  63789. */
  63790. clone(): NoiseProceduralTexture;
  63791. /**
  63792. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  63793. * @param parsedTexture defines parsed texture data
  63794. * @param scene defines the current scene
  63795. * @param rootUrl defines the root URL containing noise procedural texture information
  63796. * @returns a parsed NoiseProceduralTexture
  63797. */
  63798. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  63799. }
  63800. }
  63801. declare module BABYLON {
  63802. /**
  63803. * Raw cube texture where the raw buffers are passed in
  63804. */
  63805. export class RawCubeTexture extends CubeTexture {
  63806. /**
  63807. * Creates a cube texture where the raw buffers are passed in.
  63808. * @param scene defines the scene the texture is attached to
  63809. * @param data defines the array of data to use to create each face
  63810. * @param size defines the size of the textures
  63811. * @param format defines the format of the data
  63812. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  63813. * @param generateMipMaps defines if the engine should generate the mip levels
  63814. * @param invertY defines if data must be stored with Y axis inverted
  63815. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  63816. * @param compression defines the compression used (null by default)
  63817. */
  63818. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  63819. /**
  63820. * Updates the raw cube texture.
  63821. * @param data defines the data to store
  63822. * @param format defines the data format
  63823. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  63824. * @param invertY defines if data must be stored with Y axis inverted
  63825. * @param compression defines the compression used (null by default)
  63826. * @param level defines which level of the texture to update
  63827. */
  63828. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  63829. /**
  63830. * Updates a raw cube texture with RGBD encoded data.
  63831. * @param data defines the array of data [mipmap][face] to use to create each face
  63832. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  63833. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  63834. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  63835. * @returns a promsie that resolves when the operation is complete
  63836. */
  63837. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  63838. /**
  63839. * Clones the raw cube texture.
  63840. * @return a new cube texture
  63841. */
  63842. clone(): CubeTexture;
  63843. /** @hidden */
  63844. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  63845. }
  63846. }
  63847. declare module BABYLON {
  63848. /**
  63849. * Class used to store 2D array textures containing user data
  63850. */
  63851. export class RawTexture2DArray extends Texture {
  63852. /** Gets or sets the texture format to use */
  63853. format: number;
  63854. /**
  63855. * Create a new RawTexture2DArray
  63856. * @param data defines the data of the texture
  63857. * @param width defines the width of the texture
  63858. * @param height defines the height of the texture
  63859. * @param depth defines the number of layers of the texture
  63860. * @param format defines the texture format to use
  63861. * @param scene defines the hosting scene
  63862. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63863. * @param invertY defines if texture must be stored with Y axis inverted
  63864. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63865. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63866. */
  63867. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63868. /** Gets or sets the texture format to use */
  63869. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63870. /**
  63871. * Update the texture with new data
  63872. * @param data defines the data to store in the texture
  63873. */
  63874. update(data: ArrayBufferView): void;
  63875. }
  63876. }
  63877. declare module BABYLON {
  63878. /**
  63879. * Class used to store 3D textures containing user data
  63880. */
  63881. export class RawTexture3D extends Texture {
  63882. /** Gets or sets the texture format to use */
  63883. format: number;
  63884. /**
  63885. * Create a new RawTexture3D
  63886. * @param data defines the data of the texture
  63887. * @param width defines the width of the texture
  63888. * @param height defines the height of the texture
  63889. * @param depth defines the depth of the texture
  63890. * @param format defines the texture format to use
  63891. * @param scene defines the hosting scene
  63892. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  63893. * @param invertY defines if texture must be stored with Y axis inverted
  63894. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  63895. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  63896. */
  63897. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  63898. /** Gets or sets the texture format to use */
  63899. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  63900. /**
  63901. * Update the texture with new data
  63902. * @param data defines the data to store in the texture
  63903. */
  63904. update(data: ArrayBufferView): void;
  63905. }
  63906. }
  63907. declare module BABYLON {
  63908. /**
  63909. * Creates a refraction texture used by refraction channel of the standard material.
  63910. * It is like a mirror but to see through a material.
  63911. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63912. */
  63913. export class RefractionTexture extends RenderTargetTexture {
  63914. /**
  63915. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  63916. * 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.
  63917. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63918. */
  63919. refractionPlane: Plane;
  63920. /**
  63921. * Define how deep under the surface we should see.
  63922. */
  63923. depth: number;
  63924. /**
  63925. * Creates a refraction texture used by refraction channel of the standard material.
  63926. * It is like a mirror but to see through a material.
  63927. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  63928. * @param name Define the texture name
  63929. * @param size Define the size of the underlying texture
  63930. * @param scene Define the scene the refraction belongs to
  63931. * @param generateMipMaps Define if we need to generate mips level for the refraction
  63932. */
  63933. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  63934. /**
  63935. * Clone the refraction texture.
  63936. * @returns the cloned texture
  63937. */
  63938. clone(): RefractionTexture;
  63939. /**
  63940. * Serialize the texture to a JSON representation you could use in Parse later on
  63941. * @returns the serialized JSON representation
  63942. */
  63943. serialize(): any;
  63944. }
  63945. }
  63946. declare module BABYLON {
  63947. /**
  63948. * Block used to add support for vertex skinning (bones)
  63949. */
  63950. export class BonesBlock extends NodeMaterialBlock {
  63951. /**
  63952. * Creates a new BonesBlock
  63953. * @param name defines the block name
  63954. */
  63955. constructor(name: string);
  63956. /**
  63957. * Initialize the block and prepare the context for build
  63958. * @param state defines the state that will be used for the build
  63959. */
  63960. initialize(state: NodeMaterialBuildState): void;
  63961. /**
  63962. * Gets the current class name
  63963. * @returns the class name
  63964. */
  63965. getClassName(): string;
  63966. /**
  63967. * Gets the matrix indices input component
  63968. */
  63969. get matricesIndices(): NodeMaterialConnectionPoint;
  63970. /**
  63971. * Gets the matrix weights input component
  63972. */
  63973. get matricesWeights(): NodeMaterialConnectionPoint;
  63974. /**
  63975. * Gets the extra matrix indices input component
  63976. */
  63977. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63978. /**
  63979. * Gets the extra matrix weights input component
  63980. */
  63981. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63982. /**
  63983. * Gets the world input component
  63984. */
  63985. get world(): NodeMaterialConnectionPoint;
  63986. /**
  63987. * Gets the output component
  63988. */
  63989. get output(): NodeMaterialConnectionPoint;
  63990. autoConfigure(material: NodeMaterial): void;
  63991. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63992. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63993. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63994. protected _buildBlock(state: NodeMaterialBuildState): this;
  63995. }
  63996. }
  63997. declare module BABYLON {
  63998. /**
  63999. * Block used to add support for instances
  64000. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64001. */
  64002. export class InstancesBlock extends NodeMaterialBlock {
  64003. /**
  64004. * Creates a new InstancesBlock
  64005. * @param name defines the block name
  64006. */
  64007. constructor(name: string);
  64008. /**
  64009. * Gets the current class name
  64010. * @returns the class name
  64011. */
  64012. getClassName(): string;
  64013. /**
  64014. * Gets the first world row input component
  64015. */
  64016. get world0(): NodeMaterialConnectionPoint;
  64017. /**
  64018. * Gets the second world row input component
  64019. */
  64020. get world1(): NodeMaterialConnectionPoint;
  64021. /**
  64022. * Gets the third world row input component
  64023. */
  64024. get world2(): NodeMaterialConnectionPoint;
  64025. /**
  64026. * Gets the forth world row input component
  64027. */
  64028. get world3(): NodeMaterialConnectionPoint;
  64029. /**
  64030. * Gets the world input component
  64031. */
  64032. get world(): NodeMaterialConnectionPoint;
  64033. /**
  64034. * Gets the output component
  64035. */
  64036. get output(): NodeMaterialConnectionPoint;
  64037. /**
  64038. * Gets the isntanceID component
  64039. */
  64040. get instanceID(): NodeMaterialConnectionPoint;
  64041. autoConfigure(material: NodeMaterial): void;
  64042. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64043. protected _buildBlock(state: NodeMaterialBuildState): this;
  64044. }
  64045. }
  64046. declare module BABYLON {
  64047. /**
  64048. * Block used to add morph targets support to vertex shader
  64049. */
  64050. export class MorphTargetsBlock extends NodeMaterialBlock {
  64051. private _repeatableContentAnchor;
  64052. /**
  64053. * Create a new MorphTargetsBlock
  64054. * @param name defines the block name
  64055. */
  64056. constructor(name: string);
  64057. /**
  64058. * Gets the current class name
  64059. * @returns the class name
  64060. */
  64061. getClassName(): string;
  64062. /**
  64063. * Gets the position input component
  64064. */
  64065. get position(): NodeMaterialConnectionPoint;
  64066. /**
  64067. * Gets the normal input component
  64068. */
  64069. get normal(): NodeMaterialConnectionPoint;
  64070. /**
  64071. * Gets the tangent input component
  64072. */
  64073. get tangent(): NodeMaterialConnectionPoint;
  64074. /**
  64075. * Gets the tangent input component
  64076. */
  64077. get uv(): NodeMaterialConnectionPoint;
  64078. /**
  64079. * Gets the position output component
  64080. */
  64081. get positionOutput(): NodeMaterialConnectionPoint;
  64082. /**
  64083. * Gets the normal output component
  64084. */
  64085. get normalOutput(): NodeMaterialConnectionPoint;
  64086. /**
  64087. * Gets the tangent output component
  64088. */
  64089. get tangentOutput(): NodeMaterialConnectionPoint;
  64090. /**
  64091. * Gets the tangent output component
  64092. */
  64093. get uvOutput(): NodeMaterialConnectionPoint;
  64094. initialize(state: NodeMaterialBuildState): void;
  64095. autoConfigure(material: NodeMaterial): void;
  64096. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64098. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64099. protected _buildBlock(state: NodeMaterialBuildState): this;
  64100. }
  64101. }
  64102. declare module BABYLON {
  64103. /**
  64104. * Block used to get data information from a light
  64105. */
  64106. export class LightInformationBlock extends NodeMaterialBlock {
  64107. private _lightDataUniformName;
  64108. private _lightColorUniformName;
  64109. private _lightTypeDefineName;
  64110. /**
  64111. * Gets or sets the light associated with this block
  64112. */
  64113. light: Nullable<Light>;
  64114. /**
  64115. * Creates a new LightInformationBlock
  64116. * @param name defines the block name
  64117. */
  64118. constructor(name: string);
  64119. /**
  64120. * Gets the current class name
  64121. * @returns the class name
  64122. */
  64123. getClassName(): string;
  64124. /**
  64125. * Gets the world position input component
  64126. */
  64127. get worldPosition(): NodeMaterialConnectionPoint;
  64128. /**
  64129. * Gets the direction output component
  64130. */
  64131. get direction(): NodeMaterialConnectionPoint;
  64132. /**
  64133. * Gets the direction output component
  64134. */
  64135. get color(): NodeMaterialConnectionPoint;
  64136. /**
  64137. * Gets the direction output component
  64138. */
  64139. get intensity(): NodeMaterialConnectionPoint;
  64140. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64141. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64142. protected _buildBlock(state: NodeMaterialBuildState): this;
  64143. serialize(): any;
  64144. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64145. }
  64146. }
  64147. declare module BABYLON {
  64148. /**
  64149. * Block used to add image processing support to fragment shader
  64150. */
  64151. export class ImageProcessingBlock extends NodeMaterialBlock {
  64152. /**
  64153. * Create a new ImageProcessingBlock
  64154. * @param name defines the block name
  64155. */
  64156. constructor(name: string);
  64157. /**
  64158. * Gets the current class name
  64159. * @returns the class name
  64160. */
  64161. getClassName(): string;
  64162. /**
  64163. * Gets the color input component
  64164. */
  64165. get color(): NodeMaterialConnectionPoint;
  64166. /**
  64167. * Gets the output component
  64168. */
  64169. get output(): NodeMaterialConnectionPoint;
  64170. /**
  64171. * Initialize the block and prepare the context for build
  64172. * @param state defines the state that will be used for the build
  64173. */
  64174. initialize(state: NodeMaterialBuildState): void;
  64175. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64178. protected _buildBlock(state: NodeMaterialBuildState): this;
  64179. }
  64180. }
  64181. declare module BABYLON {
  64182. /**
  64183. * Block used to pertub normals based on a normal map
  64184. */
  64185. export class PerturbNormalBlock extends NodeMaterialBlock {
  64186. private _tangentSpaceParameterName;
  64187. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64188. invertX: boolean;
  64189. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64190. invertY: boolean;
  64191. /**
  64192. * Create a new PerturbNormalBlock
  64193. * @param name defines the block name
  64194. */
  64195. constructor(name: string);
  64196. /**
  64197. * Gets the current class name
  64198. * @returns the class name
  64199. */
  64200. getClassName(): string;
  64201. /**
  64202. * Gets the world position input component
  64203. */
  64204. get worldPosition(): NodeMaterialConnectionPoint;
  64205. /**
  64206. * Gets the world normal input component
  64207. */
  64208. get worldNormal(): NodeMaterialConnectionPoint;
  64209. /**
  64210. * Gets the world tangent input component
  64211. */
  64212. get worldTangent(): NodeMaterialConnectionPoint;
  64213. /**
  64214. * Gets the uv input component
  64215. */
  64216. get uv(): NodeMaterialConnectionPoint;
  64217. /**
  64218. * Gets the normal map color input component
  64219. */
  64220. get normalMapColor(): NodeMaterialConnectionPoint;
  64221. /**
  64222. * Gets the strength input component
  64223. */
  64224. get strength(): NodeMaterialConnectionPoint;
  64225. /**
  64226. * Gets the output component
  64227. */
  64228. get output(): NodeMaterialConnectionPoint;
  64229. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64230. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64231. autoConfigure(material: NodeMaterial): void;
  64232. protected _buildBlock(state: NodeMaterialBuildState): this;
  64233. protected _dumpPropertiesCode(): string;
  64234. serialize(): any;
  64235. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64236. }
  64237. }
  64238. declare module BABYLON {
  64239. /**
  64240. * Block used to discard a pixel if a value is smaller than a cutoff
  64241. */
  64242. export class DiscardBlock extends NodeMaterialBlock {
  64243. /**
  64244. * Create a new DiscardBlock
  64245. * @param name defines the block name
  64246. */
  64247. constructor(name: string);
  64248. /**
  64249. * Gets the current class name
  64250. * @returns the class name
  64251. */
  64252. getClassName(): string;
  64253. /**
  64254. * Gets the color input component
  64255. */
  64256. get value(): NodeMaterialConnectionPoint;
  64257. /**
  64258. * Gets the cutoff input component
  64259. */
  64260. get cutoff(): NodeMaterialConnectionPoint;
  64261. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64262. }
  64263. }
  64264. declare module BABYLON {
  64265. /**
  64266. * Block used to test if the fragment shader is front facing
  64267. */
  64268. export class FrontFacingBlock extends NodeMaterialBlock {
  64269. /**
  64270. * Creates a new FrontFacingBlock
  64271. * @param name defines the block name
  64272. */
  64273. constructor(name: string);
  64274. /**
  64275. * Gets the current class name
  64276. * @returns the class name
  64277. */
  64278. getClassName(): string;
  64279. /**
  64280. * Gets the output component
  64281. */
  64282. get output(): NodeMaterialConnectionPoint;
  64283. protected _buildBlock(state: NodeMaterialBuildState): this;
  64284. }
  64285. }
  64286. declare module BABYLON {
  64287. /**
  64288. * Block used to get the derivative value on x and y of a given input
  64289. */
  64290. export class DerivativeBlock extends NodeMaterialBlock {
  64291. /**
  64292. * Create a new DerivativeBlock
  64293. * @param name defines the block name
  64294. */
  64295. constructor(name: string);
  64296. /**
  64297. * Gets the current class name
  64298. * @returns the class name
  64299. */
  64300. getClassName(): string;
  64301. /**
  64302. * Gets the input component
  64303. */
  64304. get input(): NodeMaterialConnectionPoint;
  64305. /**
  64306. * Gets the derivative output on x
  64307. */
  64308. get dx(): NodeMaterialConnectionPoint;
  64309. /**
  64310. * Gets the derivative output on y
  64311. */
  64312. get dy(): NodeMaterialConnectionPoint;
  64313. protected _buildBlock(state: NodeMaterialBuildState): this;
  64314. }
  64315. }
  64316. declare module BABYLON {
  64317. /**
  64318. * Block used to make gl_FragCoord available
  64319. */
  64320. export class FragCoordBlock extends NodeMaterialBlock {
  64321. /**
  64322. * Creates a new FragCoordBlock
  64323. * @param name defines the block name
  64324. */
  64325. constructor(name: string);
  64326. /**
  64327. * Gets the current class name
  64328. * @returns the class name
  64329. */
  64330. getClassName(): string;
  64331. /**
  64332. * Gets the xy component
  64333. */
  64334. get xy(): NodeMaterialConnectionPoint;
  64335. /**
  64336. * Gets the xyz component
  64337. */
  64338. get xyz(): NodeMaterialConnectionPoint;
  64339. /**
  64340. * Gets the xyzw component
  64341. */
  64342. get xyzw(): NodeMaterialConnectionPoint;
  64343. /**
  64344. * Gets the x component
  64345. */
  64346. get x(): NodeMaterialConnectionPoint;
  64347. /**
  64348. * Gets the y component
  64349. */
  64350. get y(): NodeMaterialConnectionPoint;
  64351. /**
  64352. * Gets the z component
  64353. */
  64354. get z(): NodeMaterialConnectionPoint;
  64355. /**
  64356. * Gets the w component
  64357. */
  64358. get output(): NodeMaterialConnectionPoint;
  64359. protected writeOutputs(state: NodeMaterialBuildState): string;
  64360. protected _buildBlock(state: NodeMaterialBuildState): this;
  64361. }
  64362. }
  64363. declare module BABYLON {
  64364. /**
  64365. * Block used to get the screen sizes
  64366. */
  64367. export class ScreenSizeBlock extends NodeMaterialBlock {
  64368. private _varName;
  64369. private _scene;
  64370. /**
  64371. * Creates a new ScreenSizeBlock
  64372. * @param name defines the block name
  64373. */
  64374. constructor(name: string);
  64375. /**
  64376. * Gets the current class name
  64377. * @returns the class name
  64378. */
  64379. getClassName(): string;
  64380. /**
  64381. * Gets the xy component
  64382. */
  64383. get xy(): NodeMaterialConnectionPoint;
  64384. /**
  64385. * Gets the x component
  64386. */
  64387. get x(): NodeMaterialConnectionPoint;
  64388. /**
  64389. * Gets the y component
  64390. */
  64391. get y(): NodeMaterialConnectionPoint;
  64392. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64393. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64394. protected _buildBlock(state: NodeMaterialBuildState): this;
  64395. }
  64396. }
  64397. declare module BABYLON {
  64398. /**
  64399. * Block used to add support for scene fog
  64400. */
  64401. export class FogBlock extends NodeMaterialBlock {
  64402. private _fogDistanceName;
  64403. private _fogParameters;
  64404. /**
  64405. * Create a new FogBlock
  64406. * @param name defines the block name
  64407. */
  64408. constructor(name: string);
  64409. /**
  64410. * Gets the current class name
  64411. * @returns the class name
  64412. */
  64413. getClassName(): string;
  64414. /**
  64415. * Gets the world position input component
  64416. */
  64417. get worldPosition(): NodeMaterialConnectionPoint;
  64418. /**
  64419. * Gets the view input component
  64420. */
  64421. get view(): NodeMaterialConnectionPoint;
  64422. /**
  64423. * Gets the color input component
  64424. */
  64425. get input(): NodeMaterialConnectionPoint;
  64426. /**
  64427. * Gets the fog color input component
  64428. */
  64429. get fogColor(): NodeMaterialConnectionPoint;
  64430. /**
  64431. * Gets the output component
  64432. */
  64433. get output(): NodeMaterialConnectionPoint;
  64434. autoConfigure(material: NodeMaterial): void;
  64435. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64436. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64437. protected _buildBlock(state: NodeMaterialBuildState): this;
  64438. }
  64439. }
  64440. declare module BABYLON {
  64441. /**
  64442. * Block used to add light in the fragment shader
  64443. */
  64444. export class LightBlock extends NodeMaterialBlock {
  64445. private _lightId;
  64446. /**
  64447. * Gets or sets the light associated with this block
  64448. */
  64449. light: Nullable<Light>;
  64450. /**
  64451. * Create a new LightBlock
  64452. * @param name defines the block name
  64453. */
  64454. constructor(name: string);
  64455. /**
  64456. * Gets the current class name
  64457. * @returns the class name
  64458. */
  64459. getClassName(): string;
  64460. /**
  64461. * Gets the world position input component
  64462. */
  64463. get worldPosition(): NodeMaterialConnectionPoint;
  64464. /**
  64465. * Gets the world normal input component
  64466. */
  64467. get worldNormal(): NodeMaterialConnectionPoint;
  64468. /**
  64469. * Gets the camera (or eye) position component
  64470. */
  64471. get cameraPosition(): NodeMaterialConnectionPoint;
  64472. /**
  64473. * Gets the glossiness component
  64474. */
  64475. get glossiness(): NodeMaterialConnectionPoint;
  64476. /**
  64477. * Gets the glossinness power component
  64478. */
  64479. get glossPower(): NodeMaterialConnectionPoint;
  64480. /**
  64481. * Gets the diffuse color component
  64482. */
  64483. get diffuseColor(): NodeMaterialConnectionPoint;
  64484. /**
  64485. * Gets the specular color component
  64486. */
  64487. get specularColor(): NodeMaterialConnectionPoint;
  64488. /**
  64489. * Gets the view matrix component
  64490. */
  64491. get view(): NodeMaterialConnectionPoint;
  64492. /**
  64493. * Gets the diffuse output component
  64494. */
  64495. get diffuseOutput(): NodeMaterialConnectionPoint;
  64496. /**
  64497. * Gets the specular output component
  64498. */
  64499. get specularOutput(): NodeMaterialConnectionPoint;
  64500. /**
  64501. * Gets the shadow output component
  64502. */
  64503. get shadow(): NodeMaterialConnectionPoint;
  64504. autoConfigure(material: NodeMaterial): void;
  64505. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64506. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64507. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64508. private _injectVertexCode;
  64509. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64510. serialize(): any;
  64511. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64512. }
  64513. }
  64514. declare module BABYLON {
  64515. /**
  64516. * Block used to read a reflection texture from a sampler
  64517. */
  64518. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64519. /**
  64520. * Create a new ReflectionTextureBlock
  64521. * @param name defines the block name
  64522. */
  64523. constructor(name: string);
  64524. /**
  64525. * Gets the current class name
  64526. * @returns the class name
  64527. */
  64528. getClassName(): string;
  64529. /**
  64530. * Gets the world position input component
  64531. */
  64532. get position(): NodeMaterialConnectionPoint;
  64533. /**
  64534. * Gets the world position input component
  64535. */
  64536. get worldPosition(): NodeMaterialConnectionPoint;
  64537. /**
  64538. * Gets the world normal input component
  64539. */
  64540. get worldNormal(): NodeMaterialConnectionPoint;
  64541. /**
  64542. * Gets the world input component
  64543. */
  64544. get world(): NodeMaterialConnectionPoint;
  64545. /**
  64546. * Gets the camera (or eye) position component
  64547. */
  64548. get cameraPosition(): NodeMaterialConnectionPoint;
  64549. /**
  64550. * Gets the view input component
  64551. */
  64552. get view(): NodeMaterialConnectionPoint;
  64553. /**
  64554. * Gets the rgb output component
  64555. */
  64556. get rgb(): NodeMaterialConnectionPoint;
  64557. /**
  64558. * Gets the rgba output component
  64559. */
  64560. get rgba(): NodeMaterialConnectionPoint;
  64561. /**
  64562. * Gets the r output component
  64563. */
  64564. get r(): NodeMaterialConnectionPoint;
  64565. /**
  64566. * Gets the g output component
  64567. */
  64568. get g(): NodeMaterialConnectionPoint;
  64569. /**
  64570. * Gets the b output component
  64571. */
  64572. get b(): NodeMaterialConnectionPoint;
  64573. /**
  64574. * Gets the a output component
  64575. */
  64576. get a(): NodeMaterialConnectionPoint;
  64577. autoConfigure(material: NodeMaterial): void;
  64578. protected _buildBlock(state: NodeMaterialBuildState): this;
  64579. }
  64580. }
  64581. declare module BABYLON {
  64582. /**
  64583. * Block used to add 2 vectors
  64584. */
  64585. export class AddBlock extends NodeMaterialBlock {
  64586. /**
  64587. * Creates a new AddBlock
  64588. * @param name defines the block name
  64589. */
  64590. constructor(name: string);
  64591. /**
  64592. * Gets the current class name
  64593. * @returns the class name
  64594. */
  64595. getClassName(): string;
  64596. /**
  64597. * Gets the left operand input component
  64598. */
  64599. get left(): NodeMaterialConnectionPoint;
  64600. /**
  64601. * Gets the right operand input component
  64602. */
  64603. get right(): NodeMaterialConnectionPoint;
  64604. /**
  64605. * Gets the output component
  64606. */
  64607. get output(): NodeMaterialConnectionPoint;
  64608. protected _buildBlock(state: NodeMaterialBuildState): this;
  64609. }
  64610. }
  64611. declare module BABYLON {
  64612. /**
  64613. * Block used to scale a vector by a float
  64614. */
  64615. export class ScaleBlock extends NodeMaterialBlock {
  64616. /**
  64617. * Creates a new ScaleBlock
  64618. * @param name defines the block name
  64619. */
  64620. constructor(name: string);
  64621. /**
  64622. * Gets the current class name
  64623. * @returns the class name
  64624. */
  64625. getClassName(): string;
  64626. /**
  64627. * Gets the input component
  64628. */
  64629. get input(): NodeMaterialConnectionPoint;
  64630. /**
  64631. * Gets the factor input component
  64632. */
  64633. get factor(): NodeMaterialConnectionPoint;
  64634. /**
  64635. * Gets the output component
  64636. */
  64637. get output(): NodeMaterialConnectionPoint;
  64638. protected _buildBlock(state: NodeMaterialBuildState): this;
  64639. }
  64640. }
  64641. declare module BABYLON {
  64642. /**
  64643. * Block used to clamp a float
  64644. */
  64645. export class ClampBlock extends NodeMaterialBlock {
  64646. /** Gets or sets the minimum range */
  64647. minimum: number;
  64648. /** Gets or sets the maximum range */
  64649. maximum: number;
  64650. /**
  64651. * Creates a new ClampBlock
  64652. * @param name defines the block name
  64653. */
  64654. constructor(name: string);
  64655. /**
  64656. * Gets the current class name
  64657. * @returns the class name
  64658. */
  64659. getClassName(): string;
  64660. /**
  64661. * Gets the value input component
  64662. */
  64663. get value(): NodeMaterialConnectionPoint;
  64664. /**
  64665. * Gets the output component
  64666. */
  64667. get output(): NodeMaterialConnectionPoint;
  64668. protected _buildBlock(state: NodeMaterialBuildState): this;
  64669. protected _dumpPropertiesCode(): string;
  64670. serialize(): any;
  64671. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64672. }
  64673. }
  64674. declare module BABYLON {
  64675. /**
  64676. * Block used to apply a cross product between 2 vectors
  64677. */
  64678. export class CrossBlock extends NodeMaterialBlock {
  64679. /**
  64680. * Creates a new CrossBlock
  64681. * @param name defines the block name
  64682. */
  64683. constructor(name: string);
  64684. /**
  64685. * Gets the current class name
  64686. * @returns the class name
  64687. */
  64688. getClassName(): string;
  64689. /**
  64690. * Gets the left operand input component
  64691. */
  64692. get left(): NodeMaterialConnectionPoint;
  64693. /**
  64694. * Gets the right operand input component
  64695. */
  64696. get right(): NodeMaterialConnectionPoint;
  64697. /**
  64698. * Gets the output component
  64699. */
  64700. get output(): NodeMaterialConnectionPoint;
  64701. protected _buildBlock(state: NodeMaterialBuildState): this;
  64702. }
  64703. }
  64704. declare module BABYLON {
  64705. /**
  64706. * Block used to apply a dot product between 2 vectors
  64707. */
  64708. export class DotBlock extends NodeMaterialBlock {
  64709. /**
  64710. * Creates a new DotBlock
  64711. * @param name defines the block name
  64712. */
  64713. constructor(name: string);
  64714. /**
  64715. * Gets the current class name
  64716. * @returns the class name
  64717. */
  64718. getClassName(): string;
  64719. /**
  64720. * Gets the left operand input component
  64721. */
  64722. get left(): NodeMaterialConnectionPoint;
  64723. /**
  64724. * Gets the right operand input component
  64725. */
  64726. get right(): NodeMaterialConnectionPoint;
  64727. /**
  64728. * Gets the output component
  64729. */
  64730. get output(): NodeMaterialConnectionPoint;
  64731. protected _buildBlock(state: NodeMaterialBuildState): this;
  64732. }
  64733. }
  64734. declare module BABYLON {
  64735. /**
  64736. * Block used to normalize a vector
  64737. */
  64738. export class NormalizeBlock extends NodeMaterialBlock {
  64739. /**
  64740. * Creates a new NormalizeBlock
  64741. * @param name defines the block name
  64742. */
  64743. constructor(name: string);
  64744. /**
  64745. * Gets the current class name
  64746. * @returns the class name
  64747. */
  64748. getClassName(): string;
  64749. /**
  64750. * Gets the input component
  64751. */
  64752. get input(): NodeMaterialConnectionPoint;
  64753. /**
  64754. * Gets the output component
  64755. */
  64756. get output(): NodeMaterialConnectionPoint;
  64757. protected _buildBlock(state: NodeMaterialBuildState): this;
  64758. }
  64759. }
  64760. declare module BABYLON {
  64761. /**
  64762. * Block used to create a Color3/4 out of individual inputs (one for each component)
  64763. */
  64764. export class ColorMergerBlock extends NodeMaterialBlock {
  64765. /**
  64766. * Create a new ColorMergerBlock
  64767. * @param name defines the block name
  64768. */
  64769. constructor(name: string);
  64770. /**
  64771. * Gets the current class name
  64772. * @returns the class name
  64773. */
  64774. getClassName(): string;
  64775. /**
  64776. * Gets the rgb component (input)
  64777. */
  64778. get rgbIn(): NodeMaterialConnectionPoint;
  64779. /**
  64780. * Gets the r component (input)
  64781. */
  64782. get r(): NodeMaterialConnectionPoint;
  64783. /**
  64784. * Gets the g component (input)
  64785. */
  64786. get g(): NodeMaterialConnectionPoint;
  64787. /**
  64788. * Gets the b component (input)
  64789. */
  64790. get b(): NodeMaterialConnectionPoint;
  64791. /**
  64792. * Gets the a component (input)
  64793. */
  64794. get a(): NodeMaterialConnectionPoint;
  64795. /**
  64796. * Gets the rgba component (output)
  64797. */
  64798. get rgba(): NodeMaterialConnectionPoint;
  64799. /**
  64800. * Gets the rgb component (output)
  64801. */
  64802. get rgbOut(): NodeMaterialConnectionPoint;
  64803. /**
  64804. * Gets the rgb component (output)
  64805. * @deprecated Please use rgbOut instead.
  64806. */
  64807. get rgb(): NodeMaterialConnectionPoint;
  64808. protected _buildBlock(state: NodeMaterialBuildState): this;
  64809. }
  64810. }
  64811. declare module BABYLON {
  64812. /**
  64813. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  64814. */
  64815. export class VectorSplitterBlock extends NodeMaterialBlock {
  64816. /**
  64817. * Create a new VectorSplitterBlock
  64818. * @param name defines the block name
  64819. */
  64820. constructor(name: string);
  64821. /**
  64822. * Gets the current class name
  64823. * @returns the class name
  64824. */
  64825. getClassName(): string;
  64826. /**
  64827. * Gets the xyzw component (input)
  64828. */
  64829. get xyzw(): NodeMaterialConnectionPoint;
  64830. /**
  64831. * Gets the xyz component (input)
  64832. */
  64833. get xyzIn(): NodeMaterialConnectionPoint;
  64834. /**
  64835. * Gets the xy component (input)
  64836. */
  64837. get xyIn(): NodeMaterialConnectionPoint;
  64838. /**
  64839. * Gets the xyz component (output)
  64840. */
  64841. get xyzOut(): NodeMaterialConnectionPoint;
  64842. /**
  64843. * Gets the xy component (output)
  64844. */
  64845. get xyOut(): NodeMaterialConnectionPoint;
  64846. /**
  64847. * Gets the x component (output)
  64848. */
  64849. get x(): NodeMaterialConnectionPoint;
  64850. /**
  64851. * Gets the y component (output)
  64852. */
  64853. get y(): NodeMaterialConnectionPoint;
  64854. /**
  64855. * Gets the z component (output)
  64856. */
  64857. get z(): NodeMaterialConnectionPoint;
  64858. /**
  64859. * Gets the w component (output)
  64860. */
  64861. get w(): NodeMaterialConnectionPoint;
  64862. protected _inputRename(name: string): string;
  64863. protected _outputRename(name: string): string;
  64864. protected _buildBlock(state: NodeMaterialBuildState): this;
  64865. }
  64866. }
  64867. declare module BABYLON {
  64868. /**
  64869. * Block used to lerp between 2 values
  64870. */
  64871. export class LerpBlock extends NodeMaterialBlock {
  64872. /**
  64873. * Creates a new LerpBlock
  64874. * @param name defines the block name
  64875. */
  64876. constructor(name: string);
  64877. /**
  64878. * Gets the current class name
  64879. * @returns the class name
  64880. */
  64881. getClassName(): string;
  64882. /**
  64883. * Gets the left operand input component
  64884. */
  64885. get left(): NodeMaterialConnectionPoint;
  64886. /**
  64887. * Gets the right operand input component
  64888. */
  64889. get right(): NodeMaterialConnectionPoint;
  64890. /**
  64891. * Gets the gradient operand input component
  64892. */
  64893. get gradient(): NodeMaterialConnectionPoint;
  64894. /**
  64895. * Gets the output component
  64896. */
  64897. get output(): NodeMaterialConnectionPoint;
  64898. protected _buildBlock(state: NodeMaterialBuildState): this;
  64899. }
  64900. }
  64901. declare module BABYLON {
  64902. /**
  64903. * Block used to divide 2 vectors
  64904. */
  64905. export class DivideBlock extends NodeMaterialBlock {
  64906. /**
  64907. * Creates a new DivideBlock
  64908. * @param name defines the block name
  64909. */
  64910. constructor(name: string);
  64911. /**
  64912. * Gets the current class name
  64913. * @returns the class name
  64914. */
  64915. getClassName(): string;
  64916. /**
  64917. * Gets the left operand input component
  64918. */
  64919. get left(): NodeMaterialConnectionPoint;
  64920. /**
  64921. * Gets the right operand input component
  64922. */
  64923. get right(): NodeMaterialConnectionPoint;
  64924. /**
  64925. * Gets the output component
  64926. */
  64927. get output(): NodeMaterialConnectionPoint;
  64928. protected _buildBlock(state: NodeMaterialBuildState): this;
  64929. }
  64930. }
  64931. declare module BABYLON {
  64932. /**
  64933. * Block used to subtract 2 vectors
  64934. */
  64935. export class SubtractBlock extends NodeMaterialBlock {
  64936. /**
  64937. * Creates a new SubtractBlock
  64938. * @param name defines the block name
  64939. */
  64940. constructor(name: string);
  64941. /**
  64942. * Gets the current class name
  64943. * @returns the class name
  64944. */
  64945. getClassName(): string;
  64946. /**
  64947. * Gets the left operand input component
  64948. */
  64949. get left(): NodeMaterialConnectionPoint;
  64950. /**
  64951. * Gets the right operand input component
  64952. */
  64953. get right(): NodeMaterialConnectionPoint;
  64954. /**
  64955. * Gets the output component
  64956. */
  64957. get output(): NodeMaterialConnectionPoint;
  64958. protected _buildBlock(state: NodeMaterialBuildState): this;
  64959. }
  64960. }
  64961. declare module BABYLON {
  64962. /**
  64963. * Block used to step a value
  64964. */
  64965. export class StepBlock extends NodeMaterialBlock {
  64966. /**
  64967. * Creates a new StepBlock
  64968. * @param name defines the block name
  64969. */
  64970. constructor(name: string);
  64971. /**
  64972. * Gets the current class name
  64973. * @returns the class name
  64974. */
  64975. getClassName(): string;
  64976. /**
  64977. * Gets the value operand input component
  64978. */
  64979. get value(): NodeMaterialConnectionPoint;
  64980. /**
  64981. * Gets the edge operand input component
  64982. */
  64983. get edge(): NodeMaterialConnectionPoint;
  64984. /**
  64985. * Gets the output component
  64986. */
  64987. get output(): NodeMaterialConnectionPoint;
  64988. protected _buildBlock(state: NodeMaterialBuildState): this;
  64989. }
  64990. }
  64991. declare module BABYLON {
  64992. /**
  64993. * Block used to get the opposite (1 - x) of a value
  64994. */
  64995. export class OneMinusBlock extends NodeMaterialBlock {
  64996. /**
  64997. * Creates a new OneMinusBlock
  64998. * @param name defines the block name
  64999. */
  65000. constructor(name: string);
  65001. /**
  65002. * Gets the current class name
  65003. * @returns the class name
  65004. */
  65005. getClassName(): string;
  65006. /**
  65007. * Gets the input component
  65008. */
  65009. get input(): NodeMaterialConnectionPoint;
  65010. /**
  65011. * Gets the output component
  65012. */
  65013. get output(): NodeMaterialConnectionPoint;
  65014. protected _buildBlock(state: NodeMaterialBuildState): this;
  65015. }
  65016. }
  65017. declare module BABYLON {
  65018. /**
  65019. * Block used to get the view direction
  65020. */
  65021. export class ViewDirectionBlock extends NodeMaterialBlock {
  65022. /**
  65023. * Creates a new ViewDirectionBlock
  65024. * @param name defines the block name
  65025. */
  65026. constructor(name: string);
  65027. /**
  65028. * Gets the current class name
  65029. * @returns the class name
  65030. */
  65031. getClassName(): string;
  65032. /**
  65033. * Gets the world position component
  65034. */
  65035. get worldPosition(): NodeMaterialConnectionPoint;
  65036. /**
  65037. * Gets the camera position component
  65038. */
  65039. get cameraPosition(): NodeMaterialConnectionPoint;
  65040. /**
  65041. * Gets the output component
  65042. */
  65043. get output(): NodeMaterialConnectionPoint;
  65044. autoConfigure(material: NodeMaterial): void;
  65045. protected _buildBlock(state: NodeMaterialBuildState): this;
  65046. }
  65047. }
  65048. declare module BABYLON {
  65049. /**
  65050. * Block used to compute fresnel value
  65051. */
  65052. export class FresnelBlock extends NodeMaterialBlock {
  65053. /**
  65054. * Create a new FresnelBlock
  65055. * @param name defines the block name
  65056. */
  65057. constructor(name: string);
  65058. /**
  65059. * Gets the current class name
  65060. * @returns the class name
  65061. */
  65062. getClassName(): string;
  65063. /**
  65064. * Gets the world normal input component
  65065. */
  65066. get worldNormal(): NodeMaterialConnectionPoint;
  65067. /**
  65068. * Gets the view direction input component
  65069. */
  65070. get viewDirection(): NodeMaterialConnectionPoint;
  65071. /**
  65072. * Gets the bias input component
  65073. */
  65074. get bias(): NodeMaterialConnectionPoint;
  65075. /**
  65076. * Gets the camera (or eye) position component
  65077. */
  65078. get power(): NodeMaterialConnectionPoint;
  65079. /**
  65080. * Gets the fresnel output component
  65081. */
  65082. get fresnel(): NodeMaterialConnectionPoint;
  65083. autoConfigure(material: NodeMaterial): void;
  65084. protected _buildBlock(state: NodeMaterialBuildState): this;
  65085. }
  65086. }
  65087. declare module BABYLON {
  65088. /**
  65089. * Block used to get the max of 2 values
  65090. */
  65091. export class MaxBlock extends NodeMaterialBlock {
  65092. /**
  65093. * Creates a new MaxBlock
  65094. * @param name defines the block name
  65095. */
  65096. constructor(name: string);
  65097. /**
  65098. * Gets the current class name
  65099. * @returns the class name
  65100. */
  65101. getClassName(): string;
  65102. /**
  65103. * Gets the left operand input component
  65104. */
  65105. get left(): NodeMaterialConnectionPoint;
  65106. /**
  65107. * Gets the right operand input component
  65108. */
  65109. get right(): NodeMaterialConnectionPoint;
  65110. /**
  65111. * Gets the output component
  65112. */
  65113. get output(): NodeMaterialConnectionPoint;
  65114. protected _buildBlock(state: NodeMaterialBuildState): this;
  65115. }
  65116. }
  65117. declare module BABYLON {
  65118. /**
  65119. * Block used to get the min of 2 values
  65120. */
  65121. export class MinBlock extends NodeMaterialBlock {
  65122. /**
  65123. * Creates a new MinBlock
  65124. * @param name defines the block name
  65125. */
  65126. constructor(name: string);
  65127. /**
  65128. * Gets the current class name
  65129. * @returns the class name
  65130. */
  65131. getClassName(): string;
  65132. /**
  65133. * Gets the left operand input component
  65134. */
  65135. get left(): NodeMaterialConnectionPoint;
  65136. /**
  65137. * Gets the right operand input component
  65138. */
  65139. get right(): NodeMaterialConnectionPoint;
  65140. /**
  65141. * Gets the output component
  65142. */
  65143. get output(): NodeMaterialConnectionPoint;
  65144. protected _buildBlock(state: NodeMaterialBuildState): this;
  65145. }
  65146. }
  65147. declare module BABYLON {
  65148. /**
  65149. * Block used to get the distance between 2 values
  65150. */
  65151. export class DistanceBlock extends NodeMaterialBlock {
  65152. /**
  65153. * Creates a new DistanceBlock
  65154. * @param name defines the block name
  65155. */
  65156. constructor(name: string);
  65157. /**
  65158. * Gets the current class name
  65159. * @returns the class name
  65160. */
  65161. getClassName(): string;
  65162. /**
  65163. * Gets the left operand input component
  65164. */
  65165. get left(): NodeMaterialConnectionPoint;
  65166. /**
  65167. * Gets the right operand input component
  65168. */
  65169. get right(): NodeMaterialConnectionPoint;
  65170. /**
  65171. * Gets the output component
  65172. */
  65173. get output(): NodeMaterialConnectionPoint;
  65174. protected _buildBlock(state: NodeMaterialBuildState): this;
  65175. }
  65176. }
  65177. declare module BABYLON {
  65178. /**
  65179. * Block used to get the length of a vector
  65180. */
  65181. export class LengthBlock extends NodeMaterialBlock {
  65182. /**
  65183. * Creates a new LengthBlock
  65184. * @param name defines the block name
  65185. */
  65186. constructor(name: string);
  65187. /**
  65188. * Gets the current class name
  65189. * @returns the class name
  65190. */
  65191. getClassName(): string;
  65192. /**
  65193. * Gets the value input component
  65194. */
  65195. get value(): NodeMaterialConnectionPoint;
  65196. /**
  65197. * Gets the output component
  65198. */
  65199. get output(): NodeMaterialConnectionPoint;
  65200. protected _buildBlock(state: NodeMaterialBuildState): this;
  65201. }
  65202. }
  65203. declare module BABYLON {
  65204. /**
  65205. * Block used to get negative version of a value (i.e. x * -1)
  65206. */
  65207. export class NegateBlock extends NodeMaterialBlock {
  65208. /**
  65209. * Creates a new NegateBlock
  65210. * @param name defines the block name
  65211. */
  65212. constructor(name: string);
  65213. /**
  65214. * Gets the current class name
  65215. * @returns the class name
  65216. */
  65217. getClassName(): string;
  65218. /**
  65219. * Gets the value input component
  65220. */
  65221. get value(): NodeMaterialConnectionPoint;
  65222. /**
  65223. * Gets the output component
  65224. */
  65225. get output(): NodeMaterialConnectionPoint;
  65226. protected _buildBlock(state: NodeMaterialBuildState): this;
  65227. }
  65228. }
  65229. declare module BABYLON {
  65230. /**
  65231. * Block used to get the value of the first parameter raised to the power of the second
  65232. */
  65233. export class PowBlock extends NodeMaterialBlock {
  65234. /**
  65235. * Creates a new PowBlock
  65236. * @param name defines the block name
  65237. */
  65238. constructor(name: string);
  65239. /**
  65240. * Gets the current class name
  65241. * @returns the class name
  65242. */
  65243. getClassName(): string;
  65244. /**
  65245. * Gets the value operand input component
  65246. */
  65247. get value(): NodeMaterialConnectionPoint;
  65248. /**
  65249. * Gets the power operand input component
  65250. */
  65251. get power(): NodeMaterialConnectionPoint;
  65252. /**
  65253. * Gets the output component
  65254. */
  65255. get output(): NodeMaterialConnectionPoint;
  65256. protected _buildBlock(state: NodeMaterialBuildState): this;
  65257. }
  65258. }
  65259. declare module BABYLON {
  65260. /**
  65261. * Block used to get a random number
  65262. */
  65263. export class RandomNumberBlock extends NodeMaterialBlock {
  65264. /**
  65265. * Creates a new RandomNumberBlock
  65266. * @param name defines the block name
  65267. */
  65268. constructor(name: string);
  65269. /**
  65270. * Gets the current class name
  65271. * @returns the class name
  65272. */
  65273. getClassName(): string;
  65274. /**
  65275. * Gets the seed input component
  65276. */
  65277. get seed(): NodeMaterialConnectionPoint;
  65278. /**
  65279. * Gets the output component
  65280. */
  65281. get output(): NodeMaterialConnectionPoint;
  65282. protected _buildBlock(state: NodeMaterialBuildState): this;
  65283. }
  65284. }
  65285. declare module BABYLON {
  65286. /**
  65287. * Block used to compute arc tangent of 2 values
  65288. */
  65289. export class ArcTan2Block extends NodeMaterialBlock {
  65290. /**
  65291. * Creates a new ArcTan2Block
  65292. * @param name defines the block name
  65293. */
  65294. constructor(name: string);
  65295. /**
  65296. * Gets the current class name
  65297. * @returns the class name
  65298. */
  65299. getClassName(): string;
  65300. /**
  65301. * Gets the x operand input component
  65302. */
  65303. get x(): NodeMaterialConnectionPoint;
  65304. /**
  65305. * Gets the y operand input component
  65306. */
  65307. get y(): NodeMaterialConnectionPoint;
  65308. /**
  65309. * Gets the output component
  65310. */
  65311. get output(): NodeMaterialConnectionPoint;
  65312. protected _buildBlock(state: NodeMaterialBuildState): this;
  65313. }
  65314. }
  65315. declare module BABYLON {
  65316. /**
  65317. * Block used to smooth step a value
  65318. */
  65319. export class SmoothStepBlock extends NodeMaterialBlock {
  65320. /**
  65321. * Creates a new SmoothStepBlock
  65322. * @param name defines the block name
  65323. */
  65324. constructor(name: string);
  65325. /**
  65326. * Gets the current class name
  65327. * @returns the class name
  65328. */
  65329. getClassName(): string;
  65330. /**
  65331. * Gets the value operand input component
  65332. */
  65333. get value(): NodeMaterialConnectionPoint;
  65334. /**
  65335. * Gets the first edge operand input component
  65336. */
  65337. get edge0(): NodeMaterialConnectionPoint;
  65338. /**
  65339. * Gets the second edge operand input component
  65340. */
  65341. get edge1(): NodeMaterialConnectionPoint;
  65342. /**
  65343. * Gets the output component
  65344. */
  65345. get output(): NodeMaterialConnectionPoint;
  65346. protected _buildBlock(state: NodeMaterialBuildState): this;
  65347. }
  65348. }
  65349. declare module BABYLON {
  65350. /**
  65351. * Block used to get the reciprocal (1 / x) of a value
  65352. */
  65353. export class ReciprocalBlock extends NodeMaterialBlock {
  65354. /**
  65355. * Creates a new ReciprocalBlock
  65356. * @param name defines the block name
  65357. */
  65358. constructor(name: string);
  65359. /**
  65360. * Gets the current class name
  65361. * @returns the class name
  65362. */
  65363. getClassName(): string;
  65364. /**
  65365. * Gets the input component
  65366. */
  65367. get input(): NodeMaterialConnectionPoint;
  65368. /**
  65369. * Gets the output component
  65370. */
  65371. get output(): NodeMaterialConnectionPoint;
  65372. protected _buildBlock(state: NodeMaterialBuildState): this;
  65373. }
  65374. }
  65375. declare module BABYLON {
  65376. /**
  65377. * Block used to replace a color by another one
  65378. */
  65379. export class ReplaceColorBlock extends NodeMaterialBlock {
  65380. /**
  65381. * Creates a new ReplaceColorBlock
  65382. * @param name defines the block name
  65383. */
  65384. constructor(name: string);
  65385. /**
  65386. * Gets the current class name
  65387. * @returns the class name
  65388. */
  65389. getClassName(): string;
  65390. /**
  65391. * Gets the value input component
  65392. */
  65393. get value(): NodeMaterialConnectionPoint;
  65394. /**
  65395. * Gets the reference input component
  65396. */
  65397. get reference(): NodeMaterialConnectionPoint;
  65398. /**
  65399. * Gets the distance input component
  65400. */
  65401. get distance(): NodeMaterialConnectionPoint;
  65402. /**
  65403. * Gets the replacement input component
  65404. */
  65405. get replacement(): NodeMaterialConnectionPoint;
  65406. /**
  65407. * Gets the output component
  65408. */
  65409. get output(): NodeMaterialConnectionPoint;
  65410. protected _buildBlock(state: NodeMaterialBuildState): this;
  65411. }
  65412. }
  65413. declare module BABYLON {
  65414. /**
  65415. * Block used to posterize a value
  65416. * @see https://en.wikipedia.org/wiki/Posterization
  65417. */
  65418. export class PosterizeBlock extends NodeMaterialBlock {
  65419. /**
  65420. * Creates a new PosterizeBlock
  65421. * @param name defines the block name
  65422. */
  65423. constructor(name: string);
  65424. /**
  65425. * Gets the current class name
  65426. * @returns the class name
  65427. */
  65428. getClassName(): string;
  65429. /**
  65430. * Gets the value input component
  65431. */
  65432. get value(): NodeMaterialConnectionPoint;
  65433. /**
  65434. * Gets the steps input component
  65435. */
  65436. get steps(): NodeMaterialConnectionPoint;
  65437. /**
  65438. * Gets the output component
  65439. */
  65440. get output(): NodeMaterialConnectionPoint;
  65441. protected _buildBlock(state: NodeMaterialBuildState): this;
  65442. }
  65443. }
  65444. declare module BABYLON {
  65445. /**
  65446. * Operations supported by the Wave block
  65447. */
  65448. export enum WaveBlockKind {
  65449. /** SawTooth */
  65450. SawTooth = 0,
  65451. /** Square */
  65452. Square = 1,
  65453. /** Triangle */
  65454. Triangle = 2
  65455. }
  65456. /**
  65457. * Block used to apply wave operation to floats
  65458. */
  65459. export class WaveBlock extends NodeMaterialBlock {
  65460. /**
  65461. * Gets or sets the kibnd of wave to be applied by the block
  65462. */
  65463. kind: WaveBlockKind;
  65464. /**
  65465. * Creates a new WaveBlock
  65466. * @param name defines the block name
  65467. */
  65468. constructor(name: string);
  65469. /**
  65470. * Gets the current class name
  65471. * @returns the class name
  65472. */
  65473. getClassName(): string;
  65474. /**
  65475. * Gets the input component
  65476. */
  65477. get input(): NodeMaterialConnectionPoint;
  65478. /**
  65479. * Gets the output component
  65480. */
  65481. get output(): NodeMaterialConnectionPoint;
  65482. protected _buildBlock(state: NodeMaterialBuildState): this;
  65483. serialize(): any;
  65484. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65485. }
  65486. }
  65487. declare module BABYLON {
  65488. /**
  65489. * Class used to store a color step for the GradientBlock
  65490. */
  65491. export class GradientBlockColorStep {
  65492. private _step;
  65493. /**
  65494. * Gets value indicating which step this color is associated with (between 0 and 1)
  65495. */
  65496. get step(): number;
  65497. /**
  65498. * Sets a value indicating which step this color is associated with (between 0 and 1)
  65499. */
  65500. set step(val: number);
  65501. private _color;
  65502. /**
  65503. * Gets the color associated with this step
  65504. */
  65505. get color(): Color3;
  65506. /**
  65507. * Sets the color associated with this step
  65508. */
  65509. set color(val: Color3);
  65510. /**
  65511. * Creates a new GradientBlockColorStep
  65512. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  65513. * @param color defines the color associated with this step
  65514. */
  65515. constructor(step: number, color: Color3);
  65516. }
  65517. /**
  65518. * Block used to return a color from a gradient based on an input value between 0 and 1
  65519. */
  65520. export class GradientBlock extends NodeMaterialBlock {
  65521. /**
  65522. * Gets or sets the list of color steps
  65523. */
  65524. colorSteps: GradientBlockColorStep[];
  65525. /** Gets an observable raised when the value is changed */
  65526. onValueChangedObservable: Observable<GradientBlock>;
  65527. /** calls observable when the value is changed*/
  65528. colorStepsUpdated(): void;
  65529. /**
  65530. * Creates a new GradientBlock
  65531. * @param name defines the block name
  65532. */
  65533. constructor(name: string);
  65534. /**
  65535. * Gets the current class name
  65536. * @returns the class name
  65537. */
  65538. getClassName(): string;
  65539. /**
  65540. * Gets the gradient input component
  65541. */
  65542. get gradient(): NodeMaterialConnectionPoint;
  65543. /**
  65544. * Gets the output component
  65545. */
  65546. get output(): NodeMaterialConnectionPoint;
  65547. private _writeColorConstant;
  65548. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65549. serialize(): any;
  65550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65551. protected _dumpPropertiesCode(): string;
  65552. }
  65553. }
  65554. declare module BABYLON {
  65555. /**
  65556. * Block used to normalize lerp between 2 values
  65557. */
  65558. export class NLerpBlock extends NodeMaterialBlock {
  65559. /**
  65560. * Creates a new NLerpBlock
  65561. * @param name defines the block name
  65562. */
  65563. constructor(name: string);
  65564. /**
  65565. * Gets the current class name
  65566. * @returns the class name
  65567. */
  65568. getClassName(): string;
  65569. /**
  65570. * Gets the left operand input component
  65571. */
  65572. get left(): NodeMaterialConnectionPoint;
  65573. /**
  65574. * Gets the right operand input component
  65575. */
  65576. get right(): NodeMaterialConnectionPoint;
  65577. /**
  65578. * Gets the gradient operand input component
  65579. */
  65580. get gradient(): NodeMaterialConnectionPoint;
  65581. /**
  65582. * Gets the output component
  65583. */
  65584. get output(): NodeMaterialConnectionPoint;
  65585. protected _buildBlock(state: NodeMaterialBuildState): this;
  65586. }
  65587. }
  65588. declare module BABYLON {
  65589. /**
  65590. * block used to Generate a Worley Noise 3D Noise Pattern
  65591. */
  65592. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  65593. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65594. manhattanDistance: boolean;
  65595. /**
  65596. * Creates a new WorleyNoise3DBlock
  65597. * @param name defines the block name
  65598. */
  65599. constructor(name: string);
  65600. /**
  65601. * Gets the current class name
  65602. * @returns the class name
  65603. */
  65604. getClassName(): string;
  65605. /**
  65606. * Gets the seed input component
  65607. */
  65608. get seed(): NodeMaterialConnectionPoint;
  65609. /**
  65610. * Gets the jitter input component
  65611. */
  65612. get jitter(): NodeMaterialConnectionPoint;
  65613. /**
  65614. * Gets the output component
  65615. */
  65616. get output(): NodeMaterialConnectionPoint;
  65617. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65618. /**
  65619. * Exposes the properties to the UI?
  65620. */
  65621. protected _dumpPropertiesCode(): string;
  65622. /**
  65623. * Exposes the properties to the Seralize?
  65624. */
  65625. serialize(): any;
  65626. /**
  65627. * Exposes the properties to the deseralize?
  65628. */
  65629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65630. }
  65631. }
  65632. declare module BABYLON {
  65633. /**
  65634. * block used to Generate a Simplex Perlin 3d Noise Pattern
  65635. */
  65636. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  65637. /**
  65638. * Creates a new SimplexPerlin3DBlock
  65639. * @param name defines the block name
  65640. */
  65641. constructor(name: string);
  65642. /**
  65643. * Gets the current class name
  65644. * @returns the class name
  65645. */
  65646. getClassName(): string;
  65647. /**
  65648. * Gets the seed operand input component
  65649. */
  65650. get seed(): NodeMaterialConnectionPoint;
  65651. /**
  65652. * Gets the output component
  65653. */
  65654. get output(): NodeMaterialConnectionPoint;
  65655. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  65656. }
  65657. }
  65658. declare module BABYLON {
  65659. /**
  65660. * Block used to blend normals
  65661. */
  65662. export class NormalBlendBlock extends NodeMaterialBlock {
  65663. /**
  65664. * Creates a new NormalBlendBlock
  65665. * @param name defines the block name
  65666. */
  65667. constructor(name: string);
  65668. /**
  65669. * Gets the current class name
  65670. * @returns the class name
  65671. */
  65672. getClassName(): string;
  65673. /**
  65674. * Gets the first input component
  65675. */
  65676. get normalMap0(): NodeMaterialConnectionPoint;
  65677. /**
  65678. * Gets the second input component
  65679. */
  65680. get normalMap1(): NodeMaterialConnectionPoint;
  65681. /**
  65682. * Gets the output component
  65683. */
  65684. get output(): NodeMaterialConnectionPoint;
  65685. protected _buildBlock(state: NodeMaterialBuildState): this;
  65686. }
  65687. }
  65688. declare module BABYLON {
  65689. /**
  65690. * Block used to rotate a 2d vector by a given angle
  65691. */
  65692. export class Rotate2dBlock extends NodeMaterialBlock {
  65693. /**
  65694. * Creates a new Rotate2dBlock
  65695. * @param name defines the block name
  65696. */
  65697. constructor(name: string);
  65698. /**
  65699. * Gets the current class name
  65700. * @returns the class name
  65701. */
  65702. getClassName(): string;
  65703. /**
  65704. * Gets the input vector
  65705. */
  65706. get input(): NodeMaterialConnectionPoint;
  65707. /**
  65708. * Gets the input angle
  65709. */
  65710. get angle(): NodeMaterialConnectionPoint;
  65711. /**
  65712. * Gets the output component
  65713. */
  65714. get output(): NodeMaterialConnectionPoint;
  65715. autoConfigure(material: NodeMaterial): void;
  65716. protected _buildBlock(state: NodeMaterialBuildState): this;
  65717. }
  65718. }
  65719. declare module BABYLON {
  65720. /**
  65721. * Block used to get the reflected vector from a direction and a normal
  65722. */
  65723. export class ReflectBlock extends NodeMaterialBlock {
  65724. /**
  65725. * Creates a new ReflectBlock
  65726. * @param name defines the block name
  65727. */
  65728. constructor(name: string);
  65729. /**
  65730. * Gets the current class name
  65731. * @returns the class name
  65732. */
  65733. getClassName(): string;
  65734. /**
  65735. * Gets the incident component
  65736. */
  65737. get incident(): NodeMaterialConnectionPoint;
  65738. /**
  65739. * Gets the normal component
  65740. */
  65741. get normal(): NodeMaterialConnectionPoint;
  65742. /**
  65743. * Gets the output component
  65744. */
  65745. get output(): NodeMaterialConnectionPoint;
  65746. protected _buildBlock(state: NodeMaterialBuildState): this;
  65747. }
  65748. }
  65749. declare module BABYLON {
  65750. /**
  65751. * Block used to get the refracted vector from a direction and a normal
  65752. */
  65753. export class RefractBlock extends NodeMaterialBlock {
  65754. /**
  65755. * Creates a new RefractBlock
  65756. * @param name defines the block name
  65757. */
  65758. constructor(name: string);
  65759. /**
  65760. * Gets the current class name
  65761. * @returns the class name
  65762. */
  65763. getClassName(): string;
  65764. /**
  65765. * Gets the incident component
  65766. */
  65767. get incident(): NodeMaterialConnectionPoint;
  65768. /**
  65769. * Gets the normal component
  65770. */
  65771. get normal(): NodeMaterialConnectionPoint;
  65772. /**
  65773. * Gets the index of refraction component
  65774. */
  65775. get ior(): NodeMaterialConnectionPoint;
  65776. /**
  65777. * Gets the output component
  65778. */
  65779. get output(): NodeMaterialConnectionPoint;
  65780. protected _buildBlock(state: NodeMaterialBuildState): this;
  65781. }
  65782. }
  65783. declare module BABYLON {
  65784. /**
  65785. * Block used to desaturate a color
  65786. */
  65787. export class DesaturateBlock extends NodeMaterialBlock {
  65788. /**
  65789. * Creates a new DesaturateBlock
  65790. * @param name defines the block name
  65791. */
  65792. constructor(name: string);
  65793. /**
  65794. * Gets the current class name
  65795. * @returns the class name
  65796. */
  65797. getClassName(): string;
  65798. /**
  65799. * Gets the color operand input component
  65800. */
  65801. get color(): NodeMaterialConnectionPoint;
  65802. /**
  65803. * Gets the level operand input component
  65804. */
  65805. get level(): NodeMaterialConnectionPoint;
  65806. /**
  65807. * Gets the output component
  65808. */
  65809. get output(): NodeMaterialConnectionPoint;
  65810. protected _buildBlock(state: NodeMaterialBuildState): this;
  65811. }
  65812. }
  65813. declare module BABYLON {
  65814. /**
  65815. * Block used to implement the reflection module of the PBR material
  65816. */
  65817. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  65818. /** @hidden */
  65819. _defineLODReflectionAlpha: string;
  65820. /** @hidden */
  65821. _defineLinearSpecularReflection: string;
  65822. private _vEnvironmentIrradianceName;
  65823. /** @hidden */
  65824. _vReflectionMicrosurfaceInfosName: string;
  65825. /** @hidden */
  65826. _vReflectionInfosName: string;
  65827. /** @hidden */
  65828. _vReflectionFilteringInfoName: string;
  65829. private _scene;
  65830. /**
  65831. * The properties below are set by the main PBR block prior to calling methods of this class.
  65832. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65833. * It's less burden on the user side in the editor part.
  65834. */
  65835. /** @hidden */
  65836. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65837. /** @hidden */
  65838. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65839. /** @hidden */
  65840. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  65841. /** @hidden */
  65842. viewConnectionPoint: NodeMaterialConnectionPoint;
  65843. /**
  65844. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  65845. * diffuse part of the IBL.
  65846. */
  65847. useSphericalHarmonics: boolean;
  65848. /**
  65849. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  65850. */
  65851. forceIrradianceInFragment: boolean;
  65852. /**
  65853. * Create a new ReflectionBlock
  65854. * @param name defines the block name
  65855. */
  65856. constructor(name: string);
  65857. /**
  65858. * Gets the current class name
  65859. * @returns the class name
  65860. */
  65861. getClassName(): string;
  65862. /**
  65863. * Gets the position input component
  65864. */
  65865. get position(): NodeMaterialConnectionPoint;
  65866. /**
  65867. * Gets the world position input component
  65868. */
  65869. get worldPosition(): NodeMaterialConnectionPoint;
  65870. /**
  65871. * Gets the world normal input component
  65872. */
  65873. get worldNormal(): NodeMaterialConnectionPoint;
  65874. /**
  65875. * Gets the world input component
  65876. */
  65877. get world(): NodeMaterialConnectionPoint;
  65878. /**
  65879. * Gets the camera (or eye) position component
  65880. */
  65881. get cameraPosition(): NodeMaterialConnectionPoint;
  65882. /**
  65883. * Gets the view input component
  65884. */
  65885. get view(): NodeMaterialConnectionPoint;
  65886. /**
  65887. * Gets the color input component
  65888. */
  65889. get color(): NodeMaterialConnectionPoint;
  65890. /**
  65891. * Gets the reflection object output component
  65892. */
  65893. get reflection(): NodeMaterialConnectionPoint;
  65894. /**
  65895. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  65896. */
  65897. get hasTexture(): boolean;
  65898. /**
  65899. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  65900. */
  65901. get reflectionColor(): string;
  65902. protected _getTexture(): Nullable<BaseTexture>;
  65903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65904. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65905. /**
  65906. * Gets the code to inject in the vertex shader
  65907. * @param state current state of the node material building
  65908. * @returns the shader code
  65909. */
  65910. handleVertexSide(state: NodeMaterialBuildState): string;
  65911. /**
  65912. * Gets the main code of the block (fragment side)
  65913. * @param state current state of the node material building
  65914. * @param normalVarName name of the existing variable corresponding to the normal
  65915. * @returns the shader code
  65916. */
  65917. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  65918. protected _buildBlock(state: NodeMaterialBuildState): this;
  65919. protected _dumpPropertiesCode(): string;
  65920. serialize(): any;
  65921. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65922. }
  65923. }
  65924. declare module BABYLON {
  65925. /**
  65926. * Block used to implement the sheen module of the PBR material
  65927. */
  65928. export class SheenBlock extends NodeMaterialBlock {
  65929. /**
  65930. * Create a new SheenBlock
  65931. * @param name defines the block name
  65932. */
  65933. constructor(name: string);
  65934. /**
  65935. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65936. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65937. * making it easier to setup and tweak the effect
  65938. */
  65939. albedoScaling: boolean;
  65940. /**
  65941. * Defines if the sheen is linked to the sheen color.
  65942. */
  65943. linkSheenWithAlbedo: boolean;
  65944. /**
  65945. * Initialize the block and prepare the context for build
  65946. * @param state defines the state that will be used for the build
  65947. */
  65948. initialize(state: NodeMaterialBuildState): void;
  65949. /**
  65950. * Gets the current class name
  65951. * @returns the class name
  65952. */
  65953. getClassName(): string;
  65954. /**
  65955. * Gets the intensity input component
  65956. */
  65957. get intensity(): NodeMaterialConnectionPoint;
  65958. /**
  65959. * Gets the color input component
  65960. */
  65961. get color(): NodeMaterialConnectionPoint;
  65962. /**
  65963. * Gets the roughness input component
  65964. */
  65965. get roughness(): NodeMaterialConnectionPoint;
  65966. /**
  65967. * Gets the sheen object output component
  65968. */
  65969. get sheen(): NodeMaterialConnectionPoint;
  65970. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65971. /**
  65972. * Gets the main code of the block (fragment side)
  65973. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65974. * @returns the shader code
  65975. */
  65976. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65977. protected _buildBlock(state: NodeMaterialBuildState): this;
  65978. protected _dumpPropertiesCode(): string;
  65979. serialize(): any;
  65980. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65981. }
  65982. }
  65983. declare module BABYLON {
  65984. /**
  65985. * Block used to implement the anisotropy module of the PBR material
  65986. */
  65987. export class AnisotropyBlock extends NodeMaterialBlock {
  65988. /**
  65989. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65990. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65991. * It's less burden on the user side in the editor part.
  65992. */
  65993. /** @hidden */
  65994. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65995. /** @hidden */
  65996. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65997. /**
  65998. * Create a new AnisotropyBlock
  65999. * @param name defines the block name
  66000. */
  66001. constructor(name: string);
  66002. /**
  66003. * Initialize the block and prepare the context for build
  66004. * @param state defines the state that will be used for the build
  66005. */
  66006. initialize(state: NodeMaterialBuildState): void;
  66007. /**
  66008. * Gets the current class name
  66009. * @returns the class name
  66010. */
  66011. getClassName(): string;
  66012. /**
  66013. * Gets the intensity input component
  66014. */
  66015. get intensity(): NodeMaterialConnectionPoint;
  66016. /**
  66017. * Gets the direction input component
  66018. */
  66019. get direction(): NodeMaterialConnectionPoint;
  66020. /**
  66021. * Gets the uv input component
  66022. */
  66023. get uv(): NodeMaterialConnectionPoint;
  66024. /**
  66025. * Gets the worldTangent input component
  66026. */
  66027. get worldTangent(): NodeMaterialConnectionPoint;
  66028. /**
  66029. * Gets the anisotropy object output component
  66030. */
  66031. get anisotropy(): NodeMaterialConnectionPoint;
  66032. private _generateTBNSpace;
  66033. /**
  66034. * Gets the main code of the block (fragment side)
  66035. * @param state current state of the node material building
  66036. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66037. * @returns the shader code
  66038. */
  66039. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66040. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66041. protected _buildBlock(state: NodeMaterialBuildState): this;
  66042. }
  66043. }
  66044. declare module BABYLON {
  66045. /**
  66046. * Block used to implement the clear coat module of the PBR material
  66047. */
  66048. export class ClearCoatBlock extends NodeMaterialBlock {
  66049. private _scene;
  66050. /**
  66051. * Create a new ClearCoatBlock
  66052. * @param name defines the block name
  66053. */
  66054. constructor(name: string);
  66055. /**
  66056. * Defines if the F0 value should be remapped to account for the interface change in the material.
  66057. */
  66058. remapF0OnInterfaceChange: boolean;
  66059. /**
  66060. * Initialize the block and prepare the context for build
  66061. * @param state defines the state that will be used for the build
  66062. */
  66063. initialize(state: NodeMaterialBuildState): void;
  66064. /**
  66065. * Gets the current class name
  66066. * @returns the class name
  66067. */
  66068. getClassName(): string;
  66069. /**
  66070. * Gets the intensity input component
  66071. */
  66072. get intensity(): NodeMaterialConnectionPoint;
  66073. /**
  66074. * Gets the roughness input component
  66075. */
  66076. get roughness(): NodeMaterialConnectionPoint;
  66077. /**
  66078. * Gets the ior input component
  66079. */
  66080. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66081. /**
  66082. * Gets the bump texture input component
  66083. */
  66084. get normalMapColor(): NodeMaterialConnectionPoint;
  66085. /**
  66086. * Gets the uv input component
  66087. */
  66088. get uv(): NodeMaterialConnectionPoint;
  66089. /**
  66090. * Gets the tint color input component
  66091. */
  66092. get tintColor(): NodeMaterialConnectionPoint;
  66093. /**
  66094. * Gets the tint "at distance" input component
  66095. */
  66096. get tintAtDistance(): NodeMaterialConnectionPoint;
  66097. /**
  66098. * Gets the tint thickness input component
  66099. */
  66100. get tintThickness(): NodeMaterialConnectionPoint;
  66101. /**
  66102. * Gets the world tangent input component
  66103. */
  66104. get worldTangent(): NodeMaterialConnectionPoint;
  66105. /**
  66106. * Gets the clear coat object output component
  66107. */
  66108. get clearcoat(): NodeMaterialConnectionPoint;
  66109. autoConfigure(material: NodeMaterial): void;
  66110. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66111. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66112. private _generateTBNSpace;
  66113. /**
  66114. * Gets the main code of the block (fragment side)
  66115. * @param state current state of the node material building
  66116. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66117. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66118. * @param worldPosVarName name of the variable holding the world position
  66119. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66120. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66121. * @param worldNormalVarName name of the variable holding the world normal
  66122. * @returns the shader code
  66123. */
  66124. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66125. protected _buildBlock(state: NodeMaterialBuildState): this;
  66126. protected _dumpPropertiesCode(): string;
  66127. serialize(): any;
  66128. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66129. }
  66130. }
  66131. declare module BABYLON {
  66132. /**
  66133. * Block used to implement the sub surface module of the PBR material
  66134. */
  66135. export class SubSurfaceBlock extends NodeMaterialBlock {
  66136. /**
  66137. * Create a new SubSurfaceBlock
  66138. * @param name defines the block name
  66139. */
  66140. constructor(name: string);
  66141. /**
  66142. * Initialize the block and prepare the context for build
  66143. * @param state defines the state that will be used for the build
  66144. */
  66145. initialize(state: NodeMaterialBuildState): void;
  66146. /**
  66147. * Gets the current class name
  66148. * @returns the class name
  66149. */
  66150. getClassName(): string;
  66151. /**
  66152. * Gets the thickness component
  66153. */
  66154. get thickness(): NodeMaterialConnectionPoint;
  66155. /**
  66156. * Gets the tint color input component
  66157. */
  66158. get tintColor(): NodeMaterialConnectionPoint;
  66159. /**
  66160. * Gets the translucency intensity input component
  66161. */
  66162. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66163. /**
  66164. * Gets the translucency diffusion distance input component
  66165. */
  66166. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  66167. /**
  66168. * Gets the refraction object parameters
  66169. */
  66170. get refraction(): NodeMaterialConnectionPoint;
  66171. /**
  66172. * Gets the sub surface object output component
  66173. */
  66174. get subsurface(): NodeMaterialConnectionPoint;
  66175. autoConfigure(material: NodeMaterial): void;
  66176. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66177. /**
  66178. * Gets the main code of the block (fragment side)
  66179. * @param state current state of the node material building
  66180. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66181. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66182. * @param worldPosVarName name of the variable holding the world position
  66183. * @returns the shader code
  66184. */
  66185. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66186. protected _buildBlock(state: NodeMaterialBuildState): this;
  66187. }
  66188. }
  66189. declare module BABYLON {
  66190. /**
  66191. * Block used to implement the PBR metallic/roughness model
  66192. */
  66193. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  66194. /**
  66195. * Gets or sets the light associated with this block
  66196. */
  66197. light: Nullable<Light>;
  66198. private _lightId;
  66199. private _scene;
  66200. private _environmentBRDFTexture;
  66201. private _environmentBrdfSamplerName;
  66202. private _vNormalWName;
  66203. private _invertNormalName;
  66204. private _metallicReflectanceColor;
  66205. private _metallicF0Factor;
  66206. private _vMetallicReflectanceFactorsName;
  66207. /**
  66208. * Create a new ReflectionBlock
  66209. * @param name defines the block name
  66210. */
  66211. constructor(name: string);
  66212. /**
  66213. * Intensity of the direct lights e.g. the four lights available in your scene.
  66214. * This impacts both the direct diffuse and specular highlights.
  66215. */
  66216. directIntensity: number;
  66217. /**
  66218. * Intensity of the environment e.g. how much the environment will light the object
  66219. * either through harmonics for rough material or through the refelction for shiny ones.
  66220. */
  66221. environmentIntensity: number;
  66222. /**
  66223. * This is a special control allowing the reduction of the specular highlights coming from the
  66224. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  66225. */
  66226. specularIntensity: number;
  66227. /**
  66228. * Defines the falloff type used in this material.
  66229. * It by default is Physical.
  66230. */
  66231. lightFalloff: number;
  66232. /**
  66233. * Specifies that alpha test should be used
  66234. */
  66235. useAlphaTest: boolean;
  66236. /**
  66237. * Defines the alpha limits in alpha test mode.
  66238. */
  66239. alphaTestCutoff: number;
  66240. /**
  66241. * Specifies that alpha blending should be used
  66242. */
  66243. useAlphaBlending: boolean;
  66244. /**
  66245. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  66246. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  66247. */
  66248. useRadianceOverAlpha: boolean;
  66249. /**
  66250. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  66251. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  66252. */
  66253. useSpecularOverAlpha: boolean;
  66254. /**
  66255. * Enables specular anti aliasing in the PBR shader.
  66256. * It will both interacts on the Geometry for analytical and IBL lighting.
  66257. * It also prefilter the roughness map based on the bump values.
  66258. */
  66259. enableSpecularAntiAliasing: boolean;
  66260. /**
  66261. * Enables realtime filtering on the texture.
  66262. */
  66263. realTimeFiltering: boolean;
  66264. /**
  66265. * Quality switch for realtime filtering
  66266. */
  66267. realTimeFilteringQuality: number;
  66268. /**
  66269. * Defines if the material uses energy conservation.
  66270. */
  66271. useEnergyConservation: boolean;
  66272. /**
  66273. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  66274. * too much the area relying on ambient texture to define their ambient occlusion.
  66275. */
  66276. useRadianceOcclusion: boolean;
  66277. /**
  66278. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  66279. * makes the reflect vector face the model (under horizon).
  66280. */
  66281. useHorizonOcclusion: boolean;
  66282. /**
  66283. * If set to true, no lighting calculations will be applied.
  66284. */
  66285. unlit: boolean;
  66286. /**
  66287. * Force normal to face away from face.
  66288. */
  66289. forceNormalForward: boolean;
  66290. /**
  66291. * Defines the material debug mode.
  66292. * It helps seeing only some components of the material while troubleshooting.
  66293. */
  66294. debugMode: number;
  66295. /**
  66296. * Specify from where on screen the debug mode should start.
  66297. * The value goes from -1 (full screen) to 1 (not visible)
  66298. * It helps with side by side comparison against the final render
  66299. * This defaults to 0
  66300. */
  66301. debugLimit: number;
  66302. /**
  66303. * As the default viewing range might not be enough (if the ambient is really small for instance)
  66304. * You can use the factor to better multiply the final value.
  66305. */
  66306. debugFactor: number;
  66307. /**
  66308. * Initialize the block and prepare the context for build
  66309. * @param state defines the state that will be used for the build
  66310. */
  66311. initialize(state: NodeMaterialBuildState): void;
  66312. /**
  66313. * Gets the current class name
  66314. * @returns the class name
  66315. */
  66316. getClassName(): string;
  66317. /**
  66318. * Gets the world position input component
  66319. */
  66320. get worldPosition(): NodeMaterialConnectionPoint;
  66321. /**
  66322. * Gets the world normal input component
  66323. */
  66324. get worldNormal(): NodeMaterialConnectionPoint;
  66325. /**
  66326. * Gets the view matrix parameter
  66327. */
  66328. get view(): NodeMaterialConnectionPoint;
  66329. /**
  66330. * Gets the camera position input component
  66331. */
  66332. get cameraPosition(): NodeMaterialConnectionPoint;
  66333. /**
  66334. * Gets the perturbed normal input component
  66335. */
  66336. get perturbedNormal(): NodeMaterialConnectionPoint;
  66337. /**
  66338. * Gets the base color input component
  66339. */
  66340. get baseColor(): NodeMaterialConnectionPoint;
  66341. /**
  66342. * Gets the metallic input component
  66343. */
  66344. get metallic(): NodeMaterialConnectionPoint;
  66345. /**
  66346. * Gets the roughness input component
  66347. */
  66348. get roughness(): NodeMaterialConnectionPoint;
  66349. /**
  66350. * Gets the ambient occlusion input component
  66351. */
  66352. get ambientOcc(): NodeMaterialConnectionPoint;
  66353. /**
  66354. * Gets the opacity input component
  66355. */
  66356. get opacity(): NodeMaterialConnectionPoint;
  66357. /**
  66358. * Gets the index of refraction input component
  66359. */
  66360. get indexOfRefraction(): NodeMaterialConnectionPoint;
  66361. /**
  66362. * Gets the ambient color input component
  66363. */
  66364. get ambientColor(): NodeMaterialConnectionPoint;
  66365. /**
  66366. * Gets the reflection object parameters
  66367. */
  66368. get reflection(): NodeMaterialConnectionPoint;
  66369. /**
  66370. * Gets the clear coat object parameters
  66371. */
  66372. get clearcoat(): NodeMaterialConnectionPoint;
  66373. /**
  66374. * Gets the sheen object parameters
  66375. */
  66376. get sheen(): NodeMaterialConnectionPoint;
  66377. /**
  66378. * Gets the sub surface object parameters
  66379. */
  66380. get subsurface(): NodeMaterialConnectionPoint;
  66381. /**
  66382. * Gets the anisotropy object parameters
  66383. */
  66384. get anisotropy(): NodeMaterialConnectionPoint;
  66385. /**
  66386. * Gets the ambient output component
  66387. */
  66388. get ambientClr(): NodeMaterialConnectionPoint;
  66389. /**
  66390. * Gets the diffuse output component
  66391. */
  66392. get diffuseDir(): NodeMaterialConnectionPoint;
  66393. /**
  66394. * Gets the specular output component
  66395. */
  66396. get specularDir(): NodeMaterialConnectionPoint;
  66397. /**
  66398. * Gets the clear coat output component
  66399. */
  66400. get clearcoatDir(): NodeMaterialConnectionPoint;
  66401. /**
  66402. * Gets the sheen output component
  66403. */
  66404. get sheenDir(): NodeMaterialConnectionPoint;
  66405. /**
  66406. * Gets the indirect diffuse output component
  66407. */
  66408. get diffuseIndirect(): NodeMaterialConnectionPoint;
  66409. /**
  66410. * Gets the indirect specular output component
  66411. */
  66412. get specularIndirect(): NodeMaterialConnectionPoint;
  66413. /**
  66414. * Gets the indirect clear coat output component
  66415. */
  66416. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  66417. /**
  66418. * Gets the indirect sheen output component
  66419. */
  66420. get sheenIndirect(): NodeMaterialConnectionPoint;
  66421. /**
  66422. * Gets the refraction output component
  66423. */
  66424. get refraction(): NodeMaterialConnectionPoint;
  66425. /**
  66426. * Gets the global lighting output component
  66427. */
  66428. get lighting(): NodeMaterialConnectionPoint;
  66429. /**
  66430. * Gets the shadow output component
  66431. */
  66432. get shadow(): NodeMaterialConnectionPoint;
  66433. /**
  66434. * Gets the alpha output component
  66435. */
  66436. get alpha(): NodeMaterialConnectionPoint;
  66437. autoConfigure(material: NodeMaterial): void;
  66438. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66439. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66440. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66441. private _injectVertexCode;
  66442. private _getAlbedoOpacityCode;
  66443. private _getAmbientOcclusionCode;
  66444. private _getReflectivityCode;
  66445. protected _buildBlock(state: NodeMaterialBuildState): this;
  66446. protected _dumpPropertiesCode(): string;
  66447. serialize(): any;
  66448. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66449. }
  66450. }
  66451. declare module BABYLON {
  66452. /**
  66453. * Block used to compute value of one parameter modulo another
  66454. */
  66455. export class ModBlock extends NodeMaterialBlock {
  66456. /**
  66457. * Creates a new ModBlock
  66458. * @param name defines the block name
  66459. */
  66460. constructor(name: string);
  66461. /**
  66462. * Gets the current class name
  66463. * @returns the class name
  66464. */
  66465. getClassName(): string;
  66466. /**
  66467. * Gets the left operand input component
  66468. */
  66469. get left(): NodeMaterialConnectionPoint;
  66470. /**
  66471. * Gets the right operand input component
  66472. */
  66473. get right(): NodeMaterialConnectionPoint;
  66474. /**
  66475. * Gets the output component
  66476. */
  66477. get output(): NodeMaterialConnectionPoint;
  66478. protected _buildBlock(state: NodeMaterialBuildState): this;
  66479. }
  66480. }
  66481. declare module BABYLON {
  66482. /**
  66483. * Configuration for Draco compression
  66484. */
  66485. export interface IDracoCompressionConfiguration {
  66486. /**
  66487. * Configuration for the decoder.
  66488. */
  66489. decoder: {
  66490. /**
  66491. * The url to the WebAssembly module.
  66492. */
  66493. wasmUrl?: string;
  66494. /**
  66495. * The url to the WebAssembly binary.
  66496. */
  66497. wasmBinaryUrl?: string;
  66498. /**
  66499. * The url to the fallback JavaScript module.
  66500. */
  66501. fallbackUrl?: string;
  66502. };
  66503. }
  66504. /**
  66505. * Draco compression (https://google.github.io/draco/)
  66506. *
  66507. * This class wraps the Draco module.
  66508. *
  66509. * **Encoder**
  66510. *
  66511. * The encoder is not currently implemented.
  66512. *
  66513. * **Decoder**
  66514. *
  66515. * 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.
  66516. *
  66517. * To update the configuration, use the following code:
  66518. * ```javascript
  66519. * DracoCompression.Configuration = {
  66520. * decoder: {
  66521. * wasmUrl: "<url to the WebAssembly library>",
  66522. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  66523. * fallbackUrl: "<url to the fallback JavaScript library>",
  66524. * }
  66525. * };
  66526. * ```
  66527. *
  66528. * 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.
  66529. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  66530. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  66531. *
  66532. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  66533. * ```javascript
  66534. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  66535. * ```
  66536. *
  66537. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  66538. */
  66539. export class DracoCompression implements IDisposable {
  66540. private _workerPoolPromise?;
  66541. private _decoderModulePromise?;
  66542. /**
  66543. * The configuration. Defaults to the following urls:
  66544. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  66545. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  66546. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  66547. */
  66548. static Configuration: IDracoCompressionConfiguration;
  66549. /**
  66550. * Returns true if the decoder configuration is available.
  66551. */
  66552. static get DecoderAvailable(): boolean;
  66553. /**
  66554. * Default number of workers to create when creating the draco compression object.
  66555. */
  66556. static DefaultNumWorkers: number;
  66557. private static GetDefaultNumWorkers;
  66558. private static _Default;
  66559. /**
  66560. * Default instance for the draco compression object.
  66561. */
  66562. static get Default(): DracoCompression;
  66563. /**
  66564. * Constructor
  66565. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  66566. */
  66567. constructor(numWorkers?: number);
  66568. /**
  66569. * Stop all async operations and release resources.
  66570. */
  66571. dispose(): void;
  66572. /**
  66573. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  66574. * @returns a promise that resolves when ready
  66575. */
  66576. whenReadyAsync(): Promise<void>;
  66577. /**
  66578. * Decode Draco compressed mesh data to vertex data.
  66579. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  66580. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  66581. * @returns A promise that resolves with the decoded vertex data
  66582. */
  66583. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  66584. [kind: string]: number;
  66585. }): Promise<VertexData>;
  66586. }
  66587. }
  66588. declare module BABYLON {
  66589. /**
  66590. * Class for building Constructive Solid Geometry
  66591. */
  66592. export class CSG {
  66593. private polygons;
  66594. /**
  66595. * The world matrix
  66596. */
  66597. matrix: Matrix;
  66598. /**
  66599. * Stores the position
  66600. */
  66601. position: Vector3;
  66602. /**
  66603. * Stores the rotation
  66604. */
  66605. rotation: Vector3;
  66606. /**
  66607. * Stores the rotation quaternion
  66608. */
  66609. rotationQuaternion: Nullable<Quaternion>;
  66610. /**
  66611. * Stores the scaling vector
  66612. */
  66613. scaling: Vector3;
  66614. /**
  66615. * Convert the Mesh to CSG
  66616. * @param mesh The Mesh to convert to CSG
  66617. * @returns A new CSG from the Mesh
  66618. */
  66619. static FromMesh(mesh: Mesh): CSG;
  66620. /**
  66621. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  66622. * @param polygons Polygons used to construct a CSG solid
  66623. */
  66624. private static FromPolygons;
  66625. /**
  66626. * Clones, or makes a deep copy, of the CSG
  66627. * @returns A new CSG
  66628. */
  66629. clone(): CSG;
  66630. /**
  66631. * Unions this CSG with another CSG
  66632. * @param csg The CSG to union against this CSG
  66633. * @returns The unioned CSG
  66634. */
  66635. union(csg: CSG): CSG;
  66636. /**
  66637. * Unions this CSG with another CSG in place
  66638. * @param csg The CSG to union against this CSG
  66639. */
  66640. unionInPlace(csg: CSG): void;
  66641. /**
  66642. * Subtracts this CSG with another CSG
  66643. * @param csg The CSG to subtract against this CSG
  66644. * @returns A new CSG
  66645. */
  66646. subtract(csg: CSG): CSG;
  66647. /**
  66648. * Subtracts this CSG with another CSG in place
  66649. * @param csg The CSG to subtact against this CSG
  66650. */
  66651. subtractInPlace(csg: CSG): void;
  66652. /**
  66653. * Intersect this CSG with another CSG
  66654. * @param csg The CSG to intersect against this CSG
  66655. * @returns A new CSG
  66656. */
  66657. intersect(csg: CSG): CSG;
  66658. /**
  66659. * Intersects this CSG with another CSG in place
  66660. * @param csg The CSG to intersect against this CSG
  66661. */
  66662. intersectInPlace(csg: CSG): void;
  66663. /**
  66664. * Return a new CSG solid with solid and empty space switched. This solid is
  66665. * not modified.
  66666. * @returns A new CSG solid with solid and empty space switched
  66667. */
  66668. inverse(): CSG;
  66669. /**
  66670. * Inverses the CSG in place
  66671. */
  66672. inverseInPlace(): void;
  66673. /**
  66674. * This is used to keep meshes transformations so they can be restored
  66675. * when we build back a Babylon Mesh
  66676. * NB : All CSG operations are performed in world coordinates
  66677. * @param csg The CSG to copy the transform attributes from
  66678. * @returns This CSG
  66679. */
  66680. copyTransformAttributes(csg: CSG): CSG;
  66681. /**
  66682. * Build Raw mesh from CSG
  66683. * Coordinates here are in world space
  66684. * @param name The name of the mesh geometry
  66685. * @param scene The Scene
  66686. * @param keepSubMeshes Specifies if the submeshes should be kept
  66687. * @returns A new Mesh
  66688. */
  66689. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66690. /**
  66691. * Build Mesh from CSG taking material and transforms into account
  66692. * @param name The name of the Mesh
  66693. * @param material The material of the Mesh
  66694. * @param scene The Scene
  66695. * @param keepSubMeshes Specifies if submeshes should be kept
  66696. * @returns The new Mesh
  66697. */
  66698. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  66699. }
  66700. }
  66701. declare module BABYLON {
  66702. /**
  66703. * Class used to create a trail following a mesh
  66704. */
  66705. export class TrailMesh extends Mesh {
  66706. private _generator;
  66707. private _autoStart;
  66708. private _running;
  66709. private _diameter;
  66710. private _length;
  66711. private _sectionPolygonPointsCount;
  66712. private _sectionVectors;
  66713. private _sectionNormalVectors;
  66714. private _beforeRenderObserver;
  66715. /**
  66716. * @constructor
  66717. * @param name The value used by scene.getMeshByName() to do a lookup.
  66718. * @param generator The mesh or transform node to generate a trail.
  66719. * @param scene The scene to add this mesh to.
  66720. * @param diameter Diameter of trailing mesh. Default is 1.
  66721. * @param length Length of trailing mesh. Default is 60.
  66722. * @param autoStart Automatically start trailing mesh. Default true.
  66723. */
  66724. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  66725. /**
  66726. * "TrailMesh"
  66727. * @returns "TrailMesh"
  66728. */
  66729. getClassName(): string;
  66730. private _createMesh;
  66731. /**
  66732. * Start trailing mesh.
  66733. */
  66734. start(): void;
  66735. /**
  66736. * Stop trailing mesh.
  66737. */
  66738. stop(): void;
  66739. /**
  66740. * Update trailing mesh geometry.
  66741. */
  66742. update(): void;
  66743. /**
  66744. * Returns a new TrailMesh object.
  66745. * @param name is a string, the name given to the new mesh
  66746. * @param newGenerator use new generator object for cloned trail mesh
  66747. * @returns a new mesh
  66748. */
  66749. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  66750. /**
  66751. * Serializes this trail mesh
  66752. * @param serializationObject object to write serialization to
  66753. */
  66754. serialize(serializationObject: any): void;
  66755. /**
  66756. * Parses a serialized trail mesh
  66757. * @param parsedMesh the serialized mesh
  66758. * @param scene the scene to create the trail mesh in
  66759. * @returns the created trail mesh
  66760. */
  66761. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  66762. }
  66763. }
  66764. declare module BABYLON {
  66765. /**
  66766. * Class containing static functions to help procedurally build meshes
  66767. */
  66768. export class TiledBoxBuilder {
  66769. /**
  66770. * Creates a box mesh
  66771. * 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)
  66772. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66773. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66774. * * 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
  66775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66776. * @param name defines the name of the mesh
  66777. * @param options defines the options used to create the mesh
  66778. * @param scene defines the hosting scene
  66779. * @returns the box mesh
  66780. */
  66781. static CreateTiledBox(name: string, options: {
  66782. pattern?: number;
  66783. width?: number;
  66784. height?: number;
  66785. depth?: number;
  66786. tileSize?: number;
  66787. tileWidth?: number;
  66788. tileHeight?: number;
  66789. alignHorizontal?: number;
  66790. alignVertical?: number;
  66791. faceUV?: Vector4[];
  66792. faceColors?: Color4[];
  66793. sideOrientation?: number;
  66794. updatable?: boolean;
  66795. }, scene?: Nullable<Scene>): Mesh;
  66796. }
  66797. }
  66798. declare module BABYLON {
  66799. /**
  66800. * Class containing static functions to help procedurally build meshes
  66801. */
  66802. export class TorusKnotBuilder {
  66803. /**
  66804. * Creates a torus knot mesh
  66805. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66806. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66807. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66808. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66810. * * 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
  66811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66812. * @param name defines the name of the mesh
  66813. * @param options defines the options used to create the mesh
  66814. * @param scene defines the hosting scene
  66815. * @returns the torus knot mesh
  66816. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66817. */
  66818. static CreateTorusKnot(name: string, options: {
  66819. radius?: number;
  66820. tube?: number;
  66821. radialSegments?: number;
  66822. tubularSegments?: number;
  66823. p?: number;
  66824. q?: number;
  66825. updatable?: boolean;
  66826. sideOrientation?: number;
  66827. frontUVs?: Vector4;
  66828. backUVs?: Vector4;
  66829. }, scene: any): Mesh;
  66830. }
  66831. }
  66832. declare module BABYLON {
  66833. /**
  66834. * Polygon
  66835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  66836. */
  66837. export class Polygon {
  66838. /**
  66839. * Creates a rectangle
  66840. * @param xmin bottom X coord
  66841. * @param ymin bottom Y coord
  66842. * @param xmax top X coord
  66843. * @param ymax top Y coord
  66844. * @returns points that make the resulting rectation
  66845. */
  66846. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66847. /**
  66848. * Creates a circle
  66849. * @param radius radius of circle
  66850. * @param cx scale in x
  66851. * @param cy scale in y
  66852. * @param numberOfSides number of sides that make up the circle
  66853. * @returns points that make the resulting circle
  66854. */
  66855. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66856. /**
  66857. * Creates a polygon from input string
  66858. * @param input Input polygon data
  66859. * @returns the parsed points
  66860. */
  66861. static Parse(input: string): Vector2[];
  66862. /**
  66863. * Starts building a polygon from x and y coordinates
  66864. * @param x x coordinate
  66865. * @param y y coordinate
  66866. * @returns the started path2
  66867. */
  66868. static StartingAt(x: number, y: number): Path2;
  66869. }
  66870. /**
  66871. * Builds a polygon
  66872. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66873. */
  66874. export class PolygonMeshBuilder {
  66875. private _points;
  66876. private _outlinepoints;
  66877. private _holes;
  66878. private _name;
  66879. private _scene;
  66880. private _epoints;
  66881. private _eholes;
  66882. private _addToepoint;
  66883. /**
  66884. * Babylon reference to the earcut plugin.
  66885. */
  66886. bjsEarcut: any;
  66887. /**
  66888. * Creates a PolygonMeshBuilder
  66889. * @param name name of the builder
  66890. * @param contours Path of the polygon
  66891. * @param scene scene to add to when creating the mesh
  66892. * @param earcutInjection can be used to inject your own earcut reference
  66893. */
  66894. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66895. /**
  66896. * Adds a whole within the polygon
  66897. * @param hole Array of points defining the hole
  66898. * @returns this
  66899. */
  66900. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66901. /**
  66902. * Creates the polygon
  66903. * @param updatable If the mesh should be updatable
  66904. * @param depth The depth of the mesh created
  66905. * @returns the created mesh
  66906. */
  66907. build(updatable?: boolean, depth?: number): Mesh;
  66908. /**
  66909. * Creates the polygon
  66910. * @param depth The depth of the mesh created
  66911. * @returns the created VertexData
  66912. */
  66913. buildVertexData(depth?: number): VertexData;
  66914. /**
  66915. * Adds a side to the polygon
  66916. * @param positions points that make the polygon
  66917. * @param normals normals of the polygon
  66918. * @param uvs uvs of the polygon
  66919. * @param indices indices of the polygon
  66920. * @param bounds bounds of the polygon
  66921. * @param points points of the polygon
  66922. * @param depth depth of the polygon
  66923. * @param flip flip of the polygon
  66924. */
  66925. private addSide;
  66926. }
  66927. }
  66928. declare module BABYLON {
  66929. /**
  66930. * Class containing static functions to help procedurally build meshes
  66931. */
  66932. export class PolygonBuilder {
  66933. /**
  66934. * Creates a polygon mesh
  66935. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66936. * * 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
  66937. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66939. * * 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)
  66940. * * Remember you can only change the shape positions, not their number when updating a polygon
  66941. * @param name defines the name of the mesh
  66942. * @param options defines the options used to create the mesh
  66943. * @param scene defines the hosting scene
  66944. * @param earcutInjection can be used to inject your own earcut reference
  66945. * @returns the polygon mesh
  66946. */
  66947. static CreatePolygon(name: string, options: {
  66948. shape: Vector3[];
  66949. holes?: Vector3[][];
  66950. depth?: number;
  66951. faceUV?: Vector4[];
  66952. faceColors?: Color4[];
  66953. updatable?: boolean;
  66954. sideOrientation?: number;
  66955. frontUVs?: Vector4;
  66956. backUVs?: Vector4;
  66957. wrap?: boolean;
  66958. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66959. /**
  66960. * Creates an extruded polygon mesh, with depth in the Y direction.
  66961. * * 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)
  66962. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66963. * @param name defines the name of the mesh
  66964. * @param options defines the options used to create the mesh
  66965. * @param scene defines the hosting scene
  66966. * @param earcutInjection can be used to inject your own earcut reference
  66967. * @returns the polygon mesh
  66968. */
  66969. static ExtrudePolygon(name: string, options: {
  66970. shape: Vector3[];
  66971. holes?: Vector3[][];
  66972. depth?: number;
  66973. faceUV?: Vector4[];
  66974. faceColors?: Color4[];
  66975. updatable?: boolean;
  66976. sideOrientation?: number;
  66977. frontUVs?: Vector4;
  66978. backUVs?: Vector4;
  66979. wrap?: boolean;
  66980. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66981. }
  66982. }
  66983. declare module BABYLON {
  66984. /**
  66985. * Class containing static functions to help procedurally build meshes
  66986. */
  66987. export class LatheBuilder {
  66988. /**
  66989. * Creates lathe mesh.
  66990. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66991. * * 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
  66992. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66993. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66994. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66995. * * 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
  66996. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66997. * * 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
  66998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66999. * * 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
  67000. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67002. * @param name defines the name of the mesh
  67003. * @param options defines the options used to create the mesh
  67004. * @param scene defines the hosting scene
  67005. * @returns the lathe mesh
  67006. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67007. */
  67008. static CreateLathe(name: string, options: {
  67009. shape: Vector3[];
  67010. radius?: number;
  67011. tessellation?: number;
  67012. clip?: number;
  67013. arc?: number;
  67014. closed?: boolean;
  67015. updatable?: boolean;
  67016. sideOrientation?: number;
  67017. frontUVs?: Vector4;
  67018. backUVs?: Vector4;
  67019. cap?: number;
  67020. invertUV?: boolean;
  67021. }, scene?: Nullable<Scene>): Mesh;
  67022. }
  67023. }
  67024. declare module BABYLON {
  67025. /**
  67026. * Class containing static functions to help procedurally build meshes
  67027. */
  67028. export class TiledPlaneBuilder {
  67029. /**
  67030. * Creates a tiled plane mesh
  67031. * * The parameter `pattern` will, depending on value, do nothing or
  67032. * * * flip (reflect about central vertical) alternate tiles across and up
  67033. * * * flip every tile on alternate rows
  67034. * * * rotate (180 degs) alternate tiles across and up
  67035. * * * rotate every tile on alternate rows
  67036. * * * flip and rotate alternate tiles across and up
  67037. * * * flip and rotate every tile on alternate rows
  67038. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  67039. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  67040. * * 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
  67041. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67042. * * 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)
  67043. * * 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)
  67044. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67045. * @param name defines the name of the mesh
  67046. * @param options defines the options used to create the mesh
  67047. * @param scene defines the hosting scene
  67048. * @returns the box mesh
  67049. */
  67050. static CreateTiledPlane(name: string, options: {
  67051. pattern?: number;
  67052. tileSize?: number;
  67053. tileWidth?: number;
  67054. tileHeight?: number;
  67055. size?: number;
  67056. width?: number;
  67057. height?: number;
  67058. alignHorizontal?: number;
  67059. alignVertical?: number;
  67060. sideOrientation?: number;
  67061. frontUVs?: Vector4;
  67062. backUVs?: Vector4;
  67063. updatable?: boolean;
  67064. }, scene?: Nullable<Scene>): Mesh;
  67065. }
  67066. }
  67067. declare module BABYLON {
  67068. /**
  67069. * Class containing static functions to help procedurally build meshes
  67070. */
  67071. export class TubeBuilder {
  67072. /**
  67073. * Creates a tube mesh.
  67074. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67075. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67076. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67077. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67078. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67079. * * 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)
  67080. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67081. * * 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
  67082. * * 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
  67083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67084. * * 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
  67085. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67087. * @param name defines the name of the mesh
  67088. * @param options defines the options used to create the mesh
  67089. * @param scene defines the hosting scene
  67090. * @returns the tube mesh
  67091. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67092. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67093. */
  67094. static CreateTube(name: string, options: {
  67095. path: Vector3[];
  67096. radius?: number;
  67097. tessellation?: number;
  67098. radiusFunction?: {
  67099. (i: number, distance: number): number;
  67100. };
  67101. cap?: number;
  67102. arc?: number;
  67103. updatable?: boolean;
  67104. sideOrientation?: number;
  67105. frontUVs?: Vector4;
  67106. backUVs?: Vector4;
  67107. instance?: Mesh;
  67108. invertUV?: boolean;
  67109. }, scene?: Nullable<Scene>): Mesh;
  67110. }
  67111. }
  67112. declare module BABYLON {
  67113. /**
  67114. * Class containing static functions to help procedurally build meshes
  67115. */
  67116. export class IcoSphereBuilder {
  67117. /**
  67118. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67119. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67120. * * 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`)
  67121. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67122. * * 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
  67123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67124. * * 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
  67125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67126. * @param name defines the name of the mesh
  67127. * @param options defines the options used to create the mesh
  67128. * @param scene defines the hosting scene
  67129. * @returns the icosahedron mesh
  67130. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67131. */
  67132. static CreateIcoSphere(name: string, options: {
  67133. radius?: number;
  67134. radiusX?: number;
  67135. radiusY?: number;
  67136. radiusZ?: number;
  67137. flat?: boolean;
  67138. subdivisions?: number;
  67139. sideOrientation?: number;
  67140. frontUVs?: Vector4;
  67141. backUVs?: Vector4;
  67142. updatable?: boolean;
  67143. }, scene?: Nullable<Scene>): Mesh;
  67144. }
  67145. }
  67146. declare module BABYLON {
  67147. /**
  67148. * Class containing static functions to help procedurally build meshes
  67149. */
  67150. export class DecalBuilder {
  67151. /**
  67152. * Creates a decal mesh.
  67153. * 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
  67154. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67155. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67156. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67157. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67158. * @param name defines the name of the mesh
  67159. * @param sourceMesh defines the mesh where the decal must be applied
  67160. * @param options defines the options used to create the mesh
  67161. * @param scene defines the hosting scene
  67162. * @returns the decal mesh
  67163. * @see https://doc.babylonjs.com/how_to/decals
  67164. */
  67165. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67166. position?: Vector3;
  67167. normal?: Vector3;
  67168. size?: Vector3;
  67169. angle?: number;
  67170. }): Mesh;
  67171. }
  67172. }
  67173. declare module BABYLON {
  67174. /**
  67175. * Class containing static functions to help procedurally build meshes
  67176. */
  67177. export class MeshBuilder {
  67178. /**
  67179. * Creates a box mesh
  67180. * * The parameter `size` sets the size (float) of each box side (default 1)
  67181. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  67182. * * 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)
  67183. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67185. * * 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
  67186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67187. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  67188. * @param name defines the name of the mesh
  67189. * @param options defines the options used to create the mesh
  67190. * @param scene defines the hosting scene
  67191. * @returns the box mesh
  67192. */
  67193. static CreateBox(name: string, options: {
  67194. size?: number;
  67195. width?: number;
  67196. height?: number;
  67197. depth?: number;
  67198. faceUV?: Vector4[];
  67199. faceColors?: Color4[];
  67200. sideOrientation?: number;
  67201. frontUVs?: Vector4;
  67202. backUVs?: Vector4;
  67203. wrap?: boolean;
  67204. topBaseAt?: number;
  67205. bottomBaseAt?: number;
  67206. updatable?: boolean;
  67207. }, scene?: Nullable<Scene>): Mesh;
  67208. /**
  67209. * Creates a tiled box mesh
  67210. * * faceTiles sets the pattern, tile size and number of tiles for a face
  67211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67212. * @param name defines the name of the mesh
  67213. * @param options defines the options used to create the mesh
  67214. * @param scene defines the hosting scene
  67215. * @returns the tiled box mesh
  67216. */
  67217. static CreateTiledBox(name: string, options: {
  67218. pattern?: number;
  67219. size?: number;
  67220. width?: number;
  67221. height?: number;
  67222. depth: number;
  67223. tileSize?: number;
  67224. tileWidth?: number;
  67225. tileHeight?: number;
  67226. faceUV?: Vector4[];
  67227. faceColors?: Color4[];
  67228. alignHorizontal?: number;
  67229. alignVertical?: number;
  67230. sideOrientation?: number;
  67231. updatable?: boolean;
  67232. }, scene?: Nullable<Scene>): Mesh;
  67233. /**
  67234. * Creates a sphere mesh
  67235. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  67236. * * 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`)
  67237. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  67238. * * 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
  67239. * * 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)
  67240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67241. * * 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
  67242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67243. * @param name defines the name of the mesh
  67244. * @param options defines the options used to create the mesh
  67245. * @param scene defines the hosting scene
  67246. * @returns the sphere mesh
  67247. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  67248. */
  67249. static CreateSphere(name: string, options: {
  67250. segments?: number;
  67251. diameter?: number;
  67252. diameterX?: number;
  67253. diameterY?: number;
  67254. diameterZ?: number;
  67255. arc?: number;
  67256. slice?: number;
  67257. sideOrientation?: number;
  67258. frontUVs?: Vector4;
  67259. backUVs?: Vector4;
  67260. updatable?: boolean;
  67261. }, scene?: Nullable<Scene>): Mesh;
  67262. /**
  67263. * Creates a plane polygonal mesh. By default, this is a disc
  67264. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  67265. * * 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
  67266. * * 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
  67267. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67268. * * 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
  67269. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67270. * @param name defines the name of the mesh
  67271. * @param options defines the options used to create the mesh
  67272. * @param scene defines the hosting scene
  67273. * @returns the plane polygonal mesh
  67274. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  67275. */
  67276. static CreateDisc(name: string, options: {
  67277. radius?: number;
  67278. tessellation?: number;
  67279. arc?: number;
  67280. updatable?: boolean;
  67281. sideOrientation?: number;
  67282. frontUVs?: Vector4;
  67283. backUVs?: Vector4;
  67284. }, scene?: Nullable<Scene>): Mesh;
  67285. /**
  67286. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  67287. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  67288. * * 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`)
  67289. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  67290. * * 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
  67291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67292. * * 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
  67293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67294. * @param name defines the name of the mesh
  67295. * @param options defines the options used to create the mesh
  67296. * @param scene defines the hosting scene
  67297. * @returns the icosahedron mesh
  67298. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  67299. */
  67300. static CreateIcoSphere(name: string, options: {
  67301. radius?: number;
  67302. radiusX?: number;
  67303. radiusY?: number;
  67304. radiusZ?: number;
  67305. flat?: boolean;
  67306. subdivisions?: number;
  67307. sideOrientation?: number;
  67308. frontUVs?: Vector4;
  67309. backUVs?: Vector4;
  67310. updatable?: boolean;
  67311. }, scene?: Nullable<Scene>): Mesh;
  67312. /**
  67313. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67314. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  67315. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  67316. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  67317. * * 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
  67318. * * 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
  67319. * * 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
  67320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67321. * * 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
  67322. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67323. * * 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
  67324. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  67325. * * 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
  67326. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  67327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67328. * @param name defines the name of the mesh
  67329. * @param options defines the options used to create the mesh
  67330. * @param scene defines the hosting scene
  67331. * @returns the ribbon mesh
  67332. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  67333. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67334. */
  67335. static CreateRibbon(name: string, options: {
  67336. pathArray: Vector3[][];
  67337. closeArray?: boolean;
  67338. closePath?: boolean;
  67339. offset?: number;
  67340. updatable?: boolean;
  67341. sideOrientation?: number;
  67342. frontUVs?: Vector4;
  67343. backUVs?: Vector4;
  67344. instance?: Mesh;
  67345. invertUV?: boolean;
  67346. uvs?: Vector2[];
  67347. colors?: Color4[];
  67348. }, scene?: Nullable<Scene>): Mesh;
  67349. /**
  67350. * Creates a cylinder or a cone mesh
  67351. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  67352. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  67353. * * 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.
  67354. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  67355. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  67356. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  67357. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  67358. * * 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).
  67359. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  67360. * * 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).
  67361. * * 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
  67362. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  67363. * * 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
  67364. * * 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.
  67365. * * If `enclose` is false, a ring surface is one element.
  67366. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  67367. * * 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
  67368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67369. * * 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
  67370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67371. * @param name defines the name of the mesh
  67372. * @param options defines the options used to create the mesh
  67373. * @param scene defines the hosting scene
  67374. * @returns the cylinder mesh
  67375. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  67376. */
  67377. static CreateCylinder(name: string, options: {
  67378. height?: number;
  67379. diameterTop?: number;
  67380. diameterBottom?: number;
  67381. diameter?: number;
  67382. tessellation?: number;
  67383. subdivisions?: number;
  67384. arc?: number;
  67385. faceColors?: Color4[];
  67386. faceUV?: Vector4[];
  67387. updatable?: boolean;
  67388. hasRings?: boolean;
  67389. enclose?: boolean;
  67390. cap?: number;
  67391. sideOrientation?: number;
  67392. frontUVs?: Vector4;
  67393. backUVs?: Vector4;
  67394. }, scene?: Nullable<Scene>): Mesh;
  67395. /**
  67396. * Creates a torus mesh
  67397. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  67398. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  67399. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  67400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67401. * * 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
  67402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67403. * @param name defines the name of the mesh
  67404. * @param options defines the options used to create the mesh
  67405. * @param scene defines the hosting scene
  67406. * @returns the torus mesh
  67407. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  67408. */
  67409. static CreateTorus(name: string, options: {
  67410. diameter?: number;
  67411. thickness?: number;
  67412. tessellation?: number;
  67413. updatable?: boolean;
  67414. sideOrientation?: number;
  67415. frontUVs?: Vector4;
  67416. backUVs?: Vector4;
  67417. }, scene?: Nullable<Scene>): Mesh;
  67418. /**
  67419. * Creates a torus knot mesh
  67420. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67421. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67422. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67423. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67424. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67425. * * 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
  67426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67427. * @param name defines the name of the mesh
  67428. * @param options defines the options used to create the mesh
  67429. * @param scene defines the hosting scene
  67430. * @returns the torus knot mesh
  67431. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67432. */
  67433. static CreateTorusKnot(name: string, options: {
  67434. radius?: number;
  67435. tube?: number;
  67436. radialSegments?: number;
  67437. tubularSegments?: number;
  67438. p?: number;
  67439. q?: number;
  67440. updatable?: boolean;
  67441. sideOrientation?: number;
  67442. frontUVs?: Vector4;
  67443. backUVs?: Vector4;
  67444. }, scene?: Nullable<Scene>): Mesh;
  67445. /**
  67446. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  67447. * * 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
  67448. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  67449. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  67450. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  67451. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  67452. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  67453. * * 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
  67454. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  67455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  67457. * @param name defines the name of the new line system
  67458. * @param options defines the options used to create the line system
  67459. * @param scene defines the hosting scene
  67460. * @returns a new line system mesh
  67461. */
  67462. static CreateLineSystem(name: string, options: {
  67463. lines: Vector3[][];
  67464. updatable?: boolean;
  67465. instance?: Nullable<LinesMesh>;
  67466. colors?: Nullable<Color4[][]>;
  67467. useVertexAlpha?: boolean;
  67468. }, scene: Nullable<Scene>): LinesMesh;
  67469. /**
  67470. * Creates a line mesh
  67471. * 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
  67472. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67473. * * The parameter `points` is an array successive Vector3
  67474. * * 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
  67475. * * The optional parameter `colors` is an array of successive Color4, one per line point
  67476. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  67477. * * When updating an instance, remember that only point positions can change, not the number of points
  67478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67479. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  67480. * @param name defines the name of the new line system
  67481. * @param options defines the options used to create the line system
  67482. * @param scene defines the hosting scene
  67483. * @returns a new line mesh
  67484. */
  67485. static CreateLines(name: string, options: {
  67486. points: Vector3[];
  67487. updatable?: boolean;
  67488. instance?: Nullable<LinesMesh>;
  67489. colors?: Color4[];
  67490. useVertexAlpha?: boolean;
  67491. }, scene?: Nullable<Scene>): LinesMesh;
  67492. /**
  67493. * Creates a dashed line mesh
  67494. * * 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
  67495. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  67496. * * The parameter `points` is an array successive Vector3
  67497. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  67498. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  67499. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  67500. * * 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
  67501. * * When updating an instance, remember that only point positions can change, not the number of points
  67502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67503. * @param name defines the name of the mesh
  67504. * @param options defines the options used to create the mesh
  67505. * @param scene defines the hosting scene
  67506. * @returns the dashed line mesh
  67507. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  67508. */
  67509. static CreateDashedLines(name: string, options: {
  67510. points: Vector3[];
  67511. dashSize?: number;
  67512. gapSize?: number;
  67513. dashNb?: number;
  67514. updatable?: boolean;
  67515. instance?: LinesMesh;
  67516. }, scene?: Nullable<Scene>): LinesMesh;
  67517. /**
  67518. * 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.
  67519. * * 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.
  67520. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67521. * * 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.
  67522. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  67523. * * 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
  67524. * * 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
  67525. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  67526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67527. * * 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
  67528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  67529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67530. * @param name defines the name of the mesh
  67531. * @param options defines the options used to create the mesh
  67532. * @param scene defines the hosting scene
  67533. * @returns the extruded shape mesh
  67534. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67535. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67536. */
  67537. static ExtrudeShape(name: string, options: {
  67538. shape: Vector3[];
  67539. path: Vector3[];
  67540. scale?: number;
  67541. rotation?: number;
  67542. cap?: number;
  67543. updatable?: boolean;
  67544. sideOrientation?: number;
  67545. frontUVs?: Vector4;
  67546. backUVs?: Vector4;
  67547. instance?: Mesh;
  67548. invertUV?: boolean;
  67549. }, scene?: Nullable<Scene>): Mesh;
  67550. /**
  67551. * Creates an custom extruded shape mesh.
  67552. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  67553. * * 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.
  67554. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  67555. * * 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
  67556. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  67557. * * 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
  67558. * * It must returns a float value that will be the scale value applied to the shape on each path point
  67559. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  67560. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  67561. * * 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
  67562. * * 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
  67563. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  67564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67565. * * 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
  67566. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67568. * @param name defines the name of the mesh
  67569. * @param options defines the options used to create the mesh
  67570. * @param scene defines the hosting scene
  67571. * @returns the custom extruded shape mesh
  67572. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  67573. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  67575. */
  67576. static ExtrudeShapeCustom(name: string, options: {
  67577. shape: Vector3[];
  67578. path: Vector3[];
  67579. scaleFunction?: any;
  67580. rotationFunction?: any;
  67581. ribbonCloseArray?: boolean;
  67582. ribbonClosePath?: boolean;
  67583. cap?: number;
  67584. updatable?: boolean;
  67585. sideOrientation?: number;
  67586. frontUVs?: Vector4;
  67587. backUVs?: Vector4;
  67588. instance?: Mesh;
  67589. invertUV?: boolean;
  67590. }, scene?: Nullable<Scene>): Mesh;
  67591. /**
  67592. * Creates lathe mesh.
  67593. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67594. * * 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
  67595. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67596. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67597. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67598. * * 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
  67599. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67600. * * 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
  67601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67602. * * 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
  67603. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67605. * @param name defines the name of the mesh
  67606. * @param options defines the options used to create the mesh
  67607. * @param scene defines the hosting scene
  67608. * @returns the lathe mesh
  67609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67610. */
  67611. static CreateLathe(name: string, options: {
  67612. shape: Vector3[];
  67613. radius?: number;
  67614. tessellation?: number;
  67615. clip?: number;
  67616. arc?: number;
  67617. closed?: boolean;
  67618. updatable?: boolean;
  67619. sideOrientation?: number;
  67620. frontUVs?: Vector4;
  67621. backUVs?: Vector4;
  67622. cap?: number;
  67623. invertUV?: boolean;
  67624. }, scene?: Nullable<Scene>): Mesh;
  67625. /**
  67626. * Creates a tiled plane mesh
  67627. * * You can set a limited pattern arrangement with the tiles
  67628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67629. * * 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
  67630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67631. * @param name defines the name of the mesh
  67632. * @param options defines the options used to create the mesh
  67633. * @param scene defines the hosting scene
  67634. * @returns the plane mesh
  67635. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67636. */
  67637. static CreateTiledPlane(name: string, options: {
  67638. pattern?: number;
  67639. tileSize?: number;
  67640. tileWidth?: number;
  67641. tileHeight?: number;
  67642. size?: number;
  67643. width?: number;
  67644. height?: number;
  67645. alignHorizontal?: number;
  67646. alignVertical?: number;
  67647. sideOrientation?: number;
  67648. frontUVs?: Vector4;
  67649. backUVs?: Vector4;
  67650. updatable?: boolean;
  67651. }, scene?: Nullable<Scene>): Mesh;
  67652. /**
  67653. * Creates a plane mesh
  67654. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  67655. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  67656. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  67657. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67658. * * 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
  67659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67660. * @param name defines the name of the mesh
  67661. * @param options defines the options used to create the mesh
  67662. * @param scene defines the hosting scene
  67663. * @returns the plane mesh
  67664. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  67665. */
  67666. static CreatePlane(name: string, options: {
  67667. size?: number;
  67668. width?: number;
  67669. height?: number;
  67670. sideOrientation?: number;
  67671. frontUVs?: Vector4;
  67672. backUVs?: Vector4;
  67673. updatable?: boolean;
  67674. sourcePlane?: Plane;
  67675. }, scene?: Nullable<Scene>): Mesh;
  67676. /**
  67677. * Creates a ground mesh
  67678. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  67679. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  67680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67681. * @param name defines the name of the mesh
  67682. * @param options defines the options used to create the mesh
  67683. * @param scene defines the hosting scene
  67684. * @returns the ground mesh
  67685. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  67686. */
  67687. static CreateGround(name: string, options: {
  67688. width?: number;
  67689. height?: number;
  67690. subdivisions?: number;
  67691. subdivisionsX?: number;
  67692. subdivisionsY?: number;
  67693. updatable?: boolean;
  67694. }, scene?: Nullable<Scene>): Mesh;
  67695. /**
  67696. * Creates a tiled ground mesh
  67697. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  67698. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  67699. * * 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
  67700. * * 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
  67701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67702. * @param name defines the name of the mesh
  67703. * @param options defines the options used to create the mesh
  67704. * @param scene defines the hosting scene
  67705. * @returns the tiled ground mesh
  67706. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  67707. */
  67708. static CreateTiledGround(name: string, options: {
  67709. xmin: number;
  67710. zmin: number;
  67711. xmax: number;
  67712. zmax: number;
  67713. subdivisions?: {
  67714. w: number;
  67715. h: number;
  67716. };
  67717. precision?: {
  67718. w: number;
  67719. h: number;
  67720. };
  67721. updatable?: boolean;
  67722. }, scene?: Nullable<Scene>): Mesh;
  67723. /**
  67724. * Creates a ground mesh from a height map
  67725. * * The parameter `url` sets the URL of the height map image resource.
  67726. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  67727. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  67728. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  67729. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  67730. * * 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.
  67731. * * 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).
  67732. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  67733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67734. * @param name defines the name of the mesh
  67735. * @param url defines the url to the height map
  67736. * @param options defines the options used to create the mesh
  67737. * @param scene defines the hosting scene
  67738. * @returns the ground mesh
  67739. * @see https://doc.babylonjs.com/babylon101/height_map
  67740. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  67741. */
  67742. static CreateGroundFromHeightMap(name: string, url: string, options: {
  67743. width?: number;
  67744. height?: number;
  67745. subdivisions?: number;
  67746. minHeight?: number;
  67747. maxHeight?: number;
  67748. colorFilter?: Color3;
  67749. alphaFilter?: number;
  67750. updatable?: boolean;
  67751. onReady?: (mesh: GroundMesh) => void;
  67752. }, scene?: Nullable<Scene>): GroundMesh;
  67753. /**
  67754. * Creates a polygon mesh
  67755. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67756. * * 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
  67757. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67759. * * 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)
  67760. * * Remember you can only change the shape positions, not their number when updating a polygon
  67761. * @param name defines the name of the mesh
  67762. * @param options defines the options used to create the mesh
  67763. * @param scene defines the hosting scene
  67764. * @param earcutInjection can be used to inject your own earcut reference
  67765. * @returns the polygon mesh
  67766. */
  67767. static CreatePolygon(name: string, options: {
  67768. shape: Vector3[];
  67769. holes?: Vector3[][];
  67770. depth?: number;
  67771. faceUV?: Vector4[];
  67772. faceColors?: Color4[];
  67773. updatable?: boolean;
  67774. sideOrientation?: number;
  67775. frontUVs?: Vector4;
  67776. backUVs?: Vector4;
  67777. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67778. /**
  67779. * Creates an extruded polygon mesh, with depth in the Y direction.
  67780. * * 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)
  67781. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67782. * @param name defines the name of the mesh
  67783. * @param options defines the options used to create the mesh
  67784. * @param scene defines the hosting scene
  67785. * @param earcutInjection can be used to inject your own earcut reference
  67786. * @returns the polygon mesh
  67787. */
  67788. static ExtrudePolygon(name: string, options: {
  67789. shape: Vector3[];
  67790. holes?: Vector3[][];
  67791. depth?: number;
  67792. faceUV?: Vector4[];
  67793. faceColors?: Color4[];
  67794. updatable?: boolean;
  67795. sideOrientation?: number;
  67796. frontUVs?: Vector4;
  67797. backUVs?: Vector4;
  67798. wrap?: boolean;
  67799. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67800. /**
  67801. * Creates a tube mesh.
  67802. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  67803. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  67804. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  67805. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  67806. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  67807. * * 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)
  67808. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  67809. * * 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
  67810. * * 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
  67811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67812. * * 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
  67813. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67815. * @param name defines the name of the mesh
  67816. * @param options defines the options used to create the mesh
  67817. * @param scene defines the hosting scene
  67818. * @returns the tube mesh
  67819. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  67820. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  67821. */
  67822. static CreateTube(name: string, options: {
  67823. path: Vector3[];
  67824. radius?: number;
  67825. tessellation?: number;
  67826. radiusFunction?: {
  67827. (i: number, distance: number): number;
  67828. };
  67829. cap?: number;
  67830. arc?: number;
  67831. updatable?: boolean;
  67832. sideOrientation?: number;
  67833. frontUVs?: Vector4;
  67834. backUVs?: Vector4;
  67835. instance?: Mesh;
  67836. invertUV?: boolean;
  67837. }, scene?: Nullable<Scene>): Mesh;
  67838. /**
  67839. * Creates a polyhedron mesh
  67840. * * 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
  67841. * * The parameter `size` (positive float, default 1) sets the polygon size
  67842. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67843. * * 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`
  67844. * * 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
  67845. * * 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)`)
  67846. * * 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
  67847. * * 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
  67848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67849. * * 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
  67850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67851. * @param name defines the name of the mesh
  67852. * @param options defines the options used to create the mesh
  67853. * @param scene defines the hosting scene
  67854. * @returns the polyhedron mesh
  67855. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67856. */
  67857. static CreatePolyhedron(name: string, options: {
  67858. type?: number;
  67859. size?: number;
  67860. sizeX?: number;
  67861. sizeY?: number;
  67862. sizeZ?: number;
  67863. custom?: any;
  67864. faceUV?: Vector4[];
  67865. faceColors?: Color4[];
  67866. flat?: boolean;
  67867. updatable?: boolean;
  67868. sideOrientation?: number;
  67869. frontUVs?: Vector4;
  67870. backUVs?: Vector4;
  67871. }, scene?: Nullable<Scene>): Mesh;
  67872. /**
  67873. * Creates a decal mesh.
  67874. * 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
  67875. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67876. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67877. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67878. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67879. * @param name defines the name of the mesh
  67880. * @param sourceMesh defines the mesh where the decal must be applied
  67881. * @param options defines the options used to create the mesh
  67882. * @param scene defines the hosting scene
  67883. * @returns the decal mesh
  67884. * @see https://doc.babylonjs.com/how_to/decals
  67885. */
  67886. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67887. position?: Vector3;
  67888. normal?: Vector3;
  67889. size?: Vector3;
  67890. angle?: number;
  67891. }): Mesh;
  67892. /**
  67893. * Creates a Capsule Mesh
  67894. * @param name defines the name of the mesh.
  67895. * @param options the constructors options used to shape the mesh.
  67896. * @param scene defines the scene the mesh is scoped to.
  67897. * @returns the capsule mesh
  67898. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67899. */
  67900. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67901. }
  67902. }
  67903. declare module BABYLON {
  67904. /**
  67905. * A simplifier interface for future simplification implementations
  67906. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67907. */
  67908. export interface ISimplifier {
  67909. /**
  67910. * Simplification of a given mesh according to the given settings.
  67911. * Since this requires computation, it is assumed that the function runs async.
  67912. * @param settings The settings of the simplification, including quality and distance
  67913. * @param successCallback A callback that will be called after the mesh was simplified.
  67914. * @param errorCallback in case of an error, this callback will be called. optional.
  67915. */
  67916. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67917. }
  67918. /**
  67919. * Expected simplification settings.
  67920. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67921. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67922. */
  67923. export interface ISimplificationSettings {
  67924. /**
  67925. * Gets or sets the expected quality
  67926. */
  67927. quality: number;
  67928. /**
  67929. * Gets or sets the distance when this optimized version should be used
  67930. */
  67931. distance: number;
  67932. /**
  67933. * Gets an already optimized mesh
  67934. */
  67935. optimizeMesh?: boolean;
  67936. }
  67937. /**
  67938. * Class used to specify simplification options
  67939. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67940. */
  67941. export class SimplificationSettings implements ISimplificationSettings {
  67942. /** expected quality */
  67943. quality: number;
  67944. /** distance when this optimized version should be used */
  67945. distance: number;
  67946. /** already optimized mesh */
  67947. optimizeMesh?: boolean | undefined;
  67948. /**
  67949. * Creates a SimplificationSettings
  67950. * @param quality expected quality
  67951. * @param distance distance when this optimized version should be used
  67952. * @param optimizeMesh already optimized mesh
  67953. */
  67954. constructor(
  67955. /** expected quality */
  67956. quality: number,
  67957. /** distance when this optimized version should be used */
  67958. distance: number,
  67959. /** already optimized mesh */
  67960. optimizeMesh?: boolean | undefined);
  67961. }
  67962. /**
  67963. * Interface used to define a simplification task
  67964. */
  67965. export interface ISimplificationTask {
  67966. /**
  67967. * Array of settings
  67968. */
  67969. settings: Array<ISimplificationSettings>;
  67970. /**
  67971. * Simplification type
  67972. */
  67973. simplificationType: SimplificationType;
  67974. /**
  67975. * Mesh to simplify
  67976. */
  67977. mesh: Mesh;
  67978. /**
  67979. * Callback called on success
  67980. */
  67981. successCallback?: () => void;
  67982. /**
  67983. * Defines if parallel processing can be used
  67984. */
  67985. parallelProcessing: boolean;
  67986. }
  67987. /**
  67988. * Queue used to order the simplification tasks
  67989. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67990. */
  67991. export class SimplificationQueue {
  67992. private _simplificationArray;
  67993. /**
  67994. * Gets a boolean indicating that the process is still running
  67995. */
  67996. running: boolean;
  67997. /**
  67998. * Creates a new queue
  67999. */
  68000. constructor();
  68001. /**
  68002. * Adds a new simplification task
  68003. * @param task defines a task to add
  68004. */
  68005. addTask(task: ISimplificationTask): void;
  68006. /**
  68007. * Execute next task
  68008. */
  68009. executeNext(): void;
  68010. /**
  68011. * Execute a simplification task
  68012. * @param task defines the task to run
  68013. */
  68014. runSimplification(task: ISimplificationTask): void;
  68015. private getSimplifier;
  68016. }
  68017. /**
  68018. * The implemented types of simplification
  68019. * At the moment only Quadratic Error Decimation is implemented
  68020. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68021. */
  68022. export enum SimplificationType {
  68023. /** Quadratic error decimation */
  68024. QUADRATIC = 0
  68025. }
  68026. /**
  68027. * An implementation of the Quadratic Error simplification algorithm.
  68028. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  68029. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  68030. * @author RaananW
  68031. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68032. */
  68033. export class QuadraticErrorSimplification implements ISimplifier {
  68034. private _mesh;
  68035. private triangles;
  68036. private vertices;
  68037. private references;
  68038. private _reconstructedMesh;
  68039. /** Gets or sets the number pf sync interations */
  68040. syncIterations: number;
  68041. /** Gets or sets the aggressiveness of the simplifier */
  68042. aggressiveness: number;
  68043. /** Gets or sets the number of allowed iterations for decimation */
  68044. decimationIterations: number;
  68045. /** Gets or sets the espilon to use for bounding box computation */
  68046. boundingBoxEpsilon: number;
  68047. /**
  68048. * Creates a new QuadraticErrorSimplification
  68049. * @param _mesh defines the target mesh
  68050. */
  68051. constructor(_mesh: Mesh);
  68052. /**
  68053. * Simplification of a given mesh according to the given settings.
  68054. * Since this requires computation, it is assumed that the function runs async.
  68055. * @param settings The settings of the simplification, including quality and distance
  68056. * @param successCallback A callback that will be called after the mesh was simplified.
  68057. */
  68058. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  68059. private runDecimation;
  68060. private initWithMesh;
  68061. private init;
  68062. private reconstructMesh;
  68063. private initDecimatedMesh;
  68064. private isFlipped;
  68065. private updateTriangles;
  68066. private identifyBorder;
  68067. private updateMesh;
  68068. private vertexError;
  68069. private calculateError;
  68070. }
  68071. }
  68072. declare module BABYLON {
  68073. interface Scene {
  68074. /** @hidden (Backing field) */
  68075. _simplificationQueue: SimplificationQueue;
  68076. /**
  68077. * Gets or sets the simplification queue attached to the scene
  68078. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68079. */
  68080. simplificationQueue: SimplificationQueue;
  68081. }
  68082. interface Mesh {
  68083. /**
  68084. * Simplify the mesh according to the given array of settings.
  68085. * Function will return immediately and will simplify async
  68086. * @param settings a collection of simplification settings
  68087. * @param parallelProcessing should all levels calculate parallel or one after the other
  68088. * @param simplificationType the type of simplification to run
  68089. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  68090. * @returns the current mesh
  68091. */
  68092. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  68093. }
  68094. /**
  68095. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  68096. * created in a scene
  68097. */
  68098. export class SimplicationQueueSceneComponent implements ISceneComponent {
  68099. /**
  68100. * The component name helpfull to identify the component in the list of scene components.
  68101. */
  68102. readonly name: string;
  68103. /**
  68104. * The scene the component belongs to.
  68105. */
  68106. scene: Scene;
  68107. /**
  68108. * Creates a new instance of the component for the given scene
  68109. * @param scene Defines the scene to register the component in
  68110. */
  68111. constructor(scene: Scene);
  68112. /**
  68113. * Registers the component in a given scene
  68114. */
  68115. register(): void;
  68116. /**
  68117. * Rebuilds the elements related to this component in case of
  68118. * context lost for instance.
  68119. */
  68120. rebuild(): void;
  68121. /**
  68122. * Disposes the component and the associated ressources
  68123. */
  68124. dispose(): void;
  68125. private _beforeCameraUpdate;
  68126. }
  68127. }
  68128. declare module BABYLON {
  68129. interface Mesh {
  68130. /**
  68131. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  68132. */
  68133. thinInstanceEnablePicking: boolean;
  68134. /**
  68135. * Creates a new thin instance
  68136. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  68137. * @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
  68138. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  68139. */
  68140. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  68141. /**
  68142. * Adds the transformation (matrix) of the current mesh as a thin instance
  68143. * @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
  68144. * @returns the thin instance index number
  68145. */
  68146. thinInstanceAddSelf(refresh: boolean): number;
  68147. /**
  68148. * Registers a custom attribute to be used with thin instances
  68149. * @param kind name of the attribute
  68150. * @param stride size in floats of the attribute
  68151. */
  68152. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  68153. /**
  68154. * Sets the matrix of a thin instance
  68155. * @param index index of the thin instance
  68156. * @param matrix matrix to set
  68157. * @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
  68158. */
  68159. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  68160. /**
  68161. * Sets the value of a custom attribute for a thin instance
  68162. * @param kind name of the attribute
  68163. * @param index index of the thin instance
  68164. * @param value value to set
  68165. * @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
  68166. */
  68167. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  68168. /**
  68169. * 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.
  68170. */
  68171. thinInstanceCount: number;
  68172. /**
  68173. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  68174. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  68175. * @param buffer buffer to set
  68176. * @param stride size in floats of each value of the buffer
  68177. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  68178. */
  68179. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  68180. /**
  68181. * Gets the list of world matrices
  68182. * @return an array containing all the world matrices from the thin instances
  68183. */
  68184. thinInstanceGetWorldMatrices(): Matrix[];
  68185. /**
  68186. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  68187. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68188. */
  68189. thinInstanceBufferUpdated(kind: string): void;
  68190. /**
  68191. * Applies a partial update to a buffer directly on the GPU
  68192. * 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
  68193. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  68194. * @param data the data to set in the GPU buffer
  68195. * @param offset the offset in the GPU buffer where to update the data
  68196. */
  68197. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  68198. /**
  68199. * Refreshes the bounding info, taking into account all the thin instances defined
  68200. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  68201. */
  68202. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  68203. /** @hidden */
  68204. _thinInstanceInitializeUserStorage(): void;
  68205. /** @hidden */
  68206. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  68207. /** @hidden */
  68208. _userThinInstanceBuffersStorage: {
  68209. data: {
  68210. [key: string]: Float32Array;
  68211. };
  68212. sizes: {
  68213. [key: string]: number;
  68214. };
  68215. vertexBuffers: {
  68216. [key: string]: Nullable<VertexBuffer>;
  68217. };
  68218. strides: {
  68219. [key: string]: number;
  68220. };
  68221. };
  68222. }
  68223. }
  68224. declare module BABYLON {
  68225. /**
  68226. * Navigation plugin interface to add navigation constrained by a navigation mesh
  68227. */
  68228. export interface INavigationEnginePlugin {
  68229. /**
  68230. * plugin name
  68231. */
  68232. name: string;
  68233. /**
  68234. * Creates a navigation mesh
  68235. * @param meshes array of all the geometry used to compute the navigatio mesh
  68236. * @param parameters bunch of parameters used to filter geometry
  68237. */
  68238. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68239. /**
  68240. * Create a navigation mesh debug mesh
  68241. * @param scene is where the mesh will be added
  68242. * @returns debug display mesh
  68243. */
  68244. createDebugNavMesh(scene: Scene): Mesh;
  68245. /**
  68246. * Get a navigation mesh constrained position, closest to the parameter position
  68247. * @param position world position
  68248. * @returns the closest point to position constrained by the navigation mesh
  68249. */
  68250. getClosestPoint(position: Vector3): Vector3;
  68251. /**
  68252. * Get a navigation mesh constrained position, closest to the parameter position
  68253. * @param position world position
  68254. * @param result output the closest point to position constrained by the navigation mesh
  68255. */
  68256. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68257. /**
  68258. * Get a navigation mesh constrained position, within a particular radius
  68259. * @param position world position
  68260. * @param maxRadius the maximum distance to the constrained world position
  68261. * @returns the closest point to position constrained by the navigation mesh
  68262. */
  68263. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68264. /**
  68265. * Get a navigation mesh constrained position, within a particular radius
  68266. * @param position world position
  68267. * @param maxRadius the maximum distance to the constrained world position
  68268. * @param result output the closest point to position constrained by the navigation mesh
  68269. */
  68270. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68271. /**
  68272. * Compute the final position from a segment made of destination-position
  68273. * @param position world position
  68274. * @param destination world position
  68275. * @returns the resulting point along the navmesh
  68276. */
  68277. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68278. /**
  68279. * Compute the final position from a segment made of destination-position
  68280. * @param position world position
  68281. * @param destination world position
  68282. * @param result output the resulting point along the navmesh
  68283. */
  68284. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68285. /**
  68286. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68287. * @param start world position
  68288. * @param end world position
  68289. * @returns array containing world position composing the path
  68290. */
  68291. computePath(start: Vector3, end: Vector3): Vector3[];
  68292. /**
  68293. * If this plugin is supported
  68294. * @returns true if plugin is supported
  68295. */
  68296. isSupported(): boolean;
  68297. /**
  68298. * Create a new Crowd so you can add agents
  68299. * @param maxAgents the maximum agent count in the crowd
  68300. * @param maxAgentRadius the maximum radius an agent can have
  68301. * @param scene to attach the crowd to
  68302. * @returns the crowd you can add agents to
  68303. */
  68304. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68305. /**
  68306. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68307. * The queries will try to find a solution within those bounds
  68308. * default is (1,1,1)
  68309. * @param extent x,y,z value that define the extent around the queries point of reference
  68310. */
  68311. setDefaultQueryExtent(extent: Vector3): void;
  68312. /**
  68313. * Get the Bounding box extent specified by setDefaultQueryExtent
  68314. * @returns the box extent values
  68315. */
  68316. getDefaultQueryExtent(): Vector3;
  68317. /**
  68318. * build the navmesh from a previously saved state using getNavmeshData
  68319. * @param data the Uint8Array returned by getNavmeshData
  68320. */
  68321. buildFromNavmeshData(data: Uint8Array): void;
  68322. /**
  68323. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68324. * @returns data the Uint8Array that can be saved and reused
  68325. */
  68326. getNavmeshData(): Uint8Array;
  68327. /**
  68328. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68329. * @param result output the box extent values
  68330. */
  68331. getDefaultQueryExtentToRef(result: Vector3): void;
  68332. /**
  68333. * Set the time step of the navigation tick update.
  68334. * Default is 1/60.
  68335. * A value of 0 will disable fixed time update
  68336. * @param newTimeStep the new timestep to apply to this world.
  68337. */
  68338. setTimeStep(newTimeStep: number): void;
  68339. /**
  68340. * Get the time step of the navigation tick update.
  68341. * @returns the current time step
  68342. */
  68343. getTimeStep(): number;
  68344. /**
  68345. * If delta time in navigation tick update is greater than the time step
  68346. * a number of sub iterations are done. If more iterations are need to reach deltatime
  68347. * they will be discarded.
  68348. * A value of 0 will set to no maximum and update will use as many substeps as needed
  68349. * @param newStepCount the maximum number of iterations
  68350. */
  68351. setMaximumSubStepCount(newStepCount: number): void;
  68352. /**
  68353. * Get the maximum number of iterations per navigation tick update
  68354. * @returns the maximum number of iterations
  68355. */
  68356. getMaximumSubStepCount(): number;
  68357. /**
  68358. * Release all resources
  68359. */
  68360. dispose(): void;
  68361. }
  68362. /**
  68363. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  68364. */
  68365. export interface ICrowd {
  68366. /**
  68367. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68368. * You can attach anything to that node. The node position is updated in the scene update tick.
  68369. * @param pos world position that will be constrained by the navigation mesh
  68370. * @param parameters agent parameters
  68371. * @param transform hooked to the agent that will be update by the scene
  68372. * @returns agent index
  68373. */
  68374. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68375. /**
  68376. * Returns the agent position in world space
  68377. * @param index agent index returned by addAgent
  68378. * @returns world space position
  68379. */
  68380. getAgentPosition(index: number): Vector3;
  68381. /**
  68382. * Gets the agent position result in world space
  68383. * @param index agent index returned by addAgent
  68384. * @param result output world space position
  68385. */
  68386. getAgentPositionToRef(index: number, result: Vector3): void;
  68387. /**
  68388. * Gets the agent velocity in world space
  68389. * @param index agent index returned by addAgent
  68390. * @returns world space velocity
  68391. */
  68392. getAgentVelocity(index: number): Vector3;
  68393. /**
  68394. * Gets the agent velocity result in world space
  68395. * @param index agent index returned by addAgent
  68396. * @param result output world space velocity
  68397. */
  68398. getAgentVelocityToRef(index: number, result: Vector3): void;
  68399. /**
  68400. * Gets the agent next target point on the path
  68401. * @param index agent index returned by addAgent
  68402. * @returns world space position
  68403. */
  68404. getAgentNextTargetPath(index: number): Vector3;
  68405. /**
  68406. * Gets the agent state
  68407. * @param index agent index returned by addAgent
  68408. * @returns agent state
  68409. */
  68410. getAgentState(index: number): number;
  68411. /**
  68412. * returns true if the agent in over an off mesh link connection
  68413. * @param index agent index returned by addAgent
  68414. * @returns true if over an off mesh link connection
  68415. */
  68416. overOffmeshConnection(index: number): boolean;
  68417. /**
  68418. * Gets the agent next target point on the path
  68419. * @param index agent index returned by addAgent
  68420. * @param result output world space position
  68421. */
  68422. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68423. /**
  68424. * remove a particular agent previously created
  68425. * @param index agent index returned by addAgent
  68426. */
  68427. removeAgent(index: number): void;
  68428. /**
  68429. * get the list of all agents attached to this crowd
  68430. * @returns list of agent indices
  68431. */
  68432. getAgents(): number[];
  68433. /**
  68434. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68435. * @param deltaTime in seconds
  68436. */
  68437. update(deltaTime: number): void;
  68438. /**
  68439. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68440. * @param index agent index returned by addAgent
  68441. * @param destination targeted world position
  68442. */
  68443. agentGoto(index: number, destination: Vector3): void;
  68444. /**
  68445. * Teleport the agent to a new position
  68446. * @param index agent index returned by addAgent
  68447. * @param destination targeted world position
  68448. */
  68449. agentTeleport(index: number, destination: Vector3): void;
  68450. /**
  68451. * Update agent parameters
  68452. * @param index agent index returned by addAgent
  68453. * @param parameters agent parameters
  68454. */
  68455. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68456. /**
  68457. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68458. * The queries will try to find a solution within those bounds
  68459. * default is (1,1,1)
  68460. * @param extent x,y,z value that define the extent around the queries point of reference
  68461. */
  68462. setDefaultQueryExtent(extent: Vector3): void;
  68463. /**
  68464. * Get the Bounding box extent specified by setDefaultQueryExtent
  68465. * @returns the box extent values
  68466. */
  68467. getDefaultQueryExtent(): Vector3;
  68468. /**
  68469. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68470. * @param result output the box extent values
  68471. */
  68472. getDefaultQueryExtentToRef(result: Vector3): void;
  68473. /**
  68474. * Release all resources
  68475. */
  68476. dispose(): void;
  68477. }
  68478. /**
  68479. * Configures an agent
  68480. */
  68481. export interface IAgentParameters {
  68482. /**
  68483. * Agent radius. [Limit: >= 0]
  68484. */
  68485. radius: number;
  68486. /**
  68487. * Agent height. [Limit: > 0]
  68488. */
  68489. height: number;
  68490. /**
  68491. * Maximum allowed acceleration. [Limit: >= 0]
  68492. */
  68493. maxAcceleration: number;
  68494. /**
  68495. * Maximum allowed speed. [Limit: >= 0]
  68496. */
  68497. maxSpeed: number;
  68498. /**
  68499. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  68500. */
  68501. collisionQueryRange: number;
  68502. /**
  68503. * The path visibility optimization range. [Limit: > 0]
  68504. */
  68505. pathOptimizationRange: number;
  68506. /**
  68507. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  68508. */
  68509. separationWeight: number;
  68510. }
  68511. /**
  68512. * Configures the navigation mesh creation
  68513. */
  68514. export interface INavMeshParameters {
  68515. /**
  68516. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  68517. */
  68518. cs: number;
  68519. /**
  68520. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  68521. */
  68522. ch: number;
  68523. /**
  68524. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  68525. */
  68526. walkableSlopeAngle: number;
  68527. /**
  68528. * Minimum floor to 'ceiling' height that will still allow the floor area to
  68529. * be considered walkable. [Limit: >= 3] [Units: vx]
  68530. */
  68531. walkableHeight: number;
  68532. /**
  68533. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  68534. */
  68535. walkableClimb: number;
  68536. /**
  68537. * The distance to erode/shrink the walkable area of the heightfield away from
  68538. * obstructions. [Limit: >=0] [Units: vx]
  68539. */
  68540. walkableRadius: number;
  68541. /**
  68542. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  68543. */
  68544. maxEdgeLen: number;
  68545. /**
  68546. * The maximum distance a simplfied contour's border edges should deviate
  68547. * the original raw contour. [Limit: >=0] [Units: vx]
  68548. */
  68549. maxSimplificationError: number;
  68550. /**
  68551. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  68552. */
  68553. minRegionArea: number;
  68554. /**
  68555. * Any regions with a span count smaller than this value will, if possible,
  68556. * be merged with larger regions. [Limit: >=0] [Units: vx]
  68557. */
  68558. mergeRegionArea: number;
  68559. /**
  68560. * The maximum number of vertices allowed for polygons generated during the
  68561. * contour to polygon conversion process. [Limit: >= 3]
  68562. */
  68563. maxVertsPerPoly: number;
  68564. /**
  68565. * Sets the sampling distance to use when generating the detail mesh.
  68566. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  68567. */
  68568. detailSampleDist: number;
  68569. /**
  68570. * The maximum distance the detail mesh surface should deviate from heightfield
  68571. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  68572. */
  68573. detailSampleMaxError: number;
  68574. }
  68575. }
  68576. declare module BABYLON {
  68577. /**
  68578. * RecastJS navigation plugin
  68579. */
  68580. export class RecastJSPlugin implements INavigationEnginePlugin {
  68581. /**
  68582. * Reference to the Recast library
  68583. */
  68584. bjsRECAST: any;
  68585. /**
  68586. * plugin name
  68587. */
  68588. name: string;
  68589. /**
  68590. * the first navmesh created. We might extend this to support multiple navmeshes
  68591. */
  68592. navMesh: any;
  68593. private _maximumSubStepCount;
  68594. private _timeStep;
  68595. /**
  68596. * Initializes the recastJS plugin
  68597. * @param recastInjection can be used to inject your own recast reference
  68598. */
  68599. constructor(recastInjection?: any);
  68600. /**
  68601. * Set the time step of the navigation tick update.
  68602. * Default is 1/60.
  68603. * A value of 0 will disable fixed time update
  68604. * @param newTimeStep the new timestep to apply to this world.
  68605. */
  68606. setTimeStep(newTimeStep?: number): void;
  68607. /**
  68608. * Get the time step of the navigation tick update.
  68609. * @returns the current time step
  68610. */
  68611. getTimeStep(): number;
  68612. /**
  68613. * If delta time in navigation tick update is greater than the time step
  68614. * a number of sub iterations are done. If more iterations are need to reach deltatime
  68615. * they will be discarded.
  68616. * A value of 0 will set to no maximum and update will use as many substeps as needed
  68617. * @param newStepCount the maximum number of iterations
  68618. */
  68619. setMaximumSubStepCount(newStepCount?: number): void;
  68620. /**
  68621. * Get the maximum number of iterations per navigation tick update
  68622. * @returns the maximum number of iterations
  68623. */
  68624. getMaximumSubStepCount(): number;
  68625. /**
  68626. * Creates a navigation mesh
  68627. * @param meshes array of all the geometry used to compute the navigatio mesh
  68628. * @param parameters bunch of parameters used to filter geometry
  68629. */
  68630. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  68631. /**
  68632. * Create a navigation mesh debug mesh
  68633. * @param scene is where the mesh will be added
  68634. * @returns debug display mesh
  68635. */
  68636. createDebugNavMesh(scene: Scene): Mesh;
  68637. /**
  68638. * Get a navigation mesh constrained position, closest to the parameter position
  68639. * @param position world position
  68640. * @returns the closest point to position constrained by the navigation mesh
  68641. */
  68642. getClosestPoint(position: Vector3): Vector3;
  68643. /**
  68644. * Get a navigation mesh constrained position, closest to the parameter position
  68645. * @param position world position
  68646. * @param result output the closest point to position constrained by the navigation mesh
  68647. */
  68648. getClosestPointToRef(position: Vector3, result: Vector3): void;
  68649. /**
  68650. * Get a navigation mesh constrained position, within a particular radius
  68651. * @param position world position
  68652. * @param maxRadius the maximum distance to the constrained world position
  68653. * @returns the closest point to position constrained by the navigation mesh
  68654. */
  68655. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  68656. /**
  68657. * Get a navigation mesh constrained position, within a particular radius
  68658. * @param position world position
  68659. * @param maxRadius the maximum distance to the constrained world position
  68660. * @param result output the closest point to position constrained by the navigation mesh
  68661. */
  68662. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  68663. /**
  68664. * Compute the final position from a segment made of destination-position
  68665. * @param position world position
  68666. * @param destination world position
  68667. * @returns the resulting point along the navmesh
  68668. */
  68669. moveAlong(position: Vector3, destination: Vector3): Vector3;
  68670. /**
  68671. * Compute the final position from a segment made of destination-position
  68672. * @param position world position
  68673. * @param destination world position
  68674. * @param result output the resulting point along the navmesh
  68675. */
  68676. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  68677. /**
  68678. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  68679. * @param start world position
  68680. * @param end world position
  68681. * @returns array containing world position composing the path
  68682. */
  68683. computePath(start: Vector3, end: Vector3): Vector3[];
  68684. /**
  68685. * Create a new Crowd so you can add agents
  68686. * @param maxAgents the maximum agent count in the crowd
  68687. * @param maxAgentRadius the maximum radius an agent can have
  68688. * @param scene to attach the crowd to
  68689. * @returns the crowd you can add agents to
  68690. */
  68691. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  68692. /**
  68693. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68694. * The queries will try to find a solution within those bounds
  68695. * default is (1,1,1)
  68696. * @param extent x,y,z value that define the extent around the queries point of reference
  68697. */
  68698. setDefaultQueryExtent(extent: Vector3): void;
  68699. /**
  68700. * Get the Bounding box extent specified by setDefaultQueryExtent
  68701. * @returns the box extent values
  68702. */
  68703. getDefaultQueryExtent(): Vector3;
  68704. /**
  68705. * build the navmesh from a previously saved state using getNavmeshData
  68706. * @param data the Uint8Array returned by getNavmeshData
  68707. */
  68708. buildFromNavmeshData(data: Uint8Array): void;
  68709. /**
  68710. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  68711. * @returns data the Uint8Array that can be saved and reused
  68712. */
  68713. getNavmeshData(): Uint8Array;
  68714. /**
  68715. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68716. * @param result output the box extent values
  68717. */
  68718. getDefaultQueryExtentToRef(result: Vector3): void;
  68719. /**
  68720. * Disposes
  68721. */
  68722. dispose(): void;
  68723. /**
  68724. * If this plugin is supported
  68725. * @returns true if plugin is supported
  68726. */
  68727. isSupported(): boolean;
  68728. }
  68729. /**
  68730. * Recast detour crowd implementation
  68731. */
  68732. export class RecastJSCrowd implements ICrowd {
  68733. /**
  68734. * Recast/detour plugin
  68735. */
  68736. bjsRECASTPlugin: RecastJSPlugin;
  68737. /**
  68738. * Link to the detour crowd
  68739. */
  68740. recastCrowd: any;
  68741. /**
  68742. * One transform per agent
  68743. */
  68744. transforms: TransformNode[];
  68745. /**
  68746. * All agents created
  68747. */
  68748. agents: number[];
  68749. /**
  68750. * Link to the scene is kept to unregister the crowd from the scene
  68751. */
  68752. private _scene;
  68753. /**
  68754. * Observer for crowd updates
  68755. */
  68756. private _onBeforeAnimationsObserver;
  68757. /**
  68758. * Constructor
  68759. * @param plugin recastJS plugin
  68760. * @param maxAgents the maximum agent count in the crowd
  68761. * @param maxAgentRadius the maximum radius an agent can have
  68762. * @param scene to attach the crowd to
  68763. * @returns the crowd you can add agents to
  68764. */
  68765. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  68766. /**
  68767. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  68768. * You can attach anything to that node. The node position is updated in the scene update tick.
  68769. * @param pos world position that will be constrained by the navigation mesh
  68770. * @param parameters agent parameters
  68771. * @param transform hooked to the agent that will be update by the scene
  68772. * @returns agent index
  68773. */
  68774. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  68775. /**
  68776. * Returns the agent position in world space
  68777. * @param index agent index returned by addAgent
  68778. * @returns world space position
  68779. */
  68780. getAgentPosition(index: number): Vector3;
  68781. /**
  68782. * Returns the agent position result in world space
  68783. * @param index agent index returned by addAgent
  68784. * @param result output world space position
  68785. */
  68786. getAgentPositionToRef(index: number, result: Vector3): void;
  68787. /**
  68788. * Returns the agent velocity in world space
  68789. * @param index agent index returned by addAgent
  68790. * @returns world space velocity
  68791. */
  68792. getAgentVelocity(index: number): Vector3;
  68793. /**
  68794. * Returns the agent velocity result in world space
  68795. * @param index agent index returned by addAgent
  68796. * @param result output world space velocity
  68797. */
  68798. getAgentVelocityToRef(index: number, result: Vector3): void;
  68799. /**
  68800. * Returns the agent next target point on the path
  68801. * @param index agent index returned by addAgent
  68802. * @returns world space position
  68803. */
  68804. getAgentNextTargetPath(index: number): Vector3;
  68805. /**
  68806. * Returns the agent next target point on the path
  68807. * @param index agent index returned by addAgent
  68808. * @param result output world space position
  68809. */
  68810. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  68811. /**
  68812. * Gets the agent state
  68813. * @param index agent index returned by addAgent
  68814. * @returns agent state
  68815. */
  68816. getAgentState(index: number): number;
  68817. /**
  68818. * returns true if the agent in over an off mesh link connection
  68819. * @param index agent index returned by addAgent
  68820. * @returns true if over an off mesh link connection
  68821. */
  68822. overOffmeshConnection(index: number): boolean;
  68823. /**
  68824. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  68825. * @param index agent index returned by addAgent
  68826. * @param destination targeted world position
  68827. */
  68828. agentGoto(index: number, destination: Vector3): void;
  68829. /**
  68830. * Teleport the agent to a new position
  68831. * @param index agent index returned by addAgent
  68832. * @param destination targeted world position
  68833. */
  68834. agentTeleport(index: number, destination: Vector3): void;
  68835. /**
  68836. * Update agent parameters
  68837. * @param index agent index returned by addAgent
  68838. * @param parameters agent parameters
  68839. */
  68840. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  68841. /**
  68842. * remove a particular agent previously created
  68843. * @param index agent index returned by addAgent
  68844. */
  68845. removeAgent(index: number): void;
  68846. /**
  68847. * get the list of all agents attached to this crowd
  68848. * @returns list of agent indices
  68849. */
  68850. getAgents(): number[];
  68851. /**
  68852. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  68853. * @param deltaTime in seconds
  68854. */
  68855. update(deltaTime: number): void;
  68856. /**
  68857. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  68858. * The queries will try to find a solution within those bounds
  68859. * default is (1,1,1)
  68860. * @param extent x,y,z value that define the extent around the queries point of reference
  68861. */
  68862. setDefaultQueryExtent(extent: Vector3): void;
  68863. /**
  68864. * Get the Bounding box extent specified by setDefaultQueryExtent
  68865. * @returns the box extent values
  68866. */
  68867. getDefaultQueryExtent(): Vector3;
  68868. /**
  68869. * Get the Bounding box extent result specified by setDefaultQueryExtent
  68870. * @param result output the box extent values
  68871. */
  68872. getDefaultQueryExtentToRef(result: Vector3): void;
  68873. /**
  68874. * Release all resources
  68875. */
  68876. dispose(): void;
  68877. }
  68878. }
  68879. declare module BABYLON {
  68880. /**
  68881. * Class used to enable access to IndexedDB
  68882. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68883. */
  68884. export class Database implements IOfflineProvider {
  68885. private _callbackManifestChecked;
  68886. private _currentSceneUrl;
  68887. private _db;
  68888. private _enableSceneOffline;
  68889. private _enableTexturesOffline;
  68890. private _manifestVersionFound;
  68891. private _mustUpdateRessources;
  68892. private _hasReachedQuota;
  68893. private _isSupported;
  68894. private _idbFactory;
  68895. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  68896. private static IsUASupportingBlobStorage;
  68897. /**
  68898. * Gets a boolean indicating if Database storate is enabled (off by default)
  68899. */
  68900. static IDBStorageEnabled: boolean;
  68901. /**
  68902. * Gets a boolean indicating if scene must be saved in the database
  68903. */
  68904. get enableSceneOffline(): boolean;
  68905. /**
  68906. * Gets a boolean indicating if textures must be saved in the database
  68907. */
  68908. get enableTexturesOffline(): boolean;
  68909. /**
  68910. * Creates a new Database
  68911. * @param urlToScene defines the url to load the scene
  68912. * @param callbackManifestChecked defines the callback to use when manifest is checked
  68913. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  68914. */
  68915. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  68916. private static _ParseURL;
  68917. private static _ReturnFullUrlLocation;
  68918. private _checkManifestFile;
  68919. /**
  68920. * Open the database and make it available
  68921. * @param successCallback defines the callback to call on success
  68922. * @param errorCallback defines the callback to call on error
  68923. */
  68924. open(successCallback: () => void, errorCallback: () => void): void;
  68925. /**
  68926. * Loads an image from the database
  68927. * @param url defines the url to load from
  68928. * @param image defines the target DOM image
  68929. */
  68930. loadImage(url: string, image: HTMLImageElement): void;
  68931. private _loadImageFromDBAsync;
  68932. private _saveImageIntoDBAsync;
  68933. private _checkVersionFromDB;
  68934. private _loadVersionFromDBAsync;
  68935. private _saveVersionIntoDBAsync;
  68936. /**
  68937. * Loads a file from database
  68938. * @param url defines the URL to load from
  68939. * @param sceneLoaded defines a callback to call on success
  68940. * @param progressCallBack defines a callback to call when progress changed
  68941. * @param errorCallback defines a callback to call on error
  68942. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68943. */
  68944. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68945. private _loadFileAsync;
  68946. private _saveFileAsync;
  68947. /**
  68948. * Validates if xhr data is correct
  68949. * @param xhr defines the request to validate
  68950. * @param dataType defines the expected data type
  68951. * @returns true if data is correct
  68952. */
  68953. private static _ValidateXHRData;
  68954. }
  68955. }
  68956. declare module BABYLON {
  68957. /** @hidden */
  68958. export var gpuUpdateParticlesPixelShader: {
  68959. name: string;
  68960. shader: string;
  68961. };
  68962. }
  68963. declare module BABYLON {
  68964. /** @hidden */
  68965. export var gpuUpdateParticlesVertexShader: {
  68966. name: string;
  68967. shader: string;
  68968. };
  68969. }
  68970. declare module BABYLON {
  68971. /** @hidden */
  68972. export var clipPlaneFragmentDeclaration2: {
  68973. name: string;
  68974. shader: string;
  68975. };
  68976. }
  68977. declare module BABYLON {
  68978. /** @hidden */
  68979. export var gpuRenderParticlesPixelShader: {
  68980. name: string;
  68981. shader: string;
  68982. };
  68983. }
  68984. declare module BABYLON {
  68985. /** @hidden */
  68986. export var clipPlaneVertexDeclaration2: {
  68987. name: string;
  68988. shader: string;
  68989. };
  68990. }
  68991. declare module BABYLON {
  68992. /** @hidden */
  68993. export var gpuRenderParticlesVertexShader: {
  68994. name: string;
  68995. shader: string;
  68996. };
  68997. }
  68998. declare module BABYLON {
  68999. /**
  69000. * This represents a GPU particle system in Babylon
  69001. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69002. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69003. */
  69004. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69005. /**
  69006. * The layer mask we are rendering the particles through.
  69007. */
  69008. layerMask: number;
  69009. private _capacity;
  69010. private _activeCount;
  69011. private _currentActiveCount;
  69012. private _accumulatedCount;
  69013. private _renderEffect;
  69014. private _updateEffect;
  69015. private _buffer0;
  69016. private _buffer1;
  69017. private _spriteBuffer;
  69018. private _updateVAO;
  69019. private _renderVAO;
  69020. private _targetIndex;
  69021. private _sourceBuffer;
  69022. private _targetBuffer;
  69023. private _currentRenderId;
  69024. private _started;
  69025. private _stopped;
  69026. private _timeDelta;
  69027. private _randomTexture;
  69028. private _randomTexture2;
  69029. private _attributesStrideSize;
  69030. private _updateEffectOptions;
  69031. private _randomTextureSize;
  69032. private _actualFrame;
  69033. private _customEffect;
  69034. private readonly _rawTextureWidth;
  69035. /**
  69036. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  69037. */
  69038. static get IsSupported(): boolean;
  69039. /**
  69040. * An event triggered when the system is disposed.
  69041. */
  69042. onDisposeObservable: Observable<IParticleSystem>;
  69043. /**
  69044. * An event triggered when the system is stopped
  69045. */
  69046. onStoppedObservable: Observable<IParticleSystem>;
  69047. /**
  69048. * Gets the maximum number of particles active at the same time.
  69049. * @returns The max number of active particles.
  69050. */
  69051. getCapacity(): number;
  69052. /**
  69053. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69054. * to override the particles.
  69055. */
  69056. forceDepthWrite: boolean;
  69057. /**
  69058. * Gets or set the number of active particles
  69059. */
  69060. get activeParticleCount(): number;
  69061. set activeParticleCount(value: number);
  69062. private _preWarmDone;
  69063. /**
  69064. * Specifies if the particles are updated in emitter local space or world space.
  69065. */
  69066. isLocal: boolean;
  69067. /** Gets or sets a matrix to use to compute projection */
  69068. defaultProjectionMatrix: Matrix;
  69069. /**
  69070. * Is this system ready to be used/rendered
  69071. * @return true if the system is ready
  69072. */
  69073. isReady(): boolean;
  69074. /**
  69075. * Gets if the system has been started. (Note: this will still be true after stop is called)
  69076. * @returns True if it has been started, otherwise false.
  69077. */
  69078. isStarted(): boolean;
  69079. /**
  69080. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  69081. * @returns True if it has been stopped, otherwise false.
  69082. */
  69083. isStopped(): boolean;
  69084. /**
  69085. * Gets a boolean indicating that the system is stopping
  69086. * @returns true if the system is currently stopping
  69087. */
  69088. isStopping(): boolean;
  69089. /**
  69090. * Gets the number of particles active at the same time.
  69091. * @returns The number of active particles.
  69092. */
  69093. getActiveCount(): number;
  69094. /**
  69095. * Starts the particle system and begins to emit
  69096. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  69097. */
  69098. start(delay?: number): void;
  69099. /**
  69100. * Stops the particle system.
  69101. */
  69102. stop(): void;
  69103. /**
  69104. * Remove all active particles
  69105. */
  69106. reset(): void;
  69107. /**
  69108. * Returns the string "GPUParticleSystem"
  69109. * @returns a string containing the class name
  69110. */
  69111. getClassName(): string;
  69112. /**
  69113. * Gets the custom effect used to render the particles
  69114. * @param blendMode Blend mode for which the effect should be retrieved
  69115. * @returns The effect
  69116. */
  69117. getCustomEffect(blendMode?: number): Nullable<Effect>;
  69118. /**
  69119. * Sets the custom effect used to render the particles
  69120. * @param effect The effect to set
  69121. * @param blendMode Blend mode for which the effect should be set
  69122. */
  69123. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  69124. /** @hidden */
  69125. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  69126. /**
  69127. * Observable that will be called just before the particles are drawn
  69128. */
  69129. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  69130. /**
  69131. * Gets the name of the particle vertex shader
  69132. */
  69133. get vertexShaderName(): string;
  69134. private _colorGradientsTexture;
  69135. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  69136. /**
  69137. * Adds a new color gradient
  69138. * @param gradient defines the gradient to use (between 0 and 1)
  69139. * @param color1 defines the color to affect to the specified gradient
  69140. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  69141. * @returns the current particle system
  69142. */
  69143. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  69144. private _refreshColorGradient;
  69145. /** Force the system to rebuild all gradients that need to be resync */
  69146. forceRefreshGradients(): void;
  69147. /**
  69148. * Remove a specific color gradient
  69149. * @param gradient defines the gradient to remove
  69150. * @returns the current particle system
  69151. */
  69152. removeColorGradient(gradient: number): GPUParticleSystem;
  69153. private _angularSpeedGradientsTexture;
  69154. private _sizeGradientsTexture;
  69155. private _velocityGradientsTexture;
  69156. private _limitVelocityGradientsTexture;
  69157. private _dragGradientsTexture;
  69158. private _addFactorGradient;
  69159. /**
  69160. * Adds a new size gradient
  69161. * @param gradient defines the gradient to use (between 0 and 1)
  69162. * @param factor defines the size factor to affect to the specified gradient
  69163. * @returns the current particle system
  69164. */
  69165. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  69166. /**
  69167. * Remove a specific size gradient
  69168. * @param gradient defines the gradient to remove
  69169. * @returns the current particle system
  69170. */
  69171. removeSizeGradient(gradient: number): GPUParticleSystem;
  69172. private _refreshFactorGradient;
  69173. /**
  69174. * Adds a new angular speed gradient
  69175. * @param gradient defines the gradient to use (between 0 and 1)
  69176. * @param factor defines the angular speed to affect to the specified gradient
  69177. * @returns the current particle system
  69178. */
  69179. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  69180. /**
  69181. * Remove a specific angular speed gradient
  69182. * @param gradient defines the gradient to remove
  69183. * @returns the current particle system
  69184. */
  69185. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  69186. /**
  69187. * Adds a new velocity gradient
  69188. * @param gradient defines the gradient to use (between 0 and 1)
  69189. * @param factor defines the velocity to affect to the specified gradient
  69190. * @returns the current particle system
  69191. */
  69192. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69193. /**
  69194. * Remove a specific velocity gradient
  69195. * @param gradient defines the gradient to remove
  69196. * @returns the current particle system
  69197. */
  69198. removeVelocityGradient(gradient: number): GPUParticleSystem;
  69199. /**
  69200. * Adds a new limit velocity gradient
  69201. * @param gradient defines the gradient to use (between 0 and 1)
  69202. * @param factor defines the limit velocity value to affect to the specified gradient
  69203. * @returns the current particle system
  69204. */
  69205. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  69206. /**
  69207. * Remove a specific limit velocity gradient
  69208. * @param gradient defines the gradient to remove
  69209. * @returns the current particle system
  69210. */
  69211. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  69212. /**
  69213. * Adds a new drag gradient
  69214. * @param gradient defines the gradient to use (between 0 and 1)
  69215. * @param factor defines the drag value to affect to the specified gradient
  69216. * @returns the current particle system
  69217. */
  69218. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  69219. /**
  69220. * Remove a specific drag gradient
  69221. * @param gradient defines the gradient to remove
  69222. * @returns the current particle system
  69223. */
  69224. removeDragGradient(gradient: number): GPUParticleSystem;
  69225. /**
  69226. * Not supported by GPUParticleSystem
  69227. * @param gradient defines the gradient to use (between 0 and 1)
  69228. * @param factor defines the emit rate value to affect to the specified gradient
  69229. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69230. * @returns the current particle system
  69231. */
  69232. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69233. /**
  69234. * Not supported by GPUParticleSystem
  69235. * @param gradient defines the gradient to remove
  69236. * @returns the current particle system
  69237. */
  69238. removeEmitRateGradient(gradient: number): IParticleSystem;
  69239. /**
  69240. * Not supported by GPUParticleSystem
  69241. * @param gradient defines the gradient to use (between 0 and 1)
  69242. * @param factor defines the start size value to affect to the specified gradient
  69243. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69244. * @returns the current particle system
  69245. */
  69246. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69247. /**
  69248. * Not supported by GPUParticleSystem
  69249. * @param gradient defines the gradient to remove
  69250. * @returns the current particle system
  69251. */
  69252. removeStartSizeGradient(gradient: number): IParticleSystem;
  69253. /**
  69254. * Not supported by GPUParticleSystem
  69255. * @param gradient defines the gradient to use (between 0 and 1)
  69256. * @param min defines the color remap minimal range
  69257. * @param max defines the color remap maximal range
  69258. * @returns the current particle system
  69259. */
  69260. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69261. /**
  69262. * Not supported by GPUParticleSystem
  69263. * @param gradient defines the gradient to remove
  69264. * @returns the current particle system
  69265. */
  69266. removeColorRemapGradient(): IParticleSystem;
  69267. /**
  69268. * Not supported by GPUParticleSystem
  69269. * @param gradient defines the gradient to use (between 0 and 1)
  69270. * @param min defines the alpha remap minimal range
  69271. * @param max defines the alpha remap maximal range
  69272. * @returns the current particle system
  69273. */
  69274. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  69275. /**
  69276. * Not supported by GPUParticleSystem
  69277. * @param gradient defines the gradient to remove
  69278. * @returns the current particle system
  69279. */
  69280. removeAlphaRemapGradient(): IParticleSystem;
  69281. /**
  69282. * Not supported by GPUParticleSystem
  69283. * @param gradient defines the gradient to use (between 0 and 1)
  69284. * @param color defines the color to affect to the specified gradient
  69285. * @returns the current particle system
  69286. */
  69287. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  69288. /**
  69289. * Not supported by GPUParticleSystem
  69290. * @param gradient defines the gradient to remove
  69291. * @returns the current particle system
  69292. */
  69293. removeRampGradient(): IParticleSystem;
  69294. /**
  69295. * Not supported by GPUParticleSystem
  69296. * @returns the list of ramp gradients
  69297. */
  69298. getRampGradients(): Nullable<Array<Color3Gradient>>;
  69299. /**
  69300. * Not supported by GPUParticleSystem
  69301. * Gets or sets a boolean indicating that ramp gradients must be used
  69302. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69303. */
  69304. get useRampGradients(): boolean;
  69305. set useRampGradients(value: boolean);
  69306. /**
  69307. * Not supported by GPUParticleSystem
  69308. * @param gradient defines the gradient to use (between 0 and 1)
  69309. * @param factor defines the life time factor to affect to the specified gradient
  69310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69311. * @returns the current particle system
  69312. */
  69313. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69314. /**
  69315. * Not supported by GPUParticleSystem
  69316. * @param gradient defines the gradient to remove
  69317. * @returns the current particle system
  69318. */
  69319. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69320. /**
  69321. * Instantiates a GPU particle system.
  69322. * 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.
  69323. * @param name The name of the particle system
  69324. * @param options The options used to create the system
  69325. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  69326. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69327. * @param customEffect a custom effect used to change the way particles are rendered by default
  69328. */
  69329. constructor(name: string, options: Partial<{
  69330. capacity: number;
  69331. randomTextureSize: number;
  69332. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  69333. protected _reset(): void;
  69334. private _createUpdateVAO;
  69335. private _createRenderVAO;
  69336. private _initialize;
  69337. /** @hidden */
  69338. _recreateUpdateEffect(): void;
  69339. private _getEffect;
  69340. /**
  69341. * Fill the defines array according to the current settings of the particle system
  69342. * @param defines Array to be updated
  69343. * @param blendMode blend mode to take into account when updating the array
  69344. */
  69345. fillDefines(defines: Array<string>, blendMode?: number): void;
  69346. /**
  69347. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  69348. * @param uniforms Uniforms array to fill
  69349. * @param attributes Attributes array to fill
  69350. * @param samplers Samplers array to fill
  69351. */
  69352. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  69353. /** @hidden */
  69354. _recreateRenderEffect(): Effect;
  69355. /**
  69356. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  69357. * @param preWarm defines if we are in the pre-warmimg phase
  69358. */
  69359. animate(preWarm?: boolean): void;
  69360. private _createFactorGradientTexture;
  69361. private _createSizeGradientTexture;
  69362. private _createAngularSpeedGradientTexture;
  69363. private _createVelocityGradientTexture;
  69364. private _createLimitVelocityGradientTexture;
  69365. private _createDragGradientTexture;
  69366. private _createColorGradientTexture;
  69367. /**
  69368. * Renders the particle system in its current state
  69369. * @param preWarm defines if the system should only update the particles but not render them
  69370. * @returns the current number of particles
  69371. */
  69372. render(preWarm?: boolean): number;
  69373. /**
  69374. * Rebuilds the particle system
  69375. */
  69376. rebuild(): void;
  69377. private _releaseBuffers;
  69378. private _releaseVAOs;
  69379. /**
  69380. * Disposes the particle system and free the associated resources
  69381. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  69382. */
  69383. dispose(disposeTexture?: boolean): void;
  69384. /**
  69385. * Clones the particle system.
  69386. * @param name The name of the cloned object
  69387. * @param newEmitter The new emitter to use
  69388. * @returns the cloned particle system
  69389. */
  69390. clone(name: string, newEmitter: any): GPUParticleSystem;
  69391. /**
  69392. * Serializes the particle system to a JSON object
  69393. * @param serializeTexture defines if the texture must be serialized as well
  69394. * @returns the JSON object
  69395. */
  69396. serialize(serializeTexture?: boolean): any;
  69397. /**
  69398. * Parses a JSON object to create a GPU particle system.
  69399. * @param parsedParticleSystem The JSON object to parse
  69400. * @param sceneOrEngine The scene or the engine to create the particle system in
  69401. * @param rootUrl The root url to use to load external dependencies like texture
  69402. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  69403. * @returns the parsed GPU particle system
  69404. */
  69405. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  69406. }
  69407. }
  69408. declare module BABYLON {
  69409. /**
  69410. * Represents a set of particle systems working together to create a specific effect
  69411. */
  69412. export class ParticleSystemSet implements IDisposable {
  69413. /**
  69414. * Gets or sets base Assets URL
  69415. */
  69416. static BaseAssetsUrl: string;
  69417. private _emitterCreationOptions;
  69418. private _emitterNode;
  69419. /**
  69420. * Gets the particle system list
  69421. */
  69422. systems: IParticleSystem[];
  69423. /**
  69424. * Gets the emitter node used with this set
  69425. */
  69426. get emitterNode(): Nullable<TransformNode>;
  69427. /**
  69428. * Creates a new emitter mesh as a sphere
  69429. * @param options defines the options used to create the sphere
  69430. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  69431. * @param scene defines the hosting scene
  69432. */
  69433. setEmitterAsSphere(options: {
  69434. diameter: number;
  69435. segments: number;
  69436. color: Color3;
  69437. }, renderingGroupId: number, scene: Scene): void;
  69438. /**
  69439. * Starts all particle systems of the set
  69440. * @param emitter defines an optional mesh to use as emitter for the particle systems
  69441. */
  69442. start(emitter?: AbstractMesh): void;
  69443. /**
  69444. * Release all associated resources
  69445. */
  69446. dispose(): void;
  69447. /**
  69448. * Serialize the set into a JSON compatible object
  69449. * @param serializeTexture defines if the texture must be serialized as well
  69450. * @returns a JSON compatible representation of the set
  69451. */
  69452. serialize(serializeTexture?: boolean): any;
  69453. /**
  69454. * Parse a new ParticleSystemSet from a serialized source
  69455. * @param data defines a JSON compatible representation of the set
  69456. * @param scene defines the hosting scene
  69457. * @param gpu defines if we want GPU particles or CPU particles
  69458. * @returns a new ParticleSystemSet
  69459. */
  69460. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  69461. }
  69462. }
  69463. declare module BABYLON {
  69464. /**
  69465. * This class is made for on one-liner static method to help creating particle system set.
  69466. */
  69467. export class ParticleHelper {
  69468. /**
  69469. * Gets or sets base Assets URL
  69470. */
  69471. static BaseAssetsUrl: string;
  69472. /** Define the Url to load snippets */
  69473. static SnippetUrl: string;
  69474. /**
  69475. * Create a default particle system that you can tweak
  69476. * @param emitter defines the emitter to use
  69477. * @param capacity defines the system capacity (default is 500 particles)
  69478. * @param scene defines the hosting scene
  69479. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  69480. * @returns the new Particle system
  69481. */
  69482. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  69483. /**
  69484. * This is the main static method (one-liner) of this helper to create different particle systems
  69485. * @param type This string represents the type to the particle system to create
  69486. * @param scene The scene where the particle system should live
  69487. * @param gpu If the system will use gpu
  69488. * @returns the ParticleSystemSet created
  69489. */
  69490. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  69491. /**
  69492. * Static function used to export a particle system to a ParticleSystemSet variable.
  69493. * Please note that the emitter shape is not exported
  69494. * @param systems defines the particle systems to export
  69495. * @returns the created particle system set
  69496. */
  69497. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  69498. /**
  69499. * Creates a particle system from a snippet saved in a remote file
  69500. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  69501. * @param url defines the url to load from
  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 ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69508. /**
  69509. * Creates a particle system from a snippet saved by the particle system editor
  69510. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  69511. * @param scene defines the hosting scene
  69512. * @param gpu If the system will use gpu
  69513. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69514. * @returns a promise that will resolve to the new particle system
  69515. */
  69516. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  69517. }
  69518. }
  69519. declare module BABYLON {
  69520. interface Engine {
  69521. /**
  69522. * Create an effect to use with particle systems.
  69523. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  69524. * the particle system for which you want to create a custom effect in the last parameter
  69525. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  69526. * @param uniformsNames defines a list of attribute names
  69527. * @param samplers defines an array of string used to represent textures
  69528. * @param defines defines the string containing the defines to use to compile the shaders
  69529. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  69530. * @param onCompiled defines a function to call when the effect creation is successful
  69531. * @param onError defines a function to call when the effect creation has failed
  69532. * @param particleSystem the particle system you want to create the effect for
  69533. * @returns the new Effect
  69534. */
  69535. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  69536. }
  69537. interface Mesh {
  69538. /**
  69539. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  69540. * @returns an array of IParticleSystem
  69541. */
  69542. getEmittedParticleSystems(): IParticleSystem[];
  69543. /**
  69544. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  69545. * @returns an array of IParticleSystem
  69546. */
  69547. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  69548. }
  69549. }
  69550. declare module BABYLON {
  69551. /** Defines the 4 color options */
  69552. export enum PointColor {
  69553. /** color value */
  69554. Color = 2,
  69555. /** uv value */
  69556. UV = 1,
  69557. /** random value */
  69558. Random = 0,
  69559. /** stated value */
  69560. Stated = 3
  69561. }
  69562. /**
  69563. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  69564. * 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.
  69565. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  69566. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  69567. *
  69568. * Full documentation here : TO BE ENTERED
  69569. */
  69570. export class PointsCloudSystem implements IDisposable {
  69571. /**
  69572. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  69573. * Example : var p = SPS.particles[i];
  69574. */
  69575. particles: CloudPoint[];
  69576. /**
  69577. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  69578. */
  69579. nbParticles: number;
  69580. /**
  69581. * This a counter for your own usage. It's not set by any SPS functions.
  69582. */
  69583. counter: number;
  69584. /**
  69585. * The PCS name. This name is also given to the underlying mesh.
  69586. */
  69587. name: string;
  69588. /**
  69589. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  69590. */
  69591. mesh: Mesh;
  69592. /**
  69593. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  69594. * Please read :
  69595. */
  69596. vars: any;
  69597. /**
  69598. * @hidden
  69599. */
  69600. _size: number;
  69601. private _scene;
  69602. private _promises;
  69603. private _positions;
  69604. private _indices;
  69605. private _normals;
  69606. private _colors;
  69607. private _uvs;
  69608. private _indices32;
  69609. private _positions32;
  69610. private _colors32;
  69611. private _uvs32;
  69612. private _updatable;
  69613. private _isVisibilityBoxLocked;
  69614. private _alwaysVisible;
  69615. private _groups;
  69616. private _groupCounter;
  69617. private _computeParticleColor;
  69618. private _computeParticleTexture;
  69619. private _computeParticleRotation;
  69620. private _computeBoundingBox;
  69621. private _isReady;
  69622. /**
  69623. * Creates a PCS (Points Cloud System) object
  69624. * @param name (String) is the PCS name, this will be the underlying mesh name
  69625. * @param pointSize (number) is the size for each point
  69626. * @param scene (Scene) is the scene in which the PCS is added
  69627. * @param options defines the options of the PCS e.g.
  69628. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  69629. */
  69630. constructor(name: string, pointSize: number, scene: Scene, options?: {
  69631. updatable?: boolean;
  69632. });
  69633. /**
  69634. * Builds the PCS underlying mesh. Returns a standard Mesh.
  69635. * If no points were added to the PCS, the returned mesh is just a single point.
  69636. * @returns a promise for the created mesh
  69637. */
  69638. buildMeshAsync(): Promise<Mesh>;
  69639. /**
  69640. * @hidden
  69641. */
  69642. private _buildMesh;
  69643. private _addParticle;
  69644. private _randomUnitVector;
  69645. private _getColorIndicesForCoord;
  69646. private _setPointsColorOrUV;
  69647. private _colorFromTexture;
  69648. private _calculateDensity;
  69649. /**
  69650. * Adds points to the PCS in random positions within a unit sphere
  69651. * @param nb (positive integer) the number of particles to be created from this model
  69652. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  69653. * @returns the number of groups in the system
  69654. */
  69655. addPoints(nb: number, pointFunction?: any): number;
  69656. /**
  69657. * Adds points to the PCS from the surface of the model shape
  69658. * @param mesh is any Mesh object that will be used as a surface model for the points
  69659. * @param nb (positive integer) the number of particles to be created from this model
  69660. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69661. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69662. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69663. * @returns the number of groups in the system
  69664. */
  69665. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69666. /**
  69667. * Adds points to the PCS inside the model shape
  69668. * @param mesh is any Mesh object that will be used as a surface model for the points
  69669. * @param nb (positive integer) the number of particles to be created from this model
  69670. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  69671. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  69672. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  69673. * @returns the number of groups in the system
  69674. */
  69675. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  69676. /**
  69677. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  69678. * This method calls `updateParticle()` for each particle of the SPS.
  69679. * For an animated SPS, it is usually called within the render loop.
  69680. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  69681. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  69682. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  69683. * @returns the PCS.
  69684. */
  69685. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  69686. /**
  69687. * Disposes the PCS.
  69688. */
  69689. dispose(): void;
  69690. /**
  69691. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  69692. * doc :
  69693. * @returns the PCS.
  69694. */
  69695. refreshVisibleSize(): PointsCloudSystem;
  69696. /**
  69697. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  69698. * @param size the size (float) of the visibility box
  69699. * note : this doesn't lock the PCS mesh bounding box.
  69700. * doc :
  69701. */
  69702. setVisibilityBox(size: number): void;
  69703. /**
  69704. * Gets whether the PCS is always visible or not
  69705. * doc :
  69706. */
  69707. get isAlwaysVisible(): boolean;
  69708. /**
  69709. * Sets the PCS as always visible or not
  69710. * doc :
  69711. */
  69712. set isAlwaysVisible(val: boolean);
  69713. /**
  69714. * Tells to `setParticles()` to compute the particle rotations or not
  69715. * Default value : false. The PCS is faster when it's set to false
  69716. * Note : particle rotations are only applied to parent particles
  69717. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  69718. */
  69719. set computeParticleRotation(val: boolean);
  69720. /**
  69721. * Tells to `setParticles()` to compute the particle colors or not.
  69722. * Default value : true. The PCS is faster when it's set to false.
  69723. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69724. */
  69725. set computeParticleColor(val: boolean);
  69726. set computeParticleTexture(val: boolean);
  69727. /**
  69728. * Gets if `setParticles()` computes the particle colors or not.
  69729. * Default value : false. The PCS is faster when it's set to false.
  69730. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  69731. */
  69732. get computeParticleColor(): boolean;
  69733. /**
  69734. * Gets if `setParticles()` computes the particle textures or not.
  69735. * Default value : false. The PCS is faster when it's set to false.
  69736. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  69737. */
  69738. get computeParticleTexture(): boolean;
  69739. /**
  69740. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  69741. */
  69742. set computeBoundingBox(val: boolean);
  69743. /**
  69744. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  69745. */
  69746. get computeBoundingBox(): boolean;
  69747. /**
  69748. * This function does nothing. It may be overwritten to set all the particle first values.
  69749. * The PCS doesn't call this function, you may have to call it by your own.
  69750. * doc :
  69751. */
  69752. initParticles(): void;
  69753. /**
  69754. * This function does nothing. It may be overwritten to recycle a particle
  69755. * The PCS doesn't call this function, you can to call it
  69756. * doc :
  69757. * @param particle The particle to recycle
  69758. * @returns the recycled particle
  69759. */
  69760. recycleParticle(particle: CloudPoint): CloudPoint;
  69761. /**
  69762. * Updates a particle : this function should be overwritten by the user.
  69763. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  69764. * doc :
  69765. * @example : just set a particle position or velocity and recycle conditions
  69766. * @param particle The particle to update
  69767. * @returns the updated particle
  69768. */
  69769. updateParticle(particle: CloudPoint): CloudPoint;
  69770. /**
  69771. * This will be called before any other treatment by `setParticles()` and 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. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69778. /**
  69779. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  69780. * This will be passed three parameters.
  69781. * This does nothing and may be overwritten by the user.
  69782. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  69783. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  69784. * @param update the boolean update value actually passed to setParticles()
  69785. */
  69786. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  69787. }
  69788. }
  69789. declare module BABYLON {
  69790. /**
  69791. * Represents one particle of a points cloud system.
  69792. */
  69793. export class CloudPoint {
  69794. /**
  69795. * particle global index
  69796. */
  69797. idx: number;
  69798. /**
  69799. * The color of the particle
  69800. */
  69801. color: Nullable<Color4>;
  69802. /**
  69803. * The world space position of the particle.
  69804. */
  69805. position: Vector3;
  69806. /**
  69807. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  69808. */
  69809. rotation: Vector3;
  69810. /**
  69811. * The world space rotation quaternion of the particle.
  69812. */
  69813. rotationQuaternion: Nullable<Quaternion>;
  69814. /**
  69815. * The uv of the particle.
  69816. */
  69817. uv: Nullable<Vector2>;
  69818. /**
  69819. * The current speed of the particle.
  69820. */
  69821. velocity: Vector3;
  69822. /**
  69823. * The pivot point in the particle local space.
  69824. */
  69825. pivot: Vector3;
  69826. /**
  69827. * Must the particle be translated from its pivot point in its local space ?
  69828. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  69829. * Default : false
  69830. */
  69831. translateFromPivot: boolean;
  69832. /**
  69833. * Index of this particle in the global "positions" array (Internal use)
  69834. * @hidden
  69835. */
  69836. _pos: number;
  69837. /**
  69838. * @hidden Index of this particle in the global "indices" array (Internal use)
  69839. */
  69840. _ind: number;
  69841. /**
  69842. * Group this particle belongs to
  69843. */
  69844. _group: PointsGroup;
  69845. /**
  69846. * Group id of this particle
  69847. */
  69848. groupId: number;
  69849. /**
  69850. * Index of the particle in its group id (Internal use)
  69851. */
  69852. idxInGroup: number;
  69853. /**
  69854. * @hidden Particle BoundingInfo object (Internal use)
  69855. */
  69856. _boundingInfo: BoundingInfo;
  69857. /**
  69858. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  69859. */
  69860. _pcs: PointsCloudSystem;
  69861. /**
  69862. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  69863. */
  69864. _stillInvisible: boolean;
  69865. /**
  69866. * @hidden Last computed particle rotation matrix
  69867. */
  69868. _rotationMatrix: number[];
  69869. /**
  69870. * Parent particle Id, if any.
  69871. * Default null.
  69872. */
  69873. parentId: Nullable<number>;
  69874. /**
  69875. * @hidden Internal global position in the PCS.
  69876. */
  69877. _globalPosition: Vector3;
  69878. /**
  69879. * Creates a Point Cloud object.
  69880. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  69881. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  69882. * @param group (PointsGroup) is the group the particle belongs to
  69883. * @param groupId (integer) is the group identifier in the PCS.
  69884. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  69885. * @param pcs defines the PCS it is associated to
  69886. */
  69887. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  69888. /**
  69889. * get point size
  69890. */
  69891. get size(): Vector3;
  69892. /**
  69893. * Set point size
  69894. */
  69895. set size(scale: Vector3);
  69896. /**
  69897. * Legacy support, changed quaternion to rotationQuaternion
  69898. */
  69899. get quaternion(): Nullable<Quaternion>;
  69900. /**
  69901. * Legacy support, changed quaternion to rotationQuaternion
  69902. */
  69903. set quaternion(q: Nullable<Quaternion>);
  69904. /**
  69905. * Returns a boolean. True if the particle intersects a mesh, else false
  69906. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  69907. * @param target is the object (point or mesh) what the intersection is computed against
  69908. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  69909. * @returns true if it intersects
  69910. */
  69911. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  69912. /**
  69913. * get the rotation matrix of the particle
  69914. * @hidden
  69915. */
  69916. getRotationMatrix(m: Matrix): void;
  69917. }
  69918. /**
  69919. * Represents a group of points in a points cloud system
  69920. * * PCS internal tool, don't use it manually.
  69921. */
  69922. export class PointsGroup {
  69923. /**
  69924. * The group id
  69925. * @hidden
  69926. */
  69927. groupID: number;
  69928. /**
  69929. * image data for group (internal use)
  69930. * @hidden
  69931. */
  69932. _groupImageData: Nullable<ArrayBufferView>;
  69933. /**
  69934. * Image Width (internal use)
  69935. * @hidden
  69936. */
  69937. _groupImgWidth: number;
  69938. /**
  69939. * Image Height (internal use)
  69940. * @hidden
  69941. */
  69942. _groupImgHeight: number;
  69943. /**
  69944. * Custom position function (internal use)
  69945. * @hidden
  69946. */
  69947. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69948. /**
  69949. * density per facet for surface points
  69950. * @hidden
  69951. */
  69952. _groupDensity: number[];
  69953. /**
  69954. * Only when points are colored by texture carries pointer to texture list array
  69955. * @hidden
  69956. */
  69957. _textureNb: number;
  69958. /**
  69959. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69960. * PCS internal tool, don't use it manually.
  69961. * @hidden
  69962. */
  69963. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69964. }
  69965. }
  69966. declare module BABYLON {
  69967. interface Scene {
  69968. /** @hidden (Backing field) */
  69969. _physicsEngine: Nullable<IPhysicsEngine>;
  69970. /** @hidden */
  69971. _physicsTimeAccumulator: number;
  69972. /**
  69973. * Gets the current physics engine
  69974. * @returns a IPhysicsEngine or null if none attached
  69975. */
  69976. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69977. /**
  69978. * Enables physics to the current scene
  69979. * @param gravity defines the scene's gravity for the physics engine
  69980. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69981. * @return a boolean indicating if the physics engine was initialized
  69982. */
  69983. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69984. /**
  69985. * Disables and disposes the physics engine associated with the scene
  69986. */
  69987. disablePhysicsEngine(): void;
  69988. /**
  69989. * Gets a boolean indicating if there is an active physics engine
  69990. * @returns a boolean indicating if there is an active physics engine
  69991. */
  69992. isPhysicsEnabled(): boolean;
  69993. /**
  69994. * Deletes a physics compound impostor
  69995. * @param compound defines the compound to delete
  69996. */
  69997. deleteCompoundImpostor(compound: any): void;
  69998. /**
  69999. * An event triggered when physic simulation is about to be run
  70000. */
  70001. onBeforePhysicsObservable: Observable<Scene>;
  70002. /**
  70003. * An event triggered when physic simulation has been done
  70004. */
  70005. onAfterPhysicsObservable: Observable<Scene>;
  70006. }
  70007. interface AbstractMesh {
  70008. /** @hidden */
  70009. _physicsImpostor: Nullable<PhysicsImpostor>;
  70010. /**
  70011. * Gets or sets impostor used for physic simulation
  70012. * @see https://doc.babylonjs.com/features/physics_engine
  70013. */
  70014. physicsImpostor: Nullable<PhysicsImpostor>;
  70015. /**
  70016. * Gets the current physics impostor
  70017. * @see https://doc.babylonjs.com/features/physics_engine
  70018. * @returns a physics impostor or null
  70019. */
  70020. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  70021. /** Apply a physic impulse to the mesh
  70022. * @param force defines the force to apply
  70023. * @param contactPoint defines where to apply the force
  70024. * @returns the current mesh
  70025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  70026. */
  70027. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  70028. /**
  70029. * Creates a physic joint between two meshes
  70030. * @param otherMesh defines the other mesh to use
  70031. * @param pivot1 defines the pivot to use on this mesh
  70032. * @param pivot2 defines the pivot to use on the other mesh
  70033. * @param options defines additional options (can be plugin dependent)
  70034. * @returns the current mesh
  70035. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  70036. */
  70037. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  70038. /** @hidden */
  70039. _disposePhysicsObserver: Nullable<Observer<Node>>;
  70040. }
  70041. /**
  70042. * Defines the physics engine scene component responsible to manage a physics engine
  70043. */
  70044. export class PhysicsEngineSceneComponent implements ISceneComponent {
  70045. /**
  70046. * The component name helpful to identify the component in the list of scene components.
  70047. */
  70048. readonly name: string;
  70049. /**
  70050. * The scene the component belongs to.
  70051. */
  70052. scene: Scene;
  70053. /**
  70054. * Creates a new instance of the component for the given scene
  70055. * @param scene Defines the scene to register the component in
  70056. */
  70057. constructor(scene: Scene);
  70058. /**
  70059. * Registers the component in a given scene
  70060. */
  70061. register(): void;
  70062. /**
  70063. * Rebuilds the elements related to this component in case of
  70064. * context lost for instance.
  70065. */
  70066. rebuild(): void;
  70067. /**
  70068. * Disposes the component and the associated ressources
  70069. */
  70070. dispose(): void;
  70071. }
  70072. }
  70073. declare module BABYLON {
  70074. /**
  70075. * A helper for physics simulations
  70076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70077. */
  70078. export class PhysicsHelper {
  70079. private _scene;
  70080. private _physicsEngine;
  70081. /**
  70082. * Initializes the Physics helper
  70083. * @param scene Babylon.js scene
  70084. */
  70085. constructor(scene: Scene);
  70086. /**
  70087. * Applies a radial explosion impulse
  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. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70095. /**
  70096. * Applies a radial explosion force
  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 radial explosion event, or null
  70102. */
  70103. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  70104. /**
  70105. * Creates a gravitational field
  70106. * @param origin the origin of the explosion
  70107. * @param radiusOrEventOptions the radius or the options of radial explosion
  70108. * @param strength the explosion strength
  70109. * @param falloff possible options: Constant & Linear. Defaults to Constant
  70110. * @returns A physics gravitational field event, or null
  70111. */
  70112. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  70113. /**
  70114. * Creates a physics updraft event
  70115. * @param origin the origin of the updraft
  70116. * @param radiusOrEventOptions the radius or the options of the updraft
  70117. * @param strength the strength of the updraft
  70118. * @param height the height of the updraft
  70119. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  70120. * @returns A physics updraft event, or null
  70121. */
  70122. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  70123. /**
  70124. * Creates a physics vortex event
  70125. * @param origin the of the vortex
  70126. * @param radiusOrEventOptions the radius or the options of the vortex
  70127. * @param strength the strength of the vortex
  70128. * @param height the height of the vortex
  70129. * @returns a Physics vortex event, or null
  70130. * A physics vortex event or null
  70131. */
  70132. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  70133. }
  70134. /**
  70135. * Represents a physics radial explosion event
  70136. */
  70137. class PhysicsRadialExplosionEvent {
  70138. private _scene;
  70139. private _options;
  70140. private _sphere;
  70141. private _dataFetched;
  70142. /**
  70143. * Initializes a radial explosioin event
  70144. * @param _scene BabylonJS scene
  70145. * @param _options The options for the vortex event
  70146. */
  70147. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  70148. /**
  70149. * Returns the data related to the radial explosion event (sphere).
  70150. * @returns The radial explosion event data
  70151. */
  70152. getData(): PhysicsRadialExplosionEventData;
  70153. /**
  70154. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  70155. * @param impostor A physics imposter
  70156. * @param origin the origin of the explosion
  70157. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  70158. */
  70159. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  70160. /**
  70161. * Triggers affecterd impostors callbacks
  70162. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  70163. */
  70164. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  70165. /**
  70166. * Disposes the sphere.
  70167. * @param force Specifies if the sphere should be disposed by force
  70168. */
  70169. dispose(force?: boolean): void;
  70170. /*** Helpers ***/
  70171. private _prepareSphere;
  70172. private _intersectsWithSphere;
  70173. }
  70174. /**
  70175. * Represents a gravitational field event
  70176. */
  70177. class PhysicsGravitationalFieldEvent {
  70178. private _physicsHelper;
  70179. private _scene;
  70180. private _origin;
  70181. private _options;
  70182. private _tickCallback;
  70183. private _sphere;
  70184. private _dataFetched;
  70185. /**
  70186. * Initializes the physics gravitational field event
  70187. * @param _physicsHelper A physics helper
  70188. * @param _scene BabylonJS scene
  70189. * @param _origin The origin position of the gravitational field event
  70190. * @param _options The options for the vortex event
  70191. */
  70192. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  70193. /**
  70194. * Returns the data related to the gravitational field event (sphere).
  70195. * @returns A gravitational field event
  70196. */
  70197. getData(): PhysicsGravitationalFieldEventData;
  70198. /**
  70199. * Enables the gravitational field.
  70200. */
  70201. enable(): void;
  70202. /**
  70203. * Disables the gravitational field.
  70204. */
  70205. disable(): void;
  70206. /**
  70207. * Disposes the sphere.
  70208. * @param force The force to dispose from the gravitational field event
  70209. */
  70210. dispose(force?: boolean): void;
  70211. private _tick;
  70212. }
  70213. /**
  70214. * Represents a physics updraft event
  70215. */
  70216. class PhysicsUpdraftEvent {
  70217. private _scene;
  70218. private _origin;
  70219. private _options;
  70220. private _physicsEngine;
  70221. private _originTop;
  70222. private _originDirection;
  70223. private _tickCallback;
  70224. private _cylinder;
  70225. private _cylinderPosition;
  70226. private _dataFetched;
  70227. /**
  70228. * Initializes the physics updraft event
  70229. * @param _scene BabylonJS scene
  70230. * @param _origin The origin position of the updraft
  70231. * @param _options The options for the updraft event
  70232. */
  70233. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  70234. /**
  70235. * Returns the data related to the updraft event (cylinder).
  70236. * @returns A physics updraft event
  70237. */
  70238. getData(): PhysicsUpdraftEventData;
  70239. /**
  70240. * Enables the updraft.
  70241. */
  70242. enable(): void;
  70243. /**
  70244. * Disables the updraft.
  70245. */
  70246. disable(): void;
  70247. /**
  70248. * Disposes the cylinder.
  70249. * @param force Specifies if the updraft should be disposed by force
  70250. */
  70251. dispose(force?: boolean): void;
  70252. private getImpostorHitData;
  70253. private _tick;
  70254. /*** Helpers ***/
  70255. private _prepareCylinder;
  70256. private _intersectsWithCylinder;
  70257. }
  70258. /**
  70259. * Represents a physics vortex event
  70260. */
  70261. class PhysicsVortexEvent {
  70262. private _scene;
  70263. private _origin;
  70264. private _options;
  70265. private _physicsEngine;
  70266. private _originTop;
  70267. private _tickCallback;
  70268. private _cylinder;
  70269. private _cylinderPosition;
  70270. private _dataFetched;
  70271. /**
  70272. * Initializes the physics vortex event
  70273. * @param _scene The BabylonJS scene
  70274. * @param _origin The origin position of the vortex
  70275. * @param _options The options for the vortex event
  70276. */
  70277. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  70278. /**
  70279. * Returns the data related to the vortex event (cylinder).
  70280. * @returns The physics vortex event data
  70281. */
  70282. getData(): PhysicsVortexEventData;
  70283. /**
  70284. * Enables the vortex.
  70285. */
  70286. enable(): void;
  70287. /**
  70288. * Disables the cortex.
  70289. */
  70290. disable(): void;
  70291. /**
  70292. * Disposes the sphere.
  70293. * @param force
  70294. */
  70295. dispose(force?: boolean): void;
  70296. private getImpostorHitData;
  70297. private _tick;
  70298. /*** Helpers ***/
  70299. private _prepareCylinder;
  70300. private _intersectsWithCylinder;
  70301. }
  70302. /**
  70303. * Options fot the radial explosion event
  70304. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70305. */
  70306. export class PhysicsRadialExplosionEventOptions {
  70307. /**
  70308. * The radius of the sphere for the radial explosion.
  70309. */
  70310. radius: number;
  70311. /**
  70312. * The strenth of the explosion.
  70313. */
  70314. strength: number;
  70315. /**
  70316. * The strenght of the force in correspondence to the distance of the affected object
  70317. */
  70318. falloff: PhysicsRadialImpulseFalloff;
  70319. /**
  70320. * Sphere options for the radial explosion.
  70321. */
  70322. sphere: {
  70323. segments: number;
  70324. diameter: number;
  70325. };
  70326. /**
  70327. * Sphere options for the radial explosion.
  70328. */
  70329. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  70330. }
  70331. /**
  70332. * Options fot the updraft event
  70333. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70334. */
  70335. export class PhysicsUpdraftEventOptions {
  70336. /**
  70337. * The radius of the cylinder for the vortex
  70338. */
  70339. radius: number;
  70340. /**
  70341. * The strenth of the updraft.
  70342. */
  70343. strength: number;
  70344. /**
  70345. * The height of the cylinder for the updraft.
  70346. */
  70347. height: number;
  70348. /**
  70349. * The mode for the the updraft.
  70350. */
  70351. updraftMode: PhysicsUpdraftMode;
  70352. }
  70353. /**
  70354. * Options fot the vortex event
  70355. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70356. */
  70357. export class PhysicsVortexEventOptions {
  70358. /**
  70359. * The radius of the cylinder for the vortex
  70360. */
  70361. radius: number;
  70362. /**
  70363. * The strenth of the vortex.
  70364. */
  70365. strength: number;
  70366. /**
  70367. * The height of the cylinder for the vortex.
  70368. */
  70369. height: number;
  70370. /**
  70371. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  70372. */
  70373. centripetalForceThreshold: number;
  70374. /**
  70375. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  70376. */
  70377. centripetalForceMultiplier: number;
  70378. /**
  70379. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  70380. */
  70381. centrifugalForceMultiplier: number;
  70382. /**
  70383. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  70384. */
  70385. updraftForceMultiplier: number;
  70386. }
  70387. /**
  70388. * The strenght of the force in correspondence to the distance of the affected object
  70389. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70390. */
  70391. export enum PhysicsRadialImpulseFalloff {
  70392. /** Defines that impulse is constant in strength across it's whole radius */
  70393. Constant = 0,
  70394. /** Defines that impulse gets weaker if it's further from the origin */
  70395. Linear = 1
  70396. }
  70397. /**
  70398. * The strength of the force in correspondence to the distance of the affected object
  70399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70400. */
  70401. export enum PhysicsUpdraftMode {
  70402. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  70403. Center = 0,
  70404. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  70405. Perpendicular = 1
  70406. }
  70407. /**
  70408. * Interface for a physics hit data
  70409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70410. */
  70411. export interface PhysicsHitData {
  70412. /**
  70413. * The force applied at the contact point
  70414. */
  70415. force: Vector3;
  70416. /**
  70417. * The contact point
  70418. */
  70419. contactPoint: Vector3;
  70420. /**
  70421. * The distance from the origin to the contact point
  70422. */
  70423. distanceFromOrigin: number;
  70424. }
  70425. /**
  70426. * Interface for radial explosion event data
  70427. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70428. */
  70429. export interface PhysicsRadialExplosionEventData {
  70430. /**
  70431. * A sphere used for the radial explosion event
  70432. */
  70433. sphere: Mesh;
  70434. }
  70435. /**
  70436. * Interface for gravitational field event data
  70437. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70438. */
  70439. export interface PhysicsGravitationalFieldEventData {
  70440. /**
  70441. * A sphere mesh used for the gravitational field event
  70442. */
  70443. sphere: Mesh;
  70444. }
  70445. /**
  70446. * Interface for updraft event data
  70447. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70448. */
  70449. export interface PhysicsUpdraftEventData {
  70450. /**
  70451. * A cylinder used for the updraft event
  70452. */
  70453. cylinder: Mesh;
  70454. }
  70455. /**
  70456. * Interface for vortex event data
  70457. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70458. */
  70459. export interface PhysicsVortexEventData {
  70460. /**
  70461. * A cylinder used for the vortex event
  70462. */
  70463. cylinder: Mesh;
  70464. }
  70465. /**
  70466. * Interface for an affected physics impostor
  70467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  70468. */
  70469. export interface PhysicsAffectedImpostorWithData {
  70470. /**
  70471. * The impostor affected by the effect
  70472. */
  70473. impostor: PhysicsImpostor;
  70474. /**
  70475. * The data about the hit/horce from the explosion
  70476. */
  70477. hitData: PhysicsHitData;
  70478. }
  70479. }
  70480. declare module BABYLON {
  70481. /** @hidden */
  70482. export var blackAndWhitePixelShader: {
  70483. name: string;
  70484. shader: string;
  70485. };
  70486. }
  70487. declare module BABYLON {
  70488. /**
  70489. * Post process used to render in black and white
  70490. */
  70491. export class BlackAndWhitePostProcess extends PostProcess {
  70492. /**
  70493. * Linear about to convert he result to black and white (default: 1)
  70494. */
  70495. degree: number;
  70496. /**
  70497. * Gets a string identifying the name of the class
  70498. * @returns "BlackAndWhitePostProcess" string
  70499. */
  70500. getClassName(): string;
  70501. /**
  70502. * Creates a black and white post process
  70503. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  70504. * @param name The name of the effect.
  70505. * @param options The required width/height ratio to downsize to before computing the render pass.
  70506. * @param camera The camera to apply the render pass to.
  70507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70508. * @param engine The engine which the post process will be applied. (default: current engine)
  70509. * @param reusable If the post process can be reused on the same frame. (default: false)
  70510. */
  70511. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70512. /** @hidden */
  70513. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  70514. }
  70515. }
  70516. declare module BABYLON {
  70517. /**
  70518. * This represents a set of one or more post processes in Babylon.
  70519. * A post process can be used to apply a shader to a texture after it is rendered.
  70520. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70521. */
  70522. export class PostProcessRenderEffect {
  70523. private _postProcesses;
  70524. private _getPostProcesses;
  70525. private _singleInstance;
  70526. private _cameras;
  70527. private _indicesForCamera;
  70528. /**
  70529. * Name of the effect
  70530. * @hidden
  70531. */
  70532. _name: string;
  70533. /**
  70534. * Instantiates a post process render effect.
  70535. * A post process can be used to apply a shader to a texture after it is rendered.
  70536. * @param engine The engine the effect is tied to
  70537. * @param name The name of the effect
  70538. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  70539. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  70540. */
  70541. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  70542. /**
  70543. * Checks if all the post processes in the effect are supported.
  70544. */
  70545. get isSupported(): boolean;
  70546. /**
  70547. * Updates the current state of the effect
  70548. * @hidden
  70549. */
  70550. _update(): void;
  70551. /**
  70552. * Attaches the effect on cameras
  70553. * @param cameras The camera to attach to.
  70554. * @hidden
  70555. */
  70556. _attachCameras(cameras: Camera): void;
  70557. /**
  70558. * Attaches the effect on cameras
  70559. * @param cameras The camera to attach to.
  70560. * @hidden
  70561. */
  70562. _attachCameras(cameras: Camera[]): void;
  70563. /**
  70564. * Detaches the effect on cameras
  70565. * @param cameras The camera to detatch from.
  70566. * @hidden
  70567. */
  70568. _detachCameras(cameras: Camera): void;
  70569. /**
  70570. * Detatches the effect on cameras
  70571. * @param cameras The camera to detatch from.
  70572. * @hidden
  70573. */
  70574. _detachCameras(cameras: Camera[]): void;
  70575. /**
  70576. * Enables the effect on given cameras
  70577. * @param cameras The camera to enable.
  70578. * @hidden
  70579. */
  70580. _enable(cameras: Camera): void;
  70581. /**
  70582. * Enables the effect on given cameras
  70583. * @param cameras The camera to enable.
  70584. * @hidden
  70585. */
  70586. _enable(cameras: Nullable<Camera[]>): void;
  70587. /**
  70588. * Disables the effect on the given cameras
  70589. * @param cameras The camera to disable.
  70590. * @hidden
  70591. */
  70592. _disable(cameras: Camera): void;
  70593. /**
  70594. * Disables the effect on the given cameras
  70595. * @param cameras The camera to disable.
  70596. * @hidden
  70597. */
  70598. _disable(cameras: Nullable<Camera[]>): void;
  70599. /**
  70600. * Gets a list of the post processes contained in the effect.
  70601. * @param camera The camera to get the post processes on.
  70602. * @returns The list of the post processes in the effect.
  70603. */
  70604. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  70605. }
  70606. }
  70607. declare module BABYLON {
  70608. /** @hidden */
  70609. export var extractHighlightsPixelShader: {
  70610. name: string;
  70611. shader: string;
  70612. };
  70613. }
  70614. declare module BABYLON {
  70615. /**
  70616. * 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.
  70617. */
  70618. export class ExtractHighlightsPostProcess extends PostProcess {
  70619. /**
  70620. * The luminance threshold, pixels below this value will be set to black.
  70621. */
  70622. threshold: number;
  70623. /** @hidden */
  70624. _exposure: number;
  70625. /**
  70626. * Post process which has the input texture to be used when performing highlight extraction
  70627. * @hidden
  70628. */
  70629. _inputPostProcess: Nullable<PostProcess>;
  70630. /**
  70631. * Gets a string identifying the name of the class
  70632. * @returns "ExtractHighlightsPostProcess" string
  70633. */
  70634. getClassName(): string;
  70635. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70636. }
  70637. }
  70638. declare module BABYLON {
  70639. /** @hidden */
  70640. export var bloomMergePixelShader: {
  70641. name: string;
  70642. shader: string;
  70643. };
  70644. }
  70645. declare module BABYLON {
  70646. /**
  70647. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70648. */
  70649. export class BloomMergePostProcess extends PostProcess {
  70650. /** Weight of the bloom to be added to the original input. */
  70651. weight: number;
  70652. /**
  70653. * Gets a string identifying the name of the class
  70654. * @returns "BloomMergePostProcess" string
  70655. */
  70656. getClassName(): string;
  70657. /**
  70658. * Creates a new instance of @see BloomMergePostProcess
  70659. * @param name The name of the effect.
  70660. * @param originalFromInput Post process which's input will be used for the merge.
  70661. * @param blurred Blurred highlights post process which's output will be used.
  70662. * @param weight Weight of the bloom to be added to the original input.
  70663. * @param options The required width/height ratio to downsize to before computing the render pass.
  70664. * @param camera The camera to apply the render pass to.
  70665. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70666. * @param engine The engine which the post process will be applied. (default: current engine)
  70667. * @param reusable If the post process can be reused on the same frame. (default: false)
  70668. * @param textureType Type of textures used when performing the post process. (default: 0)
  70669. * @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)
  70670. */
  70671. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  70672. /** Weight of the bloom to be added to the original input. */
  70673. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70674. }
  70675. }
  70676. declare module BABYLON {
  70677. /**
  70678. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  70679. */
  70680. export class BloomEffect extends PostProcessRenderEffect {
  70681. private bloomScale;
  70682. /**
  70683. * @hidden Internal
  70684. */
  70685. _effects: Array<PostProcess>;
  70686. /**
  70687. * @hidden Internal
  70688. */
  70689. _downscale: ExtractHighlightsPostProcess;
  70690. private _blurX;
  70691. private _blurY;
  70692. private _merge;
  70693. /**
  70694. * The luminance threshold to find bright areas of the image to bloom.
  70695. */
  70696. get threshold(): number;
  70697. set threshold(value: number);
  70698. /**
  70699. * The strength of the bloom.
  70700. */
  70701. get weight(): number;
  70702. set weight(value: number);
  70703. /**
  70704. * Specifies the size of the bloom blur kernel, relative to the final output size
  70705. */
  70706. get kernel(): number;
  70707. set kernel(value: number);
  70708. /**
  70709. * Creates a new instance of @see BloomEffect
  70710. * @param scene The scene the effect belongs to.
  70711. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  70712. * @param bloomKernel The size of the kernel to be used when applying the blur.
  70713. * @param bloomWeight The the strength of bloom.
  70714. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70715. * @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)
  70716. */
  70717. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  70718. /**
  70719. * Disposes each of the internal effects for a given camera.
  70720. * @param camera The camera to dispose the effect on.
  70721. */
  70722. disposeEffects(camera: Camera): void;
  70723. /**
  70724. * @hidden Internal
  70725. */
  70726. _updateEffects(): void;
  70727. /**
  70728. * Internal
  70729. * @returns if all the contained post processes are ready.
  70730. * @hidden
  70731. */
  70732. _isReady(): boolean;
  70733. }
  70734. }
  70735. declare module BABYLON {
  70736. /** @hidden */
  70737. export var chromaticAberrationPixelShader: {
  70738. name: string;
  70739. shader: string;
  70740. };
  70741. }
  70742. declare module BABYLON {
  70743. /**
  70744. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  70745. */
  70746. export class ChromaticAberrationPostProcess extends PostProcess {
  70747. /**
  70748. * The amount of seperation of rgb channels (default: 30)
  70749. */
  70750. aberrationAmount: number;
  70751. /**
  70752. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  70753. */
  70754. radialIntensity: number;
  70755. /**
  70756. * 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))
  70757. */
  70758. direction: Vector2;
  70759. /**
  70760. * 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))
  70761. */
  70762. centerPosition: Vector2;
  70763. /** The width of the screen to apply the effect on */
  70764. screenWidth: number;
  70765. /** The height of the screen to apply the effect on */
  70766. screenHeight: number;
  70767. /**
  70768. * Gets a string identifying the name of the class
  70769. * @returns "ChromaticAberrationPostProcess" string
  70770. */
  70771. getClassName(): string;
  70772. /**
  70773. * Creates a new instance ChromaticAberrationPostProcess
  70774. * @param name The name of the effect.
  70775. * @param screenWidth The width of the screen to apply the effect on.
  70776. * @param screenHeight The height of the screen to apply the effect on.
  70777. * @param options The required width/height ratio to downsize to before computing the render pass.
  70778. * @param camera The camera to apply the render pass to.
  70779. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70780. * @param engine The engine which the post process will be applied. (default: current engine)
  70781. * @param reusable If the post process can be reused on the same frame. (default: false)
  70782. * @param textureType Type of textures used when performing the post process. (default: 0)
  70783. * @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)
  70784. */
  70785. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70786. /** @hidden */
  70787. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  70788. }
  70789. }
  70790. declare module BABYLON {
  70791. /** @hidden */
  70792. export var circleOfConfusionPixelShader: {
  70793. name: string;
  70794. shader: string;
  70795. };
  70796. }
  70797. declare module BABYLON {
  70798. /**
  70799. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  70800. */
  70801. export class CircleOfConfusionPostProcess extends PostProcess {
  70802. /**
  70803. * 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.
  70804. */
  70805. lensSize: number;
  70806. /**
  70807. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70808. */
  70809. fStop: number;
  70810. /**
  70811. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70812. */
  70813. focusDistance: number;
  70814. /**
  70815. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  70816. */
  70817. focalLength: number;
  70818. /**
  70819. * Gets a string identifying the name of the class
  70820. * @returns "CircleOfConfusionPostProcess" string
  70821. */
  70822. getClassName(): string;
  70823. private _depthTexture;
  70824. /**
  70825. * Creates a new instance CircleOfConfusionPostProcess
  70826. * @param name The name of the effect.
  70827. * @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.
  70828. * @param options The required width/height ratio to downsize to before computing the render pass.
  70829. * @param camera The camera to apply the render pass to.
  70830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70831. * @param engine The engine which the post process will be applied. (default: current engine)
  70832. * @param reusable If the post process can be reused on the same frame. (default: false)
  70833. * @param textureType Type of textures used when performing the post process. (default: 0)
  70834. * @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)
  70835. */
  70836. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70837. /**
  70838. * 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.
  70839. */
  70840. set depthTexture(value: RenderTargetTexture);
  70841. }
  70842. }
  70843. declare module BABYLON {
  70844. /** @hidden */
  70845. export var colorCorrectionPixelShader: {
  70846. name: string;
  70847. shader: string;
  70848. };
  70849. }
  70850. declare module BABYLON {
  70851. /**
  70852. *
  70853. * This post-process allows the modification of rendered colors by using
  70854. * a 'look-up table' (LUT). This effect is also called Color Grading.
  70855. *
  70856. * The object needs to be provided an url to a texture containing the color
  70857. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  70858. * Use an image editing software to tweak the LUT to match your needs.
  70859. *
  70860. * For an example of a color LUT, see here:
  70861. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  70862. * For explanations on color grading, see here:
  70863. * @see http://udn.epicgames.com/Three/ColorGrading.html
  70864. *
  70865. */
  70866. export class ColorCorrectionPostProcess extends PostProcess {
  70867. private _colorTableTexture;
  70868. /**
  70869. * Gets the color table url used to create the LUT texture
  70870. */
  70871. colorTableUrl: string;
  70872. /**
  70873. * Gets a string identifying the name of the class
  70874. * @returns "ColorCorrectionPostProcess" string
  70875. */
  70876. getClassName(): string;
  70877. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70878. /** @hidden */
  70879. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  70880. }
  70881. }
  70882. declare module BABYLON {
  70883. /** @hidden */
  70884. export var convolutionPixelShader: {
  70885. name: string;
  70886. shader: string;
  70887. };
  70888. }
  70889. declare module BABYLON {
  70890. /**
  70891. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  70892. * input texture to perform effects such as edge detection or sharpening
  70893. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70894. */
  70895. export class ConvolutionPostProcess extends PostProcess {
  70896. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  70897. kernel: number[];
  70898. /**
  70899. * Gets a string identifying the name of the class
  70900. * @returns "ConvolutionPostProcess" string
  70901. */
  70902. getClassName(): string;
  70903. /**
  70904. * Creates a new instance ConvolutionPostProcess
  70905. * @param name The name of the effect.
  70906. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  70907. * @param options The required width/height ratio to downsize to before computing the render pass.
  70908. * @param camera The camera to apply the render pass to.
  70909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70910. * @param engine The engine which the post process will be applied. (default: current engine)
  70911. * @param reusable If the post process can be reused on the same frame. (default: false)
  70912. * @param textureType Type of textures used when performing the post process. (default: 0)
  70913. */
  70914. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70915. /** @hidden */
  70916. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  70917. /**
  70918. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70919. */
  70920. static EdgeDetect0Kernel: number[];
  70921. /**
  70922. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70923. */
  70924. static EdgeDetect1Kernel: number[];
  70925. /**
  70926. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70927. */
  70928. static EdgeDetect2Kernel: number[];
  70929. /**
  70930. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70931. */
  70932. static SharpenKernel: number[];
  70933. /**
  70934. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70935. */
  70936. static EmbossKernel: number[];
  70937. /**
  70938. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70939. */
  70940. static GaussianKernel: number[];
  70941. }
  70942. }
  70943. declare module BABYLON {
  70944. /**
  70945. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70946. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70947. * based on samples that have a large difference in distance than the center pixel.
  70948. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70949. */
  70950. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70951. /**
  70952. * The direction the blur should be applied
  70953. */
  70954. direction: Vector2;
  70955. /**
  70956. * Gets a string identifying the name of the class
  70957. * @returns "DepthOfFieldBlurPostProcess" string
  70958. */
  70959. getClassName(): string;
  70960. /**
  70961. * Creates a new instance CircleOfConfusionPostProcess
  70962. * @param name The name of the effect.
  70963. * @param scene The scene the effect belongs to.
  70964. * @param direction The direction the blur should be applied.
  70965. * @param kernel The size of the kernel used to blur.
  70966. * @param options The required width/height ratio to downsize to before computing the render pass.
  70967. * @param camera The camera to apply the render pass to.
  70968. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70969. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70971. * @param engine The engine which the post process will be applied. (default: current engine)
  70972. * @param reusable If the post process can be reused on the same frame. (default: false)
  70973. * @param textureType Type of textures used when performing the post process. (default: 0)
  70974. * @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)
  70975. */
  70976. 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);
  70977. }
  70978. }
  70979. declare module BABYLON {
  70980. /** @hidden */
  70981. export var depthOfFieldMergePixelShader: {
  70982. name: string;
  70983. shader: string;
  70984. };
  70985. }
  70986. declare module BABYLON {
  70987. /**
  70988. * Options to be set when merging outputs from the default pipeline.
  70989. */
  70990. export class DepthOfFieldMergePostProcessOptions {
  70991. /**
  70992. * The original image to merge on top of
  70993. */
  70994. originalFromInput: PostProcess;
  70995. /**
  70996. * Parameters to perform the merge of the depth of field effect
  70997. */
  70998. depthOfField?: {
  70999. circleOfConfusion: PostProcess;
  71000. blurSteps: Array<PostProcess>;
  71001. };
  71002. /**
  71003. * Parameters to perform the merge of bloom effect
  71004. */
  71005. bloom?: {
  71006. blurred: PostProcess;
  71007. weight: number;
  71008. };
  71009. }
  71010. /**
  71011. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71012. */
  71013. export class DepthOfFieldMergePostProcess extends PostProcess {
  71014. private blurSteps;
  71015. /**
  71016. * Gets a string identifying the name of the class
  71017. * @returns "DepthOfFieldMergePostProcess" string
  71018. */
  71019. getClassName(): string;
  71020. /**
  71021. * Creates a new instance of DepthOfFieldMergePostProcess
  71022. * @param name The name of the effect.
  71023. * @param originalFromInput Post process which's input will be used for the merge.
  71024. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  71025. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  71026. * @param options The required width/height ratio to downsize to before computing the render pass.
  71027. * @param camera The camera to apply the render pass to.
  71028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71029. * @param engine The engine which the post process will be applied. (default: current engine)
  71030. * @param reusable If the post process can be reused on the same frame. (default: false)
  71031. * @param textureType Type of textures used when performing the post process. (default: 0)
  71032. * @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)
  71033. */
  71034. 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);
  71035. /**
  71036. * Updates the effect with the current post process compile time values and recompiles the shader.
  71037. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71038. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71039. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71040. * @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
  71041. * @param onCompiled Called when the shader has been compiled.
  71042. * @param onError Called if there is an error when compiling a shader.
  71043. */
  71044. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71045. }
  71046. }
  71047. declare module BABYLON {
  71048. /**
  71049. * Specifies the level of max blur that should be applied when using the depth of field effect
  71050. */
  71051. export enum DepthOfFieldEffectBlurLevel {
  71052. /**
  71053. * Subtle blur
  71054. */
  71055. Low = 0,
  71056. /**
  71057. * Medium blur
  71058. */
  71059. Medium = 1,
  71060. /**
  71061. * Large blur
  71062. */
  71063. High = 2
  71064. }
  71065. /**
  71066. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  71067. */
  71068. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  71069. private _circleOfConfusion;
  71070. /**
  71071. * @hidden Internal, blurs from high to low
  71072. */
  71073. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  71074. private _depthOfFieldBlurY;
  71075. private _dofMerge;
  71076. /**
  71077. * @hidden Internal post processes in depth of field effect
  71078. */
  71079. _effects: Array<PostProcess>;
  71080. /**
  71081. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  71082. */
  71083. set focalLength(value: number);
  71084. get focalLength(): number;
  71085. /**
  71086. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71087. */
  71088. set fStop(value: number);
  71089. get fStop(): number;
  71090. /**
  71091. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71092. */
  71093. set focusDistance(value: number);
  71094. get focusDistance(): number;
  71095. /**
  71096. * 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.
  71097. */
  71098. set lensSize(value: number);
  71099. get lensSize(): number;
  71100. /**
  71101. * Creates a new instance DepthOfFieldEffect
  71102. * @param scene The scene the effect belongs to.
  71103. * @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.
  71104. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71105. * @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)
  71106. */
  71107. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  71108. /**
  71109. * Get the current class name of the current effet
  71110. * @returns "DepthOfFieldEffect"
  71111. */
  71112. getClassName(): string;
  71113. /**
  71114. * 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.
  71115. */
  71116. set depthTexture(value: RenderTargetTexture);
  71117. /**
  71118. * Disposes each of the internal effects for a given camera.
  71119. * @param camera The camera to dispose the effect on.
  71120. */
  71121. disposeEffects(camera: Camera): void;
  71122. /**
  71123. * @hidden Internal
  71124. */
  71125. _updateEffects(): void;
  71126. /**
  71127. * Internal
  71128. * @returns if all the contained post processes are ready.
  71129. * @hidden
  71130. */
  71131. _isReady(): boolean;
  71132. }
  71133. }
  71134. declare module BABYLON {
  71135. /** @hidden */
  71136. export var displayPassPixelShader: {
  71137. name: string;
  71138. shader: string;
  71139. };
  71140. }
  71141. declare module BABYLON {
  71142. /**
  71143. * DisplayPassPostProcess which produces an output the same as it's input
  71144. */
  71145. export class DisplayPassPostProcess extends PostProcess {
  71146. /**
  71147. * Gets a string identifying the name of the class
  71148. * @returns "DisplayPassPostProcess" string
  71149. */
  71150. getClassName(): string;
  71151. /**
  71152. * Creates the DisplayPassPostProcess
  71153. * @param name The name of the effect.
  71154. * @param options The required width/height ratio to downsize to before computing the render pass.
  71155. * @param camera The camera to apply the render pass to.
  71156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71157. * @param engine The engine which the post process will be applied. (default: current engine)
  71158. * @param reusable If the post process can be reused on the same frame. (default: false)
  71159. */
  71160. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71161. /** @hidden */
  71162. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  71163. }
  71164. }
  71165. declare module BABYLON {
  71166. /** @hidden */
  71167. export var filterPixelShader: {
  71168. name: string;
  71169. shader: string;
  71170. };
  71171. }
  71172. declare module BABYLON {
  71173. /**
  71174. * Applies a kernel filter to the image
  71175. */
  71176. export class FilterPostProcess extends PostProcess {
  71177. /** The matrix to be applied to the image */
  71178. kernelMatrix: Matrix;
  71179. /**
  71180. * Gets a string identifying the name of the class
  71181. * @returns "FilterPostProcess" string
  71182. */
  71183. getClassName(): string;
  71184. /**
  71185. *
  71186. * @param name The name of the effect.
  71187. * @param kernelMatrix The matrix to be applied to the image
  71188. * @param options The required width/height ratio to downsize to before computing the render pass.
  71189. * @param camera The camera to apply the render pass to.
  71190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71191. * @param engine The engine which the post process will be applied. (default: current engine)
  71192. * @param reusable If the post process can be reused on the same frame. (default: false)
  71193. */
  71194. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71195. /** @hidden */
  71196. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  71197. }
  71198. }
  71199. declare module BABYLON {
  71200. /** @hidden */
  71201. export var fxaaPixelShader: {
  71202. name: string;
  71203. shader: string;
  71204. };
  71205. }
  71206. declare module BABYLON {
  71207. /** @hidden */
  71208. export var fxaaVertexShader: {
  71209. name: string;
  71210. shader: string;
  71211. };
  71212. }
  71213. declare module BABYLON {
  71214. /**
  71215. * Fxaa post process
  71216. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  71217. */
  71218. export class FxaaPostProcess extends PostProcess {
  71219. /**
  71220. * Gets a string identifying the name of the class
  71221. * @returns "FxaaPostProcess" string
  71222. */
  71223. getClassName(): string;
  71224. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71225. private _getDefines;
  71226. /** @hidden */
  71227. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  71228. }
  71229. }
  71230. declare module BABYLON {
  71231. /** @hidden */
  71232. export var grainPixelShader: {
  71233. name: string;
  71234. shader: string;
  71235. };
  71236. }
  71237. declare module BABYLON {
  71238. /**
  71239. * The GrainPostProcess adds noise to the image at mid luminance levels
  71240. */
  71241. export class GrainPostProcess extends PostProcess {
  71242. /**
  71243. * The intensity of the grain added (default: 30)
  71244. */
  71245. intensity: number;
  71246. /**
  71247. * If the grain should be randomized on every frame
  71248. */
  71249. animated: boolean;
  71250. /**
  71251. * Gets a string identifying the name of the class
  71252. * @returns "GrainPostProcess" string
  71253. */
  71254. getClassName(): string;
  71255. /**
  71256. * Creates a new instance of @see GrainPostProcess
  71257. * @param name The name of the effect.
  71258. * @param options The required width/height ratio to downsize to before computing the render pass.
  71259. * @param camera The camera to apply the render pass to.
  71260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71261. * @param engine The engine which the post process will be applied. (default: current engine)
  71262. * @param reusable If the post process can be reused on the same frame. (default: false)
  71263. * @param textureType Type of textures used when performing the post process. (default: 0)
  71264. * @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)
  71265. */
  71266. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71267. /** @hidden */
  71268. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  71269. }
  71270. }
  71271. declare module BABYLON {
  71272. /** @hidden */
  71273. export var highlightsPixelShader: {
  71274. name: string;
  71275. shader: string;
  71276. };
  71277. }
  71278. declare module BABYLON {
  71279. /**
  71280. * Extracts highlights from the image
  71281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71282. */
  71283. export class HighlightsPostProcess extends PostProcess {
  71284. /**
  71285. * Gets a string identifying the name of the class
  71286. * @returns "HighlightsPostProcess" string
  71287. */
  71288. getClassName(): string;
  71289. /**
  71290. * Extracts highlights from the image
  71291. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  71292. * @param name The name of the effect.
  71293. * @param options The required width/height ratio to downsize to before computing the render pass.
  71294. * @param camera The camera to apply the render pass to.
  71295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71296. * @param engine The engine which the post process will be applied. (default: current engine)
  71297. * @param reusable If the post process can be reused on the same frame. (default: false)
  71298. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  71299. */
  71300. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71301. }
  71302. }
  71303. declare module BABYLON {
  71304. /**
  71305. * Contains all parameters needed for the prepass to perform
  71306. * motion blur
  71307. */
  71308. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  71309. /**
  71310. * Is motion blur enabled
  71311. */
  71312. enabled: boolean;
  71313. /**
  71314. * Name of the configuration
  71315. */
  71316. name: string;
  71317. /**
  71318. * Textures that should be present in the MRT for this effect to work
  71319. */
  71320. readonly texturesRequired: number[];
  71321. }
  71322. }
  71323. declare module BABYLON {
  71324. interface Scene {
  71325. /** @hidden (Backing field) */
  71326. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71327. /**
  71328. * Gets or Sets the current geometry buffer associated to the scene.
  71329. */
  71330. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  71331. /**
  71332. * Enables a GeometryBufferRender and associates it with the scene
  71333. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  71334. * @returns the GeometryBufferRenderer
  71335. */
  71336. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  71337. /**
  71338. * Disables the GeometryBufferRender associated with the scene
  71339. */
  71340. disableGeometryBufferRenderer(): void;
  71341. }
  71342. /**
  71343. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71344. * in several rendering techniques.
  71345. */
  71346. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  71347. /**
  71348. * The component name helpful to identify the component in the list of scene components.
  71349. */
  71350. readonly name: string;
  71351. /**
  71352. * The scene the component belongs to.
  71353. */
  71354. scene: Scene;
  71355. /**
  71356. * Creates a new instance of the component for the given scene
  71357. * @param scene Defines the scene to register the component in
  71358. */
  71359. constructor(scene: Scene);
  71360. /**
  71361. * Registers the component in a given scene
  71362. */
  71363. register(): void;
  71364. /**
  71365. * Rebuilds the elements related to this component in case of
  71366. * context lost for instance.
  71367. */
  71368. rebuild(): void;
  71369. /**
  71370. * Disposes the component and the associated ressources
  71371. */
  71372. dispose(): void;
  71373. private _gatherRenderTargets;
  71374. }
  71375. }
  71376. declare module BABYLON {
  71377. /** @hidden */
  71378. export var motionBlurPixelShader: {
  71379. name: string;
  71380. shader: string;
  71381. };
  71382. }
  71383. declare module BABYLON {
  71384. /**
  71385. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  71386. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  71387. * As an example, all you have to do is to create the post-process:
  71388. * var mb = new BABYLON.MotionBlurPostProcess(
  71389. * 'mb', // The name of the effect.
  71390. * scene, // The scene containing the objects to blur according to their velocity.
  71391. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  71392. * camera // The camera to apply the render pass to.
  71393. * );
  71394. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  71395. */
  71396. export class MotionBlurPostProcess extends PostProcess {
  71397. /**
  71398. * Defines how much the image is blurred by the movement. Default value is equal to 1
  71399. */
  71400. motionStrength: number;
  71401. /**
  71402. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  71403. */
  71404. get motionBlurSamples(): number;
  71405. /**
  71406. * Sets the number of iterations to be used for motion blur quality
  71407. */
  71408. set motionBlurSamples(samples: number);
  71409. private _motionBlurSamples;
  71410. /**
  71411. * Gets wether or not the motion blur post-process is in object based mode.
  71412. */
  71413. get isObjectBased(): boolean;
  71414. /**
  71415. * Sets wether or not the motion blur post-process is in object based mode.
  71416. */
  71417. set isObjectBased(value: boolean);
  71418. private _isObjectBased;
  71419. private _forceGeometryBuffer;
  71420. private _geometryBufferRenderer;
  71421. private _prePassRenderer;
  71422. private _invViewProjection;
  71423. private _previousViewProjection;
  71424. /**
  71425. * Gets a string identifying the name of the class
  71426. * @returns "MotionBlurPostProcess" string
  71427. */
  71428. getClassName(): string;
  71429. /**
  71430. * Creates a new instance MotionBlurPostProcess
  71431. * @param name The name of the effect.
  71432. * @param scene The scene containing the objects to blur according to their velocity.
  71433. * @param options The required width/height ratio to downsize to before computing the render pass.
  71434. * @param camera The camera to apply the render pass to.
  71435. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71436. * @param engine The engine which the post process will be applied. (default: current engine)
  71437. * @param reusable If the post process can be reused on the same frame. (default: false)
  71438. * @param textureType Type of textures used when performing the post process. (default: 0)
  71439. * @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)
  71440. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71441. */
  71442. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71443. /**
  71444. * Excludes the given skinned mesh from computing bones velocities.
  71445. * 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.
  71446. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  71447. */
  71448. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71449. /**
  71450. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  71451. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  71452. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  71453. */
  71454. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  71455. /**
  71456. * Disposes the post process.
  71457. * @param camera The camera to dispose the post process on.
  71458. */
  71459. dispose(camera?: Camera): void;
  71460. /**
  71461. * Called on the mode changed (object based or screen based).
  71462. */
  71463. private _applyMode;
  71464. /**
  71465. * Called on the effect is applied when the motion blur post-process is in object based mode.
  71466. */
  71467. private _onApplyObjectBased;
  71468. /**
  71469. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  71470. */
  71471. private _onApplyScreenBased;
  71472. /**
  71473. * Called on the effect must be updated (changed mode, samples count, etc.).
  71474. */
  71475. private _updateEffect;
  71476. /** @hidden */
  71477. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  71478. }
  71479. }
  71480. declare module BABYLON {
  71481. /** @hidden */
  71482. export var refractionPixelShader: {
  71483. name: string;
  71484. shader: string;
  71485. };
  71486. }
  71487. declare module BABYLON {
  71488. /**
  71489. * Post process which applies a refractin texture
  71490. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71491. */
  71492. export class RefractionPostProcess extends PostProcess {
  71493. private _refTexture;
  71494. private _ownRefractionTexture;
  71495. /** the base color of the refraction (used to taint the rendering) */
  71496. color: Color3;
  71497. /** simulated refraction depth */
  71498. depth: number;
  71499. /** the coefficient of the base color (0 to remove base color tainting) */
  71500. colorLevel: number;
  71501. /** Gets the url used to load the refraction texture */
  71502. refractionTextureUrl: string;
  71503. /**
  71504. * Gets or sets the refraction texture
  71505. * Please note that you are responsible for disposing the texture if you set it manually
  71506. */
  71507. get refractionTexture(): Texture;
  71508. set refractionTexture(value: Texture);
  71509. /**
  71510. * Gets a string identifying the name of the class
  71511. * @returns "RefractionPostProcess" string
  71512. */
  71513. getClassName(): string;
  71514. /**
  71515. * Initializes the RefractionPostProcess
  71516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  71517. * @param name The name of the effect.
  71518. * @param refractionTextureUrl Url of the refraction texture to use
  71519. * @param color the base color of the refraction (used to taint the rendering)
  71520. * @param depth simulated refraction depth
  71521. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  71522. * @param camera The camera to apply the render pass to.
  71523. * @param options The required width/height ratio to downsize to before computing the render pass.
  71524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71525. * @param engine The engine which the post process will be applied. (default: current engine)
  71526. * @param reusable If the post process can be reused on the same frame. (default: false)
  71527. */
  71528. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71529. /**
  71530. * Disposes of the post process
  71531. * @param camera Camera to dispose post process on
  71532. */
  71533. dispose(camera: Camera): void;
  71534. /** @hidden */
  71535. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  71536. }
  71537. }
  71538. declare module BABYLON {
  71539. /** @hidden */
  71540. export var sharpenPixelShader: {
  71541. name: string;
  71542. shader: string;
  71543. };
  71544. }
  71545. declare module BABYLON {
  71546. /**
  71547. * The SharpenPostProcess applies a sharpen kernel to every pixel
  71548. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71549. */
  71550. export class SharpenPostProcess extends PostProcess {
  71551. /**
  71552. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  71553. */
  71554. colorAmount: number;
  71555. /**
  71556. * How much sharpness should be applied (default: 0.3)
  71557. */
  71558. edgeAmount: number;
  71559. /**
  71560. * Gets a string identifying the name of the class
  71561. * @returns "SharpenPostProcess" string
  71562. */
  71563. getClassName(): string;
  71564. /**
  71565. * Creates a new instance ConvolutionPostProcess
  71566. * @param name The name of the effect.
  71567. * @param options The required width/height ratio to downsize to before computing the render pass.
  71568. * @param camera The camera to apply the render pass to.
  71569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71570. * @param engine The engine which the post process will be applied. (default: current engine)
  71571. * @param reusable If the post process can be reused on the same frame. (default: false)
  71572. * @param textureType Type of textures used when performing the post process. (default: 0)
  71573. * @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)
  71574. */
  71575. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71576. /** @hidden */
  71577. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  71578. }
  71579. }
  71580. declare module BABYLON {
  71581. /**
  71582. * PostProcessRenderPipeline
  71583. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71584. */
  71585. export class PostProcessRenderPipeline {
  71586. private engine;
  71587. private _renderEffects;
  71588. private _renderEffectsForIsolatedPass;
  71589. /**
  71590. * List of inspectable custom properties (used by the Inspector)
  71591. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71592. */
  71593. inspectableCustomProperties: IInspectable[];
  71594. /**
  71595. * @hidden
  71596. */
  71597. protected _cameras: Camera[];
  71598. /** @hidden */
  71599. _name: string;
  71600. /**
  71601. * Gets pipeline name
  71602. */
  71603. get name(): string;
  71604. /** Gets the list of attached cameras */
  71605. get cameras(): Camera[];
  71606. /**
  71607. * Initializes a PostProcessRenderPipeline
  71608. * @param engine engine to add the pipeline to
  71609. * @param name name of the pipeline
  71610. */
  71611. constructor(engine: Engine, name: string);
  71612. /**
  71613. * Gets the class name
  71614. * @returns "PostProcessRenderPipeline"
  71615. */
  71616. getClassName(): string;
  71617. /**
  71618. * If all the render effects in the pipeline are supported
  71619. */
  71620. get isSupported(): boolean;
  71621. /**
  71622. * Adds an effect to the pipeline
  71623. * @param renderEffect the effect to add
  71624. */
  71625. addEffect(renderEffect: PostProcessRenderEffect): void;
  71626. /** @hidden */
  71627. _rebuild(): void;
  71628. /** @hidden */
  71629. _enableEffect(renderEffectName: string, cameras: Camera): void;
  71630. /** @hidden */
  71631. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  71632. /** @hidden */
  71633. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71634. /** @hidden */
  71635. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  71636. /** @hidden */
  71637. _attachCameras(cameras: Camera, unique: boolean): void;
  71638. /** @hidden */
  71639. _attachCameras(cameras: Camera[], unique: boolean): void;
  71640. /** @hidden */
  71641. _detachCameras(cameras: Camera): void;
  71642. /** @hidden */
  71643. _detachCameras(cameras: Nullable<Camera[]>): void;
  71644. /** @hidden */
  71645. _update(): void;
  71646. /** @hidden */
  71647. _reset(): void;
  71648. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  71649. /**
  71650. * Sets the required values to the prepass renderer.
  71651. * @param prePassRenderer defines the prepass renderer to setup.
  71652. * @returns true if the pre pass is needed.
  71653. */
  71654. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  71655. /**
  71656. * Disposes of the pipeline
  71657. */
  71658. dispose(): void;
  71659. }
  71660. }
  71661. declare module BABYLON {
  71662. /**
  71663. * PostProcessRenderPipelineManager class
  71664. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71665. */
  71666. export class PostProcessRenderPipelineManager {
  71667. private _renderPipelines;
  71668. /**
  71669. * Initializes a PostProcessRenderPipelineManager
  71670. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71671. */
  71672. constructor();
  71673. /**
  71674. * Gets the list of supported render pipelines
  71675. */
  71676. get supportedPipelines(): PostProcessRenderPipeline[];
  71677. /**
  71678. * Adds a pipeline to the manager
  71679. * @param renderPipeline The pipeline to add
  71680. */
  71681. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  71682. /**
  71683. * Attaches a camera to the pipeline
  71684. * @param renderPipelineName The name of the pipeline to attach to
  71685. * @param cameras the camera to attach
  71686. * @param unique if the camera can be attached multiple times to the pipeline
  71687. */
  71688. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  71689. /**
  71690. * Detaches a camera from the pipeline
  71691. * @param renderPipelineName The name of the pipeline to detach from
  71692. * @param cameras the camera to detach
  71693. */
  71694. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  71695. /**
  71696. * Enables an effect by name on a pipeline
  71697. * @param renderPipelineName the name of the pipeline to enable the effect in
  71698. * @param renderEffectName the name of the effect to enable
  71699. * @param cameras the cameras that the effect should be enabled on
  71700. */
  71701. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71702. /**
  71703. * Disables an effect by name on a pipeline
  71704. * @param renderPipelineName the name of the pipeline to disable the effect in
  71705. * @param renderEffectName the name of the effect to disable
  71706. * @param cameras the cameras that the effect should be disabled on
  71707. */
  71708. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  71709. /**
  71710. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  71711. */
  71712. update(): void;
  71713. /** @hidden */
  71714. _rebuild(): void;
  71715. /**
  71716. * Disposes of the manager and pipelines
  71717. */
  71718. dispose(): void;
  71719. }
  71720. }
  71721. declare module BABYLON {
  71722. interface Scene {
  71723. /** @hidden (Backing field) */
  71724. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71725. /**
  71726. * Gets the postprocess render pipeline manager
  71727. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71728. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71729. */
  71730. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  71731. }
  71732. /**
  71733. * Defines the Render Pipeline scene component responsible to rendering pipelines
  71734. */
  71735. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  71736. /**
  71737. * The component name helpfull to identify the component in the list of scene components.
  71738. */
  71739. readonly name: string;
  71740. /**
  71741. * The scene the component belongs to.
  71742. */
  71743. scene: Scene;
  71744. /**
  71745. * Creates a new instance of the component for the given scene
  71746. * @param scene Defines the scene to register the component in
  71747. */
  71748. constructor(scene: Scene);
  71749. /**
  71750. * Registers the component in a given scene
  71751. */
  71752. register(): void;
  71753. /**
  71754. * Rebuilds the elements related to this component in case of
  71755. * context lost for instance.
  71756. */
  71757. rebuild(): void;
  71758. /**
  71759. * Disposes the component and the associated ressources
  71760. */
  71761. dispose(): void;
  71762. private _gatherRenderTargets;
  71763. }
  71764. }
  71765. declare module BABYLON {
  71766. /**
  71767. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  71768. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  71769. */
  71770. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71771. private _scene;
  71772. private _camerasToBeAttached;
  71773. /**
  71774. * ID of the sharpen post process,
  71775. */
  71776. private readonly SharpenPostProcessId;
  71777. /**
  71778. * @ignore
  71779. * ID of the image processing post process;
  71780. */
  71781. readonly ImageProcessingPostProcessId: string;
  71782. /**
  71783. * @ignore
  71784. * ID of the Fast Approximate Anti-Aliasing post process;
  71785. */
  71786. readonly FxaaPostProcessId: string;
  71787. /**
  71788. * ID of the chromatic aberration post process,
  71789. */
  71790. private readonly ChromaticAberrationPostProcessId;
  71791. /**
  71792. * ID of the grain post process
  71793. */
  71794. private readonly GrainPostProcessId;
  71795. /**
  71796. * Sharpen post process which will apply a sharpen convolution to enhance edges
  71797. */
  71798. sharpen: SharpenPostProcess;
  71799. private _sharpenEffect;
  71800. private bloom;
  71801. /**
  71802. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  71803. */
  71804. depthOfField: DepthOfFieldEffect;
  71805. /**
  71806. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71807. */
  71808. fxaa: FxaaPostProcess;
  71809. /**
  71810. * Image post processing pass used to perform operations such as tone mapping or color grading.
  71811. */
  71812. imageProcessing: ImageProcessingPostProcess;
  71813. /**
  71814. * Chromatic aberration post process which will shift rgb colors in the image
  71815. */
  71816. chromaticAberration: ChromaticAberrationPostProcess;
  71817. private _chromaticAberrationEffect;
  71818. /**
  71819. * Grain post process which add noise to the image
  71820. */
  71821. grain: GrainPostProcess;
  71822. private _grainEffect;
  71823. /**
  71824. * Glow post process which adds a glow to emissive areas of the image
  71825. */
  71826. private _glowLayer;
  71827. /**
  71828. * Animations which can be used to tweak settings over a period of time
  71829. */
  71830. animations: Animation[];
  71831. private _imageProcessingConfigurationObserver;
  71832. private _sharpenEnabled;
  71833. private _bloomEnabled;
  71834. private _depthOfFieldEnabled;
  71835. private _depthOfFieldBlurLevel;
  71836. private _fxaaEnabled;
  71837. private _imageProcessingEnabled;
  71838. private _defaultPipelineTextureType;
  71839. private _bloomScale;
  71840. private _chromaticAberrationEnabled;
  71841. private _grainEnabled;
  71842. private _buildAllowed;
  71843. /**
  71844. * This is triggered each time the pipeline has been built.
  71845. */
  71846. onBuildObservable: Observable<DefaultRenderingPipeline>;
  71847. /**
  71848. * Gets active scene
  71849. */
  71850. get scene(): Scene;
  71851. /**
  71852. * Enable or disable the sharpen process from the pipeline
  71853. */
  71854. set sharpenEnabled(enabled: boolean);
  71855. get sharpenEnabled(): boolean;
  71856. private _resizeObserver;
  71857. private _hardwareScaleLevel;
  71858. private _bloomKernel;
  71859. /**
  71860. * Specifies the size of the bloom blur kernel, relative to the final output size
  71861. */
  71862. get bloomKernel(): number;
  71863. set bloomKernel(value: number);
  71864. /**
  71865. * Specifies the weight of the bloom in the final rendering
  71866. */
  71867. private _bloomWeight;
  71868. /**
  71869. * Specifies the luma threshold for the area that will be blurred by the bloom
  71870. */
  71871. private _bloomThreshold;
  71872. private _hdr;
  71873. /**
  71874. * The strength of the bloom.
  71875. */
  71876. set bloomWeight(value: number);
  71877. get bloomWeight(): number;
  71878. /**
  71879. * The strength of the bloom.
  71880. */
  71881. set bloomThreshold(value: number);
  71882. get bloomThreshold(): number;
  71883. /**
  71884. * The scale of the bloom, lower value will provide better performance.
  71885. */
  71886. set bloomScale(value: number);
  71887. get bloomScale(): number;
  71888. /**
  71889. * Enable or disable the bloom from the pipeline
  71890. */
  71891. set bloomEnabled(enabled: boolean);
  71892. get bloomEnabled(): boolean;
  71893. private _rebuildBloom;
  71894. /**
  71895. * If the depth of field is enabled.
  71896. */
  71897. get depthOfFieldEnabled(): boolean;
  71898. set depthOfFieldEnabled(enabled: boolean);
  71899. /**
  71900. * Blur level of the depth of field effect. (Higher blur will effect performance)
  71901. */
  71902. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  71903. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  71904. /**
  71905. * If the anti aliasing is enabled.
  71906. */
  71907. set fxaaEnabled(enabled: boolean);
  71908. get fxaaEnabled(): boolean;
  71909. private _samples;
  71910. /**
  71911. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71912. */
  71913. set samples(sampleCount: number);
  71914. get samples(): number;
  71915. /**
  71916. * If image processing is enabled.
  71917. */
  71918. set imageProcessingEnabled(enabled: boolean);
  71919. get imageProcessingEnabled(): boolean;
  71920. /**
  71921. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  71922. */
  71923. set glowLayerEnabled(enabled: boolean);
  71924. get glowLayerEnabled(): boolean;
  71925. /**
  71926. * Gets the glow layer (or null if not defined)
  71927. */
  71928. get glowLayer(): Nullable<GlowLayer>;
  71929. /**
  71930. * Enable or disable the chromaticAberration process from the pipeline
  71931. */
  71932. set chromaticAberrationEnabled(enabled: boolean);
  71933. get chromaticAberrationEnabled(): boolean;
  71934. /**
  71935. * Enable or disable the grain process from the pipeline
  71936. */
  71937. set grainEnabled(enabled: boolean);
  71938. get grainEnabled(): boolean;
  71939. /**
  71940. * @constructor
  71941. * @param name - The rendering pipeline name (default: "")
  71942. * @param hdr - If high dynamic range textures should be used (default: true)
  71943. * @param scene - The scene linked to this pipeline (default: the last created scene)
  71944. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  71945. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  71946. */
  71947. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  71948. /**
  71949. * Get the class name
  71950. * @returns "DefaultRenderingPipeline"
  71951. */
  71952. getClassName(): string;
  71953. /**
  71954. * Force the compilation of the entire pipeline.
  71955. */
  71956. prepare(): void;
  71957. private _hasCleared;
  71958. private _prevPostProcess;
  71959. private _prevPrevPostProcess;
  71960. private _setAutoClearAndTextureSharing;
  71961. private _depthOfFieldSceneObserver;
  71962. private _buildPipeline;
  71963. private _disposePostProcesses;
  71964. /**
  71965. * Adds a camera to the pipeline
  71966. * @param camera the camera to be added
  71967. */
  71968. addCamera(camera: Camera): void;
  71969. /**
  71970. * Removes a camera from the pipeline
  71971. * @param camera the camera to remove
  71972. */
  71973. removeCamera(camera: Camera): void;
  71974. /**
  71975. * Dispose of the pipeline and stop all post processes
  71976. */
  71977. dispose(): void;
  71978. /**
  71979. * Serialize the rendering pipeline (Used when exporting)
  71980. * @returns the serialized object
  71981. */
  71982. serialize(): any;
  71983. /**
  71984. * Parse the serialized pipeline
  71985. * @param source Source pipeline.
  71986. * @param scene The scene to load the pipeline to.
  71987. * @param rootUrl The URL of the serialized pipeline.
  71988. * @returns An instantiated pipeline from the serialized object.
  71989. */
  71990. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71991. }
  71992. }
  71993. declare module BABYLON {
  71994. /** @hidden */
  71995. export var lensHighlightsPixelShader: {
  71996. name: string;
  71997. shader: string;
  71998. };
  71999. }
  72000. declare module BABYLON {
  72001. /** @hidden */
  72002. export var depthOfFieldPixelShader: {
  72003. name: string;
  72004. shader: string;
  72005. };
  72006. }
  72007. declare module BABYLON {
  72008. /**
  72009. * BABYLON.JS Chromatic Aberration GLSL Shader
  72010. * Author: Olivier Guyot
  72011. * Separates very slightly R, G and B colors on the edges of the screen
  72012. * Inspired by Francois Tarlier & Martins Upitis
  72013. */
  72014. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  72015. /**
  72016. * @ignore
  72017. * The chromatic aberration PostProcess id in the pipeline
  72018. */
  72019. LensChromaticAberrationEffect: string;
  72020. /**
  72021. * @ignore
  72022. * The highlights enhancing PostProcess id in the pipeline
  72023. */
  72024. HighlightsEnhancingEffect: string;
  72025. /**
  72026. * @ignore
  72027. * The depth-of-field PostProcess id in the pipeline
  72028. */
  72029. LensDepthOfFieldEffect: string;
  72030. private _scene;
  72031. private _depthTexture;
  72032. private _grainTexture;
  72033. private _chromaticAberrationPostProcess;
  72034. private _highlightsPostProcess;
  72035. private _depthOfFieldPostProcess;
  72036. private _edgeBlur;
  72037. private _grainAmount;
  72038. private _chromaticAberration;
  72039. private _distortion;
  72040. private _highlightsGain;
  72041. private _highlightsThreshold;
  72042. private _dofDistance;
  72043. private _dofAperture;
  72044. private _dofDarken;
  72045. private _dofPentagon;
  72046. private _blurNoise;
  72047. /**
  72048. * @constructor
  72049. *
  72050. * Effect parameters are as follow:
  72051. * {
  72052. * chromatic_aberration: number; // from 0 to x (1 for realism)
  72053. * edge_blur: number; // from 0 to x (1 for realism)
  72054. * distortion: number; // from 0 to x (1 for realism)
  72055. * grain_amount: number; // from 0 to 1
  72056. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  72057. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  72058. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  72059. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  72060. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  72061. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  72062. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  72063. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  72064. * }
  72065. * Note: if an effect parameter is unset, effect is disabled
  72066. *
  72067. * @param name The rendering pipeline name
  72068. * @param parameters - An object containing all parameters (see above)
  72069. * @param scene The scene linked to this pipeline
  72070. * @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)
  72071. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72072. */
  72073. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  72074. /**
  72075. * Get the class name
  72076. * @returns "LensRenderingPipeline"
  72077. */
  72078. getClassName(): string;
  72079. /**
  72080. * Gets associated scene
  72081. */
  72082. get scene(): Scene;
  72083. /**
  72084. * Gets or sets the edge blur
  72085. */
  72086. get edgeBlur(): number;
  72087. set edgeBlur(value: number);
  72088. /**
  72089. * Gets or sets the grain amount
  72090. */
  72091. get grainAmount(): number;
  72092. set grainAmount(value: number);
  72093. /**
  72094. * Gets or sets the chromatic aberration amount
  72095. */
  72096. get chromaticAberration(): number;
  72097. set chromaticAberration(value: number);
  72098. /**
  72099. * Gets or sets the depth of field aperture
  72100. */
  72101. get dofAperture(): number;
  72102. set dofAperture(value: number);
  72103. /**
  72104. * Gets or sets the edge distortion
  72105. */
  72106. get edgeDistortion(): number;
  72107. set edgeDistortion(value: number);
  72108. /**
  72109. * Gets or sets the depth of field distortion
  72110. */
  72111. get dofDistortion(): number;
  72112. set dofDistortion(value: number);
  72113. /**
  72114. * Gets or sets the darken out of focus amount
  72115. */
  72116. get darkenOutOfFocus(): number;
  72117. set darkenOutOfFocus(value: number);
  72118. /**
  72119. * Gets or sets a boolean indicating if blur noise is enabled
  72120. */
  72121. get blurNoise(): boolean;
  72122. set blurNoise(value: boolean);
  72123. /**
  72124. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  72125. */
  72126. get pentagonBokeh(): boolean;
  72127. set pentagonBokeh(value: boolean);
  72128. /**
  72129. * Gets or sets the highlight grain amount
  72130. */
  72131. get highlightsGain(): number;
  72132. set highlightsGain(value: number);
  72133. /**
  72134. * Gets or sets the highlight threshold
  72135. */
  72136. get highlightsThreshold(): number;
  72137. set highlightsThreshold(value: number);
  72138. /**
  72139. * Sets the amount of blur at the edges
  72140. * @param amount blur amount
  72141. */
  72142. setEdgeBlur(amount: number): void;
  72143. /**
  72144. * Sets edge blur to 0
  72145. */
  72146. disableEdgeBlur(): void;
  72147. /**
  72148. * Sets the amout of grain
  72149. * @param amount Amount of grain
  72150. */
  72151. setGrainAmount(amount: number): void;
  72152. /**
  72153. * Set grain amount to 0
  72154. */
  72155. disableGrain(): void;
  72156. /**
  72157. * Sets the chromatic aberration amount
  72158. * @param amount amount of chromatic aberration
  72159. */
  72160. setChromaticAberration(amount: number): void;
  72161. /**
  72162. * Sets chromatic aberration amount to 0
  72163. */
  72164. disableChromaticAberration(): void;
  72165. /**
  72166. * Sets the EdgeDistortion amount
  72167. * @param amount amount of EdgeDistortion
  72168. */
  72169. setEdgeDistortion(amount: number): void;
  72170. /**
  72171. * Sets edge distortion to 0
  72172. */
  72173. disableEdgeDistortion(): void;
  72174. /**
  72175. * Sets the FocusDistance amount
  72176. * @param amount amount of FocusDistance
  72177. */
  72178. setFocusDistance(amount: number): void;
  72179. /**
  72180. * Disables depth of field
  72181. */
  72182. disableDepthOfField(): void;
  72183. /**
  72184. * Sets the Aperture amount
  72185. * @param amount amount of Aperture
  72186. */
  72187. setAperture(amount: number): void;
  72188. /**
  72189. * Sets the DarkenOutOfFocus amount
  72190. * @param amount amount of DarkenOutOfFocus
  72191. */
  72192. setDarkenOutOfFocus(amount: number): void;
  72193. private _pentagonBokehIsEnabled;
  72194. /**
  72195. * Creates a pentagon bokeh effect
  72196. */
  72197. enablePentagonBokeh(): void;
  72198. /**
  72199. * Disables the pentagon bokeh effect
  72200. */
  72201. disablePentagonBokeh(): void;
  72202. /**
  72203. * Enables noise blur
  72204. */
  72205. enableNoiseBlur(): void;
  72206. /**
  72207. * Disables noise blur
  72208. */
  72209. disableNoiseBlur(): void;
  72210. /**
  72211. * Sets the HighlightsGain amount
  72212. * @param amount amount of HighlightsGain
  72213. */
  72214. setHighlightsGain(amount: number): void;
  72215. /**
  72216. * Sets the HighlightsThreshold amount
  72217. * @param amount amount of HighlightsThreshold
  72218. */
  72219. setHighlightsThreshold(amount: number): void;
  72220. /**
  72221. * Disables highlights
  72222. */
  72223. disableHighlights(): void;
  72224. /**
  72225. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  72226. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  72227. */
  72228. dispose(disableDepthRender?: boolean): void;
  72229. private _createChromaticAberrationPostProcess;
  72230. private _createHighlightsPostProcess;
  72231. private _createDepthOfFieldPostProcess;
  72232. private _createGrainTexture;
  72233. }
  72234. }
  72235. declare module BABYLON {
  72236. /**
  72237. * Contains all parameters needed for the prepass to perform
  72238. * screen space subsurface scattering
  72239. */
  72240. export class SSAO2Configuration implements PrePassEffectConfiguration {
  72241. /**
  72242. * Is subsurface enabled
  72243. */
  72244. enabled: boolean;
  72245. /**
  72246. * Name of the configuration
  72247. */
  72248. name: string;
  72249. /**
  72250. * Textures that should be present in the MRT for this effect to work
  72251. */
  72252. readonly texturesRequired: number[];
  72253. }
  72254. }
  72255. declare module BABYLON {
  72256. /** @hidden */
  72257. export var ssao2PixelShader: {
  72258. name: string;
  72259. shader: string;
  72260. };
  72261. }
  72262. declare module BABYLON {
  72263. /** @hidden */
  72264. export var ssaoCombinePixelShader: {
  72265. name: string;
  72266. shader: string;
  72267. };
  72268. }
  72269. declare module BABYLON {
  72270. /**
  72271. * Render pipeline to produce ssao effect
  72272. */
  72273. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  72274. /**
  72275. * @ignore
  72276. * The PassPostProcess id in the pipeline that contains the original scene color
  72277. */
  72278. SSAOOriginalSceneColorEffect: string;
  72279. /**
  72280. * @ignore
  72281. * The SSAO PostProcess id in the pipeline
  72282. */
  72283. SSAORenderEffect: string;
  72284. /**
  72285. * @ignore
  72286. * The horizontal blur PostProcess id in the pipeline
  72287. */
  72288. SSAOBlurHRenderEffect: string;
  72289. /**
  72290. * @ignore
  72291. * The vertical blur PostProcess id in the pipeline
  72292. */
  72293. SSAOBlurVRenderEffect: string;
  72294. /**
  72295. * @ignore
  72296. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72297. */
  72298. SSAOCombineRenderEffect: string;
  72299. /**
  72300. * The output strength of the SSAO post-process. Default value is 1.0.
  72301. */
  72302. totalStrength: number;
  72303. /**
  72304. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  72305. */
  72306. maxZ: number;
  72307. /**
  72308. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  72309. */
  72310. minZAspect: number;
  72311. private _samples;
  72312. /**
  72313. * Number of samples used for the SSAO calculations. Default value is 8
  72314. */
  72315. set samples(n: number);
  72316. get samples(): number;
  72317. private _textureSamples;
  72318. /**
  72319. * Number of samples to use for antialiasing
  72320. */
  72321. set textureSamples(n: number);
  72322. get textureSamples(): number;
  72323. /**
  72324. * Force rendering the geometry through geometry buffer
  72325. */
  72326. private _forceGeometryBuffer;
  72327. /**
  72328. * Ratio object used for SSAO ratio and blur ratio
  72329. */
  72330. private _ratio;
  72331. /**
  72332. * Dynamically generated sphere sampler.
  72333. */
  72334. private _sampleSphere;
  72335. /**
  72336. * Blur filter offsets
  72337. */
  72338. private _samplerOffsets;
  72339. private _expensiveBlur;
  72340. /**
  72341. * If bilateral blur should be used
  72342. */
  72343. set expensiveBlur(b: boolean);
  72344. get expensiveBlur(): boolean;
  72345. /**
  72346. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  72347. */
  72348. radius: number;
  72349. /**
  72350. * The base color of the SSAO post-process
  72351. * The final result is "base + ssao" between [0, 1]
  72352. */
  72353. base: number;
  72354. /**
  72355. * Support test.
  72356. */
  72357. static get IsSupported(): boolean;
  72358. private _scene;
  72359. private _randomTexture;
  72360. private _originalColorPostProcess;
  72361. private _ssaoPostProcess;
  72362. private _blurHPostProcess;
  72363. private _blurVPostProcess;
  72364. private _ssaoCombinePostProcess;
  72365. private _prePassRenderer;
  72366. /**
  72367. * Gets active scene
  72368. */
  72369. get scene(): Scene;
  72370. /**
  72371. * @constructor
  72372. * @param name The rendering pipeline name
  72373. * @param scene The scene linked to this pipeline
  72374. * @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 }
  72375. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72376. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  72377. */
  72378. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  72379. /**
  72380. * Get the class name
  72381. * @returns "SSAO2RenderingPipeline"
  72382. */
  72383. getClassName(): string;
  72384. /**
  72385. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72386. */
  72387. dispose(disableGeometryBufferRenderer?: boolean): void;
  72388. private _createBlurPostProcess;
  72389. /** @hidden */
  72390. _rebuild(): void;
  72391. private _bits;
  72392. private _radicalInverse_VdC;
  72393. private _hammersley;
  72394. private _hemisphereSample_uniform;
  72395. private _generateHemisphere;
  72396. private _getDefinesForSSAO;
  72397. private _createSSAOPostProcess;
  72398. private _createSSAOCombinePostProcess;
  72399. private _createRandomTexture;
  72400. /**
  72401. * Serialize the rendering pipeline (Used when exporting)
  72402. * @returns the serialized object
  72403. */
  72404. serialize(): any;
  72405. /**
  72406. * Parse the serialized pipeline
  72407. * @param source Source pipeline.
  72408. * @param scene The scene to load the pipeline to.
  72409. * @param rootUrl The URL of the serialized pipeline.
  72410. * @returns An instantiated pipeline from the serialized object.
  72411. */
  72412. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  72413. }
  72414. }
  72415. declare module BABYLON {
  72416. /** @hidden */
  72417. export var ssaoPixelShader: {
  72418. name: string;
  72419. shader: string;
  72420. };
  72421. }
  72422. declare module BABYLON {
  72423. /**
  72424. * Render pipeline to produce ssao effect
  72425. */
  72426. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  72427. /**
  72428. * @ignore
  72429. * The PassPostProcess id in the pipeline that contains the original scene color
  72430. */
  72431. SSAOOriginalSceneColorEffect: string;
  72432. /**
  72433. * @ignore
  72434. * The SSAO PostProcess id in the pipeline
  72435. */
  72436. SSAORenderEffect: string;
  72437. /**
  72438. * @ignore
  72439. * The horizontal blur PostProcess id in the pipeline
  72440. */
  72441. SSAOBlurHRenderEffect: string;
  72442. /**
  72443. * @ignore
  72444. * The vertical blur PostProcess id in the pipeline
  72445. */
  72446. SSAOBlurVRenderEffect: string;
  72447. /**
  72448. * @ignore
  72449. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  72450. */
  72451. SSAOCombineRenderEffect: string;
  72452. /**
  72453. * The output strength of the SSAO post-process. Default value is 1.0.
  72454. */
  72455. totalStrength: number;
  72456. /**
  72457. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  72458. */
  72459. radius: number;
  72460. /**
  72461. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  72462. * Must not be equal to fallOff and superior to fallOff.
  72463. * Default value is 0.0075
  72464. */
  72465. area: number;
  72466. /**
  72467. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  72468. * Must not be equal to area and inferior to area.
  72469. * Default value is 0.000001
  72470. */
  72471. fallOff: number;
  72472. /**
  72473. * The base color of the SSAO post-process
  72474. * The final result is "base + ssao" between [0, 1]
  72475. */
  72476. base: number;
  72477. private _scene;
  72478. private _depthTexture;
  72479. private _randomTexture;
  72480. private _originalColorPostProcess;
  72481. private _ssaoPostProcess;
  72482. private _blurHPostProcess;
  72483. private _blurVPostProcess;
  72484. private _ssaoCombinePostProcess;
  72485. private _firstUpdate;
  72486. /**
  72487. * Gets active scene
  72488. */
  72489. get scene(): Scene;
  72490. /**
  72491. * @constructor
  72492. * @param name - The rendering pipeline name
  72493. * @param scene - The scene linked to this pipeline
  72494. * @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 }
  72495. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  72496. */
  72497. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  72498. /**
  72499. * Get the class name
  72500. * @returns "SSAORenderingPipeline"
  72501. */
  72502. getClassName(): string;
  72503. /**
  72504. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  72505. */
  72506. dispose(disableDepthRender?: boolean): void;
  72507. private _createBlurPostProcess;
  72508. /** @hidden */
  72509. _rebuild(): void;
  72510. private _createSSAOPostProcess;
  72511. private _createSSAOCombinePostProcess;
  72512. private _createRandomTexture;
  72513. }
  72514. }
  72515. declare module BABYLON {
  72516. /**
  72517. * Contains all parameters needed for the prepass to perform
  72518. * screen space reflections
  72519. */
  72520. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  72521. /**
  72522. * Is ssr enabled
  72523. */
  72524. enabled: boolean;
  72525. /**
  72526. * Name of the configuration
  72527. */
  72528. name: string;
  72529. /**
  72530. * Textures that should be present in the MRT for this effect to work
  72531. */
  72532. readonly texturesRequired: number[];
  72533. }
  72534. }
  72535. declare module BABYLON {
  72536. /** @hidden */
  72537. export var screenSpaceReflectionPixelShader: {
  72538. name: string;
  72539. shader: string;
  72540. };
  72541. }
  72542. declare module BABYLON {
  72543. /**
  72544. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  72545. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  72546. */
  72547. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  72548. /**
  72549. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  72550. */
  72551. threshold: number;
  72552. /**
  72553. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  72554. */
  72555. strength: number;
  72556. /**
  72557. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  72558. */
  72559. reflectionSpecularFalloffExponent: number;
  72560. /**
  72561. * 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]
  72562. */
  72563. step: number;
  72564. /**
  72565. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  72566. */
  72567. roughnessFactor: number;
  72568. private _forceGeometryBuffer;
  72569. private _geometryBufferRenderer;
  72570. private _prePassRenderer;
  72571. private _enableSmoothReflections;
  72572. private _reflectionSamples;
  72573. private _smoothSteps;
  72574. /**
  72575. * Gets a string identifying the name of the class
  72576. * @returns "ScreenSpaceReflectionPostProcess" string
  72577. */
  72578. getClassName(): string;
  72579. /**
  72580. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  72581. * @param name The name of the effect.
  72582. * @param scene The scene containing the objects to calculate reflections.
  72583. * @param options The required width/height ratio to downsize to before computing the render pass.
  72584. * @param camera The camera to apply the render pass to.
  72585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72586. * @param engine The engine which the post process will be applied. (default: current engine)
  72587. * @param reusable If the post process can be reused on the same frame. (default: false)
  72588. * @param textureType Type of textures used when performing the post process. (default: 0)
  72589. * @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)
  72590. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  72591. */
  72592. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  72593. /**
  72594. * Gets wether or not smoothing reflections is enabled.
  72595. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72596. */
  72597. get enableSmoothReflections(): boolean;
  72598. /**
  72599. * Sets wether or not smoothing reflections is enabled.
  72600. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  72601. */
  72602. set enableSmoothReflections(enabled: boolean);
  72603. /**
  72604. * Gets the number of samples taken while computing reflections. More samples count is high,
  72605. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72606. */
  72607. get reflectionSamples(): number;
  72608. /**
  72609. * Sets the number of samples taken while computing reflections. More samples count is high,
  72610. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  72611. */
  72612. set reflectionSamples(samples: number);
  72613. /**
  72614. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  72615. * more the post-process will require GPU power and can generate a drop in FPS.
  72616. * Default value (5.0) work pretty well in all cases but can be adjusted.
  72617. */
  72618. get smoothSteps(): number;
  72619. set smoothSteps(steps: number);
  72620. private _updateEffectDefines;
  72621. /** @hidden */
  72622. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  72623. }
  72624. }
  72625. declare module BABYLON {
  72626. /** @hidden */
  72627. export var standardPixelShader: {
  72628. name: string;
  72629. shader: string;
  72630. };
  72631. }
  72632. declare module BABYLON {
  72633. /**
  72634. * Standard rendering pipeline
  72635. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72636. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  72637. */
  72638. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  72639. /**
  72640. * Public members
  72641. */
  72642. /**
  72643. * Post-process which contains the original scene color before the pipeline applies all the effects
  72644. */
  72645. originalPostProcess: Nullable<PostProcess>;
  72646. /**
  72647. * Post-process used to down scale an image x4
  72648. */
  72649. downSampleX4PostProcess: Nullable<PostProcess>;
  72650. /**
  72651. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  72652. */
  72653. brightPassPostProcess: Nullable<PostProcess>;
  72654. /**
  72655. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  72656. */
  72657. blurHPostProcesses: PostProcess[];
  72658. /**
  72659. * Post-process array storing all the vertical blur post-processes used by the pipeline
  72660. */
  72661. blurVPostProcesses: PostProcess[];
  72662. /**
  72663. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  72664. */
  72665. textureAdderPostProcess: Nullable<PostProcess>;
  72666. /**
  72667. * Post-process used to create volumetric lighting effect
  72668. */
  72669. volumetricLightPostProcess: Nullable<PostProcess>;
  72670. /**
  72671. * Post-process used to smooth the previous volumetric light post-process on the X axis
  72672. */
  72673. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  72674. /**
  72675. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  72676. */
  72677. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  72678. /**
  72679. * Post-process used to merge the volumetric light effect and the real scene color
  72680. */
  72681. volumetricLightMergePostProces: Nullable<PostProcess>;
  72682. /**
  72683. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  72684. */
  72685. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  72686. /**
  72687. * Base post-process used to calculate the average luminance of the final image for HDR
  72688. */
  72689. luminancePostProcess: Nullable<PostProcess>;
  72690. /**
  72691. * Post-processes used to create down sample post-processes in order to get
  72692. * the average luminance of the final image for HDR
  72693. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  72694. */
  72695. luminanceDownSamplePostProcesses: PostProcess[];
  72696. /**
  72697. * Post-process used to create a HDR effect (light adaptation)
  72698. */
  72699. hdrPostProcess: Nullable<PostProcess>;
  72700. /**
  72701. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  72702. */
  72703. textureAdderFinalPostProcess: Nullable<PostProcess>;
  72704. /**
  72705. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  72706. */
  72707. lensFlareFinalPostProcess: Nullable<PostProcess>;
  72708. /**
  72709. * Post-process used to merge the final HDR post-process and the real scene color
  72710. */
  72711. hdrFinalPostProcess: Nullable<PostProcess>;
  72712. /**
  72713. * Post-process used to create a lens flare effect
  72714. */
  72715. lensFlarePostProcess: Nullable<PostProcess>;
  72716. /**
  72717. * Post-process that merges the result of the lens flare post-process and the real scene color
  72718. */
  72719. lensFlareComposePostProcess: Nullable<PostProcess>;
  72720. /**
  72721. * Post-process used to create a motion blur effect
  72722. */
  72723. motionBlurPostProcess: Nullable<PostProcess>;
  72724. /**
  72725. * Post-process used to create a depth of field effect
  72726. */
  72727. depthOfFieldPostProcess: Nullable<PostProcess>;
  72728. /**
  72729. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  72730. */
  72731. fxaaPostProcess: Nullable<FxaaPostProcess>;
  72732. /**
  72733. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  72734. */
  72735. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  72736. /**
  72737. * Represents the brightness threshold in order to configure the illuminated surfaces
  72738. */
  72739. brightThreshold: number;
  72740. /**
  72741. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  72742. */
  72743. blurWidth: number;
  72744. /**
  72745. * Sets if the blur for highlighted surfaces must be only horizontal
  72746. */
  72747. horizontalBlur: boolean;
  72748. /**
  72749. * Gets the overall exposure used by the pipeline
  72750. */
  72751. get exposure(): number;
  72752. /**
  72753. * Sets the overall exposure used by the pipeline
  72754. */
  72755. set exposure(value: number);
  72756. /**
  72757. * Texture used typically to simulate "dirty" on camera lens
  72758. */
  72759. lensTexture: Nullable<Texture>;
  72760. /**
  72761. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  72762. */
  72763. volumetricLightCoefficient: number;
  72764. /**
  72765. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  72766. */
  72767. volumetricLightPower: number;
  72768. /**
  72769. * Used the set the blur intensity to smooth the volumetric lights
  72770. */
  72771. volumetricLightBlurScale: number;
  72772. /**
  72773. * Light (spot or directional) used to generate the volumetric lights rays
  72774. * The source light must have a shadow generate so the pipeline can get its
  72775. * depth map
  72776. */
  72777. sourceLight: Nullable<SpotLight | DirectionalLight>;
  72778. /**
  72779. * For eye adaptation, represents the minimum luminance the eye can see
  72780. */
  72781. hdrMinimumLuminance: number;
  72782. /**
  72783. * For eye adaptation, represents the decrease luminance speed
  72784. */
  72785. hdrDecreaseRate: number;
  72786. /**
  72787. * For eye adaptation, represents the increase luminance speed
  72788. */
  72789. hdrIncreaseRate: number;
  72790. /**
  72791. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72792. */
  72793. get hdrAutoExposure(): boolean;
  72794. /**
  72795. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  72796. */
  72797. set hdrAutoExposure(value: boolean);
  72798. /**
  72799. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  72800. */
  72801. lensColorTexture: Nullable<Texture>;
  72802. /**
  72803. * The overall strengh for the lens flare effect
  72804. */
  72805. lensFlareStrength: number;
  72806. /**
  72807. * Dispersion coefficient for lens flare ghosts
  72808. */
  72809. lensFlareGhostDispersal: number;
  72810. /**
  72811. * Main lens flare halo width
  72812. */
  72813. lensFlareHaloWidth: number;
  72814. /**
  72815. * Based on the lens distortion effect, defines how much the lens flare result
  72816. * is distorted
  72817. */
  72818. lensFlareDistortionStrength: number;
  72819. /**
  72820. * Configures the blur intensity used for for lens flare (halo)
  72821. */
  72822. lensFlareBlurWidth: number;
  72823. /**
  72824. * Lens star texture must be used to simulate rays on the flares and is available
  72825. * in the documentation
  72826. */
  72827. lensStarTexture: Nullable<Texture>;
  72828. /**
  72829. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  72830. * flare effect by taking account of the dirt texture
  72831. */
  72832. lensFlareDirtTexture: Nullable<Texture>;
  72833. /**
  72834. * Represents the focal length for the depth of field effect
  72835. */
  72836. depthOfFieldDistance: number;
  72837. /**
  72838. * Represents the blur intensity for the blurred part of the depth of field effect
  72839. */
  72840. depthOfFieldBlurWidth: number;
  72841. /**
  72842. * Gets how much the image is blurred by the movement while using the motion blur post-process
  72843. */
  72844. get motionStrength(): number;
  72845. /**
  72846. * Sets how much the image is blurred by the movement while using the motion blur post-process
  72847. */
  72848. set motionStrength(strength: number);
  72849. /**
  72850. * Gets wether or not the motion blur post-process is object based or screen based.
  72851. */
  72852. get objectBasedMotionBlur(): boolean;
  72853. /**
  72854. * Sets wether or not the motion blur post-process should be object based or screen based
  72855. */
  72856. set objectBasedMotionBlur(value: boolean);
  72857. /**
  72858. * List of animations for the pipeline (IAnimatable implementation)
  72859. */
  72860. animations: Animation[];
  72861. /**
  72862. * Private members
  72863. */
  72864. private _scene;
  72865. private _currentDepthOfFieldSource;
  72866. private _basePostProcess;
  72867. private _fixedExposure;
  72868. private _currentExposure;
  72869. private _hdrAutoExposure;
  72870. private _hdrCurrentLuminance;
  72871. private _motionStrength;
  72872. private _isObjectBasedMotionBlur;
  72873. private _floatTextureType;
  72874. private _camerasToBeAttached;
  72875. private _ratio;
  72876. private _bloomEnabled;
  72877. private _depthOfFieldEnabled;
  72878. private _vlsEnabled;
  72879. private _lensFlareEnabled;
  72880. private _hdrEnabled;
  72881. private _motionBlurEnabled;
  72882. private _fxaaEnabled;
  72883. private _screenSpaceReflectionsEnabled;
  72884. private _motionBlurSamples;
  72885. private _volumetricLightStepsCount;
  72886. private _samples;
  72887. /**
  72888. * @ignore
  72889. * Specifies if the bloom pipeline is enabled
  72890. */
  72891. get BloomEnabled(): boolean;
  72892. set BloomEnabled(enabled: boolean);
  72893. /**
  72894. * @ignore
  72895. * Specifies if the depth of field pipeline is enabed
  72896. */
  72897. get DepthOfFieldEnabled(): boolean;
  72898. set DepthOfFieldEnabled(enabled: boolean);
  72899. /**
  72900. * @ignore
  72901. * Specifies if the lens flare pipeline is enabed
  72902. */
  72903. get LensFlareEnabled(): boolean;
  72904. set LensFlareEnabled(enabled: boolean);
  72905. /**
  72906. * @ignore
  72907. * Specifies if the HDR pipeline is enabled
  72908. */
  72909. get HDREnabled(): boolean;
  72910. set HDREnabled(enabled: boolean);
  72911. /**
  72912. * @ignore
  72913. * Specifies if the volumetric lights scattering effect is enabled
  72914. */
  72915. get VLSEnabled(): boolean;
  72916. set VLSEnabled(enabled: boolean);
  72917. /**
  72918. * @ignore
  72919. * Specifies if the motion blur effect is enabled
  72920. */
  72921. get MotionBlurEnabled(): boolean;
  72922. set MotionBlurEnabled(enabled: boolean);
  72923. /**
  72924. * Specifies if anti-aliasing is enabled
  72925. */
  72926. get fxaaEnabled(): boolean;
  72927. set fxaaEnabled(enabled: boolean);
  72928. /**
  72929. * Specifies if screen space reflections are enabled.
  72930. */
  72931. get screenSpaceReflectionsEnabled(): boolean;
  72932. set screenSpaceReflectionsEnabled(enabled: boolean);
  72933. /**
  72934. * Specifies the number of steps used to calculate the volumetric lights
  72935. * Typically in interval [50, 200]
  72936. */
  72937. get volumetricLightStepsCount(): number;
  72938. set volumetricLightStepsCount(count: number);
  72939. /**
  72940. * Specifies the number of samples used for the motion blur effect
  72941. * Typically in interval [16, 64]
  72942. */
  72943. get motionBlurSamples(): number;
  72944. set motionBlurSamples(samples: number);
  72945. /**
  72946. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  72947. */
  72948. get samples(): number;
  72949. set samples(sampleCount: number);
  72950. /**
  72951. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  72952. * @constructor
  72953. * @param name The rendering pipeline name
  72954. * @param scene The scene linked to this pipeline
  72955. * @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)
  72956. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  72957. * @param cameras The array of cameras that the rendering pipeline will be attached to
  72958. */
  72959. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  72960. private _buildPipeline;
  72961. private _createDownSampleX4PostProcess;
  72962. private _createBrightPassPostProcess;
  72963. private _createBlurPostProcesses;
  72964. private _createTextureAdderPostProcess;
  72965. private _createVolumetricLightPostProcess;
  72966. private _createLuminancePostProcesses;
  72967. private _createHdrPostProcess;
  72968. private _createLensFlarePostProcess;
  72969. private _createDepthOfFieldPostProcess;
  72970. private _createMotionBlurPostProcess;
  72971. private _getDepthTexture;
  72972. private _disposePostProcesses;
  72973. /**
  72974. * Dispose of the pipeline and stop all post processes
  72975. */
  72976. dispose(): void;
  72977. /**
  72978. * Serialize the rendering pipeline (Used when exporting)
  72979. * @returns the serialized object
  72980. */
  72981. serialize(): any;
  72982. /**
  72983. * Parse the serialized pipeline
  72984. * @param source Source pipeline.
  72985. * @param scene The scene to load the pipeline to.
  72986. * @param rootUrl The URL of the serialized pipeline.
  72987. * @returns An instantiated pipeline from the serialized object.
  72988. */
  72989. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72990. /**
  72991. * Luminance steps
  72992. */
  72993. static LuminanceSteps: number;
  72994. }
  72995. }
  72996. declare module BABYLON {
  72997. /** @hidden */
  72998. export var stereoscopicInterlacePixelShader: {
  72999. name: string;
  73000. shader: string;
  73001. };
  73002. }
  73003. declare module BABYLON {
  73004. /**
  73005. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  73006. */
  73007. export class StereoscopicInterlacePostProcessI extends PostProcess {
  73008. private _stepSize;
  73009. private _passedProcess;
  73010. /**
  73011. * Gets a string identifying the name of the class
  73012. * @returns "StereoscopicInterlacePostProcessI" string
  73013. */
  73014. getClassName(): string;
  73015. /**
  73016. * Initializes a StereoscopicInterlacePostProcessI
  73017. * @param name The name of the effect.
  73018. * @param rigCameras The rig cameras to be appled to the post process
  73019. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  73020. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  73021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73022. * @param engine The engine which the post process will be applied. (default: current engine)
  73023. * @param reusable If the post process can be reused on the same frame. (default: false)
  73024. */
  73025. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73026. }
  73027. /**
  73028. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  73029. */
  73030. export class StereoscopicInterlacePostProcess extends PostProcess {
  73031. private _stepSize;
  73032. private _passedProcess;
  73033. /**
  73034. * Gets a string identifying the name of the class
  73035. * @returns "StereoscopicInterlacePostProcess" string
  73036. */
  73037. getClassName(): string;
  73038. /**
  73039. * Initializes a StereoscopicInterlacePostProcess
  73040. * @param name The name of the effect.
  73041. * @param rigCameras The rig cameras to be appled to the post process
  73042. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  73043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73044. * @param engine The engine which the post process will be applied. (default: current engine)
  73045. * @param reusable If the post process can be reused on the same frame. (default: false)
  73046. */
  73047. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73048. }
  73049. }
  73050. declare module BABYLON {
  73051. /** @hidden */
  73052. export var tonemapPixelShader: {
  73053. name: string;
  73054. shader: string;
  73055. };
  73056. }
  73057. declare module BABYLON {
  73058. /** Defines operator used for tonemapping */
  73059. export enum TonemappingOperator {
  73060. /** Hable */
  73061. Hable = 0,
  73062. /** Reinhard */
  73063. Reinhard = 1,
  73064. /** HejiDawson */
  73065. HejiDawson = 2,
  73066. /** Photographic */
  73067. Photographic = 3
  73068. }
  73069. /**
  73070. * Defines a post process to apply tone mapping
  73071. */
  73072. export class TonemapPostProcess extends PostProcess {
  73073. private _operator;
  73074. /** Defines the required exposure adjustement */
  73075. exposureAdjustment: number;
  73076. /**
  73077. * Gets a string identifying the name of the class
  73078. * @returns "TonemapPostProcess" string
  73079. */
  73080. getClassName(): string;
  73081. /**
  73082. * Creates a new TonemapPostProcess
  73083. * @param name defines the name of the postprocess
  73084. * @param _operator defines the operator to use
  73085. * @param exposureAdjustment defines the required exposure adjustement
  73086. * @param camera defines the camera to use (can be null)
  73087. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  73088. * @param engine defines the hosting engine (can be ignore if camera is set)
  73089. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  73090. */
  73091. constructor(name: string, _operator: TonemappingOperator,
  73092. /** Defines the required exposure adjustement */
  73093. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  73094. }
  73095. }
  73096. declare module BABYLON {
  73097. /** @hidden */
  73098. export var volumetricLightScatteringPixelShader: {
  73099. name: string;
  73100. shader: string;
  73101. };
  73102. }
  73103. declare module BABYLON {
  73104. /** @hidden */
  73105. export var volumetricLightScatteringPassVertexShader: {
  73106. name: string;
  73107. shader: string;
  73108. };
  73109. }
  73110. declare module BABYLON {
  73111. /** @hidden */
  73112. export var volumetricLightScatteringPassPixelShader: {
  73113. name: string;
  73114. shader: string;
  73115. };
  73116. }
  73117. declare module BABYLON {
  73118. /**
  73119. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  73120. */
  73121. export class VolumetricLightScatteringPostProcess extends PostProcess {
  73122. private _volumetricLightScatteringPass;
  73123. private _volumetricLightScatteringRTT;
  73124. private _viewPort;
  73125. private _screenCoordinates;
  73126. private _cachedDefines;
  73127. /**
  73128. * If not undefined, the mesh position is computed from the attached node position
  73129. */
  73130. attachedNode: {
  73131. position: Vector3;
  73132. };
  73133. /**
  73134. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  73135. */
  73136. customMeshPosition: Vector3;
  73137. /**
  73138. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  73139. */
  73140. useCustomMeshPosition: boolean;
  73141. /**
  73142. * If the post-process should inverse the light scattering direction
  73143. */
  73144. invert: boolean;
  73145. /**
  73146. * The internal mesh used by the post-process
  73147. */
  73148. mesh: Mesh;
  73149. /**
  73150. * @hidden
  73151. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  73152. */
  73153. get useDiffuseColor(): boolean;
  73154. set useDiffuseColor(useDiffuseColor: boolean);
  73155. /**
  73156. * Array containing the excluded meshes not rendered in the internal pass
  73157. */
  73158. excludedMeshes: AbstractMesh[];
  73159. /**
  73160. * Controls the overall intensity of the post-process
  73161. */
  73162. exposure: number;
  73163. /**
  73164. * Dissipates each sample's contribution in range [0, 1]
  73165. */
  73166. decay: number;
  73167. /**
  73168. * Controls the overall intensity of each sample
  73169. */
  73170. weight: number;
  73171. /**
  73172. * Controls the density of each sample
  73173. */
  73174. density: number;
  73175. /**
  73176. * @constructor
  73177. * @param name The post-process name
  73178. * @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)
  73179. * @param camera The camera that the post-process will be attached to
  73180. * @param mesh The mesh used to create the light scattering
  73181. * @param samples The post-process quality, default 100
  73182. * @param samplingModeThe post-process filtering mode
  73183. * @param engine The babylon engine
  73184. * @param reusable If the post-process is reusable
  73185. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  73186. */
  73187. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  73188. /**
  73189. * Returns the string "VolumetricLightScatteringPostProcess"
  73190. * @returns "VolumetricLightScatteringPostProcess"
  73191. */
  73192. getClassName(): string;
  73193. private _isReady;
  73194. /**
  73195. * Sets the new light position for light scattering effect
  73196. * @param position The new custom light position
  73197. */
  73198. setCustomMeshPosition(position: Vector3): void;
  73199. /**
  73200. * Returns the light position for light scattering effect
  73201. * @return Vector3 The custom light position
  73202. */
  73203. getCustomMeshPosition(): Vector3;
  73204. /**
  73205. * Disposes the internal assets and detaches the post-process from the camera
  73206. */
  73207. dispose(camera: Camera): void;
  73208. /**
  73209. * Returns the render target texture used by the post-process
  73210. * @return the render target texture used by the post-process
  73211. */
  73212. getPass(): RenderTargetTexture;
  73213. private _meshExcluded;
  73214. private _createPass;
  73215. private _updateMeshScreenCoordinates;
  73216. /**
  73217. * Creates a default mesh for the Volumeric Light Scattering post-process
  73218. * @param name The mesh name
  73219. * @param scene The scene where to create the mesh
  73220. * @return the default mesh
  73221. */
  73222. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  73223. }
  73224. }
  73225. declare module BABYLON {
  73226. /** @hidden */
  73227. export var screenSpaceCurvaturePixelShader: {
  73228. name: string;
  73229. shader: string;
  73230. };
  73231. }
  73232. declare module BABYLON {
  73233. /**
  73234. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  73235. */
  73236. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  73237. /**
  73238. * Defines how much ridge the curvature effect displays.
  73239. */
  73240. ridge: number;
  73241. /**
  73242. * Defines how much valley the curvature effect displays.
  73243. */
  73244. valley: number;
  73245. private _geometryBufferRenderer;
  73246. /**
  73247. * Gets a string identifying the name of the class
  73248. * @returns "ScreenSpaceCurvaturePostProcess" string
  73249. */
  73250. getClassName(): string;
  73251. /**
  73252. * Creates a new instance ScreenSpaceCurvaturePostProcess
  73253. * @param name The name of the effect.
  73254. * @param scene The scene containing the objects to blur according to their velocity.
  73255. * @param options The required width/height ratio to downsize to before computing the render pass.
  73256. * @param camera The camera to apply the render pass to.
  73257. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73258. * @param engine The engine which the post process will be applied. (default: current engine)
  73259. * @param reusable If the post process can be reused on the same frame. (default: false)
  73260. * @param textureType Type of textures used when performing the post process. (default: 0)
  73261. * @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)
  73262. */
  73263. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73264. /**
  73265. * Support test.
  73266. */
  73267. static get IsSupported(): boolean;
  73268. /** @hidden */
  73269. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  73270. }
  73271. }
  73272. declare module BABYLON {
  73273. interface Scene {
  73274. /** @hidden (Backing field) */
  73275. _boundingBoxRenderer: BoundingBoxRenderer;
  73276. /** @hidden (Backing field) */
  73277. _forceShowBoundingBoxes: boolean;
  73278. /**
  73279. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  73280. */
  73281. forceShowBoundingBoxes: boolean;
  73282. /**
  73283. * Gets the bounding box renderer associated with the scene
  73284. * @returns a BoundingBoxRenderer
  73285. */
  73286. getBoundingBoxRenderer(): BoundingBoxRenderer;
  73287. }
  73288. interface AbstractMesh {
  73289. /** @hidden (Backing field) */
  73290. _showBoundingBox: boolean;
  73291. /**
  73292. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  73293. */
  73294. showBoundingBox: boolean;
  73295. }
  73296. /**
  73297. * Component responsible of rendering the bounding box of the meshes in a scene.
  73298. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  73299. */
  73300. export class BoundingBoxRenderer implements ISceneComponent {
  73301. /**
  73302. * The component name helpfull to identify the component in the list of scene components.
  73303. */
  73304. readonly name: string;
  73305. /**
  73306. * The scene the component belongs to.
  73307. */
  73308. scene: Scene;
  73309. /**
  73310. * Color of the bounding box lines placed in front of an object
  73311. */
  73312. frontColor: Color3;
  73313. /**
  73314. * Color of the bounding box lines placed behind an object
  73315. */
  73316. backColor: Color3;
  73317. /**
  73318. * Defines if the renderer should show the back lines or not
  73319. */
  73320. showBackLines: boolean;
  73321. /**
  73322. * Observable raised before rendering a bounding box
  73323. */
  73324. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  73325. /**
  73326. * Observable raised after rendering a bounding box
  73327. */
  73328. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  73329. /**
  73330. * Observable raised after resources are created
  73331. */
  73332. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  73333. /**
  73334. * When false, no bounding boxes will be rendered
  73335. */
  73336. enabled: boolean;
  73337. /**
  73338. * @hidden
  73339. */
  73340. renderList: SmartArray<BoundingBox>;
  73341. private _colorShader;
  73342. private _vertexBuffers;
  73343. private _indexBuffer;
  73344. private _fillIndexBuffer;
  73345. private _fillIndexData;
  73346. /**
  73347. * Instantiates a new bounding box renderer in a scene.
  73348. * @param scene the scene the renderer renders in
  73349. */
  73350. constructor(scene: Scene);
  73351. /**
  73352. * Registers the component in a given scene
  73353. */
  73354. register(): void;
  73355. private _evaluateSubMesh;
  73356. private _preActiveMesh;
  73357. private _prepareResources;
  73358. private _createIndexBuffer;
  73359. /**
  73360. * Rebuilds the elements related to this component in case of
  73361. * context lost for instance.
  73362. */
  73363. rebuild(): void;
  73364. /**
  73365. * @hidden
  73366. */
  73367. reset(): void;
  73368. /**
  73369. * Render the bounding boxes of a specific rendering group
  73370. * @param renderingGroupId defines the rendering group to render
  73371. */
  73372. render(renderingGroupId: number): void;
  73373. /**
  73374. * In case of occlusion queries, we can render the occlusion bounding box through this method
  73375. * @param mesh Define the mesh to render the occlusion bounding box for
  73376. */
  73377. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  73378. /**
  73379. * Dispose and release the resources attached to this renderer.
  73380. */
  73381. dispose(): void;
  73382. }
  73383. }
  73384. declare module BABYLON {
  73385. interface Scene {
  73386. /** @hidden (Backing field) */
  73387. _depthRenderer: {
  73388. [id: string]: DepthRenderer;
  73389. };
  73390. /**
  73391. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  73392. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  73393. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  73394. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  73395. * @returns the created depth renderer
  73396. */
  73397. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  73398. /**
  73399. * Disables a depth renderer for a given camera
  73400. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  73401. */
  73402. disableDepthRenderer(camera?: Nullable<Camera>): void;
  73403. }
  73404. /**
  73405. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  73406. * in several rendering techniques.
  73407. */
  73408. export class DepthRendererSceneComponent implements ISceneComponent {
  73409. /**
  73410. * The component name helpfull to identify the component in the list of scene components.
  73411. */
  73412. readonly name: string;
  73413. /**
  73414. * The scene the component belongs to.
  73415. */
  73416. scene: Scene;
  73417. /**
  73418. * Creates a new instance of the component for the given scene
  73419. * @param scene Defines the scene to register the component in
  73420. */
  73421. constructor(scene: Scene);
  73422. /**
  73423. * Registers the component in a given scene
  73424. */
  73425. register(): void;
  73426. /**
  73427. * Rebuilds the elements related to this component in case of
  73428. * context lost for instance.
  73429. */
  73430. rebuild(): void;
  73431. /**
  73432. * Disposes the component and the associated ressources
  73433. */
  73434. dispose(): void;
  73435. private _gatherRenderTargets;
  73436. private _gatherActiveCameraRenderTargets;
  73437. }
  73438. }
  73439. declare module BABYLON {
  73440. interface AbstractScene {
  73441. /** @hidden (Backing field) */
  73442. _prePassRenderer: Nullable<PrePassRenderer>;
  73443. /**
  73444. * Gets or Sets the current prepass renderer associated to the scene.
  73445. */
  73446. prePassRenderer: Nullable<PrePassRenderer>;
  73447. /**
  73448. * Enables the prepass and associates it with the scene
  73449. * @returns the PrePassRenderer
  73450. */
  73451. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  73452. /**
  73453. * Disables the prepass associated with the scene
  73454. */
  73455. disablePrePassRenderer(): void;
  73456. }
  73457. /**
  73458. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73459. * in several rendering techniques.
  73460. */
  73461. export class PrePassRendererSceneComponent implements ISceneComponent {
  73462. /**
  73463. * The component name helpful to identify the component in the list of scene components.
  73464. */
  73465. readonly name: string;
  73466. /**
  73467. * The scene the component belongs to.
  73468. */
  73469. scene: Scene;
  73470. /**
  73471. * Creates a new instance of the component for the given scene
  73472. * @param scene Defines the scene to register the component in
  73473. */
  73474. constructor(scene: Scene);
  73475. /**
  73476. * Registers the component in a given scene
  73477. */
  73478. register(): void;
  73479. private _beforeCameraDraw;
  73480. private _afterCameraDraw;
  73481. private _beforeClearStage;
  73482. private _beforeRenderingMeshStage;
  73483. private _afterRenderingMeshStage;
  73484. /**
  73485. * Rebuilds the elements related to this component in case of
  73486. * context lost for instance.
  73487. */
  73488. rebuild(): void;
  73489. /**
  73490. * Disposes the component and the associated ressources
  73491. */
  73492. dispose(): void;
  73493. }
  73494. }
  73495. declare module BABYLON {
  73496. /** @hidden */
  73497. export var fibonacci: {
  73498. name: string;
  73499. shader: string;
  73500. };
  73501. }
  73502. declare module BABYLON {
  73503. /** @hidden */
  73504. export var diffusionProfile: {
  73505. name: string;
  73506. shader: string;
  73507. };
  73508. }
  73509. declare module BABYLON {
  73510. /** @hidden */
  73511. export var subSurfaceScatteringPixelShader: {
  73512. name: string;
  73513. shader: string;
  73514. };
  73515. }
  73516. declare module BABYLON {
  73517. /**
  73518. * Sub surface scattering post process
  73519. */
  73520. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73521. /**
  73522. * Gets a string identifying the name of the class
  73523. * @returns "SubSurfaceScatteringPostProcess" string
  73524. */
  73525. getClassName(): string;
  73526. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73527. }
  73528. }
  73529. declare module BABYLON {
  73530. /**
  73531. * Contains all parameters needed for the prepass to perform
  73532. * screen space subsurface scattering
  73533. */
  73534. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73535. /** @hidden */
  73536. static _SceneComponentInitialization: (scene: Scene) => void;
  73537. private _ssDiffusionS;
  73538. private _ssFilterRadii;
  73539. private _ssDiffusionD;
  73540. /**
  73541. * Post process to attach for screen space subsurface scattering
  73542. */
  73543. postProcess: SubSurfaceScatteringPostProcess;
  73544. /**
  73545. * Diffusion profile color for subsurface scattering
  73546. */
  73547. get ssDiffusionS(): number[];
  73548. /**
  73549. * Diffusion profile max color channel value for subsurface scattering
  73550. */
  73551. get ssDiffusionD(): number[];
  73552. /**
  73553. * Diffusion profile filter radius for subsurface scattering
  73554. */
  73555. get ssFilterRadii(): number[];
  73556. /**
  73557. * Is subsurface enabled
  73558. */
  73559. enabled: boolean;
  73560. /**
  73561. * Name of the configuration
  73562. */
  73563. name: string;
  73564. /**
  73565. * Diffusion profile colors for subsurface scattering
  73566. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73567. * See ...
  73568. * Note that you can only store up to 5 of them
  73569. */
  73570. ssDiffusionProfileColors: Color3[];
  73571. /**
  73572. * Defines the ratio real world => scene units.
  73573. * Used for subsurface scattering
  73574. */
  73575. metersPerUnit: number;
  73576. /**
  73577. * Textures that should be present in the MRT for this effect to work
  73578. */
  73579. readonly texturesRequired: number[];
  73580. private _scene;
  73581. /**
  73582. * Builds a subsurface configuration object
  73583. * @param scene The scene
  73584. */
  73585. constructor(scene: Scene);
  73586. /**
  73587. * Adds a new diffusion profile.
  73588. * Useful for more realistic subsurface scattering on diverse materials.
  73589. * @param color The color of the diffusion profile. Should be the average color of the material.
  73590. * @return The index of the diffusion profile for the material subsurface configuration
  73591. */
  73592. addDiffusionProfile(color: Color3): number;
  73593. /**
  73594. * Creates the sss post process
  73595. * @return The created post process
  73596. */
  73597. createPostProcess(): SubSurfaceScatteringPostProcess;
  73598. /**
  73599. * Deletes all diffusion profiles.
  73600. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73601. */
  73602. clearAllDiffusionProfiles(): void;
  73603. /**
  73604. * Disposes this object
  73605. */
  73606. dispose(): void;
  73607. /**
  73608. * @hidden
  73609. * https://zero-radiance.github.io/post/sampling-diffusion/
  73610. *
  73611. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73612. * ------------------------------------------------------------------------------------
  73613. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73614. * PDF[r, phi, s] = r * R[r, phi, s]
  73615. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73616. * ------------------------------------------------------------------------------------
  73617. * We importance sample the color channel with the widest scattering distance.
  73618. */
  73619. getDiffusionProfileParameters(color: Color3): number;
  73620. /**
  73621. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73622. * 'u' is the random number (the value of the CDF): [0, 1).
  73623. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73624. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73625. */
  73626. private _sampleBurleyDiffusionProfile;
  73627. }
  73628. }
  73629. declare module BABYLON {
  73630. interface AbstractScene {
  73631. /** @hidden (Backing field) */
  73632. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73633. /**
  73634. * Gets or Sets the current prepass renderer associated to the scene.
  73635. */
  73636. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  73637. /**
  73638. * Enables the subsurface effect for prepass
  73639. * @returns the SubSurfaceConfiguration
  73640. */
  73641. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  73642. /**
  73643. * Disables the subsurface effect for prepass
  73644. */
  73645. disableSubSurfaceForPrePass(): void;
  73646. }
  73647. /**
  73648. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73649. * in several rendering techniques.
  73650. */
  73651. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  73652. /**
  73653. * The component name helpful to identify the component in the list of scene components.
  73654. */
  73655. readonly name: string;
  73656. /**
  73657. * The scene the component belongs to.
  73658. */
  73659. scene: Scene;
  73660. /**
  73661. * Creates a new instance of the component for the given scene
  73662. * @param scene Defines the scene to register the component in
  73663. */
  73664. constructor(scene: Scene);
  73665. /**
  73666. * Registers the component in a given scene
  73667. */
  73668. register(): void;
  73669. /**
  73670. * Serializes the component data to the specified json object
  73671. * @param serializationObject The object to serialize to
  73672. */
  73673. serialize(serializationObject: any): void;
  73674. /**
  73675. * Adds all the elements from the container to the scene
  73676. * @param container the container holding the elements
  73677. */
  73678. addFromContainer(container: AbstractScene): void;
  73679. /**
  73680. * Removes all the elements in the container from the scene
  73681. * @param container contains the elements to remove
  73682. * @param dispose if the removed element should be disposed (default: false)
  73683. */
  73684. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73685. /**
  73686. * Rebuilds the elements related to this component in case of
  73687. * context lost for instance.
  73688. */
  73689. rebuild(): void;
  73690. /**
  73691. * Disposes the component and the associated ressources
  73692. */
  73693. dispose(): void;
  73694. }
  73695. }
  73696. declare module BABYLON {
  73697. /** @hidden */
  73698. export var outlinePixelShader: {
  73699. name: string;
  73700. shader: string;
  73701. };
  73702. }
  73703. declare module BABYLON {
  73704. /** @hidden */
  73705. export var outlineVertexShader: {
  73706. name: string;
  73707. shader: string;
  73708. };
  73709. }
  73710. declare module BABYLON {
  73711. interface Scene {
  73712. /** @hidden */
  73713. _outlineRenderer: OutlineRenderer;
  73714. /**
  73715. * Gets the outline renderer associated with the scene
  73716. * @returns a OutlineRenderer
  73717. */
  73718. getOutlineRenderer(): OutlineRenderer;
  73719. }
  73720. interface AbstractMesh {
  73721. /** @hidden (Backing field) */
  73722. _renderOutline: boolean;
  73723. /**
  73724. * Gets or sets a boolean indicating if the outline must be rendered as well
  73725. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  73726. */
  73727. renderOutline: boolean;
  73728. /** @hidden (Backing field) */
  73729. _renderOverlay: boolean;
  73730. /**
  73731. * Gets or sets a boolean indicating if the overlay must be rendered as well
  73732. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  73733. */
  73734. renderOverlay: boolean;
  73735. }
  73736. /**
  73737. * This class is responsible to draw bothe outline/overlay of meshes.
  73738. * It should not be used directly but through the available method on mesh.
  73739. */
  73740. export class OutlineRenderer implements ISceneComponent {
  73741. /**
  73742. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  73743. */
  73744. private static _StencilReference;
  73745. /**
  73746. * The name of the component. Each component must have a unique name.
  73747. */
  73748. name: string;
  73749. /**
  73750. * The scene the component belongs to.
  73751. */
  73752. scene: Scene;
  73753. /**
  73754. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  73755. */
  73756. zOffset: number;
  73757. private _engine;
  73758. private _effect;
  73759. private _cachedDefines;
  73760. private _savedDepthWrite;
  73761. /**
  73762. * Instantiates a new outline renderer. (There could be only one per scene).
  73763. * @param scene Defines the scene it belongs to
  73764. */
  73765. constructor(scene: Scene);
  73766. /**
  73767. * Register the component to one instance of a scene.
  73768. */
  73769. register(): void;
  73770. /**
  73771. * Rebuilds the elements related to this component in case of
  73772. * context lost for instance.
  73773. */
  73774. rebuild(): void;
  73775. /**
  73776. * Disposes the component and the associated ressources.
  73777. */
  73778. dispose(): void;
  73779. /**
  73780. * Renders the outline in the canvas.
  73781. * @param subMesh Defines the sumesh to render
  73782. * @param batch Defines the batch of meshes in case of instances
  73783. * @param useOverlay Defines if the rendering is for the overlay or the outline
  73784. */
  73785. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  73786. /**
  73787. * Returns whether or not the outline renderer is ready for a given submesh.
  73788. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  73789. * @param subMesh Defines the submesh to check readyness for
  73790. * @param useInstances Defines wheter wee are trying to render instances or not
  73791. * @returns true if ready otherwise false
  73792. */
  73793. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73794. private _beforeRenderingMesh;
  73795. private _afterRenderingMesh;
  73796. }
  73797. }
  73798. declare module BABYLON {
  73799. /**
  73800. * Defines the basic options interface of a Sprite Frame Source Size.
  73801. */
  73802. export interface ISpriteJSONSpriteSourceSize {
  73803. /**
  73804. * number of the original width of the Frame
  73805. */
  73806. w: number;
  73807. /**
  73808. * number of the original height of the Frame
  73809. */
  73810. h: number;
  73811. }
  73812. /**
  73813. * Defines the basic options interface of a Sprite Frame Data.
  73814. */
  73815. export interface ISpriteJSONSpriteFrameData {
  73816. /**
  73817. * number of the x offset of the Frame
  73818. */
  73819. x: number;
  73820. /**
  73821. * number of the y offset of the Frame
  73822. */
  73823. y: number;
  73824. /**
  73825. * number of the width of the Frame
  73826. */
  73827. w: number;
  73828. /**
  73829. * number of the height of the Frame
  73830. */
  73831. h: number;
  73832. }
  73833. /**
  73834. * Defines the basic options interface of a JSON Sprite.
  73835. */
  73836. export interface ISpriteJSONSprite {
  73837. /**
  73838. * string name of the Frame
  73839. */
  73840. filename: string;
  73841. /**
  73842. * ISpriteJSONSpriteFrame basic object of the frame data
  73843. */
  73844. frame: ISpriteJSONSpriteFrameData;
  73845. /**
  73846. * boolean to flag is the frame was rotated.
  73847. */
  73848. rotated: boolean;
  73849. /**
  73850. * boolean to flag is the frame was trimmed.
  73851. */
  73852. trimmed: boolean;
  73853. /**
  73854. * ISpriteJSONSpriteFrame basic object of the source data
  73855. */
  73856. spriteSourceSize: ISpriteJSONSpriteFrameData;
  73857. /**
  73858. * ISpriteJSONSpriteFrame basic object of the source data
  73859. */
  73860. sourceSize: ISpriteJSONSpriteSourceSize;
  73861. }
  73862. /**
  73863. * Defines the basic options interface of a JSON atlas.
  73864. */
  73865. export interface ISpriteJSONAtlas {
  73866. /**
  73867. * Array of objects that contain the frame data.
  73868. */
  73869. frames: Array<ISpriteJSONSprite>;
  73870. /**
  73871. * object basic object containing the sprite meta data.
  73872. */
  73873. meta?: object;
  73874. }
  73875. }
  73876. declare module BABYLON {
  73877. /** @hidden */
  73878. export var spriteMapPixelShader: {
  73879. name: string;
  73880. shader: string;
  73881. };
  73882. }
  73883. declare module BABYLON {
  73884. /** @hidden */
  73885. export var spriteMapVertexShader: {
  73886. name: string;
  73887. shader: string;
  73888. };
  73889. }
  73890. declare module BABYLON {
  73891. /**
  73892. * Defines the basic options interface of a SpriteMap
  73893. */
  73894. export interface ISpriteMapOptions {
  73895. /**
  73896. * Vector2 of the number of cells in the grid.
  73897. */
  73898. stageSize?: Vector2;
  73899. /**
  73900. * Vector2 of the size of the output plane in World Units.
  73901. */
  73902. outputSize?: Vector2;
  73903. /**
  73904. * Vector3 of the position of the output plane in World Units.
  73905. */
  73906. outputPosition?: Vector3;
  73907. /**
  73908. * Vector3 of the rotation of the output plane.
  73909. */
  73910. outputRotation?: Vector3;
  73911. /**
  73912. * number of layers that the system will reserve in resources.
  73913. */
  73914. layerCount?: number;
  73915. /**
  73916. * number of max animation frames a single cell will reserve in resources.
  73917. */
  73918. maxAnimationFrames?: number;
  73919. /**
  73920. * number cell index of the base tile when the system compiles.
  73921. */
  73922. baseTile?: number;
  73923. /**
  73924. * boolean flip the sprite after its been repositioned by the framing data.
  73925. */
  73926. flipU?: boolean;
  73927. /**
  73928. * Vector3 scalar of the global RGB values of the SpriteMap.
  73929. */
  73930. colorMultiply?: Vector3;
  73931. }
  73932. /**
  73933. * Defines the IDisposable interface in order to be cleanable from resources.
  73934. */
  73935. export interface ISpriteMap extends IDisposable {
  73936. /**
  73937. * String name of the SpriteMap.
  73938. */
  73939. name: string;
  73940. /**
  73941. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  73942. */
  73943. atlasJSON: ISpriteJSONAtlas;
  73944. /**
  73945. * Texture of the SpriteMap.
  73946. */
  73947. spriteSheet: Texture;
  73948. /**
  73949. * The parameters to initialize the SpriteMap with.
  73950. */
  73951. options: ISpriteMapOptions;
  73952. }
  73953. /**
  73954. * Class used to manage a grid restricted sprite deployment on an Output plane.
  73955. */
  73956. export class SpriteMap implements ISpriteMap {
  73957. /** The Name of the spriteMap */
  73958. name: string;
  73959. /** The JSON file with the frame and meta data */
  73960. atlasJSON: ISpriteJSONAtlas;
  73961. /** The systems Sprite Sheet Texture */
  73962. spriteSheet: Texture;
  73963. /** Arguments passed with the Constructor */
  73964. options: ISpriteMapOptions;
  73965. /** Public Sprite Storage array, parsed from atlasJSON */
  73966. sprites: Array<ISpriteJSONSprite>;
  73967. /** Returns the Number of Sprites in the System */
  73968. get spriteCount(): number;
  73969. /** Returns the Position of Output Plane*/
  73970. get position(): Vector3;
  73971. /** Returns the Position of Output Plane*/
  73972. set position(v: Vector3);
  73973. /** Returns the Rotation of Output Plane*/
  73974. get rotation(): Vector3;
  73975. /** Returns the Rotation of Output Plane*/
  73976. set rotation(v: Vector3);
  73977. /** Sets the AnimationMap*/
  73978. get animationMap(): RawTexture;
  73979. /** Sets the AnimationMap*/
  73980. set animationMap(v: RawTexture);
  73981. /** Scene that the SpriteMap was created in */
  73982. private _scene;
  73983. /** Texture Buffer of Float32 that holds tile frame data*/
  73984. private _frameMap;
  73985. /** Texture Buffers of Float32 that holds tileMap data*/
  73986. private _tileMaps;
  73987. /** Texture Buffer of Float32 that holds Animation Data*/
  73988. private _animationMap;
  73989. /** Custom ShaderMaterial Central to the System*/
  73990. private _material;
  73991. /** Custom ShaderMaterial Central to the System*/
  73992. private _output;
  73993. /** Systems Time Ticker*/
  73994. private _time;
  73995. /**
  73996. * Creates a new SpriteMap
  73997. * @param name defines the SpriteMaps Name
  73998. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73999. * @param spriteSheet is the Texture that the Sprites are on.
  74000. * @param options a basic deployment configuration
  74001. * @param scene The Scene that the map is deployed on
  74002. */
  74003. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  74004. /**
  74005. * Returns tileID location
  74006. * @returns Vector2 the cell position ID
  74007. */
  74008. getTileID(): Vector2;
  74009. /**
  74010. * Gets the UV location of the mouse over the SpriteMap.
  74011. * @returns Vector2 the UV position of the mouse interaction
  74012. */
  74013. getMousePosition(): Vector2;
  74014. /**
  74015. * Creates the "frame" texture Buffer
  74016. * -------------------------------------
  74017. * Structure of frames
  74018. * "filename": "Falling-Water-2.png",
  74019. * "frame": {"x":69,"y":103,"w":24,"h":32},
  74020. * "rotated": true,
  74021. * "trimmed": true,
  74022. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  74023. * "sourceSize": {"w":32,"h":32}
  74024. * @returns RawTexture of the frameMap
  74025. */
  74026. private _createFrameBuffer;
  74027. /**
  74028. * Creates the tileMap texture Buffer
  74029. * @param buffer normally and array of numbers, or a false to generate from scratch
  74030. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  74031. * @returns RawTexture of the tileMap
  74032. */
  74033. private _createTileBuffer;
  74034. /**
  74035. * Modifies the data of the tileMaps
  74036. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  74037. * @param pos is the iVector2 Coordinates of the Tile
  74038. * @param tile The SpriteIndex of the new Tile
  74039. */
  74040. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  74041. /**
  74042. * Creates the animationMap texture Buffer
  74043. * @param buffer normally and array of numbers, or a false to generate from scratch
  74044. * @returns RawTexture of the animationMap
  74045. */
  74046. private _createTileAnimationBuffer;
  74047. /**
  74048. * Modifies the data of the animationMap
  74049. * @param cellID is the Index of the Sprite
  74050. * @param _frame is the target Animation frame
  74051. * @param toCell is the Target Index of the next frame of the animation
  74052. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  74053. * @param speed is a global scalar of the time variable on the map.
  74054. */
  74055. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  74056. /**
  74057. * Exports the .tilemaps file
  74058. */
  74059. saveTileMaps(): void;
  74060. /**
  74061. * Imports the .tilemaps file
  74062. * @param url of the .tilemaps file
  74063. */
  74064. loadTileMaps(url: string): void;
  74065. /**
  74066. * Release associated resources
  74067. */
  74068. dispose(): void;
  74069. }
  74070. }
  74071. declare module BABYLON {
  74072. /**
  74073. * Class used to manage multiple sprites of different sizes on the same spritesheet
  74074. * @see https://doc.babylonjs.com/babylon101/sprites
  74075. */
  74076. export class SpritePackedManager extends SpriteManager {
  74077. /** defines the packed manager's name */
  74078. name: string;
  74079. /**
  74080. * Creates a new sprite manager from a packed sprite sheet
  74081. * @param name defines the manager's name
  74082. * @param imgUrl defines the sprite sheet url
  74083. * @param capacity defines the maximum allowed number of sprites
  74084. * @param scene defines the hosting scene
  74085. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  74086. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74087. * @param samplingMode defines the smapling mode to use with spritesheet
  74088. * @param fromPacked set to true; do not alter
  74089. */
  74090. constructor(
  74091. /** defines the packed manager's name */
  74092. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  74093. }
  74094. }
  74095. declare module BABYLON {
  74096. /**
  74097. * Defines the list of states available for a task inside a AssetsManager
  74098. */
  74099. export enum AssetTaskState {
  74100. /**
  74101. * Initialization
  74102. */
  74103. INIT = 0,
  74104. /**
  74105. * Running
  74106. */
  74107. RUNNING = 1,
  74108. /**
  74109. * Done
  74110. */
  74111. DONE = 2,
  74112. /**
  74113. * Error
  74114. */
  74115. ERROR = 3
  74116. }
  74117. /**
  74118. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  74119. */
  74120. export abstract class AbstractAssetTask {
  74121. /**
  74122. * Task name
  74123. */ name: string;
  74124. /**
  74125. * Callback called when the task is successful
  74126. */
  74127. onSuccess: (task: any) => void;
  74128. /**
  74129. * Callback called when the task is not successful
  74130. */
  74131. onError: (task: any, message?: string, exception?: any) => void;
  74132. /**
  74133. * Creates a new AssetsManager
  74134. * @param name defines the name of the task
  74135. */
  74136. constructor(
  74137. /**
  74138. * Task name
  74139. */ name: string);
  74140. private _isCompleted;
  74141. private _taskState;
  74142. private _errorObject;
  74143. /**
  74144. * Get if the task is completed
  74145. */
  74146. get isCompleted(): boolean;
  74147. /**
  74148. * Gets the current state of the task
  74149. */
  74150. get taskState(): AssetTaskState;
  74151. /**
  74152. * Gets the current error object (if task is in error)
  74153. */
  74154. get errorObject(): {
  74155. message?: string;
  74156. exception?: any;
  74157. };
  74158. /**
  74159. * Internal only
  74160. * @hidden
  74161. */
  74162. _setErrorObject(message?: string, exception?: any): void;
  74163. /**
  74164. * Execute the current task
  74165. * @param scene defines the scene where you want your assets to be loaded
  74166. * @param onSuccess is a callback called when the task is successfully executed
  74167. * @param onError is a callback called if an error occurs
  74168. */
  74169. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74170. /**
  74171. * Execute the current task
  74172. * @param scene defines the scene where you want your assets to be loaded
  74173. * @param onSuccess is a callback called when the task is successfully executed
  74174. * @param onError is a callback called if an error occurs
  74175. */
  74176. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74177. /**
  74178. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  74179. * This can be used with failed tasks that have the reason for failure fixed.
  74180. */
  74181. reset(): void;
  74182. private onErrorCallback;
  74183. private onDoneCallback;
  74184. }
  74185. /**
  74186. * Define the interface used by progress events raised during assets loading
  74187. */
  74188. export interface IAssetsProgressEvent {
  74189. /**
  74190. * Defines the number of remaining tasks to process
  74191. */
  74192. remainingCount: number;
  74193. /**
  74194. * Defines the total number of tasks
  74195. */
  74196. totalCount: number;
  74197. /**
  74198. * Defines the task that was just processed
  74199. */
  74200. task: AbstractAssetTask;
  74201. }
  74202. /**
  74203. * Class used to share progress information about assets loading
  74204. */
  74205. export class AssetsProgressEvent implements IAssetsProgressEvent {
  74206. /**
  74207. * Defines the number of remaining tasks to process
  74208. */
  74209. remainingCount: number;
  74210. /**
  74211. * Defines the total number of tasks
  74212. */
  74213. totalCount: number;
  74214. /**
  74215. * Defines the task that was just processed
  74216. */
  74217. task: AbstractAssetTask;
  74218. /**
  74219. * Creates a AssetsProgressEvent
  74220. * @param remainingCount defines the number of remaining tasks to process
  74221. * @param totalCount defines the total number of tasks
  74222. * @param task defines the task that was just processed
  74223. */
  74224. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  74225. }
  74226. /**
  74227. * Define a task used by AssetsManager to load assets into a container
  74228. */
  74229. export class ContainerAssetTask extends AbstractAssetTask {
  74230. /**
  74231. * Defines the name of the task
  74232. */
  74233. name: string;
  74234. /**
  74235. * Defines the list of mesh's names you want to load
  74236. */
  74237. meshesNames: any;
  74238. /**
  74239. * Defines the root url to use as a base to load your meshes and associated resources
  74240. */
  74241. rootUrl: string;
  74242. /**
  74243. * Defines the filename or File of the scene to load from
  74244. */
  74245. sceneFilename: string | File;
  74246. /**
  74247. * Get the loaded asset container
  74248. */
  74249. loadedContainer: AssetContainer;
  74250. /**
  74251. * Gets the list of loaded meshes
  74252. */
  74253. loadedMeshes: Array<AbstractMesh>;
  74254. /**
  74255. * Gets the list of loaded particle systems
  74256. */
  74257. loadedParticleSystems: Array<IParticleSystem>;
  74258. /**
  74259. * Gets the list of loaded skeletons
  74260. */
  74261. loadedSkeletons: Array<Skeleton>;
  74262. /**
  74263. * Gets the list of loaded animation groups
  74264. */
  74265. loadedAnimationGroups: Array<AnimationGroup>;
  74266. /**
  74267. * Callback called when the task is successful
  74268. */
  74269. onSuccess: (task: ContainerAssetTask) => void;
  74270. /**
  74271. * Callback called when the task is successful
  74272. */
  74273. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  74274. /**
  74275. * Creates a new ContainerAssetTask
  74276. * @param name defines the name of the task
  74277. * @param meshesNames defines the list of mesh's names you want to load
  74278. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74279. * @param sceneFilename defines the filename or File of the scene to load from
  74280. */
  74281. constructor(
  74282. /**
  74283. * Defines the name of the task
  74284. */
  74285. name: string,
  74286. /**
  74287. * Defines the list of mesh's names you want to load
  74288. */
  74289. meshesNames: any,
  74290. /**
  74291. * Defines the root url to use as a base to load your meshes and associated resources
  74292. */
  74293. rootUrl: string,
  74294. /**
  74295. * Defines the filename or File of the scene to load from
  74296. */
  74297. sceneFilename: string | File);
  74298. /**
  74299. * Execute the current task
  74300. * @param scene defines the scene where you want your assets to be loaded
  74301. * @param onSuccess is a callback called when the task is successfully executed
  74302. * @param onError is a callback called if an error occurs
  74303. */
  74304. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74305. }
  74306. /**
  74307. * Define a task used by AssetsManager to load meshes
  74308. */
  74309. export class MeshAssetTask extends AbstractAssetTask {
  74310. /**
  74311. * Defines the name of the task
  74312. */
  74313. name: string;
  74314. /**
  74315. * Defines the list of mesh's names you want to load
  74316. */
  74317. meshesNames: any;
  74318. /**
  74319. * Defines the root url to use as a base to load your meshes and associated resources
  74320. */
  74321. rootUrl: string;
  74322. /**
  74323. * Defines the filename or File of the scene to load from
  74324. */
  74325. sceneFilename: string | File;
  74326. /**
  74327. * Gets the list of loaded meshes
  74328. */
  74329. loadedMeshes: Array<AbstractMesh>;
  74330. /**
  74331. * Gets the list of loaded particle systems
  74332. */
  74333. loadedParticleSystems: Array<IParticleSystem>;
  74334. /**
  74335. * Gets the list of loaded skeletons
  74336. */
  74337. loadedSkeletons: Array<Skeleton>;
  74338. /**
  74339. * Gets the list of loaded animation groups
  74340. */
  74341. loadedAnimationGroups: Array<AnimationGroup>;
  74342. /**
  74343. * Callback called when the task is successful
  74344. */
  74345. onSuccess: (task: MeshAssetTask) => void;
  74346. /**
  74347. * Callback called when the task is successful
  74348. */
  74349. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  74350. /**
  74351. * Creates a new MeshAssetTask
  74352. * @param name defines the name of the task
  74353. * @param meshesNames defines the list of mesh's names you want to load
  74354. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  74355. * @param sceneFilename defines the filename or File of the scene to load from
  74356. */
  74357. constructor(
  74358. /**
  74359. * Defines the name of the task
  74360. */
  74361. name: string,
  74362. /**
  74363. * Defines the list of mesh's names you want to load
  74364. */
  74365. meshesNames: any,
  74366. /**
  74367. * Defines the root url to use as a base to load your meshes and associated resources
  74368. */
  74369. rootUrl: string,
  74370. /**
  74371. * Defines the filename or File of the scene to load from
  74372. */
  74373. sceneFilename: string | File);
  74374. /**
  74375. * Execute the current task
  74376. * @param scene defines the scene where you want your assets to be loaded
  74377. * @param onSuccess is a callback called when the task is successfully executed
  74378. * @param onError is a callback called if an error occurs
  74379. */
  74380. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74381. }
  74382. /**
  74383. * Define a task used by AssetsManager to load text content
  74384. */
  74385. export class TextFileAssetTask extends AbstractAssetTask {
  74386. /**
  74387. * Defines the name of the task
  74388. */
  74389. name: string;
  74390. /**
  74391. * Defines the location of the file to load
  74392. */
  74393. url: string;
  74394. /**
  74395. * Gets the loaded text string
  74396. */
  74397. text: string;
  74398. /**
  74399. * Callback called when the task is successful
  74400. */
  74401. onSuccess: (task: TextFileAssetTask) => void;
  74402. /**
  74403. * Callback called when the task is successful
  74404. */
  74405. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  74406. /**
  74407. * Creates a new TextFileAssetTask object
  74408. * @param name defines the name of the task
  74409. * @param url defines the location of the file to load
  74410. */
  74411. constructor(
  74412. /**
  74413. * Defines the name of the task
  74414. */
  74415. name: string,
  74416. /**
  74417. * Defines the location of the file to load
  74418. */
  74419. url: string);
  74420. /**
  74421. * Execute the current task
  74422. * @param scene defines the scene where you want your assets to be loaded
  74423. * @param onSuccess is a callback called when the task is successfully executed
  74424. * @param onError is a callback called if an error occurs
  74425. */
  74426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74427. }
  74428. /**
  74429. * Define a task used by AssetsManager to load binary data
  74430. */
  74431. export class BinaryFileAssetTask extends AbstractAssetTask {
  74432. /**
  74433. * Defines the name of the task
  74434. */
  74435. name: string;
  74436. /**
  74437. * Defines the location of the file to load
  74438. */
  74439. url: string;
  74440. /**
  74441. * Gets the lodaded data (as an array buffer)
  74442. */
  74443. data: ArrayBuffer;
  74444. /**
  74445. * Callback called when the task is successful
  74446. */
  74447. onSuccess: (task: BinaryFileAssetTask) => void;
  74448. /**
  74449. * Callback called when the task is successful
  74450. */
  74451. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  74452. /**
  74453. * Creates a new BinaryFileAssetTask object
  74454. * @param name defines the name of the new task
  74455. * @param url defines the location of the file to load
  74456. */
  74457. constructor(
  74458. /**
  74459. * Defines the name of the task
  74460. */
  74461. name: string,
  74462. /**
  74463. * Defines the location of the file to load
  74464. */
  74465. url: string);
  74466. /**
  74467. * Execute the current task
  74468. * @param scene defines the scene where you want your assets to be loaded
  74469. * @param onSuccess is a callback called when the task is successfully executed
  74470. * @param onError is a callback called if an error occurs
  74471. */
  74472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74473. }
  74474. /**
  74475. * Define a task used by AssetsManager to load images
  74476. */
  74477. export class ImageAssetTask extends AbstractAssetTask {
  74478. /**
  74479. * Defines the name of the task
  74480. */
  74481. name: string;
  74482. /**
  74483. * Defines the location of the image to load
  74484. */
  74485. url: string;
  74486. /**
  74487. * Gets the loaded images
  74488. */
  74489. image: HTMLImageElement;
  74490. /**
  74491. * Callback called when the task is successful
  74492. */
  74493. onSuccess: (task: ImageAssetTask) => void;
  74494. /**
  74495. * Callback called when the task is successful
  74496. */
  74497. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  74498. /**
  74499. * Creates a new ImageAssetTask
  74500. * @param name defines the name of the task
  74501. * @param url defines the location of the image to load
  74502. */
  74503. constructor(
  74504. /**
  74505. * Defines the name of the task
  74506. */
  74507. name: string,
  74508. /**
  74509. * Defines the location of the image to load
  74510. */
  74511. url: string);
  74512. /**
  74513. * Execute the current task
  74514. * @param scene defines the scene where you want your assets to be loaded
  74515. * @param onSuccess is a callback called when the task is successfully executed
  74516. * @param onError is a callback called if an error occurs
  74517. */
  74518. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74519. }
  74520. /**
  74521. * Defines the interface used by texture loading tasks
  74522. */
  74523. export interface ITextureAssetTask<TEX extends BaseTexture> {
  74524. /**
  74525. * Gets the loaded texture
  74526. */
  74527. texture: TEX;
  74528. }
  74529. /**
  74530. * Define a task used by AssetsManager to load 2D textures
  74531. */
  74532. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  74533. /**
  74534. * Defines the name of the task
  74535. */
  74536. name: string;
  74537. /**
  74538. * Defines the location of the file to load
  74539. */
  74540. url: string;
  74541. /**
  74542. * Defines if mipmap should not be generated (default is false)
  74543. */
  74544. noMipmap?: boolean | undefined;
  74545. /**
  74546. * Defines if texture must be inverted on Y axis (default is true)
  74547. */
  74548. invertY: boolean;
  74549. /**
  74550. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74551. */
  74552. samplingMode: number;
  74553. /**
  74554. * Gets the loaded texture
  74555. */
  74556. texture: Texture;
  74557. /**
  74558. * Callback called when the task is successful
  74559. */
  74560. onSuccess: (task: TextureAssetTask) => void;
  74561. /**
  74562. * Callback called when the task is successful
  74563. */
  74564. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  74565. /**
  74566. * Creates a new TextureAssetTask object
  74567. * @param name defines the name of the task
  74568. * @param url defines the location of the file to load
  74569. * @param noMipmap defines if mipmap should not be generated (default is false)
  74570. * @param invertY defines if texture must be inverted on Y axis (default is true)
  74571. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74572. */
  74573. constructor(
  74574. /**
  74575. * Defines the name of the task
  74576. */
  74577. name: string,
  74578. /**
  74579. * Defines the location of the file to load
  74580. */
  74581. url: string,
  74582. /**
  74583. * Defines if mipmap should not be generated (default is false)
  74584. */
  74585. noMipmap?: boolean | undefined,
  74586. /**
  74587. * Defines if texture must be inverted on Y axis (default is true)
  74588. */
  74589. invertY?: boolean,
  74590. /**
  74591. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  74592. */
  74593. samplingMode?: number);
  74594. /**
  74595. * Execute the current task
  74596. * @param scene defines the scene where you want your assets to be loaded
  74597. * @param onSuccess is a callback called when the task is successfully executed
  74598. * @param onError is a callback called if an error occurs
  74599. */
  74600. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74601. }
  74602. /**
  74603. * Define a task used by AssetsManager to load cube textures
  74604. */
  74605. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  74606. /**
  74607. * Defines the name of the task
  74608. */
  74609. name: string;
  74610. /**
  74611. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74612. */
  74613. url: string;
  74614. /**
  74615. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74616. */
  74617. extensions?: string[] | undefined;
  74618. /**
  74619. * Defines if mipmaps should not be generated (default is false)
  74620. */
  74621. noMipmap?: boolean | undefined;
  74622. /**
  74623. * Defines the explicit list of files (undefined by default)
  74624. */
  74625. files?: string[] | undefined;
  74626. /**
  74627. * Gets the loaded texture
  74628. */
  74629. texture: CubeTexture;
  74630. /**
  74631. * Callback called when the task is successful
  74632. */
  74633. onSuccess: (task: CubeTextureAssetTask) => void;
  74634. /**
  74635. * Callback called when the task is successful
  74636. */
  74637. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  74638. /**
  74639. * Creates a new CubeTextureAssetTask
  74640. * @param name defines the name of the task
  74641. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74642. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74643. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74644. * @param files defines the explicit list of files (undefined by default)
  74645. */
  74646. constructor(
  74647. /**
  74648. * Defines the name of the task
  74649. */
  74650. name: string,
  74651. /**
  74652. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  74653. */
  74654. url: string,
  74655. /**
  74656. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  74657. */
  74658. extensions?: string[] | undefined,
  74659. /**
  74660. * Defines if mipmaps should not be generated (default is false)
  74661. */
  74662. noMipmap?: boolean | undefined,
  74663. /**
  74664. * Defines the explicit list of files (undefined by default)
  74665. */
  74666. files?: string[] | undefined);
  74667. /**
  74668. * Execute the current task
  74669. * @param scene defines the scene where you want your assets to be loaded
  74670. * @param onSuccess is a callback called when the task is successfully executed
  74671. * @param onError is a callback called if an error occurs
  74672. */
  74673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74674. }
  74675. /**
  74676. * Define a task used by AssetsManager to load HDR cube textures
  74677. */
  74678. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  74679. /**
  74680. * Defines the name of the task
  74681. */
  74682. name: string;
  74683. /**
  74684. * Defines the location of the file to load
  74685. */
  74686. url: string;
  74687. /**
  74688. * Defines the desired size (the more it increases the longer the generation will be)
  74689. */
  74690. size: number;
  74691. /**
  74692. * Defines if mipmaps should not be generated (default is false)
  74693. */
  74694. noMipmap: boolean;
  74695. /**
  74696. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74697. */
  74698. generateHarmonics: boolean;
  74699. /**
  74700. * 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)
  74701. */
  74702. gammaSpace: boolean;
  74703. /**
  74704. * Internal Use Only
  74705. */
  74706. reserved: boolean;
  74707. /**
  74708. * Gets the loaded texture
  74709. */
  74710. texture: HDRCubeTexture;
  74711. /**
  74712. * Callback called when the task is successful
  74713. */
  74714. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  74715. /**
  74716. * Callback called when the task is successful
  74717. */
  74718. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  74719. /**
  74720. * Creates a new HDRCubeTextureAssetTask object
  74721. * @param name defines the name of the task
  74722. * @param url defines the location of the file to load
  74723. * @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.
  74724. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74725. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74726. * @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)
  74727. * @param reserved Internal use only
  74728. */
  74729. constructor(
  74730. /**
  74731. * Defines the name of the task
  74732. */
  74733. name: string,
  74734. /**
  74735. * Defines the location of the file to load
  74736. */
  74737. url: string,
  74738. /**
  74739. * Defines the desired size (the more it increases the longer the generation will be)
  74740. */
  74741. size: number,
  74742. /**
  74743. * Defines if mipmaps should not be generated (default is false)
  74744. */
  74745. noMipmap?: boolean,
  74746. /**
  74747. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  74748. */
  74749. generateHarmonics?: boolean,
  74750. /**
  74751. * 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)
  74752. */
  74753. gammaSpace?: boolean,
  74754. /**
  74755. * Internal Use Only
  74756. */
  74757. reserved?: boolean);
  74758. /**
  74759. * Execute the current task
  74760. * @param scene defines the scene where you want your assets to be loaded
  74761. * @param onSuccess is a callback called when the task is successfully executed
  74762. * @param onError is a callback called if an error occurs
  74763. */
  74764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74765. }
  74766. /**
  74767. * Define a task used by AssetsManager to load Equirectangular cube textures
  74768. */
  74769. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  74770. /**
  74771. * Defines the name of the task
  74772. */
  74773. name: string;
  74774. /**
  74775. * Defines the location of the file to load
  74776. */
  74777. url: string;
  74778. /**
  74779. * Defines the desired size (the more it increases the longer the generation will be)
  74780. */
  74781. size: number;
  74782. /**
  74783. * Defines if mipmaps should not be generated (default is false)
  74784. */
  74785. noMipmap: boolean;
  74786. /**
  74787. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74788. * but the standard material would require them in Gamma space) (default is true)
  74789. */
  74790. gammaSpace: boolean;
  74791. /**
  74792. * Gets the loaded texture
  74793. */
  74794. texture: EquiRectangularCubeTexture;
  74795. /**
  74796. * Callback called when the task is successful
  74797. */
  74798. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  74799. /**
  74800. * Callback called when the task is successful
  74801. */
  74802. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  74803. /**
  74804. * Creates a new EquiRectangularCubeTextureAssetTask object
  74805. * @param name defines the name of the task
  74806. * @param url defines the location of the file to load
  74807. * @param size defines the desired size (the more it increases the longer the generation will be)
  74808. * If the size is omitted this implies you are using a preprocessed cubemap.
  74809. * @param noMipmap defines if mipmaps should not be generated (default is false)
  74810. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  74811. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  74812. * (default is true)
  74813. */
  74814. constructor(
  74815. /**
  74816. * Defines the name of the task
  74817. */
  74818. name: string,
  74819. /**
  74820. * Defines the location of the file to load
  74821. */
  74822. url: string,
  74823. /**
  74824. * Defines the desired size (the more it increases the longer the generation will be)
  74825. */
  74826. size: number,
  74827. /**
  74828. * Defines if mipmaps should not be generated (default is false)
  74829. */
  74830. noMipmap?: boolean,
  74831. /**
  74832. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  74833. * but the standard material would require them in Gamma space) (default is true)
  74834. */
  74835. gammaSpace?: boolean);
  74836. /**
  74837. * Execute the current task
  74838. * @param scene defines the scene where you want your assets to be loaded
  74839. * @param onSuccess is a callback called when the task is successfully executed
  74840. * @param onError is a callback called if an error occurs
  74841. */
  74842. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  74843. }
  74844. /**
  74845. * This class can be used to easily import assets into a scene
  74846. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  74847. */
  74848. export class AssetsManager {
  74849. private _scene;
  74850. private _isLoading;
  74851. protected _tasks: AbstractAssetTask[];
  74852. protected _waitingTasksCount: number;
  74853. protected _totalTasksCount: number;
  74854. /**
  74855. * Callback called when all tasks are processed
  74856. */
  74857. onFinish: (tasks: AbstractAssetTask[]) => void;
  74858. /**
  74859. * Callback called when a task is successful
  74860. */
  74861. onTaskSuccess: (task: AbstractAssetTask) => void;
  74862. /**
  74863. * Callback called when a task had an error
  74864. */
  74865. onTaskError: (task: AbstractAssetTask) => void;
  74866. /**
  74867. * Callback called when a task is done (whatever the result is)
  74868. */
  74869. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  74870. /**
  74871. * Observable called when all tasks are processed
  74872. */
  74873. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  74874. /**
  74875. * Observable called when a task had an error
  74876. */
  74877. onTaskErrorObservable: Observable<AbstractAssetTask>;
  74878. /**
  74879. * Observable called when all tasks were executed
  74880. */
  74881. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  74882. /**
  74883. * Observable called when a task is done (whatever the result is)
  74884. */
  74885. onProgressObservable: Observable<IAssetsProgressEvent>;
  74886. /**
  74887. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  74888. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  74889. */
  74890. useDefaultLoadingScreen: boolean;
  74891. /**
  74892. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  74893. * when all assets have been downloaded.
  74894. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  74895. */
  74896. autoHideLoadingUI: boolean;
  74897. /**
  74898. * Creates a new AssetsManager
  74899. * @param scene defines the scene to work on
  74900. */
  74901. constructor(scene: Scene);
  74902. /**
  74903. * Add a ContainerAssetTask 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 ContainerAssetTask object
  74909. */
  74910. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  74911. /**
  74912. * Add a MeshAssetTask to the list of active tasks
  74913. * @param taskName defines the name of the new task
  74914. * @param meshesNames defines the name of meshes to load
  74915. * @param rootUrl defines the root url to use to locate files
  74916. * @param sceneFilename defines the filename of the scene file
  74917. * @returns a new MeshAssetTask object
  74918. */
  74919. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  74920. /**
  74921. * Add a TextFileAssetTask to the list of active tasks
  74922. * @param taskName defines the name of the new task
  74923. * @param url defines the url of the file to load
  74924. * @returns a new TextFileAssetTask object
  74925. */
  74926. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  74927. /**
  74928. * Add a BinaryFileAssetTask to the list of active tasks
  74929. * @param taskName defines the name of the new task
  74930. * @param url defines the url of the file to load
  74931. * @returns a new BinaryFileAssetTask object
  74932. */
  74933. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  74934. /**
  74935. * Add a ImageAssetTask to the list of active tasks
  74936. * @param taskName defines the name of the new task
  74937. * @param url defines the url of the file to load
  74938. * @returns a new ImageAssetTask object
  74939. */
  74940. addImageTask(taskName: string, url: string): ImageAssetTask;
  74941. /**
  74942. * Add a TextureAssetTask to the list of active tasks
  74943. * @param taskName defines the name of the new task
  74944. * @param url defines the url of the file to load
  74945. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74946. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  74947. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  74948. * @returns a new TextureAssetTask object
  74949. */
  74950. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  74951. /**
  74952. * Add a CubeTextureAssetTask to the list of active tasks
  74953. * @param taskName defines the name of the new task
  74954. * @param url defines the url of the file to load
  74955. * @param extensions defines the extension to use to load the cube map (can be null)
  74956. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74957. * @param files defines the list of files to load (can be null)
  74958. * @returns a new CubeTextureAssetTask object
  74959. */
  74960. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  74961. /**
  74962. *
  74963. * Add a HDRCubeTextureAssetTask to the list of active tasks
  74964. * @param taskName defines the name of the new task
  74965. * @param url defines the url of the file to load
  74966. * @param size defines the size you want for the cubemap (can be null)
  74967. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74968. * @param generateHarmonics defines if you want to automatically generate (true by default)
  74969. * @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)
  74970. * @param reserved Internal use only
  74971. * @returns a new HDRCubeTextureAssetTask object
  74972. */
  74973. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  74974. /**
  74975. *
  74976. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  74977. * @param taskName defines the name of the new task
  74978. * @param url defines the url of the file to load
  74979. * @param size defines the size you want for the cubemap (can be null)
  74980. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74981. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74982. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74983. * @returns a new EquiRectangularCubeTextureAssetTask object
  74984. */
  74985. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74986. /**
  74987. * Remove a task from the assets manager.
  74988. * @param task the task to remove
  74989. */
  74990. removeTask(task: AbstractAssetTask): void;
  74991. private _decreaseWaitingTasksCount;
  74992. private _runTask;
  74993. /**
  74994. * Reset the AssetsManager and remove all tasks
  74995. * @return the current instance of the AssetsManager
  74996. */
  74997. reset(): AssetsManager;
  74998. /**
  74999. * Start the loading process
  75000. * @return the current instance of the AssetsManager
  75001. */
  75002. load(): AssetsManager;
  75003. /**
  75004. * Start the loading process as an async operation
  75005. * @return a promise returning the list of failed tasks
  75006. */
  75007. loadAsync(): Promise<void>;
  75008. }
  75009. }
  75010. declare module BABYLON {
  75011. /**
  75012. * Wrapper class for promise with external resolve and reject.
  75013. */
  75014. export class Deferred<T> {
  75015. /**
  75016. * The promise associated with this deferred object.
  75017. */
  75018. readonly promise: Promise<T>;
  75019. private _resolve;
  75020. private _reject;
  75021. /**
  75022. * The resolve method of the promise associated with this deferred object.
  75023. */
  75024. get resolve(): (value: T | PromiseLike<T>) => void;
  75025. /**
  75026. * The reject method of the promise associated with this deferred object.
  75027. */
  75028. get reject(): (reason?: any) => void;
  75029. /**
  75030. * Constructor for this deferred object.
  75031. */
  75032. constructor();
  75033. }
  75034. }
  75035. declare module BABYLON {
  75036. /**
  75037. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  75038. */
  75039. export class MeshExploder {
  75040. private _centerMesh;
  75041. private _meshes;
  75042. private _meshesOrigins;
  75043. private _toCenterVectors;
  75044. private _scaledDirection;
  75045. private _newPosition;
  75046. private _centerPosition;
  75047. /**
  75048. * Explodes meshes from a center mesh.
  75049. * @param meshes The meshes to explode.
  75050. * @param centerMesh The mesh to be center of explosion.
  75051. */
  75052. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  75053. private _setCenterMesh;
  75054. /**
  75055. * Get class name
  75056. * @returns "MeshExploder"
  75057. */
  75058. getClassName(): string;
  75059. /**
  75060. * "Exploded meshes"
  75061. * @returns Array of meshes with the centerMesh at index 0.
  75062. */
  75063. getMeshes(): Array<Mesh>;
  75064. /**
  75065. * Explodes meshes giving a specific direction
  75066. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  75067. */
  75068. explode(direction?: number): void;
  75069. }
  75070. }
  75071. declare module BABYLON {
  75072. /**
  75073. * Class used to help managing file picking and drag'n'drop
  75074. */
  75075. export class FilesInput {
  75076. /**
  75077. * List of files ready to be loaded
  75078. */
  75079. static get FilesToLoad(): {
  75080. [key: string]: File;
  75081. };
  75082. /**
  75083. * Callback called when a file is processed
  75084. */
  75085. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  75086. /**
  75087. * Function used when loading the scene file
  75088. */
  75089. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  75090. private _engine;
  75091. private _currentScene;
  75092. private _sceneLoadedCallback;
  75093. private _progressCallback;
  75094. private _additionalRenderLoopLogicCallback;
  75095. private _textureLoadingCallback;
  75096. private _startingProcessingFilesCallback;
  75097. private _onReloadCallback;
  75098. private _errorCallback;
  75099. private _elementToMonitor;
  75100. private _sceneFileToLoad;
  75101. private _filesToLoad;
  75102. /**
  75103. * Creates a new FilesInput
  75104. * @param engine defines the rendering engine
  75105. * @param scene defines the hosting scene
  75106. * @param sceneLoadedCallback callback called when scene is loaded
  75107. * @param progressCallback callback called to track progress
  75108. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  75109. * @param textureLoadingCallback callback called when a texture is loading
  75110. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  75111. * @param onReloadCallback callback called when a reload is requested
  75112. * @param errorCallback callback call if an error occurs
  75113. */
  75114. 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>);
  75115. private _dragEnterHandler;
  75116. private _dragOverHandler;
  75117. private _dropHandler;
  75118. /**
  75119. * Calls this function to listen to drag'n'drop events on a specific DOM element
  75120. * @param elementToMonitor defines the DOM element to track
  75121. */
  75122. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  75123. /** Gets the current list of files to load */
  75124. get filesToLoad(): File[];
  75125. /**
  75126. * Release all associated resources
  75127. */
  75128. dispose(): void;
  75129. private renderFunction;
  75130. private drag;
  75131. private drop;
  75132. private _traverseFolder;
  75133. private _processFiles;
  75134. /**
  75135. * Load files from a drop event
  75136. * @param event defines the drop event to use as source
  75137. */
  75138. loadFiles(event: any): void;
  75139. private _processReload;
  75140. /**
  75141. * Reload the current scene from the loaded files
  75142. */
  75143. reload(): void;
  75144. }
  75145. }
  75146. declare module BABYLON {
  75147. /**
  75148. * Defines the root class used to create scene optimization to use with SceneOptimizer
  75149. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75150. */
  75151. export class SceneOptimization {
  75152. /**
  75153. * Defines the priority of this optimization (0 by default which means first in the list)
  75154. */
  75155. priority: number;
  75156. /**
  75157. * Gets a string describing the action executed by the current optimization
  75158. * @returns description string
  75159. */
  75160. getDescription(): string;
  75161. /**
  75162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75163. * @param scene defines the current scene where to apply this optimization
  75164. * @param optimizer defines the current optimizer
  75165. * @returns true if everything that can be done was applied
  75166. */
  75167. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75168. /**
  75169. * Creates the SceneOptimization object
  75170. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75171. * @param desc defines the description associated with the optimization
  75172. */
  75173. constructor(
  75174. /**
  75175. * Defines the priority of this optimization (0 by default which means first in the list)
  75176. */
  75177. priority?: number);
  75178. }
  75179. /**
  75180. * Defines an optimization used to reduce the size of render target textures
  75181. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75182. */
  75183. export class TextureOptimization extends SceneOptimization {
  75184. /**
  75185. * Defines the priority of this optimization (0 by default which means first in the list)
  75186. */
  75187. priority: number;
  75188. /**
  75189. * 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
  75190. */
  75191. maximumSize: number;
  75192. /**
  75193. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75194. */
  75195. step: number;
  75196. /**
  75197. * Gets a string describing the action executed by the current optimization
  75198. * @returns description string
  75199. */
  75200. getDescription(): string;
  75201. /**
  75202. * Creates the TextureOptimization object
  75203. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75204. * @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
  75205. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75206. */
  75207. constructor(
  75208. /**
  75209. * Defines the priority of this optimization (0 by default which means first in the list)
  75210. */
  75211. priority?: number,
  75212. /**
  75213. * Defines the maximum 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
  75214. */
  75215. maximumSize?: number,
  75216. /**
  75217. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  75218. */
  75219. step?: number);
  75220. /**
  75221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75222. * @param scene defines the current scene where to apply this optimization
  75223. * @param optimizer defines the current optimizer
  75224. * @returns true if everything that can be done was applied
  75225. */
  75226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75227. }
  75228. /**
  75229. * Defines an optimization used to increase or decrease the rendering resolution
  75230. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75231. */
  75232. export class HardwareScalingOptimization extends SceneOptimization {
  75233. /**
  75234. * Defines the priority of this optimization (0 by default which means first in the list)
  75235. */
  75236. priority: number;
  75237. /**
  75238. * Defines the maximum scale to use (2 by default)
  75239. */
  75240. maximumScale: number;
  75241. /**
  75242. * Defines the step to use between two passes (0.5 by default)
  75243. */
  75244. step: number;
  75245. private _currentScale;
  75246. private _directionOffset;
  75247. /**
  75248. * Gets a string describing the action executed by the current optimization
  75249. * @return description string
  75250. */
  75251. getDescription(): string;
  75252. /**
  75253. * Creates the HardwareScalingOptimization object
  75254. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75255. * @param maximumScale defines the maximum scale to use (2 by default)
  75256. * @param step defines the step to use between two passes (0.5 by default)
  75257. */
  75258. constructor(
  75259. /**
  75260. * Defines the priority of this optimization (0 by default which means first in the list)
  75261. */
  75262. priority?: number,
  75263. /**
  75264. * Defines the maximum scale to use (2 by default)
  75265. */
  75266. maximumScale?: number,
  75267. /**
  75268. * Defines the step to use between two passes (0.5 by default)
  75269. */
  75270. step?: number);
  75271. /**
  75272. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75273. * @param scene defines the current scene where to apply this optimization
  75274. * @param optimizer defines the current optimizer
  75275. * @returns true if everything that can be done was applied
  75276. */
  75277. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75278. }
  75279. /**
  75280. * Defines an optimization used to remove shadows
  75281. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75282. */
  75283. export class ShadowsOptimization extends SceneOptimization {
  75284. /**
  75285. * Gets a string describing the action executed by the current optimization
  75286. * @return description string
  75287. */
  75288. getDescription(): string;
  75289. /**
  75290. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75291. * @param scene defines the current scene where to apply this optimization
  75292. * @param optimizer defines the current optimizer
  75293. * @returns true if everything that can be done was applied
  75294. */
  75295. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75296. }
  75297. /**
  75298. * Defines an optimization used to turn post-processes off
  75299. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75300. */
  75301. export class PostProcessesOptimization extends SceneOptimization {
  75302. /**
  75303. * Gets a string describing the action executed by the current optimization
  75304. * @return description string
  75305. */
  75306. getDescription(): string;
  75307. /**
  75308. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75309. * @param scene defines the current scene where to apply this optimization
  75310. * @param optimizer defines the current optimizer
  75311. * @returns true if everything that can be done was applied
  75312. */
  75313. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75314. }
  75315. /**
  75316. * Defines an optimization used to turn lens flares off
  75317. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75318. */
  75319. export class LensFlaresOptimization extends SceneOptimization {
  75320. /**
  75321. * Gets a string describing the action executed by the current optimization
  75322. * @return description string
  75323. */
  75324. getDescription(): string;
  75325. /**
  75326. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75327. * @param scene defines the current scene where to apply this optimization
  75328. * @param optimizer defines the current optimizer
  75329. * @returns true if everything that can be done was applied
  75330. */
  75331. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75332. }
  75333. /**
  75334. * Defines an optimization based on user defined callback.
  75335. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75336. */
  75337. export class CustomOptimization extends SceneOptimization {
  75338. /**
  75339. * Callback called to apply the custom optimization.
  75340. */
  75341. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  75342. /**
  75343. * Callback called to get custom description
  75344. */
  75345. onGetDescription: () => string;
  75346. /**
  75347. * Gets a string describing the action executed by the current optimization
  75348. * @returns description string
  75349. */
  75350. getDescription(): string;
  75351. /**
  75352. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75353. * @param scene defines the current scene where to apply this optimization
  75354. * @param optimizer defines the current optimizer
  75355. * @returns true if everything that can be done was applied
  75356. */
  75357. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75358. }
  75359. /**
  75360. * Defines an optimization used to turn particles off
  75361. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75362. */
  75363. export class ParticlesOptimization extends SceneOptimization {
  75364. /**
  75365. * Gets a string describing the action executed by the current optimization
  75366. * @return description string
  75367. */
  75368. getDescription(): string;
  75369. /**
  75370. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75371. * @param scene defines the current scene where to apply this optimization
  75372. * @param optimizer defines the current optimizer
  75373. * @returns true if everything that can be done was applied
  75374. */
  75375. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75376. }
  75377. /**
  75378. * Defines an optimization used to turn render targets off
  75379. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75380. */
  75381. export class RenderTargetsOptimization extends SceneOptimization {
  75382. /**
  75383. * Gets a string describing the action executed by the current optimization
  75384. * @return description string
  75385. */
  75386. getDescription(): string;
  75387. /**
  75388. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75389. * @param scene defines the current scene where to apply this optimization
  75390. * @param optimizer defines the current optimizer
  75391. * @returns true if everything that can be done was applied
  75392. */
  75393. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  75394. }
  75395. /**
  75396. * Defines an optimization used to merge meshes with compatible materials
  75397. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75398. */
  75399. export class MergeMeshesOptimization extends SceneOptimization {
  75400. private static _UpdateSelectionTree;
  75401. /**
  75402. * Gets or sets a boolean which defines if optimization octree has to be updated
  75403. */
  75404. static get UpdateSelectionTree(): boolean;
  75405. /**
  75406. * Gets or sets a boolean which defines if optimization octree has to be updated
  75407. */
  75408. static set UpdateSelectionTree(value: boolean);
  75409. /**
  75410. * Gets a string describing the action executed by the current optimization
  75411. * @return description string
  75412. */
  75413. getDescription(): string;
  75414. private _canBeMerged;
  75415. /**
  75416. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  75417. * @param scene defines the current scene where to apply this optimization
  75418. * @param optimizer defines the current optimizer
  75419. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  75420. * @returns true if everything that can be done was applied
  75421. */
  75422. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  75423. }
  75424. /**
  75425. * Defines a list of options used by SceneOptimizer
  75426. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75427. */
  75428. export class SceneOptimizerOptions {
  75429. /**
  75430. * Defines the target frame rate to reach (60 by default)
  75431. */
  75432. targetFrameRate: number;
  75433. /**
  75434. * Defines the interval between two checkes (2000ms by default)
  75435. */
  75436. trackerDuration: number;
  75437. /**
  75438. * Gets the list of optimizations to apply
  75439. */
  75440. optimizations: SceneOptimization[];
  75441. /**
  75442. * Creates a new list of options used by SceneOptimizer
  75443. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  75444. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  75445. */
  75446. constructor(
  75447. /**
  75448. * Defines the target frame rate to reach (60 by default)
  75449. */
  75450. targetFrameRate?: number,
  75451. /**
  75452. * Defines the interval between two checkes (2000ms by default)
  75453. */
  75454. trackerDuration?: number);
  75455. /**
  75456. * Add a new optimization
  75457. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  75458. * @returns the current SceneOptimizerOptions
  75459. */
  75460. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  75461. /**
  75462. * Add a new custom optimization
  75463. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  75464. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  75465. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  75466. * @returns the current SceneOptimizerOptions
  75467. */
  75468. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  75469. /**
  75470. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  75471. * @param targetFrameRate defines the target frame rate (60 by default)
  75472. * @returns a SceneOptimizerOptions object
  75473. */
  75474. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75475. /**
  75476. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  75477. * @param targetFrameRate defines the target frame rate (60 by default)
  75478. * @returns a SceneOptimizerOptions object
  75479. */
  75480. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75481. /**
  75482. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  75483. * @param targetFrameRate defines the target frame rate (60 by default)
  75484. * @returns a SceneOptimizerOptions object
  75485. */
  75486. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  75487. }
  75488. /**
  75489. * Class used to run optimizations in order to reach a target frame rate
  75490. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  75491. */
  75492. export class SceneOptimizer implements IDisposable {
  75493. private _isRunning;
  75494. private _options;
  75495. private _scene;
  75496. private _currentPriorityLevel;
  75497. private _targetFrameRate;
  75498. private _trackerDuration;
  75499. private _currentFrameRate;
  75500. private _sceneDisposeObserver;
  75501. private _improvementMode;
  75502. /**
  75503. * Defines an observable called when the optimizer reaches the target frame rate
  75504. */
  75505. onSuccessObservable: Observable<SceneOptimizer>;
  75506. /**
  75507. * Defines an observable called when the optimizer enables an optimization
  75508. */
  75509. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  75510. /**
  75511. * Defines an observable called when the optimizer is not able to reach the target frame rate
  75512. */
  75513. onFailureObservable: Observable<SceneOptimizer>;
  75514. /**
  75515. * Gets a boolean indicating if the optimizer is in improvement mode
  75516. */
  75517. get isInImprovementMode(): boolean;
  75518. /**
  75519. * Gets the current priority level (0 at start)
  75520. */
  75521. get currentPriorityLevel(): number;
  75522. /**
  75523. * Gets the current frame rate checked by the SceneOptimizer
  75524. */
  75525. get currentFrameRate(): number;
  75526. /**
  75527. * Gets or sets the current target frame rate (60 by default)
  75528. */
  75529. get targetFrameRate(): number;
  75530. /**
  75531. * Gets or sets the current target frame rate (60 by default)
  75532. */
  75533. set targetFrameRate(value: number);
  75534. /**
  75535. * Gets or sets the current interval between two checks (every 2000ms by default)
  75536. */
  75537. get trackerDuration(): number;
  75538. /**
  75539. * Gets or sets the current interval between two checks (every 2000ms by default)
  75540. */
  75541. set trackerDuration(value: number);
  75542. /**
  75543. * Gets the list of active optimizations
  75544. */
  75545. get optimizations(): SceneOptimization[];
  75546. /**
  75547. * Creates a new SceneOptimizer
  75548. * @param scene defines the scene to work on
  75549. * @param options defines the options to use with the SceneOptimizer
  75550. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  75551. * @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)
  75552. */
  75553. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  75554. /**
  75555. * Stops the current optimizer
  75556. */
  75557. stop(): void;
  75558. /**
  75559. * Reset the optimizer to initial step (current priority level = 0)
  75560. */
  75561. reset(): void;
  75562. /**
  75563. * Start the optimizer. By default it will try to reach a specific framerate
  75564. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  75565. */
  75566. start(): void;
  75567. private _checkCurrentState;
  75568. /**
  75569. * Release all resources
  75570. */
  75571. dispose(): void;
  75572. /**
  75573. * Helper function to create a SceneOptimizer with one single line of code
  75574. * @param scene defines the scene to work on
  75575. * @param options defines the options to use with the SceneOptimizer
  75576. * @param onSuccess defines a callback to call on success
  75577. * @param onFailure defines a callback to call on failure
  75578. * @returns the new SceneOptimizer object
  75579. */
  75580. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  75581. }
  75582. }
  75583. declare module BABYLON {
  75584. /**
  75585. * Class used to serialize a scene into a string
  75586. */
  75587. export class SceneSerializer {
  75588. /**
  75589. * Clear cache used by a previous serialization
  75590. */
  75591. static ClearCache(): void;
  75592. /**
  75593. * Serialize a scene into a JSON compatible object
  75594. * @param scene defines the scene to serialize
  75595. * @returns a JSON compatible object
  75596. */
  75597. static Serialize(scene: Scene): any;
  75598. /**
  75599. * Serialize a mesh into a JSON compatible object
  75600. * @param toSerialize defines the mesh to serialize
  75601. * @param withParents defines if parents must be serialized as well
  75602. * @param withChildren defines if children must be serialized as well
  75603. * @returns a JSON compatible object
  75604. */
  75605. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  75606. }
  75607. }
  75608. declare module BABYLON {
  75609. /**
  75610. * Class used to host texture specific utilities
  75611. */
  75612. export class TextureTools {
  75613. /**
  75614. * Uses the GPU to create a copy texture rescaled at a given size
  75615. * @param texture Texture to copy from
  75616. * @param width defines the desired width
  75617. * @param height defines the desired height
  75618. * @param useBilinearMode defines if bilinear mode has to be used
  75619. * @return the generated texture
  75620. */
  75621. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  75622. }
  75623. }
  75624. declare module BABYLON {
  75625. /**
  75626. * This represents the different options available for the video capture.
  75627. */
  75628. export interface VideoRecorderOptions {
  75629. /** Defines the mime type of the video. */
  75630. mimeType: string;
  75631. /** Defines the FPS the video should be recorded at. */
  75632. fps: number;
  75633. /** Defines the chunk size for the recording data. */
  75634. recordChunckSize: number;
  75635. /** The audio tracks to attach to the recording. */
  75636. audioTracks?: MediaStreamTrack[];
  75637. }
  75638. /**
  75639. * This can help with recording videos from BabylonJS.
  75640. * This is based on the available WebRTC functionalities of the browser.
  75641. *
  75642. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  75643. */
  75644. export class VideoRecorder {
  75645. private static readonly _defaultOptions;
  75646. /**
  75647. * Returns whether or not the VideoRecorder is available in your browser.
  75648. * @param engine Defines the Babylon Engine.
  75649. * @returns true if supported otherwise false.
  75650. */
  75651. static IsSupported(engine: Engine): boolean;
  75652. private readonly _options;
  75653. private _canvas;
  75654. private _mediaRecorder;
  75655. private _recordedChunks;
  75656. private _fileName;
  75657. private _resolve;
  75658. private _reject;
  75659. /**
  75660. * True when a recording is already in progress.
  75661. */
  75662. get isRecording(): boolean;
  75663. /**
  75664. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  75665. * @param engine Defines the BabylonJS Engine you wish to record.
  75666. * @param options Defines options that can be used to customize the capture.
  75667. */
  75668. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  75669. /**
  75670. * Stops the current recording before the default capture timeout passed in the startRecording function.
  75671. */
  75672. stopRecording(): void;
  75673. /**
  75674. * Starts recording the canvas for a max duration specified in parameters.
  75675. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  75676. * If null no automatic download will start and you can rely on the promise to get the data back.
  75677. * @param maxDuration Defines the maximum recording time in seconds.
  75678. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  75679. * @return A promise callback at the end of the recording with the video data in Blob.
  75680. */
  75681. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  75682. /**
  75683. * Releases internal resources used during the recording.
  75684. */
  75685. dispose(): void;
  75686. private _handleDataAvailable;
  75687. private _handleError;
  75688. private _handleStop;
  75689. }
  75690. }
  75691. declare module BABYLON {
  75692. /**
  75693. * Class containing a set of static utilities functions for screenshots
  75694. */
  75695. export class ScreenshotTools {
  75696. /**
  75697. * Captures a screenshot of the current rendering
  75698. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75699. * @param engine defines the rendering engine
  75700. * @param camera defines the source camera
  75701. * @param size This parameter can be set to a single number or to an object with the
  75702. * following (optional) properties: precision, width, height. If a single number is passed,
  75703. * it will be used for both width and height. If an object is passed, the screenshot size
  75704. * will be derived from the parameters. The precision property is a multiplier allowing
  75705. * rendering at a higher or lower resolution
  75706. * @param successCallback defines the callback receives a single parameter which contains the
  75707. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75708. * src parameter of an <img> to display it
  75709. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75710. * Check your browser for supported MIME types
  75711. */
  75712. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  75713. /**
  75714. * Captures a screenshot of the current rendering
  75715. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75716. * @param engine defines the rendering engine
  75717. * @param camera defines the source camera
  75718. * @param size This parameter can be set to a single number or to an object with the
  75719. * following (optional) properties: precision, width, height. If a single number is passed,
  75720. * it will be used for both width and height. If an object is passed, the screenshot size
  75721. * will be derived from the parameters. The precision property is a multiplier allowing
  75722. * rendering at a higher or lower resolution
  75723. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  75724. * Check your browser for supported MIME types
  75725. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75726. * to the src parameter of an <img> to display it
  75727. */
  75728. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  75729. /**
  75730. * Generates an image screenshot from the specified camera.
  75731. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75732. * @param engine The engine to use for rendering
  75733. * @param camera The camera to use for rendering
  75734. * @param size This parameter can be set to a single number or to an object with the
  75735. * following (optional) properties: precision, width, height. If a single number is passed,
  75736. * it will be used for both width and height. If an object is passed, the screenshot size
  75737. * will be derived from the parameters. The precision property is a multiplier allowing
  75738. * rendering at a higher or lower resolution
  75739. * @param successCallback The callback receives a single parameter which contains the
  75740. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  75741. * src parameter of an <img> to display it
  75742. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75743. * Check your browser for supported MIME types
  75744. * @param samples Texture samples (default: 1)
  75745. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75746. * @param fileName A name for for the downloaded file.
  75747. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75748. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  75749. */
  75750. 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;
  75751. /**
  75752. * Generates an image screenshot from the specified camera.
  75753. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  75754. * @param engine The engine to use for rendering
  75755. * @param camera The camera to use for rendering
  75756. * @param size This parameter can be set to a single number or to an object with the
  75757. * following (optional) properties: precision, width, height. If a single number is passed,
  75758. * it will be used for both width and height. If an object is passed, the screenshot size
  75759. * will be derived from the parameters. The precision property is a multiplier allowing
  75760. * rendering at a higher or lower resolution
  75761. * @param mimeType The MIME type of the screenshot image (default: image/png).
  75762. * Check your browser for supported MIME types
  75763. * @param samples Texture samples (default: 1)
  75764. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  75765. * @param fileName A name for for the downloaded file.
  75766. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  75767. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  75768. * to the src parameter of an <img> to display it
  75769. */
  75770. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  75771. /**
  75772. * Gets height and width for screenshot size
  75773. * @private
  75774. */
  75775. private static _getScreenshotSize;
  75776. }
  75777. }
  75778. declare module BABYLON {
  75779. /**
  75780. * Interface for a data buffer
  75781. */
  75782. export interface IDataBuffer {
  75783. /**
  75784. * Reads bytes from the data buffer.
  75785. * @param byteOffset The byte offset to read
  75786. * @param byteLength The byte length to read
  75787. * @returns A promise that resolves when the bytes are read
  75788. */
  75789. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  75790. /**
  75791. * The byte length of the buffer.
  75792. */
  75793. readonly byteLength: number;
  75794. }
  75795. /**
  75796. * Utility class for reading from a data buffer
  75797. */
  75798. export class DataReader {
  75799. /**
  75800. * The data buffer associated with this data reader.
  75801. */
  75802. readonly buffer: IDataBuffer;
  75803. /**
  75804. * The current byte offset from the beginning of the data buffer.
  75805. */
  75806. byteOffset: number;
  75807. private _dataView;
  75808. private _dataByteOffset;
  75809. /**
  75810. * Constructor
  75811. * @param buffer The buffer to read
  75812. */
  75813. constructor(buffer: IDataBuffer);
  75814. /**
  75815. * Loads the given byte length.
  75816. * @param byteLength The byte length to load
  75817. * @returns A promise that resolves when the load is complete
  75818. */
  75819. loadAsync(byteLength: number): Promise<void>;
  75820. /**
  75821. * Read a unsigned 32-bit integer from the currently loaded data range.
  75822. * @returns The 32-bit integer read
  75823. */
  75824. readUint32(): number;
  75825. /**
  75826. * Read a byte array from the currently loaded data range.
  75827. * @param byteLength The byte length to read
  75828. * @returns The byte array read
  75829. */
  75830. readUint8Array(byteLength: number): Uint8Array;
  75831. /**
  75832. * Read a string from the currently loaded data range.
  75833. * @param byteLength The byte length to read
  75834. * @returns The string read
  75835. */
  75836. readString(byteLength: number): string;
  75837. /**
  75838. * Skips the given byte length the currently loaded data range.
  75839. * @param byteLength The byte length to skip
  75840. */
  75841. skipBytes(byteLength: number): void;
  75842. }
  75843. }
  75844. declare module BABYLON {
  75845. /**
  75846. * Class for storing data to local storage if available or in-memory storage otherwise
  75847. */
  75848. export class DataStorage {
  75849. private static _Storage;
  75850. private static _GetStorage;
  75851. /**
  75852. * Reads a string 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 string value
  75856. */
  75857. static ReadString(key: string, defaultValue: string): string;
  75858. /**
  75859. * Writes a string to the data storage
  75860. * @param key The key to write
  75861. * @param value The value to write
  75862. */
  75863. static WriteString(key: string, value: string): void;
  75864. /**
  75865. * Reads a boolean 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 boolean value
  75869. */
  75870. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  75871. /**
  75872. * Writes a boolean to the data storage
  75873. * @param key The key to write
  75874. * @param value The value to write
  75875. */
  75876. static WriteBoolean(key: string, value: boolean): void;
  75877. /**
  75878. * Reads a number from the data storage
  75879. * @param key The key to read
  75880. * @param defaultValue The value if the key doesn't exist
  75881. * @returns The number value
  75882. */
  75883. static ReadNumber(key: string, defaultValue: number): number;
  75884. /**
  75885. * Writes a number to the data storage
  75886. * @param key The key to write
  75887. * @param value The value to write
  75888. */
  75889. static WriteNumber(key: string, value: number): void;
  75890. }
  75891. }
  75892. declare module BABYLON {
  75893. /**
  75894. * Class used to record delta files between 2 scene states
  75895. */
  75896. export class SceneRecorder {
  75897. private _trackedScene;
  75898. private _savedJSON;
  75899. /**
  75900. * Track a given scene. This means the current scene state will be considered the original state
  75901. * @param scene defines the scene to track
  75902. */
  75903. track(scene: Scene): void;
  75904. /**
  75905. * Get the delta between current state and original state
  75906. * @returns a string containing the delta
  75907. */
  75908. getDelta(): any;
  75909. private _compareArray;
  75910. private _compareObjects;
  75911. private _compareCollections;
  75912. private static GetShadowGeneratorById;
  75913. /**
  75914. * Apply a given delta to a given scene
  75915. * @param deltaJSON defines the JSON containing the delta
  75916. * @param scene defines the scene to apply the delta to
  75917. */
  75918. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  75919. private static _ApplyPropertiesToEntity;
  75920. private static _ApplyDeltaForEntity;
  75921. }
  75922. }
  75923. declare module BABYLON {
  75924. /**
  75925. * A 3D trajectory consisting of an order list of vectors describing a
  75926. * path of motion through 3D space.
  75927. */
  75928. export class Trajectory {
  75929. private _points;
  75930. private readonly _segmentLength;
  75931. /**
  75932. * Serialize to JSON.
  75933. * @returns serialized JSON string
  75934. */
  75935. serialize(): string;
  75936. /**
  75937. * Deserialize from JSON.
  75938. * @param json serialized JSON string
  75939. * @returns deserialized Trajectory
  75940. */
  75941. static Deserialize(json: string): Trajectory;
  75942. /**
  75943. * Create a new empty Trajectory.
  75944. * @param segmentLength radius of discretization for Trajectory points
  75945. */
  75946. constructor(segmentLength?: number);
  75947. /**
  75948. * Get the length of the Trajectory.
  75949. * @returns length of the Trajectory
  75950. */
  75951. getLength(): number;
  75952. /**
  75953. * Append a new point to the Trajectory.
  75954. * NOTE: This implementation has many allocations.
  75955. * @param point point to append to the Trajectory
  75956. */
  75957. add(point: DeepImmutable<Vector3>): void;
  75958. /**
  75959. * Create a new Trajectory with a segment length chosen to make it
  75960. * probable that the new Trajectory will have a specified number of
  75961. * segments. This operation is imprecise.
  75962. * @param targetResolution number of segments desired
  75963. * @returns new Trajectory with approximately the requested number of segments
  75964. */
  75965. resampleAtTargetResolution(targetResolution: number): Trajectory;
  75966. /**
  75967. * Convert Trajectory segments into tokenized representation. This
  75968. * representation is an array of numbers where each nth number is the
  75969. * index of the token which is most similar to the nth segment of the
  75970. * Trajectory.
  75971. * @param tokens list of vectors which serve as discrete tokens
  75972. * @returns list of indices of most similar token per segment
  75973. */
  75974. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  75975. private static _forwardDir;
  75976. private static _inverseFromVec;
  75977. private static _upDir;
  75978. private static _fromToVec;
  75979. private static _lookMatrix;
  75980. /**
  75981. * Transform the rotation (i.e., direction) of a segment to isolate
  75982. * the relative transformation represented by the segment. This operation
  75983. * may or may not succeed due to singularities in the equations that define
  75984. * motion relativity in this context.
  75985. * @param priorVec the origin of the prior segment
  75986. * @param fromVec the origin of the current segment
  75987. * @param toVec the destination of the current segment
  75988. * @param result reference to output variable
  75989. * @returns whether or not transformation was successful
  75990. */
  75991. private static _transformSegmentDirToRef;
  75992. private static _bestMatch;
  75993. private static _score;
  75994. private static _bestScore;
  75995. /**
  75996. * Determine which token vector is most similar to the
  75997. * segment vector.
  75998. * @param segment segment vector
  75999. * @param tokens token vector list
  76000. * @returns index of the most similar token to the segment
  76001. */
  76002. private static _tokenizeSegment;
  76003. }
  76004. /**
  76005. * Class representing a set of known, named trajectories to which Trajectories can be
  76006. * added and using which Trajectories can be recognized.
  76007. */
  76008. export class TrajectoryClassifier {
  76009. private _maximumAllowableMatchCost;
  76010. private _vector3Alphabet;
  76011. private _levenshteinAlphabet;
  76012. private _nameToDescribedTrajectory;
  76013. /**
  76014. * Serialize to JSON.
  76015. * @returns JSON serialization
  76016. */
  76017. serialize(): string;
  76018. /**
  76019. * Deserialize from JSON.
  76020. * @param json JSON serialization
  76021. * @returns deserialized TrajectorySet
  76022. */
  76023. static Deserialize(json: string): TrajectoryClassifier;
  76024. /**
  76025. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  76026. * VERY naive, need to be generating these things from known
  76027. * sets. Better version later, probably eliminating this one.
  76028. * @returns auto-generated TrajectorySet
  76029. */
  76030. static Generate(): TrajectoryClassifier;
  76031. private constructor();
  76032. /**
  76033. * Add a new Trajectory to the set with a given name.
  76034. * @param trajectory new Trajectory to be added
  76035. * @param classification name to which to add the Trajectory
  76036. */
  76037. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  76038. /**
  76039. * Remove a known named trajectory and all Trajectories associated with it.
  76040. * @param classification name to remove
  76041. * @returns whether anything was removed
  76042. */
  76043. deleteClassification(classification: string): boolean;
  76044. /**
  76045. * Attempt to recognize a Trajectory from among all the classifications
  76046. * already known to the classifier.
  76047. * @param trajectory Trajectory to be recognized
  76048. * @returns classification of Trajectory if recognized, null otherwise
  76049. */
  76050. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  76051. }
  76052. }
  76053. declare module BABYLON {
  76054. /**
  76055. * An interface for all Hit test features
  76056. */
  76057. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  76058. /**
  76059. * Triggered when new babylon (transformed) hit test results are available
  76060. */
  76061. onHitTestResultObservable: Observable<T[]>;
  76062. }
  76063. /**
  76064. * Options used for hit testing
  76065. */
  76066. export interface IWebXRLegacyHitTestOptions {
  76067. /**
  76068. * Only test when user interacted with the scene. Default - hit test every frame
  76069. */
  76070. testOnPointerDownOnly?: boolean;
  76071. /**
  76072. * The node to use to transform the local results to world coordinates
  76073. */
  76074. worldParentNode?: TransformNode;
  76075. }
  76076. /**
  76077. * Interface defining the babylon result of raycasting/hit-test
  76078. */
  76079. export interface IWebXRLegacyHitResult {
  76080. /**
  76081. * Transformation matrix that can be applied to a node that will put it in the hit point location
  76082. */
  76083. transformationMatrix: Matrix;
  76084. /**
  76085. * The native hit test result
  76086. */
  76087. xrHitResult: XRHitResult | XRHitTestResult;
  76088. }
  76089. /**
  76090. * The currently-working hit-test module.
  76091. * Hit test (or Ray-casting) is used to interact with the real world.
  76092. * For further information read here - https://github.com/immersive-web/hit-test
  76093. */
  76094. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  76095. /**
  76096. * options to use when constructing this feature
  76097. */
  76098. readonly options: IWebXRLegacyHitTestOptions;
  76099. private _direction;
  76100. private _mat;
  76101. private _onSelectEnabled;
  76102. private _origin;
  76103. /**
  76104. * The module's name
  76105. */
  76106. static readonly Name: string;
  76107. /**
  76108. * The (Babylon) version of this module.
  76109. * This is an integer representing the implementation version.
  76110. * This number does not correspond to the WebXR specs version
  76111. */
  76112. static readonly Version: number;
  76113. /**
  76114. * Populated with the last native XR Hit Results
  76115. */
  76116. lastNativeXRHitResults: XRHitResult[];
  76117. /**
  76118. * Triggered when new babylon (transformed) hit test results are available
  76119. */
  76120. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  76121. /**
  76122. * Creates a new instance of the (legacy version) hit test feature
  76123. * @param _xrSessionManager an instance of WebXRSessionManager
  76124. * @param options options to use when constructing this feature
  76125. */
  76126. constructor(_xrSessionManager: WebXRSessionManager,
  76127. /**
  76128. * options to use when constructing this feature
  76129. */
  76130. options?: IWebXRLegacyHitTestOptions);
  76131. /**
  76132. * execute a hit test with an XR Ray
  76133. *
  76134. * @param xrSession a native xrSession that will execute this hit test
  76135. * @param xrRay the ray (position and direction) to use for ray-casting
  76136. * @param referenceSpace native XR reference space to use for the hit-test
  76137. * @param filter filter function that will filter the results
  76138. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76139. */
  76140. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  76141. /**
  76142. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  76143. * @param event the (select) event to use to select with
  76144. * @param referenceSpace the reference space to use for this hit test
  76145. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  76146. */
  76147. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76148. /**
  76149. * attach this feature
  76150. * Will usually be called by the features manager
  76151. *
  76152. * @returns true if successful.
  76153. */
  76154. attach(): boolean;
  76155. /**
  76156. * detach this feature.
  76157. * Will usually be called by the features manager
  76158. *
  76159. * @returns true if successful.
  76160. */
  76161. detach(): boolean;
  76162. /**
  76163. * Dispose this feature and all of the resources attached
  76164. */
  76165. dispose(): void;
  76166. protected _onXRFrame(frame: XRFrame): void;
  76167. private _onHitTestResults;
  76168. private _onSelect;
  76169. }
  76170. }
  76171. declare module BABYLON {
  76172. /**
  76173. * Options used for hit testing (version 2)
  76174. */
  76175. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  76176. /**
  76177. * Do not create a permanent hit test. Will usually be used when only
  76178. * transient inputs are needed.
  76179. */
  76180. disablePermanentHitTest?: boolean;
  76181. /**
  76182. * Enable transient (for example touch-based) hit test inspections
  76183. */
  76184. enableTransientHitTest?: boolean;
  76185. /**
  76186. * Offset ray for the permanent hit test
  76187. */
  76188. offsetRay?: Vector3;
  76189. /**
  76190. * Offset ray for the transient hit test
  76191. */
  76192. transientOffsetRay?: Vector3;
  76193. /**
  76194. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  76195. */
  76196. useReferenceSpace?: boolean;
  76197. /**
  76198. * Override the default entity type(s) of the hit-test result
  76199. */
  76200. entityTypes?: XRHitTestTrackableType[];
  76201. }
  76202. /**
  76203. * Interface defining the babylon result of hit-test
  76204. */
  76205. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  76206. /**
  76207. * The input source that generated this hit test (if transient)
  76208. */
  76209. inputSource?: XRInputSource;
  76210. /**
  76211. * Is this a transient hit test
  76212. */
  76213. isTransient?: boolean;
  76214. /**
  76215. * Position of the hit test result
  76216. */
  76217. position: Vector3;
  76218. /**
  76219. * Rotation of the hit test result
  76220. */
  76221. rotationQuaternion: Quaternion;
  76222. /**
  76223. * The native hit test result
  76224. */
  76225. xrHitResult: XRHitTestResult;
  76226. }
  76227. /**
  76228. * The currently-working hit-test module.
  76229. * Hit test (or Ray-casting) is used to interact with the real world.
  76230. * For further information read here - https://github.com/immersive-web/hit-test
  76231. *
  76232. * Tested on chrome (mobile) 80.
  76233. */
  76234. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  76235. /**
  76236. * options to use when constructing this feature
  76237. */
  76238. readonly options: IWebXRHitTestOptions;
  76239. private _tmpMat;
  76240. private _tmpPos;
  76241. private _tmpQuat;
  76242. private _transientXrHitTestSource;
  76243. private _xrHitTestSource;
  76244. private initHitTestSource;
  76245. /**
  76246. * The module's name
  76247. */
  76248. static readonly Name: string;
  76249. /**
  76250. * The (Babylon) version of this module.
  76251. * This is an integer representing the implementation version.
  76252. * This number does not correspond to the WebXR specs version
  76253. */
  76254. static readonly Version: number;
  76255. /**
  76256. * When set to true, each hit test will have its own position/rotation objects
  76257. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  76258. * the developers will clone them or copy them as they see fit.
  76259. */
  76260. autoCloneTransformation: boolean;
  76261. /**
  76262. * Triggered when new babylon (transformed) hit test results are available
  76263. * Note - this will be called when results come back from the device. It can be an empty array!!
  76264. */
  76265. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  76266. /**
  76267. * Use this to temporarily pause hit test checks.
  76268. */
  76269. paused: boolean;
  76270. /**
  76271. * Creates a new instance of the hit test feature
  76272. * @param _xrSessionManager an instance of WebXRSessionManager
  76273. * @param options options to use when constructing this feature
  76274. */
  76275. constructor(_xrSessionManager: WebXRSessionManager,
  76276. /**
  76277. * options to use when constructing this feature
  76278. */
  76279. options?: IWebXRHitTestOptions);
  76280. /**
  76281. * attach this feature
  76282. * Will usually be called by the features manager
  76283. *
  76284. * @returns true if successful.
  76285. */
  76286. attach(): boolean;
  76287. /**
  76288. * detach this feature.
  76289. * Will usually be called by the features manager
  76290. *
  76291. * @returns true if successful.
  76292. */
  76293. detach(): boolean;
  76294. /**
  76295. * Dispose this feature and all of the resources attached
  76296. */
  76297. dispose(): void;
  76298. protected _onXRFrame(frame: XRFrame): void;
  76299. private _processWebXRHitTestResult;
  76300. }
  76301. }
  76302. declare module BABYLON {
  76303. /**
  76304. * Configuration options of the anchor system
  76305. */
  76306. export interface IWebXRAnchorSystemOptions {
  76307. /**
  76308. * a node that will be used to convert local to world coordinates
  76309. */
  76310. worldParentNode?: TransformNode;
  76311. /**
  76312. * If set to true a reference of the created anchors will be kept until the next session starts
  76313. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  76314. */
  76315. doNotRemoveAnchorsOnSessionEnded?: boolean;
  76316. }
  76317. /**
  76318. * A babylon container for an XR Anchor
  76319. */
  76320. export interface IWebXRAnchor {
  76321. /**
  76322. * A babylon-assigned ID for this anchor
  76323. */
  76324. id: number;
  76325. /**
  76326. * Transformation matrix to apply to an object attached to this anchor
  76327. */
  76328. transformationMatrix: Matrix;
  76329. /**
  76330. * The native anchor object
  76331. */
  76332. xrAnchor: XRAnchor;
  76333. /**
  76334. * if defined, this object will be constantly updated by the anchor's position and rotation
  76335. */
  76336. attachedNode?: TransformNode;
  76337. /**
  76338. * Remove this anchor from the scene
  76339. */
  76340. remove(): void;
  76341. }
  76342. /**
  76343. * An implementation of the anchor system for WebXR.
  76344. * For further information see https://github.com/immersive-web/anchors/
  76345. */
  76346. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  76347. private _options;
  76348. private _lastFrameDetected;
  76349. private _trackedAnchors;
  76350. private _referenceSpaceForFrameAnchors;
  76351. private _futureAnchors;
  76352. /**
  76353. * The module's name
  76354. */
  76355. static readonly Name: string;
  76356. /**
  76357. * The (Babylon) version of this module.
  76358. * This is an integer representing the implementation version.
  76359. * This number does not correspond to the WebXR specs version
  76360. */
  76361. static readonly Version: number;
  76362. /**
  76363. * Observers registered here will be executed when a new anchor was added to the session
  76364. */
  76365. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  76366. /**
  76367. * Observers registered here will be executed when an anchor was removed from the session
  76368. */
  76369. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  76370. /**
  76371. * Observers registered here will be executed when an existing anchor updates
  76372. * This can execute N times every frame
  76373. */
  76374. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  76375. /**
  76376. * Set the reference space to use for anchor creation, when not using a hit test.
  76377. * Will default to the session's reference space if not defined
  76378. */
  76379. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  76380. /**
  76381. * constructs a new anchor system
  76382. * @param _xrSessionManager an instance of WebXRSessionManager
  76383. * @param _options configuration object for this feature
  76384. */
  76385. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  76386. private _tmpVector;
  76387. private _tmpQuaternion;
  76388. private _populateTmpTransformation;
  76389. /**
  76390. * Create a new anchor point using a hit test result at a specific point in the scene
  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 hitTestResult The hit test result to use for this anchor creation
  76395. * @param position an optional position offset for this anchor
  76396. * @param rotationQuaternion an optional rotation offset for this anchor
  76397. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76398. */
  76399. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  76400. /**
  76401. * Add a new anchor at a specific position and rotation
  76402. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  76403. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  76404. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  76405. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  76406. *
  76407. * @param position the position in which to add an anchor
  76408. * @param rotationQuaternion an optional rotation for the anchor transformation
  76409. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  76410. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  76411. */
  76412. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  76413. /**
  76414. * Get the list of anchors currently being tracked by the system
  76415. */
  76416. get anchors(): IWebXRAnchor[];
  76417. /**
  76418. * detach this feature.
  76419. * Will usually be called by the features manager
  76420. *
  76421. * @returns true if successful.
  76422. */
  76423. detach(): boolean;
  76424. /**
  76425. * Dispose this feature and all of the resources attached
  76426. */
  76427. dispose(): void;
  76428. protected _onXRFrame(frame: XRFrame): void;
  76429. /**
  76430. * avoiding using Array.find for global support.
  76431. * @param xrAnchor the plane to find in the array
  76432. */
  76433. private _findIndexInAnchorArray;
  76434. private _updateAnchorWithXRFrame;
  76435. private _createAnchorAtTransformation;
  76436. }
  76437. }
  76438. declare module BABYLON {
  76439. /**
  76440. * Options used in the plane detector module
  76441. */
  76442. export interface IWebXRPlaneDetectorOptions {
  76443. /**
  76444. * The node to use to transform the local results to world coordinates
  76445. */
  76446. worldParentNode?: TransformNode;
  76447. /**
  76448. * If set to true a reference of the created planes will be kept until the next session starts
  76449. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  76450. */
  76451. doNotRemovePlanesOnSessionEnded?: boolean;
  76452. }
  76453. /**
  76454. * A babylon interface for a WebXR plane.
  76455. * A Plane is actually a polygon, built from N points in space
  76456. *
  76457. * Supported in chrome 79, not supported in canary 81 ATM
  76458. */
  76459. export interface IWebXRPlane {
  76460. /**
  76461. * a babylon-assigned ID for this polygon
  76462. */
  76463. id: number;
  76464. /**
  76465. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  76466. */
  76467. polygonDefinition: Array<Vector3>;
  76468. /**
  76469. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  76470. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  76471. */
  76472. transformationMatrix: Matrix;
  76473. /**
  76474. * the native xr-plane object
  76475. */
  76476. xrPlane: XRPlane;
  76477. }
  76478. /**
  76479. * The plane detector is used to detect planes in the real world when in AR
  76480. * For more information see https://github.com/immersive-web/real-world-geometry/
  76481. */
  76482. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  76483. private _options;
  76484. private _detectedPlanes;
  76485. private _enabled;
  76486. private _lastFrameDetected;
  76487. /**
  76488. * The module's name
  76489. */
  76490. static readonly Name: string;
  76491. /**
  76492. * The (Babylon) version of this module.
  76493. * This is an integer representing the implementation version.
  76494. * This number does not correspond to the WebXR specs version
  76495. */
  76496. static readonly Version: number;
  76497. /**
  76498. * Observers registered here will be executed when a new plane was added to the session
  76499. */
  76500. onPlaneAddedObservable: Observable<IWebXRPlane>;
  76501. /**
  76502. * Observers registered here will be executed when a plane is no longer detected in the session
  76503. */
  76504. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  76505. /**
  76506. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  76507. * This can execute N times every frame
  76508. */
  76509. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  76510. /**
  76511. * construct a new Plane Detector
  76512. * @param _xrSessionManager an instance of xr Session manager
  76513. * @param _options configuration to use when constructing this feature
  76514. */
  76515. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  76516. /**
  76517. * detach this feature.
  76518. * Will usually be called by the features manager
  76519. *
  76520. * @returns true if successful.
  76521. */
  76522. detach(): boolean;
  76523. /**
  76524. * Dispose this feature and all of the resources attached
  76525. */
  76526. dispose(): void;
  76527. /**
  76528. * Check if the needed objects are defined.
  76529. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76530. */
  76531. isCompatible(): boolean;
  76532. protected _onXRFrame(frame: XRFrame): void;
  76533. private _init;
  76534. private _updatePlaneWithXRPlane;
  76535. /**
  76536. * avoiding using Array.find for global support.
  76537. * @param xrPlane the plane to find in the array
  76538. */
  76539. private findIndexInPlaneArray;
  76540. }
  76541. }
  76542. declare module BABYLON {
  76543. /**
  76544. * Options interface for the background remover plugin
  76545. */
  76546. export interface IWebXRBackgroundRemoverOptions {
  76547. /**
  76548. * Further background meshes to disable when entering AR
  76549. */
  76550. backgroundMeshes?: AbstractMesh[];
  76551. /**
  76552. * flags to configure the removal of the environment helper.
  76553. * If not set, the entire background will be removed. If set, flags should be set as well.
  76554. */
  76555. environmentHelperRemovalFlags?: {
  76556. /**
  76557. * Should the skybox be removed (default false)
  76558. */
  76559. skyBox?: boolean;
  76560. /**
  76561. * Should the ground be removed (default false)
  76562. */
  76563. ground?: boolean;
  76564. };
  76565. /**
  76566. * don't disable the environment helper
  76567. */
  76568. ignoreEnvironmentHelper?: boolean;
  76569. }
  76570. /**
  76571. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  76572. */
  76573. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  76574. /**
  76575. * read-only options to be used in this module
  76576. */
  76577. readonly options: IWebXRBackgroundRemoverOptions;
  76578. /**
  76579. * The module's name
  76580. */
  76581. static readonly Name: string;
  76582. /**
  76583. * The (Babylon) version of this module.
  76584. * This is an integer representing the implementation version.
  76585. * This number does not correspond to the WebXR specs version
  76586. */
  76587. static readonly Version: number;
  76588. /**
  76589. * registered observers will be triggered when the background state changes
  76590. */
  76591. onBackgroundStateChangedObservable: Observable<boolean>;
  76592. /**
  76593. * constructs a new background remover module
  76594. * @param _xrSessionManager the session manager for this module
  76595. * @param options read-only options to be used in this module
  76596. */
  76597. constructor(_xrSessionManager: WebXRSessionManager,
  76598. /**
  76599. * read-only options to be used in this module
  76600. */
  76601. options?: IWebXRBackgroundRemoverOptions);
  76602. /**
  76603. * attach this feature
  76604. * Will usually be called by the features manager
  76605. *
  76606. * @returns true if successful.
  76607. */
  76608. attach(): boolean;
  76609. /**
  76610. * detach this feature.
  76611. * Will usually be called by the features manager
  76612. *
  76613. * @returns true if successful.
  76614. */
  76615. detach(): boolean;
  76616. /**
  76617. * Dispose this feature and all of the resources attached
  76618. */
  76619. dispose(): void;
  76620. protected _onXRFrame(_xrFrame: XRFrame): void;
  76621. private _setBackgroundState;
  76622. }
  76623. }
  76624. declare module BABYLON {
  76625. /**
  76626. * Options for the controller physics feature
  76627. */
  76628. export class IWebXRControllerPhysicsOptions {
  76629. /**
  76630. * Should the headset get its own impostor
  76631. */
  76632. enableHeadsetImpostor?: boolean;
  76633. /**
  76634. * Optional parameters for the headset impostor
  76635. */
  76636. headsetImpostorParams?: {
  76637. /**
  76638. * The type of impostor to create. Default is sphere
  76639. */
  76640. impostorType: number;
  76641. /**
  76642. * the size of the impostor. Defaults to 10cm
  76643. */
  76644. impostorSize?: number | {
  76645. width: number;
  76646. height: number;
  76647. depth: number;
  76648. };
  76649. /**
  76650. * Friction definitions
  76651. */
  76652. friction?: number;
  76653. /**
  76654. * Restitution
  76655. */
  76656. restitution?: number;
  76657. };
  76658. /**
  76659. * The physics properties of the future impostors
  76660. */
  76661. physicsProperties?: {
  76662. /**
  76663. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  76664. * Note that this requires a physics engine that supports mesh impostors!
  76665. */
  76666. useControllerMesh?: boolean;
  76667. /**
  76668. * The type of impostor to create. Default is sphere
  76669. */
  76670. impostorType?: number;
  76671. /**
  76672. * the size of the impostor. Defaults to 10cm
  76673. */
  76674. impostorSize?: number | {
  76675. width: number;
  76676. height: number;
  76677. depth: number;
  76678. };
  76679. /**
  76680. * Friction definitions
  76681. */
  76682. friction?: number;
  76683. /**
  76684. * Restitution
  76685. */
  76686. restitution?: number;
  76687. };
  76688. /**
  76689. * the xr input to use with this pointer selection
  76690. */
  76691. xrInput: WebXRInput;
  76692. }
  76693. /**
  76694. * Add physics impostor to your webxr controllers,
  76695. * including naive calculation of their linear and angular velocity
  76696. */
  76697. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  76698. private readonly _options;
  76699. private _attachController;
  76700. private _controllers;
  76701. private _debugMode;
  76702. private _delta;
  76703. private _headsetImpostor?;
  76704. private _headsetMesh?;
  76705. private _lastTimestamp;
  76706. private _tmpQuaternion;
  76707. private _tmpVector;
  76708. /**
  76709. * The module's name
  76710. */
  76711. static readonly Name: string;
  76712. /**
  76713. * The (Babylon) version of this module.
  76714. * This is an integer representing the implementation version.
  76715. * This number does not correspond to the webxr specs version
  76716. */
  76717. static readonly Version: number;
  76718. /**
  76719. * Construct a new Controller Physics Feature
  76720. * @param _xrSessionManager the corresponding xr session manager
  76721. * @param _options options to create this feature with
  76722. */
  76723. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  76724. /**
  76725. * @hidden
  76726. * enable debugging - will show console outputs and the impostor mesh
  76727. */
  76728. _enablePhysicsDebug(): void;
  76729. /**
  76730. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  76731. * @param xrController the controller to add
  76732. */
  76733. addController(xrController: WebXRInputSource): void;
  76734. /**
  76735. * attach this feature
  76736. * Will usually be called by the features manager
  76737. *
  76738. * @returns true if successful.
  76739. */
  76740. attach(): boolean;
  76741. /**
  76742. * detach this feature.
  76743. * Will usually be called by the features manager
  76744. *
  76745. * @returns true if successful.
  76746. */
  76747. detach(): boolean;
  76748. /**
  76749. * Get the headset impostor, if enabled
  76750. * @returns the impostor
  76751. */
  76752. getHeadsetImpostor(): PhysicsImpostor | undefined;
  76753. /**
  76754. * Get the physics impostor of a specific controller.
  76755. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  76756. * @param controller the controller or the controller id of which to get the impostor
  76757. * @returns the impostor or null
  76758. */
  76759. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  76760. /**
  76761. * Update the physics properties provided in the constructor
  76762. * @param newProperties the new properties object
  76763. */
  76764. setPhysicsProperties(newProperties: {
  76765. impostorType?: number;
  76766. impostorSize?: number | {
  76767. width: number;
  76768. height: number;
  76769. depth: number;
  76770. };
  76771. friction?: number;
  76772. restitution?: number;
  76773. }): void;
  76774. protected _onXRFrame(_xrFrame: any): void;
  76775. private _detachController;
  76776. }
  76777. }
  76778. declare module BABYLON {
  76779. /**
  76780. * A babylon interface for a "WebXR" feature point.
  76781. * Represents the position and confidence value of a given feature point.
  76782. */
  76783. export interface IWebXRFeaturePoint {
  76784. /**
  76785. * Represents the position of the feature point in world space.
  76786. */
  76787. position: Vector3;
  76788. /**
  76789. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  76790. */
  76791. confidenceValue: number;
  76792. }
  76793. /**
  76794. * The feature point system is used to detect feature points from real world geometry.
  76795. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  76796. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  76797. */
  76798. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  76799. private _enabled;
  76800. private _featurePointCloud;
  76801. /**
  76802. * The module's name
  76803. */
  76804. static readonly Name: string;
  76805. /**
  76806. * The (Babylon) version of this module.
  76807. * This is an integer representing the implementation version.
  76808. * This number does not correspond to the WebXR specs version
  76809. */
  76810. static readonly Version: number;
  76811. /**
  76812. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  76813. * Will notify the observers about which feature points have been added.
  76814. */
  76815. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  76816. /**
  76817. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  76818. * Will notify the observers about which feature points have been updated.
  76819. */
  76820. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  76821. /**
  76822. * The current feature point cloud maintained across frames.
  76823. */
  76824. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  76825. /**
  76826. * construct the feature point system
  76827. * @param _xrSessionManager an instance of xr Session manager
  76828. */
  76829. constructor(_xrSessionManager: WebXRSessionManager);
  76830. /**
  76831. * Detach this feature.
  76832. * Will usually be called by the features manager
  76833. *
  76834. * @returns true if successful.
  76835. */
  76836. detach(): boolean;
  76837. /**
  76838. * Dispose this feature and all of the resources attached
  76839. */
  76840. dispose(): void;
  76841. /**
  76842. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  76843. */
  76844. protected _onXRFrame(frame: XRFrame): void;
  76845. /**
  76846. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  76847. */
  76848. private _init;
  76849. }
  76850. }
  76851. declare module BABYLON {
  76852. /**
  76853. * Configuration interface for the hand tracking feature
  76854. */
  76855. export interface IWebXRHandTrackingOptions {
  76856. /**
  76857. * The xrInput that will be used as source for new hands
  76858. */
  76859. xrInput: WebXRInput;
  76860. /**
  76861. * Configuration object for the joint meshes
  76862. */
  76863. jointMeshes?: {
  76864. /**
  76865. * Should the meshes created be invisible (defaults to false)
  76866. */
  76867. invisible?: boolean;
  76868. /**
  76869. * A source mesh to be used to create instances. Defaults to a sphere.
  76870. * This mesh will be the source for all other (25) meshes.
  76871. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  76872. */
  76873. sourceMesh?: Mesh;
  76874. /**
  76875. * This function will be called after a mesh was created for a specific joint.
  76876. * Using this function you can either manipulate the instance or return a new mesh.
  76877. * When returning a new mesh the instance created before will be disposed
  76878. */
  76879. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  76880. /**
  76881. * Should the source mesh stay visible. Defaults to false
  76882. */
  76883. keepOriginalVisible?: boolean;
  76884. /**
  76885. * Scale factor for all instances (defaults to 2)
  76886. */
  76887. scaleFactor?: number;
  76888. /**
  76889. * Should each instance have its own physics impostor
  76890. */
  76891. enablePhysics?: boolean;
  76892. /**
  76893. * If enabled, override default physics properties
  76894. */
  76895. physicsProps?: {
  76896. friction?: number;
  76897. restitution?: number;
  76898. impostorType?: number;
  76899. };
  76900. /**
  76901. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  76902. */
  76903. disableDefaultHandMesh?: boolean;
  76904. /**
  76905. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  76906. */
  76907. handMeshes?: {
  76908. right: AbstractMesh;
  76909. left: AbstractMesh;
  76910. };
  76911. /**
  76912. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  76913. */
  76914. rigMapping?: {
  76915. right: string[];
  76916. left: string[];
  76917. };
  76918. };
  76919. }
  76920. /**
  76921. * Parts of the hands divided to writs and finger names
  76922. */
  76923. export const enum HandPart {
  76924. /**
  76925. * HandPart - Wrist
  76926. */
  76927. WRIST = "wrist",
  76928. /**
  76929. * HandPart - The THumb
  76930. */
  76931. THUMB = "thumb",
  76932. /**
  76933. * HandPart - Index finger
  76934. */
  76935. INDEX = "index",
  76936. /**
  76937. * HandPart - Middle finger
  76938. */
  76939. MIDDLE = "middle",
  76940. /**
  76941. * HandPart - Ring finger
  76942. */
  76943. RING = "ring",
  76944. /**
  76945. * HandPart - Little finger
  76946. */
  76947. LITTLE = "little"
  76948. }
  76949. /**
  76950. * Representing a single hand (with its corresponding native XRHand object)
  76951. */
  76952. export class WebXRHand implements IDisposable {
  76953. /** the controller to which the hand correlates */
  76954. readonly xrController: WebXRInputSource;
  76955. /** the meshes to be used to track the hand joints */
  76956. readonly trackedMeshes: AbstractMesh[];
  76957. private _handMesh?;
  76958. private _rigMapping?;
  76959. private _scene;
  76960. private _defaultHandMesh;
  76961. private _transformNodeMapping;
  76962. /**
  76963. * Hand-parts definition (key is HandPart)
  76964. */
  76965. handPartsDefinition: {
  76966. [key: string]: number[];
  76967. };
  76968. /**
  76969. * Observers will be triggered when the mesh for this hand was initialized.
  76970. */
  76971. onHandMeshReadyObservable: Observable<WebXRHand>;
  76972. /**
  76973. * Populate the HandPartsDefinition object.
  76974. * This is called as a side effect since certain browsers don't have XRHand defined.
  76975. */
  76976. private generateHandPartsDefinition;
  76977. /**
  76978. * Construct a new hand object
  76979. * @param xrController the controller to which the hand correlates
  76980. * @param trackedMeshes the meshes to be used to track the hand joints
  76981. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  76982. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  76983. * @param disableDefaultHandMesh should the default mesh creation be disabled
  76984. */
  76985. constructor(
  76986. /** the controller to which the hand correlates */
  76987. xrController: WebXRInputSource,
  76988. /** the meshes to be used to track the hand joints */
  76989. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  76990. /**
  76991. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  76992. */
  76993. get handMesh(): AbstractMesh | undefined;
  76994. /**
  76995. * Update this hand from the latest xr frame
  76996. * @param xrFrame xrFrame to update from
  76997. * @param referenceSpace The current viewer reference space
  76998. * @param scaleFactor optional scale factor for the meshes
  76999. */
  77000. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  77001. /**
  77002. * Get meshes of part of the hand
  77003. * @param part the part of hand to get
  77004. * @returns An array of meshes that correlate to the hand part requested
  77005. */
  77006. getHandPartMeshes(part: HandPart): AbstractMesh[];
  77007. /**
  77008. * Dispose this Hand object
  77009. */
  77010. dispose(): void;
  77011. private _generateDefaultHandMesh;
  77012. }
  77013. /**
  77014. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  77015. */
  77016. export class WebXRHandTracking extends WebXRAbstractFeature {
  77017. /**
  77018. * options to use when constructing this feature
  77019. */
  77020. readonly options: IWebXRHandTrackingOptions;
  77021. private static _idCounter;
  77022. /**
  77023. * The module's name
  77024. */
  77025. static readonly Name: string;
  77026. /**
  77027. * The (Babylon) version of this module.
  77028. * This is an integer representing the implementation version.
  77029. * This number does not correspond to the WebXR specs version
  77030. */
  77031. static readonly Version: number;
  77032. /**
  77033. * This observable will notify registered observers when a new hand object was added and initialized
  77034. */
  77035. onHandAddedObservable: Observable<WebXRHand>;
  77036. /**
  77037. * This observable will notify its observers right before the hand object is disposed
  77038. */
  77039. onHandRemovedObservable: Observable<WebXRHand>;
  77040. private _hands;
  77041. /**
  77042. * Creates a new instance of the hit test feature
  77043. * @param _xrSessionManager an instance of WebXRSessionManager
  77044. * @param options options to use when constructing this feature
  77045. */
  77046. constructor(_xrSessionManager: WebXRSessionManager,
  77047. /**
  77048. * options to use when constructing this feature
  77049. */
  77050. options: IWebXRHandTrackingOptions);
  77051. /**
  77052. * Check if the needed objects are defined.
  77053. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  77054. */
  77055. isCompatible(): boolean;
  77056. /**
  77057. * attach this feature
  77058. * Will usually be called by the features manager
  77059. *
  77060. * @returns true if successful.
  77061. */
  77062. attach(): boolean;
  77063. /**
  77064. * detach this feature.
  77065. * Will usually be called by the features manager
  77066. *
  77067. * @returns true if successful.
  77068. */
  77069. detach(): boolean;
  77070. /**
  77071. * Dispose this feature and all of the resources attached
  77072. */
  77073. dispose(): void;
  77074. /**
  77075. * Get the hand object according to the controller id
  77076. * @param controllerId the controller id to which we want to get the hand
  77077. * @returns null if not found or the WebXRHand object if found
  77078. */
  77079. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  77080. /**
  77081. * Get a hand object according to the requested handedness
  77082. * @param handedness the handedness to request
  77083. * @returns null if not found or the WebXRHand object if found
  77084. */
  77085. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  77086. protected _onXRFrame(_xrFrame: XRFrame): void;
  77087. private _attachHand;
  77088. private _detachHand;
  77089. }
  77090. }
  77091. declare module BABYLON {
  77092. /**
  77093. * The motion controller class for all microsoft mixed reality controllers
  77094. */
  77095. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  77096. protected readonly _mapping: {
  77097. defaultButton: {
  77098. valueNodeName: string;
  77099. unpressedNodeName: string;
  77100. pressedNodeName: string;
  77101. };
  77102. defaultAxis: {
  77103. valueNodeName: string;
  77104. minNodeName: string;
  77105. maxNodeName: string;
  77106. };
  77107. buttons: {
  77108. "xr-standard-trigger": {
  77109. rootNodeName: string;
  77110. componentProperty: string;
  77111. states: string[];
  77112. };
  77113. "xr-standard-squeeze": {
  77114. rootNodeName: string;
  77115. componentProperty: string;
  77116. states: string[];
  77117. };
  77118. "xr-standard-touchpad": {
  77119. rootNodeName: string;
  77120. labelAnchorNodeName: string;
  77121. touchPointNodeName: string;
  77122. };
  77123. "xr-standard-thumbstick": {
  77124. rootNodeName: string;
  77125. componentProperty: string;
  77126. states: string[];
  77127. };
  77128. };
  77129. axes: {
  77130. "xr-standard-touchpad": {
  77131. "x-axis": {
  77132. rootNodeName: string;
  77133. };
  77134. "y-axis": {
  77135. rootNodeName: string;
  77136. };
  77137. };
  77138. "xr-standard-thumbstick": {
  77139. "x-axis": {
  77140. rootNodeName: string;
  77141. };
  77142. "y-axis": {
  77143. rootNodeName: string;
  77144. };
  77145. };
  77146. };
  77147. };
  77148. /**
  77149. * The base url used to load the left and right controller models
  77150. */
  77151. static MODEL_BASE_URL: string;
  77152. /**
  77153. * The name of the left controller model file
  77154. */
  77155. static MODEL_LEFT_FILENAME: string;
  77156. /**
  77157. * The name of the right controller model file
  77158. */
  77159. static MODEL_RIGHT_FILENAME: string;
  77160. profileId: string;
  77161. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77162. protected _getFilenameAndPath(): {
  77163. filename: string;
  77164. path: string;
  77165. };
  77166. protected _getModelLoadingConstraints(): boolean;
  77167. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77168. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77169. protected _updateModel(): void;
  77170. }
  77171. }
  77172. declare module BABYLON {
  77173. /**
  77174. * The motion controller class for oculus touch (quest, rift).
  77175. * This class supports legacy mapping as well the standard xr mapping
  77176. */
  77177. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  77178. private _forceLegacyControllers;
  77179. private _modelRootNode;
  77180. /**
  77181. * The base url used to load the left and right controller models
  77182. */
  77183. static MODEL_BASE_URL: string;
  77184. /**
  77185. * The name of the left controller model file
  77186. */
  77187. static MODEL_LEFT_FILENAME: string;
  77188. /**
  77189. * The name of the right controller model file
  77190. */
  77191. static MODEL_RIGHT_FILENAME: string;
  77192. /**
  77193. * Base Url for the Quest controller model.
  77194. */
  77195. static QUEST_MODEL_BASE_URL: string;
  77196. profileId: string;
  77197. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  77198. protected _getFilenameAndPath(): {
  77199. filename: string;
  77200. path: string;
  77201. };
  77202. protected _getModelLoadingConstraints(): boolean;
  77203. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77204. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77205. protected _updateModel(): void;
  77206. /**
  77207. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  77208. * between the touch and touch 2.
  77209. */
  77210. private _isQuest;
  77211. }
  77212. }
  77213. declare module BABYLON {
  77214. /**
  77215. * The motion controller class for the standard HTC-Vive controllers
  77216. */
  77217. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  77218. private _modelRootNode;
  77219. /**
  77220. * The base url used to load the left and right controller models
  77221. */
  77222. static MODEL_BASE_URL: string;
  77223. /**
  77224. * File name for the controller model.
  77225. */
  77226. static MODEL_FILENAME: string;
  77227. profileId: string;
  77228. /**
  77229. * Create a new Vive motion controller object
  77230. * @param scene the scene to use to create this controller
  77231. * @param gamepadObject the corresponding gamepad object
  77232. * @param handedness the handedness of the controller
  77233. */
  77234. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  77235. protected _getFilenameAndPath(): {
  77236. filename: string;
  77237. path: string;
  77238. };
  77239. protected _getModelLoadingConstraints(): boolean;
  77240. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  77241. protected _setRootMesh(meshes: AbstractMesh[]): void;
  77242. protected _updateModel(): void;
  77243. }
  77244. }
  77245. declare module BABYLON {
  77246. /**
  77247. * A cursor which tracks a point on a path
  77248. */
  77249. export class PathCursor {
  77250. private path;
  77251. /**
  77252. * Stores path cursor callbacks for when an onchange event is triggered
  77253. */
  77254. private _onchange;
  77255. /**
  77256. * The value of the path cursor
  77257. */
  77258. value: number;
  77259. /**
  77260. * The animation array of the path cursor
  77261. */
  77262. animations: Animation[];
  77263. /**
  77264. * Initializes the path cursor
  77265. * @param path The path to track
  77266. */
  77267. constructor(path: Path2);
  77268. /**
  77269. * Gets the cursor point on the path
  77270. * @returns A point on the path cursor at the cursor location
  77271. */
  77272. getPoint(): Vector3;
  77273. /**
  77274. * Moves the cursor ahead by the step amount
  77275. * @param step The amount to move the cursor forward
  77276. * @returns This path cursor
  77277. */
  77278. moveAhead(step?: number): PathCursor;
  77279. /**
  77280. * Moves the cursor behind by the step amount
  77281. * @param step The amount to move the cursor back
  77282. * @returns This path cursor
  77283. */
  77284. moveBack(step?: number): PathCursor;
  77285. /**
  77286. * Moves the cursor by the step amount
  77287. * If the step amount is greater than one, an exception is thrown
  77288. * @param step The amount to move the cursor
  77289. * @returns This path cursor
  77290. */
  77291. move(step: number): PathCursor;
  77292. /**
  77293. * Ensures that the value is limited between zero and one
  77294. * @returns This path cursor
  77295. */
  77296. private ensureLimits;
  77297. /**
  77298. * Runs onchange callbacks on change (used by the animation engine)
  77299. * @returns This path cursor
  77300. */
  77301. private raiseOnChange;
  77302. /**
  77303. * Executes a function on change
  77304. * @param f A path cursor onchange callback
  77305. * @returns This path cursor
  77306. */
  77307. onchange(f: (cursor: PathCursor) => void): PathCursor;
  77308. }
  77309. }
  77310. declare module BABYLON {
  77311. /** @hidden */
  77312. export var blurPixelShader: {
  77313. name: string;
  77314. shader: string;
  77315. };
  77316. }
  77317. declare module BABYLON {
  77318. /** @hidden */
  77319. export var pointCloudVertexDeclaration: {
  77320. name: string;
  77321. shader: string;
  77322. };
  77323. }
  77324. // Mixins
  77325. interface Window {
  77326. mozIndexedDB: IDBFactory;
  77327. webkitIndexedDB: IDBFactory;
  77328. msIndexedDB: IDBFactory;
  77329. webkitURL: typeof URL;
  77330. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  77331. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  77332. WebGLRenderingContext: WebGLRenderingContext;
  77333. MSGesture: MSGesture;
  77334. CANNON: any;
  77335. AudioContext: AudioContext;
  77336. webkitAudioContext: AudioContext;
  77337. PointerEvent: any;
  77338. Math: Math;
  77339. Uint8Array: Uint8ArrayConstructor;
  77340. Float32Array: Float32ArrayConstructor;
  77341. mozURL: typeof URL;
  77342. msURL: typeof URL;
  77343. VRFrameData: any; // WebVR, from specs 1.1
  77344. DracoDecoderModule: any;
  77345. setImmediate(handler: (...args: any[]) => void): number;
  77346. }
  77347. interface HTMLCanvasElement {
  77348. requestPointerLock(): void;
  77349. msRequestPointerLock?(): void;
  77350. mozRequestPointerLock?(): void;
  77351. webkitRequestPointerLock?(): void;
  77352. /** Track wether a record is in progress */
  77353. isRecording: boolean;
  77354. /** Capture Stream method defined by some browsers */
  77355. captureStream(fps?: number): MediaStream;
  77356. }
  77357. interface CanvasRenderingContext2D {
  77358. msImageSmoothingEnabled: boolean;
  77359. }
  77360. interface MouseEvent {
  77361. mozMovementX: number;
  77362. mozMovementY: number;
  77363. webkitMovementX: number;
  77364. webkitMovementY: number;
  77365. msMovementX: number;
  77366. msMovementY: number;
  77367. }
  77368. interface Navigator {
  77369. mozGetVRDevices: (any: any) => any;
  77370. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77371. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77372. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  77373. webkitGetGamepads(): Gamepad[];
  77374. msGetGamepads(): Gamepad[];
  77375. webkitGamepads(): Gamepad[];
  77376. }
  77377. interface HTMLVideoElement {
  77378. mozSrcObject: any;
  77379. }
  77380. interface Math {
  77381. fround(x: number): number;
  77382. imul(a: number, b: number): number;
  77383. }
  77384. interface WebGLRenderingContext {
  77385. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  77386. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  77387. vertexAttribDivisor(index: number, divisor: number): void;
  77388. createVertexArray(): any;
  77389. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  77390. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  77391. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  77392. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  77393. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  77394. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  77395. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  77396. // Queries
  77397. createQuery(): WebGLQuery;
  77398. deleteQuery(query: WebGLQuery): void;
  77399. beginQuery(target: number, query: WebGLQuery): void;
  77400. endQuery(target: number): void;
  77401. getQueryParameter(query: WebGLQuery, pname: number): any;
  77402. getQuery(target: number, pname: number): any;
  77403. MAX_SAMPLES: number;
  77404. RGBA8: number;
  77405. READ_FRAMEBUFFER: number;
  77406. DRAW_FRAMEBUFFER: number;
  77407. UNIFORM_BUFFER: number;
  77408. HALF_FLOAT_OES: number;
  77409. RGBA16F: number;
  77410. RGBA32F: number;
  77411. R32F: number;
  77412. RG32F: number;
  77413. RGB32F: number;
  77414. R16F: number;
  77415. RG16F: number;
  77416. RGB16F: number;
  77417. RED: number;
  77418. RG: number;
  77419. R8: number;
  77420. RG8: number;
  77421. UNSIGNED_INT_24_8: number;
  77422. DEPTH24_STENCIL8: number;
  77423. MIN: number;
  77424. MAX: number;
  77425. /* Multiple Render Targets */
  77426. drawBuffers(buffers: number[]): void;
  77427. readBuffer(src: number): void;
  77428. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  77429. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  77430. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  77431. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  77432. // Occlusion Query
  77433. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  77434. ANY_SAMPLES_PASSED: number;
  77435. QUERY_RESULT_AVAILABLE: number;
  77436. QUERY_RESULT: number;
  77437. }
  77438. interface WebGLProgram {
  77439. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  77440. }
  77441. interface EXT_disjoint_timer_query {
  77442. QUERY_COUNTER_BITS_EXT: number;
  77443. TIME_ELAPSED_EXT: number;
  77444. TIMESTAMP_EXT: number;
  77445. GPU_DISJOINT_EXT: number;
  77446. QUERY_RESULT_EXT: number;
  77447. QUERY_RESULT_AVAILABLE_EXT: number;
  77448. queryCounterEXT(query: WebGLQuery, target: number): void;
  77449. createQueryEXT(): WebGLQuery;
  77450. beginQueryEXT(target: number, query: WebGLQuery): void;
  77451. endQueryEXT(target: number): void;
  77452. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  77453. deleteQueryEXT(query: WebGLQuery): void;
  77454. }
  77455. interface WebGLUniformLocation {
  77456. _currentState: any;
  77457. }
  77458. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  77459. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  77460. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  77461. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77462. interface WebGLRenderingContext {
  77463. readonly RASTERIZER_DISCARD: number;
  77464. readonly DEPTH_COMPONENT24: number;
  77465. readonly TEXTURE_3D: number;
  77466. readonly TEXTURE_2D_ARRAY: number;
  77467. readonly TEXTURE_COMPARE_FUNC: number;
  77468. readonly TEXTURE_COMPARE_MODE: number;
  77469. readonly COMPARE_REF_TO_TEXTURE: number;
  77470. readonly TEXTURE_WRAP_R: number;
  77471. readonly HALF_FLOAT: number;
  77472. readonly RGB8: number;
  77473. readonly RED_INTEGER: number;
  77474. readonly RG_INTEGER: number;
  77475. readonly RGB_INTEGER: number;
  77476. readonly RGBA_INTEGER: number;
  77477. readonly R8_SNORM: number;
  77478. readonly RG8_SNORM: number;
  77479. readonly RGB8_SNORM: number;
  77480. readonly RGBA8_SNORM: number;
  77481. readonly R8I: number;
  77482. readonly RG8I: number;
  77483. readonly RGB8I: number;
  77484. readonly RGBA8I: number;
  77485. readonly R8UI: number;
  77486. readonly RG8UI: number;
  77487. readonly RGB8UI: number;
  77488. readonly RGBA8UI: number;
  77489. readonly R16I: number;
  77490. readonly RG16I: number;
  77491. readonly RGB16I: number;
  77492. readonly RGBA16I: number;
  77493. readonly R16UI: number;
  77494. readonly RG16UI: number;
  77495. readonly RGB16UI: number;
  77496. readonly RGBA16UI: number;
  77497. readonly R32I: number;
  77498. readonly RG32I: number;
  77499. readonly RGB32I: number;
  77500. readonly RGBA32I: number;
  77501. readonly R32UI: number;
  77502. readonly RG32UI: number;
  77503. readonly RGB32UI: number;
  77504. readonly RGBA32UI: number;
  77505. readonly RGB10_A2UI: number;
  77506. readonly R11F_G11F_B10F: number;
  77507. readonly RGB9_E5: number;
  77508. readonly RGB10_A2: number;
  77509. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  77510. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  77511. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  77512. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  77513. readonly DEPTH_COMPONENT32F: number;
  77514. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  77515. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  77516. 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;
  77517. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  77518. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  77519. readonly TRANSFORM_FEEDBACK: number;
  77520. readonly INTERLEAVED_ATTRIBS: number;
  77521. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  77522. createTransformFeedback(): WebGLTransformFeedback;
  77523. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  77524. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  77525. beginTransformFeedback(primitiveMode: number): void;
  77526. endTransformFeedback(): void;
  77527. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  77528. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77529. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77530. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  77531. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  77532. }
  77533. interface ImageBitmap {
  77534. readonly width: number;
  77535. readonly height: number;
  77536. close(): void;
  77537. }
  77538. interface WebGLQuery extends WebGLObject {
  77539. }
  77540. declare var WebGLQuery: {
  77541. prototype: WebGLQuery;
  77542. new(): WebGLQuery;
  77543. };
  77544. interface WebGLSampler extends WebGLObject {
  77545. }
  77546. declare var WebGLSampler: {
  77547. prototype: WebGLSampler;
  77548. new(): WebGLSampler;
  77549. };
  77550. interface WebGLSync extends WebGLObject {
  77551. }
  77552. declare var WebGLSync: {
  77553. prototype: WebGLSync;
  77554. new(): WebGLSync;
  77555. };
  77556. interface WebGLTransformFeedback extends WebGLObject {
  77557. }
  77558. declare var WebGLTransformFeedback: {
  77559. prototype: WebGLTransformFeedback;
  77560. new(): WebGLTransformFeedback;
  77561. };
  77562. interface WebGLVertexArrayObject extends WebGLObject {
  77563. }
  77564. declare var WebGLVertexArrayObject: {
  77565. prototype: WebGLVertexArrayObject;
  77566. new(): WebGLVertexArrayObject;
  77567. };
  77568. // Type definitions for WebVR API
  77569. // Project: https://w3c.github.io/webvr/
  77570. // Definitions by: six a <https://github.com/lostfictions>
  77571. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  77572. interface VRDisplay extends EventTarget {
  77573. /**
  77574. * Dictionary of capabilities describing the VRDisplay.
  77575. */
  77576. readonly capabilities: VRDisplayCapabilities;
  77577. /**
  77578. * z-depth defining the far plane of the eye view frustum
  77579. * enables mapping of values in the render target depth
  77580. * attachment to scene coordinates. Initially set to 10000.0.
  77581. */
  77582. depthFar: number;
  77583. /**
  77584. * z-depth defining the near plane of the eye view frustum
  77585. * enables mapping of values in the render target depth
  77586. * attachment to scene coordinates. Initially set to 0.01.
  77587. */
  77588. depthNear: number;
  77589. /**
  77590. * An identifier for this distinct VRDisplay. Used as an
  77591. * association point in the Gamepad API.
  77592. */
  77593. readonly displayId: number;
  77594. /**
  77595. * A display name, a user-readable name identifying it.
  77596. */
  77597. readonly displayName: string;
  77598. readonly isConnected: boolean;
  77599. readonly isPresenting: boolean;
  77600. /**
  77601. * If this VRDisplay supports room-scale experiences, the optional
  77602. * stage attribute contains details on the room-scale parameters.
  77603. */
  77604. readonly stageParameters: VRStageParameters | null;
  77605. /**
  77606. * Passing the value returned by `requestAnimationFrame` to
  77607. * `cancelAnimationFrame` will unregister the callback.
  77608. * @param handle Define the hanle of the request to cancel
  77609. */
  77610. cancelAnimationFrame(handle: number): void;
  77611. /**
  77612. * Stops presenting to the VRDisplay.
  77613. * @returns a promise to know when it stopped
  77614. */
  77615. exitPresent(): Promise<void>;
  77616. /**
  77617. * Return the current VREyeParameters for the given eye.
  77618. * @param whichEye Define the eye we want the parameter for
  77619. * @returns the eye parameters
  77620. */
  77621. getEyeParameters(whichEye: string): VREyeParameters;
  77622. /**
  77623. * Populates the passed VRFrameData with the information required to render
  77624. * the current frame.
  77625. * @param frameData Define the data structure to populate
  77626. * @returns true if ok otherwise false
  77627. */
  77628. getFrameData(frameData: VRFrameData): boolean;
  77629. /**
  77630. * Get the layers currently being presented.
  77631. * @returns the list of VR layers
  77632. */
  77633. getLayers(): VRLayer[];
  77634. /**
  77635. * Return a VRPose containing the future predicted pose of the VRDisplay
  77636. * when the current frame will be presented. The value returned will not
  77637. * change until JavaScript has returned control to the browser.
  77638. *
  77639. * The VRPose will contain the position, orientation, velocity,
  77640. * and acceleration of each of these properties.
  77641. * @returns the pose object
  77642. */
  77643. getPose(): VRPose;
  77644. /**
  77645. * Return the current instantaneous pose of the VRDisplay, with no
  77646. * prediction applied.
  77647. * @returns the current instantaneous pose
  77648. */
  77649. getImmediatePose(): VRPose;
  77650. /**
  77651. * The callback passed to `requestAnimationFrame` will be called
  77652. * any time a new frame should be rendered. When the VRDisplay is
  77653. * presenting the callback will be called at the native refresh
  77654. * rate of the HMD. When not presenting this function acts
  77655. * identically to how window.requestAnimationFrame acts. Content should
  77656. * make no assumptions of frame rate or vsync behavior as the HMD runs
  77657. * asynchronously from other displays and at differing refresh rates.
  77658. * @param callback Define the eaction to run next frame
  77659. * @returns the request handle it
  77660. */
  77661. requestAnimationFrame(callback: FrameRequestCallback): number;
  77662. /**
  77663. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  77664. * Repeat calls while already presenting will update the VRLayers being displayed.
  77665. * @param layers Define the list of layer to present
  77666. * @returns a promise to know when the request has been fulfilled
  77667. */
  77668. requestPresent(layers: VRLayer[]): Promise<void>;
  77669. /**
  77670. * Reset the pose for this display, treating its current position and
  77671. * orientation as the "origin/zero" values. VRPose.position,
  77672. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  77673. * updated when calling resetPose(). This should be called in only
  77674. * sitting-space experiences.
  77675. */
  77676. resetPose(): void;
  77677. /**
  77678. * The VRLayer provided to the VRDisplay will be captured and presented
  77679. * in the HMD. Calling this function has the same effect on the source
  77680. * canvas as any other operation that uses its source image, and canvases
  77681. * created without preserveDrawingBuffer set to true will be cleared.
  77682. * @param pose Define the pose to submit
  77683. */
  77684. submitFrame(pose?: VRPose): void;
  77685. }
  77686. declare var VRDisplay: {
  77687. prototype: VRDisplay;
  77688. new(): VRDisplay;
  77689. };
  77690. interface VRLayer {
  77691. leftBounds?: number[] | Float32Array | null;
  77692. rightBounds?: number[] | Float32Array | null;
  77693. source?: HTMLCanvasElement | null;
  77694. }
  77695. interface VRDisplayCapabilities {
  77696. readonly canPresent: boolean;
  77697. readonly hasExternalDisplay: boolean;
  77698. readonly hasOrientation: boolean;
  77699. readonly hasPosition: boolean;
  77700. readonly maxLayers: number;
  77701. }
  77702. interface VREyeParameters {
  77703. /** @deprecated */
  77704. readonly fieldOfView: VRFieldOfView;
  77705. readonly offset: Float32Array;
  77706. readonly renderHeight: number;
  77707. readonly renderWidth: number;
  77708. }
  77709. interface VRFieldOfView {
  77710. readonly downDegrees: number;
  77711. readonly leftDegrees: number;
  77712. readonly rightDegrees: number;
  77713. readonly upDegrees: number;
  77714. }
  77715. interface VRFrameData {
  77716. readonly leftProjectionMatrix: Float32Array;
  77717. readonly leftViewMatrix: Float32Array;
  77718. readonly pose: VRPose;
  77719. readonly rightProjectionMatrix: Float32Array;
  77720. readonly rightViewMatrix: Float32Array;
  77721. readonly timestamp: number;
  77722. }
  77723. interface VRPose {
  77724. readonly angularAcceleration: Float32Array | null;
  77725. readonly angularVelocity: Float32Array | null;
  77726. readonly linearAcceleration: Float32Array | null;
  77727. readonly linearVelocity: Float32Array | null;
  77728. readonly orientation: Float32Array | null;
  77729. readonly position: Float32Array | null;
  77730. readonly timestamp: number;
  77731. }
  77732. interface VRStageParameters {
  77733. sittingToStandingTransform?: Float32Array;
  77734. sizeX?: number;
  77735. sizeY?: number;
  77736. }
  77737. interface Navigator {
  77738. getVRDisplays(): Promise<VRDisplay[]>;
  77739. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  77740. }
  77741. interface Window {
  77742. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  77743. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  77744. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  77745. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77746. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  77747. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  77748. }
  77749. interface Gamepad {
  77750. readonly displayId: number;
  77751. }
  77752. /**
  77753. * Available session modes
  77754. */
  77755. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  77756. /**
  77757. * Reference space types
  77758. */
  77759. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  77760. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  77761. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  77762. /**
  77763. * Handedness types
  77764. */
  77765. type XRHandedness = "none" | "left" | "right";
  77766. /**
  77767. * InputSource target ray modes
  77768. */
  77769. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  77770. /**
  77771. * Eye types
  77772. */
  77773. type XREye = "none" | "left" | "right";
  77774. /**
  77775. * Type of XR events available
  77776. */
  77777. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  77778. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  77779. type XRPlaneSet = Set<XRPlane>;
  77780. type XRAnchorSet = Set<XRAnchor>;
  77781. type XREventHandler = (callback: any) => void;
  77782. interface XRLayer extends EventTarget {}
  77783. interface XRSessionInit {
  77784. optionalFeatures?: string[];
  77785. requiredFeatures?: string[];
  77786. }
  77787. interface XRSessionEvent extends Event {
  77788. readonly session: XRSession;
  77789. }
  77790. interface XRSystem {
  77791. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  77792. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  77793. }
  77794. interface XRViewport {
  77795. readonly x: number;
  77796. readonly y: number;
  77797. readonly width: number;
  77798. readonly height: number;
  77799. }
  77800. interface XRWebGLLayerInit {
  77801. antialias?: boolean;
  77802. depth?: boolean;
  77803. stencil?: boolean;
  77804. alpha?: boolean;
  77805. multiview?: boolean;
  77806. framebufferScaleFactor?: number;
  77807. }
  77808. declare class XRWebGLLayer {
  77809. static getNativeFramebufferScaleFactor(session: XRSession): number;
  77810. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  77811. readonly antialias: boolean;
  77812. readonly framebuffer: WebGLFramebuffer;
  77813. readonly framebufferWidth: number;
  77814. readonly framebufferHeight: number;
  77815. readonly ignoreDepthValues: boolean;
  77816. getViewport: (view: XRView) => XRViewport;
  77817. }
  77818. // tslint:disable-next-line no-empty-interface
  77819. interface XRSpace extends EventTarget {}
  77820. interface XRRenderState {
  77821. readonly baseLayer?: XRWebGLLayer;
  77822. readonly depthFar: number;
  77823. readonly depthNear: number;
  77824. readonly inlineVerticalFieldOfView?: number;
  77825. }
  77826. interface XRRenderStateInit extends XRRenderState {
  77827. baseLayer: XRWebGLLayer;
  77828. depthFar: number;
  77829. depthNear: number;
  77830. inlineVerticalFieldOfView?: number;
  77831. layers?: XRLayer[];
  77832. }
  77833. interface XRReferenceSpace extends XRSpace {
  77834. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  77835. onreset: XREventHandler;
  77836. }
  77837. interface XRBoundedReferenceSpace extends XRSpace {
  77838. readonly boundsGeometry: DOMPointReadOnly[];
  77839. }
  77840. interface XRInputSource {
  77841. readonly handedness: XRHandedness;
  77842. readonly targetRayMode: XRTargetRayMode;
  77843. readonly targetRaySpace: XRSpace;
  77844. readonly gripSpace?: XRSpace;
  77845. readonly gamepad?: Gamepad;
  77846. readonly profiles: Array<string>;
  77847. readonly hand?: XRHand;
  77848. }
  77849. interface XRPose {
  77850. readonly transform: XRRigidTransform;
  77851. readonly emulatedPosition: boolean;
  77852. }
  77853. interface XRFrame {
  77854. readonly session: XRSession;
  77855. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  77856. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  77857. // AR
  77858. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  77859. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  77860. // Anchors
  77861. trackedAnchors?: XRAnchorSet;
  77862. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  77863. // Planes
  77864. worldInformation?: {
  77865. detectedPlanes?: XRPlaneSet;
  77866. };
  77867. // Hand tracking
  77868. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  77869. }
  77870. interface XRInputSourceEvent extends Event {
  77871. readonly frame: XRFrame;
  77872. readonly inputSource: XRInputSource;
  77873. }
  77874. type XRInputSourceArray = XRInputSource[];
  77875. interface XRSession {
  77876. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  77877. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  77878. /**
  77879. * Returns a list of this session's XRInputSources, each representing an input device
  77880. * used to control the camera and/or scene.
  77881. */
  77882. readonly inputSources: Array<XRInputSource>;
  77883. /**
  77884. * object which contains options affecting how the imagery is rendered.
  77885. * This includes things such as the near and far clipping planes
  77886. */
  77887. readonly renderState: XRRenderState;
  77888. readonly visibilityState: XRVisibilityState;
  77889. /**
  77890. * Removes a callback from the animation frame painting callback from
  77891. * XRSession's set of animation frame rendering callbacks, given the
  77892. * identifying handle returned by a previous call to requestAnimationFrame().
  77893. */
  77894. cancelAnimationFrame: (handle: number) => void;
  77895. /**
  77896. * Ends the WebXR session. Returns a promise which resolves when the
  77897. * session has been shut down.
  77898. */
  77899. end(): Promise<void>;
  77900. /**
  77901. * Schedules the specified method to be called the next time the user agent
  77902. * is working on rendering an animation frame for the WebXR device. Returns an
  77903. * integer value which can be used to identify the request for the purposes of
  77904. * canceling the callback using cancelAnimationFrame(). This method is comparable
  77905. * to the Window.requestAnimationFrame() method.
  77906. */
  77907. requestAnimationFrame: XRFrameRequestCallback;
  77908. /**
  77909. * Requests that a new XRReferenceSpace of the specified type be created.
  77910. * Returns a promise which resolves with the XRReferenceSpace or
  77911. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  77912. * the requested space type isn't supported by the device.
  77913. */
  77914. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  77915. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  77916. onend: XREventHandler;
  77917. oninputsourceschange: XREventHandler;
  77918. onselect: XREventHandler;
  77919. onselectstart: XREventHandler;
  77920. onselectend: XREventHandler;
  77921. onsqueeze: XREventHandler;
  77922. onsqueezestart: XREventHandler;
  77923. onsqueezeend: XREventHandler;
  77924. onvisibilitychange: XREventHandler;
  77925. // hit test
  77926. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  77927. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  77928. // legacy AR hit test
  77929. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77930. // legacy plane detection
  77931. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  77932. }
  77933. interface XRViewerPose extends XRPose {
  77934. readonly views: Array<XRView>;
  77935. }
  77936. declare class XRRigidTransform {
  77937. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  77938. position: DOMPointReadOnly;
  77939. orientation: DOMPointReadOnly;
  77940. matrix: Float32Array;
  77941. inverse: XRRigidTransform;
  77942. }
  77943. interface XRView {
  77944. readonly eye: XREye;
  77945. readonly projectionMatrix: Float32Array;
  77946. readonly transform: XRRigidTransform;
  77947. readonly recommendedViewportScale?: number;
  77948. requestViewportScale(scale: number): void;
  77949. }
  77950. interface XRInputSourceChangeEvent extends Event {
  77951. session: XRSession;
  77952. removed: Array<XRInputSource>;
  77953. added: Array<XRInputSource>;
  77954. }
  77955. // Experimental/Draft features
  77956. declare class XRRay {
  77957. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  77958. origin: DOMPointReadOnly;
  77959. direction: DOMPointReadOnly;
  77960. matrix: Float32Array;
  77961. }
  77962. declare enum XRHitTestTrackableType {
  77963. "point",
  77964. "plane",
  77965. "mesh",
  77966. }
  77967. interface XRHitResult {
  77968. hitMatrix: Float32Array;
  77969. }
  77970. interface XRTransientInputHitTestResult {
  77971. readonly inputSource: XRInputSource;
  77972. readonly results: Array<XRHitTestResult>;
  77973. }
  77974. interface XRHitTestResult {
  77975. getPose(baseSpace: XRSpace): XRPose | undefined;
  77976. // When anchor system is enabled
  77977. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  77978. }
  77979. interface XRHitTestSource {
  77980. cancel(): void;
  77981. }
  77982. interface XRTransientInputHitTestSource {
  77983. cancel(): void;
  77984. }
  77985. interface XRHitTestOptionsInit {
  77986. space: XRSpace;
  77987. entityTypes?: Array<XRHitTestTrackableType>;
  77988. offsetRay?: XRRay;
  77989. }
  77990. interface XRTransientInputHitTestOptionsInit {
  77991. profile: string;
  77992. entityTypes?: Array<XRHitTestTrackableType>;
  77993. offsetRay?: XRRay;
  77994. }
  77995. interface XRAnchor {
  77996. anchorSpace: XRSpace;
  77997. delete(): void;
  77998. }
  77999. interface XRPlane {
  78000. orientation: "Horizontal" | "Vertical";
  78001. planeSpace: XRSpace;
  78002. polygon: Array<DOMPointReadOnly>;
  78003. lastChangedTime: number;
  78004. }
  78005. interface XRJointSpace extends XRSpace {}
  78006. interface XRJointPose extends XRPose {
  78007. radius: number | undefined;
  78008. }
  78009. interface XRHand extends Iterable<XRJointSpace> {
  78010. readonly length: number;
  78011. [index: number]: XRJointSpace;
  78012. readonly WRIST: number;
  78013. readonly THUMB_METACARPAL: number;
  78014. readonly THUMB_PHALANX_PROXIMAL: number;
  78015. readonly THUMB_PHALANX_DISTAL: number;
  78016. readonly THUMB_PHALANX_TIP: number;
  78017. readonly INDEX_METACARPAL: number;
  78018. readonly INDEX_PHALANX_PROXIMAL: number;
  78019. readonly INDEX_PHALANX_INTERMEDIATE: number;
  78020. readonly INDEX_PHALANX_DISTAL: number;
  78021. readonly INDEX_PHALANX_TIP: number;
  78022. readonly MIDDLE_METACARPAL: number;
  78023. readonly MIDDLE_PHALANX_PROXIMAL: number;
  78024. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  78025. readonly MIDDLE_PHALANX_DISTAL: number;
  78026. readonly MIDDLE_PHALANX_TIP: number;
  78027. readonly RING_METACARPAL: number;
  78028. readonly RING_PHALANX_PROXIMAL: number;
  78029. readonly RING_PHALANX_INTERMEDIATE: number;
  78030. readonly RING_PHALANX_DISTAL: number;
  78031. readonly RING_PHALANX_TIP: number;
  78032. readonly LITTLE_METACARPAL: number;
  78033. readonly LITTLE_PHALANX_PROXIMAL: number;
  78034. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  78035. readonly LITTLE_PHALANX_DISTAL: number;
  78036. readonly LITTLE_PHALANX_TIP: number;
  78037. }
  78038. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  78039. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  78040. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  78041. interface XRSession {
  78042. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  78043. }
  78044. interface XRFrame {
  78045. featurePointCloud? : Array<number>;
  78046. }
  78047. /**
  78048. * @ignore
  78049. */
  78050. declare module BABYLON.GLTF2.Exporter {
  78051. }
  78052. /**
  78053. * @ignore
  78054. */
  78055. declare module BABYLON.GLTF1 {
  78056. }
  78057. declare module BABYLON.GUI {
  78058. /**
  78059. * Interface used to define a control that can receive focus
  78060. */
  78061. export interface IFocusableControl {
  78062. /**
  78063. * Function called when the control receives the focus
  78064. */
  78065. onFocus(): void;
  78066. /**
  78067. * Function called when the control loses the focus
  78068. */
  78069. onBlur(): void;
  78070. /**
  78071. * Function called to let the control handle keyboard events
  78072. * @param evt defines the current keyboard event
  78073. */
  78074. processKeyboard(evt: KeyboardEvent): void;
  78075. /**
  78076. * Function called to get the list of controls that should not steal the focus from this control
  78077. * @returns an array of controls
  78078. */
  78079. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78080. /**
  78081. * Function to focus the control programmatically
  78082. */
  78083. focus(): void;
  78084. /**
  78085. * Function to unfocus the control programmatically
  78086. */
  78087. blur(): void;
  78088. }
  78089. }
  78090. declare module BABYLON.GUI {
  78091. /**
  78092. * Class used to specific a value and its associated unit
  78093. */
  78094. export class ValueAndUnit {
  78095. /** defines the unit to store */
  78096. unit: number;
  78097. /** defines a boolean indicating if the value can be negative */
  78098. negativeValueAllowed: boolean;
  78099. private _value;
  78100. private _originalUnit;
  78101. /**
  78102. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  78103. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78104. */
  78105. ignoreAdaptiveScaling: boolean;
  78106. /**
  78107. * Creates a new ValueAndUnit
  78108. * @param value defines the value to store
  78109. * @param unit defines the unit to store
  78110. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  78111. */
  78112. constructor(value: number,
  78113. /** defines the unit to store */
  78114. unit?: number,
  78115. /** defines a boolean indicating if the value can be negative */
  78116. negativeValueAllowed?: boolean);
  78117. /** Gets a boolean indicating if the value is a percentage */
  78118. get isPercentage(): boolean;
  78119. /** Gets a boolean indicating if the value is store as pixel */
  78120. get isPixel(): boolean;
  78121. /** Gets direct internal value */
  78122. get internalValue(): number;
  78123. /**
  78124. * Gets value as pixel
  78125. * @param host defines the root host
  78126. * @param refValue defines the reference value for percentages
  78127. * @returns the value as pixel
  78128. */
  78129. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  78130. /**
  78131. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  78132. * @param value defines the value to store
  78133. * @param unit defines the unit to store
  78134. * @returns the current ValueAndUnit
  78135. */
  78136. updateInPlace(value: number, unit?: number): ValueAndUnit;
  78137. /**
  78138. * Gets the value accordingly to its unit
  78139. * @param host defines the root host
  78140. * @returns the value
  78141. */
  78142. getValue(host: AdvancedDynamicTexture): number;
  78143. /**
  78144. * Gets a string representation of the value
  78145. * @param host defines the root host
  78146. * @param decimals defines an optional number of decimals to display
  78147. * @returns a string
  78148. */
  78149. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  78150. /**
  78151. * Store a value parsed from a string
  78152. * @param source defines the source string
  78153. * @returns true if the value was successfully parsed
  78154. */
  78155. fromString(source: string | number): boolean;
  78156. private static _Regex;
  78157. private static _UNITMODE_PERCENTAGE;
  78158. private static _UNITMODE_PIXEL;
  78159. /** UNITMODE_PERCENTAGE */
  78160. static get UNITMODE_PERCENTAGE(): number;
  78161. /** UNITMODE_PIXEL */
  78162. static get UNITMODE_PIXEL(): number;
  78163. }
  78164. }
  78165. declare module BABYLON.GUI {
  78166. /**
  78167. * Define a style used by control to automatically setup properties based on a template.
  78168. * Only support font related properties so far
  78169. */
  78170. export class Style implements BABYLON.IDisposable {
  78171. private _fontFamily;
  78172. private _fontStyle;
  78173. private _fontWeight;
  78174. /** @hidden */
  78175. _host: AdvancedDynamicTexture;
  78176. /** @hidden */
  78177. _fontSize: ValueAndUnit;
  78178. /**
  78179. * BABYLON.Observable raised when the style values are changed
  78180. */
  78181. onChangedObservable: BABYLON.Observable<Style>;
  78182. /**
  78183. * Creates a new style object
  78184. * @param host defines the AdvancedDynamicTexture which hosts this style
  78185. */
  78186. constructor(host: AdvancedDynamicTexture);
  78187. /**
  78188. * Gets or sets the font size
  78189. */
  78190. get fontSize(): string | number;
  78191. set fontSize(value: string | number);
  78192. /**
  78193. * Gets or sets the font family
  78194. */
  78195. get fontFamily(): string;
  78196. set fontFamily(value: string);
  78197. /**
  78198. * Gets or sets the font style
  78199. */
  78200. get fontStyle(): string;
  78201. set fontStyle(value: string);
  78202. /** Gets or sets font weight */
  78203. get fontWeight(): string;
  78204. set fontWeight(value: string);
  78205. /** Dispose all associated resources */
  78206. dispose(): void;
  78207. }
  78208. }
  78209. declare module BABYLON.GUI {
  78210. /**
  78211. * Class used to transport BABYLON.Vector2 information for pointer events
  78212. */
  78213. export class Vector2WithInfo extends BABYLON.Vector2 {
  78214. /** defines the current mouse button index */
  78215. buttonIndex: number;
  78216. /**
  78217. * Creates a new Vector2WithInfo
  78218. * @param source defines the vector2 data to transport
  78219. * @param buttonIndex defines the current mouse button index
  78220. */
  78221. constructor(source: BABYLON.Vector2,
  78222. /** defines the current mouse button index */
  78223. buttonIndex?: number);
  78224. }
  78225. /** Class used to provide 2D matrix features */
  78226. export class Matrix2D {
  78227. /** Gets the internal array of 6 floats used to store matrix data */
  78228. m: Float32Array;
  78229. /**
  78230. * Creates a new matrix
  78231. * @param m00 defines value for (0, 0)
  78232. * @param m01 defines value for (0, 1)
  78233. * @param m10 defines value for (1, 0)
  78234. * @param m11 defines value for (1, 1)
  78235. * @param m20 defines value for (2, 0)
  78236. * @param m21 defines value for (2, 1)
  78237. */
  78238. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  78239. /**
  78240. * Fills the matrix from direct values
  78241. * @param m00 defines value for (0, 0)
  78242. * @param m01 defines value for (0, 1)
  78243. * @param m10 defines value for (1, 0)
  78244. * @param m11 defines value for (1, 1)
  78245. * @param m20 defines value for (2, 0)
  78246. * @param m21 defines value for (2, 1)
  78247. * @returns the current modified matrix
  78248. */
  78249. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  78250. /**
  78251. * Gets matrix determinant
  78252. * @returns the determinant
  78253. */
  78254. determinant(): number;
  78255. /**
  78256. * Inverses the matrix and stores it in a target matrix
  78257. * @param result defines the target matrix
  78258. * @returns the current matrix
  78259. */
  78260. invertToRef(result: Matrix2D): Matrix2D;
  78261. /**
  78262. * Multiplies the current matrix with another one
  78263. * @param other defines the second operand
  78264. * @param result defines the target matrix
  78265. * @returns the current matrix
  78266. */
  78267. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  78268. /**
  78269. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  78270. * @param x defines the x coordinate to transform
  78271. * @param y defines the x coordinate to transform
  78272. * @param result defines the target vector2
  78273. * @returns the current matrix
  78274. */
  78275. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  78276. /**
  78277. * Creates an identity matrix
  78278. * @returns a new matrix
  78279. */
  78280. static Identity(): Matrix2D;
  78281. /**
  78282. * Creates a translation matrix and stores it in a target matrix
  78283. * @param x defines the x coordinate of the translation
  78284. * @param y defines the y coordinate of the translation
  78285. * @param result defines the target matrix
  78286. */
  78287. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  78288. /**
  78289. * Creates a scaling matrix and stores it in a target matrix
  78290. * @param x defines the x coordinate of the scaling
  78291. * @param y defines the y coordinate of the scaling
  78292. * @param result defines the target matrix
  78293. */
  78294. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  78295. /**
  78296. * Creates a rotation matrix and stores it in a target matrix
  78297. * @param angle defines the rotation angle
  78298. * @param result defines the target matrix
  78299. */
  78300. static RotationToRef(angle: number, result: Matrix2D): void;
  78301. private static _TempPreTranslationMatrix;
  78302. private static _TempPostTranslationMatrix;
  78303. private static _TempRotationMatrix;
  78304. private static _TempScalingMatrix;
  78305. private static _TempCompose0;
  78306. private static _TempCompose1;
  78307. private static _TempCompose2;
  78308. /**
  78309. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  78310. * @param tx defines the x coordinate of the translation
  78311. * @param ty defines the y coordinate of the translation
  78312. * @param angle defines the rotation angle
  78313. * @param scaleX defines the x coordinate of the scaling
  78314. * @param scaleY defines the y coordinate of the scaling
  78315. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  78316. * @param result defines the target matrix
  78317. */
  78318. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  78319. }
  78320. }
  78321. declare module BABYLON.GUI {
  78322. /**
  78323. * Class used to store 2D control sizes
  78324. */
  78325. export class Measure {
  78326. /** defines left coordinate */
  78327. left: number;
  78328. /** defines top coordinate */
  78329. top: number;
  78330. /** defines width dimension */
  78331. width: number;
  78332. /** defines height dimension */
  78333. height: number;
  78334. /**
  78335. * Creates a new measure
  78336. * @param left defines left coordinate
  78337. * @param top defines top coordinate
  78338. * @param width defines width dimension
  78339. * @param height defines height dimension
  78340. */
  78341. constructor(
  78342. /** defines left coordinate */
  78343. left: number,
  78344. /** defines top coordinate */
  78345. top: number,
  78346. /** defines width dimension */
  78347. width: number,
  78348. /** defines height dimension */
  78349. height: number);
  78350. /**
  78351. * Copy from another measure
  78352. * @param other defines the other measure to copy from
  78353. */
  78354. copyFrom(other: Measure): void;
  78355. /**
  78356. * Copy from a group of 4 floats
  78357. * @param left defines left coordinate
  78358. * @param top defines top coordinate
  78359. * @param width defines width dimension
  78360. * @param height defines height dimension
  78361. */
  78362. copyFromFloats(left: number, top: number, width: number, height: number): void;
  78363. /**
  78364. * Computes the axis aligned bounding box measure for two given measures
  78365. * @param a Input measure
  78366. * @param b Input measure
  78367. * @param result the resulting bounding measure
  78368. */
  78369. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  78370. /**
  78371. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78372. * @param transform the matrix to transform the measure before computing the AABB
  78373. * @param addX number to add to left
  78374. * @param addY number to add to top
  78375. * @param addWidth number to add to width
  78376. * @param addHeight number to add to height
  78377. * @param result the resulting AABB
  78378. */
  78379. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  78380. /**
  78381. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  78382. * @param transform the matrix to transform the measure before computing the AABB
  78383. * @param result the resulting AABB
  78384. */
  78385. transformToRef(transform: Matrix2D, result: Measure): void;
  78386. /**
  78387. * Check equality between this measure and another one
  78388. * @param other defines the other measures
  78389. * @returns true if both measures are equals
  78390. */
  78391. isEqualsTo(other: Measure): boolean;
  78392. /**
  78393. * Creates an empty measure
  78394. * @returns a new measure
  78395. */
  78396. static Empty(): Measure;
  78397. }
  78398. }
  78399. declare module BABYLON.GUI {
  78400. /**
  78401. * Class used to create texture to support 2D GUI elements
  78402. * @see https://doc.babylonjs.com/how_to/gui
  78403. */
  78404. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  78405. private _isDirty;
  78406. private _renderObserver;
  78407. private _resizeObserver;
  78408. private _preKeyboardObserver;
  78409. private _pointerMoveObserver;
  78410. private _pointerObserver;
  78411. private _canvasPointerOutObserver;
  78412. private _canvasBlurObserver;
  78413. private _background;
  78414. /** @hidden */
  78415. _rootContainer: Container;
  78416. /** @hidden */
  78417. _lastPickedControl: Control;
  78418. /** @hidden */
  78419. _lastControlOver: {
  78420. [pointerId: number]: Control;
  78421. };
  78422. /** @hidden */
  78423. _lastControlDown: {
  78424. [pointerId: number]: Control;
  78425. };
  78426. /** @hidden */
  78427. _capturingControl: {
  78428. [pointerId: number]: Control;
  78429. };
  78430. /** @hidden */
  78431. _shouldBlockPointer: boolean;
  78432. /** @hidden */
  78433. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  78434. /** @hidden */
  78435. _linkedControls: Control[];
  78436. private _isFullscreen;
  78437. private _fullscreenViewport;
  78438. private _idealWidth;
  78439. private _idealHeight;
  78440. private _useSmallestIdeal;
  78441. private _renderAtIdealSize;
  78442. private _focusedControl;
  78443. private _blockNextFocusCheck;
  78444. private _renderScale;
  78445. private _rootElement;
  78446. private _cursorChanged;
  78447. private _defaultMousePointerId;
  78448. /** @hidden */
  78449. _numLayoutCalls: number;
  78450. /** Gets the number of layout calls made the last time the ADT has been rendered */
  78451. get numLayoutCalls(): number;
  78452. /** @hidden */
  78453. _numRenderCalls: number;
  78454. /** Gets the number of render calls made the last time the ADT has been rendered */
  78455. get numRenderCalls(): number;
  78456. /**
  78457. * Define type to string to ensure compatibility across browsers
  78458. * Safari doesn't support DataTransfer constructor
  78459. */
  78460. private _clipboardData;
  78461. /**
  78462. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  78463. */
  78464. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  78465. /**
  78466. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  78467. */
  78468. onControlPickedObservable: BABYLON.Observable<Control>;
  78469. /**
  78470. * BABYLON.Observable event triggered before layout is evaluated
  78471. */
  78472. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78473. /**
  78474. * BABYLON.Observable event triggered after the layout was evaluated
  78475. */
  78476. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78477. /**
  78478. * BABYLON.Observable event triggered before the texture is rendered
  78479. */
  78480. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78481. /**
  78482. * BABYLON.Observable event triggered after the texture was rendered
  78483. */
  78484. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  78485. /**
  78486. * Gets or sets a boolean defining if alpha is stored as premultiplied
  78487. */
  78488. premulAlpha: boolean;
  78489. /**
  78490. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  78491. */
  78492. applyYInversionOnUpdate: boolean;
  78493. /**
  78494. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  78495. * Useful when you want more antialiasing
  78496. */
  78497. get renderScale(): number;
  78498. set renderScale(value: number);
  78499. /** Gets or sets the background color */
  78500. get background(): string;
  78501. set background(value: string);
  78502. /**
  78503. * Gets or sets the ideal width used to design controls.
  78504. * The GUI will then rescale everything accordingly
  78505. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78506. */
  78507. get idealWidth(): number;
  78508. set idealWidth(value: number);
  78509. /**
  78510. * Gets or sets the ideal height used to design controls.
  78511. * The GUI will then rescale everything accordingly
  78512. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78513. */
  78514. get idealHeight(): number;
  78515. set idealHeight(value: number);
  78516. /**
  78517. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  78518. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78519. */
  78520. get useSmallestIdeal(): boolean;
  78521. set useSmallestIdeal(value: boolean);
  78522. /**
  78523. * Gets or sets a boolean indicating if adaptive scaling must be used
  78524. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78525. */
  78526. get renderAtIdealSize(): boolean;
  78527. set renderAtIdealSize(value: boolean);
  78528. /**
  78529. * Gets the ratio used when in "ideal mode"
  78530. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  78531. * */
  78532. get idealRatio(): number;
  78533. /**
  78534. * Gets the underlying layer used to render the texture when in fullscreen mode
  78535. */
  78536. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  78537. /**
  78538. * Gets the root container control
  78539. */
  78540. get rootContainer(): Container;
  78541. /**
  78542. * Returns an array containing the root container.
  78543. * This is mostly used to let the Inspector introspects the ADT
  78544. * @returns an array containing the rootContainer
  78545. */
  78546. getChildren(): Array<Container>;
  78547. /**
  78548. * Will return all controls that are inside this texture
  78549. * @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
  78550. * @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
  78551. * @return all child controls
  78552. */
  78553. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78554. /**
  78555. * Gets or sets the current focused control
  78556. */
  78557. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  78558. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  78559. /**
  78560. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  78561. */
  78562. get isForeground(): boolean;
  78563. set isForeground(value: boolean);
  78564. /**
  78565. * Gets or set information about clipboardData
  78566. */
  78567. get clipboardData(): string;
  78568. set clipboardData(value: string);
  78569. /**
  78570. * Creates a new AdvancedDynamicTexture
  78571. * @param name defines the name of the texture
  78572. * @param width defines the width of the texture
  78573. * @param height defines the height of the texture
  78574. * @param scene defines the hosting scene
  78575. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  78576. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  78577. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78578. */
  78579. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  78580. /**
  78581. * Get the current class name of the texture useful for serialization or dynamic coding.
  78582. * @returns "AdvancedDynamicTexture"
  78583. */
  78584. getClassName(): string;
  78585. /**
  78586. * Function used to execute a function on all controls
  78587. * @param func defines the function to execute
  78588. * @param container defines the container where controls belong. If null the root container will be used
  78589. */
  78590. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  78591. private _useInvalidateRectOptimization;
  78592. /**
  78593. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  78594. */
  78595. get useInvalidateRectOptimization(): boolean;
  78596. set useInvalidateRectOptimization(value: boolean);
  78597. private _invalidatedRectangle;
  78598. /**
  78599. * Invalidates a rectangle area on the gui texture
  78600. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  78601. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  78602. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  78603. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  78604. */
  78605. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  78606. /**
  78607. * Marks the texture as dirty forcing a complete update
  78608. */
  78609. markAsDirty(): void;
  78610. /**
  78611. * Helper function used to create a new style
  78612. * @returns a new style
  78613. * @see https://doc.babylonjs.com/how_to/gui#styles
  78614. */
  78615. createStyle(): Style;
  78616. /**
  78617. * Adds a new control to the root container
  78618. * @param control defines the control to add
  78619. * @returns the current texture
  78620. */
  78621. addControl(control: Control): AdvancedDynamicTexture;
  78622. /**
  78623. * Removes a control from the root container
  78624. * @param control defines the control to remove
  78625. * @returns the current texture
  78626. */
  78627. removeControl(control: Control): AdvancedDynamicTexture;
  78628. /**
  78629. * Release all resources
  78630. */
  78631. dispose(): void;
  78632. private _onResize;
  78633. /** @hidden */
  78634. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  78635. /**
  78636. * Get screen coordinates for a vector3
  78637. * @param position defines the position to project
  78638. * @param worldMatrix defines the world matrix to use
  78639. * @returns the projected position
  78640. */
  78641. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  78642. /**
  78643. * Get screen coordinates for a vector3
  78644. * @param position defines the position to project
  78645. * @param worldMatrix defines the world matrix to use
  78646. * @returns the projected position with Z
  78647. */
  78648. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  78649. private _checkUpdate;
  78650. private _clearMeasure;
  78651. private _render;
  78652. /** @hidden */
  78653. _changeCursor(cursor: string): void;
  78654. /** @hidden */
  78655. _registerLastControlDown(control: Control, pointerId: number): void;
  78656. private _doPicking;
  78657. /** @hidden */
  78658. _cleanControlAfterRemovalFromList(list: {
  78659. [pointerId: number]: Control;
  78660. }, control: Control): void;
  78661. /** @hidden */
  78662. _cleanControlAfterRemoval(control: Control): void;
  78663. /** Attach to all scene events required to support pointer events */
  78664. attach(): void;
  78665. /** @hidden */
  78666. private onClipboardCopy;
  78667. /** @hidden */
  78668. private onClipboardCut;
  78669. /** @hidden */
  78670. private onClipboardPaste;
  78671. /**
  78672. * Register the clipboard Events onto the canvas
  78673. */
  78674. registerClipboardEvents(): void;
  78675. /**
  78676. * Unregister the clipboard Events from the canvas
  78677. */
  78678. unRegisterClipboardEvents(): void;
  78679. /**
  78680. * Connect the texture to a hosting mesh to enable interactions
  78681. * @param mesh defines the mesh to attach to
  78682. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  78683. */
  78684. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  78685. /**
  78686. * Move the focus to a specific control
  78687. * @param control defines the control which will receive the focus
  78688. */
  78689. moveFocusToControl(control: IFocusableControl): void;
  78690. private _manageFocus;
  78691. private _attachToOnPointerOut;
  78692. private _attachToOnBlur;
  78693. /**
  78694. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  78695. * @param mesh defines the mesh which will receive the texture
  78696. * @param width defines the texture width (1024 by default)
  78697. * @param height defines the texture height (1024 by default)
  78698. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78699. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  78700. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78701. * @returns a new AdvancedDynamicTexture
  78702. */
  78703. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78704. /**
  78705. * 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
  78706. * @param mesh defines the mesh which will receive the texture
  78707. * @param width defines the texture width (1024 by default)
  78708. * @param height defines the texture height (1024 by default)
  78709. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  78710. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  78711. * @returns a new AdvancedDynamicTexture
  78712. */
  78713. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  78714. /**
  78715. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  78716. * In this mode the texture will rely on a layer for its rendering.
  78717. * This allows it to be treated like any other layer.
  78718. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  78719. * LayerMask is set through advancedTexture.layer.layerMask
  78720. * @param name defines name for the texture
  78721. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  78722. * @param scene defines the hsoting scene
  78723. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  78724. * @returns a new AdvancedDynamicTexture
  78725. */
  78726. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  78727. }
  78728. }
  78729. declare module BABYLON.GUI {
  78730. /**
  78731. * Root class used for all 2D controls
  78732. * @see https://doc.babylonjs.com/how_to/gui#controls
  78733. */
  78734. export class Control {
  78735. /** defines the name of the control */
  78736. name?: string | undefined;
  78737. /**
  78738. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  78739. */
  78740. static AllowAlphaInheritance: boolean;
  78741. private _alpha;
  78742. private _alphaSet;
  78743. private _zIndex;
  78744. /** @hidden */
  78745. _host: AdvancedDynamicTexture;
  78746. /** Gets or sets the control parent */
  78747. parent: BABYLON.Nullable<Container>;
  78748. /** @hidden */
  78749. _currentMeasure: Measure;
  78750. private _fontFamily;
  78751. private _fontStyle;
  78752. private _fontWeight;
  78753. private _fontSize;
  78754. private _font;
  78755. /** @hidden */
  78756. _width: ValueAndUnit;
  78757. /** @hidden */
  78758. _height: ValueAndUnit;
  78759. /** @hidden */
  78760. protected _fontOffset: {
  78761. ascent: number;
  78762. height: number;
  78763. descent: number;
  78764. };
  78765. private _color;
  78766. private _style;
  78767. private _styleObserver;
  78768. /** @hidden */
  78769. protected _horizontalAlignment: number;
  78770. /** @hidden */
  78771. protected _verticalAlignment: number;
  78772. /** @hidden */
  78773. protected _isDirty: boolean;
  78774. /** @hidden */
  78775. protected _wasDirty: boolean;
  78776. /** @hidden */
  78777. _tempParentMeasure: Measure;
  78778. /** @hidden */
  78779. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  78780. /** @hidden */
  78781. protected _cachedParentMeasure: Measure;
  78782. private _paddingLeft;
  78783. private _paddingRight;
  78784. private _paddingTop;
  78785. private _paddingBottom;
  78786. /** @hidden */
  78787. _left: ValueAndUnit;
  78788. /** @hidden */
  78789. _top: ValueAndUnit;
  78790. private _scaleX;
  78791. private _scaleY;
  78792. private _rotation;
  78793. private _transformCenterX;
  78794. private _transformCenterY;
  78795. /** @hidden */
  78796. _transformMatrix: Matrix2D;
  78797. /** @hidden */
  78798. protected _invertTransformMatrix: Matrix2D;
  78799. /** @hidden */
  78800. protected _transformedPosition: BABYLON.Vector2;
  78801. private _isMatrixDirty;
  78802. private _cachedOffsetX;
  78803. private _cachedOffsetY;
  78804. private _isVisible;
  78805. private _isHighlighted;
  78806. /** @hidden */
  78807. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  78808. private _fontSet;
  78809. private _dummyVector2;
  78810. private _downCount;
  78811. private _enterCount;
  78812. private _doNotRender;
  78813. private _downPointerIds;
  78814. protected _isEnabled: boolean;
  78815. protected _disabledColor: string;
  78816. protected _disabledColorItem: string;
  78817. /** @hidden */
  78818. protected _rebuildLayout: boolean;
  78819. /** @hidden */
  78820. _customData: any;
  78821. /** @hidden */
  78822. _isClipped: boolean;
  78823. /** @hidden */
  78824. _automaticSize: boolean;
  78825. /** @hidden */
  78826. _tag: any;
  78827. /**
  78828. * 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
  78829. */
  78830. uniqueId: number;
  78831. /**
  78832. * Gets or sets an object used to store user defined information for the node
  78833. */
  78834. metadata: any;
  78835. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  78836. isHitTestVisible: boolean;
  78837. /** Gets or sets a boolean indicating if the control can block pointer events */
  78838. isPointerBlocker: boolean;
  78839. /** Gets or sets a boolean indicating if the control can be focusable */
  78840. isFocusInvisible: boolean;
  78841. /**
  78842. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  78843. * 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
  78844. */
  78845. clipChildren: boolean;
  78846. /**
  78847. * Gets or sets a boolean indicating that control content must be clipped
  78848. * 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
  78849. */
  78850. clipContent: boolean;
  78851. /**
  78852. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  78853. */
  78854. useBitmapCache: boolean;
  78855. private _cacheData;
  78856. private _shadowOffsetX;
  78857. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  78858. get shadowOffsetX(): number;
  78859. set shadowOffsetX(value: number);
  78860. private _shadowOffsetY;
  78861. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  78862. get shadowOffsetY(): number;
  78863. set shadowOffsetY(value: number);
  78864. private _shadowBlur;
  78865. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  78866. get shadowBlur(): number;
  78867. set shadowBlur(value: number);
  78868. private _shadowColor;
  78869. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  78870. get shadowColor(): string;
  78871. set shadowColor(value: string);
  78872. /** Gets or sets the cursor to use when the control is hovered */
  78873. hoverCursor: string;
  78874. /** @hidden */
  78875. protected _linkOffsetX: ValueAndUnit;
  78876. /** @hidden */
  78877. protected _linkOffsetY: ValueAndUnit;
  78878. /** Gets the control type name */
  78879. get typeName(): string;
  78880. /**
  78881. * Get the current class name of the control.
  78882. * @returns current class name
  78883. */
  78884. getClassName(): string;
  78885. /**
  78886. * An event triggered when pointer wheel is scrolled
  78887. */
  78888. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  78889. /**
  78890. * An event triggered when the pointer move over the control.
  78891. */
  78892. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  78893. /**
  78894. * An event triggered when the pointer move out of the control.
  78895. */
  78896. onPointerOutObservable: BABYLON.Observable<Control>;
  78897. /**
  78898. * An event triggered when the pointer taps the control
  78899. */
  78900. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  78901. /**
  78902. * An event triggered when pointer up
  78903. */
  78904. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  78905. /**
  78906. * An event triggered when a control is clicked on
  78907. */
  78908. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  78909. /**
  78910. * An event triggered when pointer enters the control
  78911. */
  78912. onPointerEnterObservable: BABYLON.Observable<Control>;
  78913. /**
  78914. * An event triggered when the control is marked as dirty
  78915. */
  78916. onDirtyObservable: BABYLON.Observable<Control>;
  78917. /**
  78918. * An event triggered before drawing the control
  78919. */
  78920. onBeforeDrawObservable: BABYLON.Observable<Control>;
  78921. /**
  78922. * An event triggered after the control was drawn
  78923. */
  78924. onAfterDrawObservable: BABYLON.Observable<Control>;
  78925. /**
  78926. * An event triggered when the control has been disposed
  78927. */
  78928. onDisposeObservable: BABYLON.Observable<Control>;
  78929. /**
  78930. * Get the hosting AdvancedDynamicTexture
  78931. */
  78932. get host(): AdvancedDynamicTexture;
  78933. /** Gets or set information about font offsets (used to render and align text) */
  78934. get fontOffset(): {
  78935. ascent: number;
  78936. height: number;
  78937. descent: number;
  78938. };
  78939. set fontOffset(offset: {
  78940. ascent: number;
  78941. height: number;
  78942. descent: number;
  78943. });
  78944. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  78945. get alpha(): number;
  78946. set alpha(value: number);
  78947. /**
  78948. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  78949. */
  78950. get isHighlighted(): boolean;
  78951. set isHighlighted(value: boolean);
  78952. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  78953. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78954. */
  78955. get scaleX(): number;
  78956. set scaleX(value: number);
  78957. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  78958. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78959. */
  78960. get scaleY(): number;
  78961. set scaleY(value: number);
  78962. /** Gets or sets the rotation angle (0 by default)
  78963. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78964. */
  78965. get rotation(): number;
  78966. set rotation(value: number);
  78967. /** Gets or sets the transformation center on Y axis (0 by default)
  78968. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78969. */
  78970. get transformCenterY(): number;
  78971. set transformCenterY(value: number);
  78972. /** Gets or sets the transformation center on X axis (0 by default)
  78973. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  78974. */
  78975. get transformCenterX(): number;
  78976. set transformCenterX(value: number);
  78977. /**
  78978. * Gets or sets the horizontal alignment
  78979. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78980. */
  78981. get horizontalAlignment(): number;
  78982. set horizontalAlignment(value: number);
  78983. /**
  78984. * Gets or sets the vertical alignment
  78985. * @see https://doc.babylonjs.com/how_to/gui#alignments
  78986. */
  78987. get verticalAlignment(): number;
  78988. set verticalAlignment(value: number);
  78989. /**
  78990. * Gets or sets a fixed ratio for this control.
  78991. * When different from 0, the ratio is used to compute the "second" dimension.
  78992. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  78993. * second dimension is computed as first dimension * fixedRatio
  78994. */
  78995. fixedRatio: number;
  78996. private _fixedRatioMasterIsWidth;
  78997. /**
  78998. * Gets or sets control width
  78999. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79000. */
  79001. get width(): string | number;
  79002. set width(value: string | number);
  79003. /**
  79004. * Gets or sets the control width in pixel
  79005. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79006. */
  79007. get widthInPixels(): number;
  79008. set widthInPixels(value: number);
  79009. /**
  79010. * Gets or sets control height
  79011. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79012. */
  79013. get height(): string | number;
  79014. set height(value: string | number);
  79015. /**
  79016. * Gets or sets control height in pixel
  79017. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79018. */
  79019. get heightInPixels(): number;
  79020. set heightInPixels(value: number);
  79021. /** Gets or set font family */
  79022. get fontFamily(): string;
  79023. set fontFamily(value: string);
  79024. /** Gets or sets font style */
  79025. get fontStyle(): string;
  79026. set fontStyle(value: string);
  79027. /** Gets or sets font weight */
  79028. get fontWeight(): string;
  79029. set fontWeight(value: string);
  79030. /**
  79031. * Gets or sets style
  79032. * @see https://doc.babylonjs.com/how_to/gui#styles
  79033. */
  79034. get style(): BABYLON.Nullable<Style>;
  79035. set style(value: BABYLON.Nullable<Style>);
  79036. /** @hidden */
  79037. get _isFontSizeInPercentage(): boolean;
  79038. /** Gets or sets font size in pixels */
  79039. get fontSizeInPixels(): number;
  79040. set fontSizeInPixels(value: number);
  79041. /** Gets or sets font size */
  79042. get fontSize(): string | number;
  79043. set fontSize(value: string | number);
  79044. /** Gets or sets foreground color */
  79045. get color(): string;
  79046. set color(value: string);
  79047. /** Gets or sets z index which is used to reorder controls on the z axis */
  79048. get zIndex(): number;
  79049. set zIndex(value: number);
  79050. /** Gets or sets a boolean indicating if the control can be rendered */
  79051. get notRenderable(): boolean;
  79052. set notRenderable(value: boolean);
  79053. /** Gets or sets a boolean indicating if the control is visible */
  79054. get isVisible(): boolean;
  79055. set isVisible(value: boolean);
  79056. /** Gets a boolean indicating that the control needs to update its rendering */
  79057. get isDirty(): boolean;
  79058. /**
  79059. * Gets the current linked mesh (or null if none)
  79060. */
  79061. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  79062. /**
  79063. * Gets or sets a value indicating the padding to use on the left of the control
  79064. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79065. */
  79066. get paddingLeft(): string | number;
  79067. set paddingLeft(value: string | number);
  79068. /**
  79069. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  79070. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79071. */
  79072. get paddingLeftInPixels(): number;
  79073. set paddingLeftInPixels(value: number);
  79074. /**
  79075. * Gets or sets a value indicating the padding to use on the right of the control
  79076. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79077. */
  79078. get paddingRight(): string | number;
  79079. set paddingRight(value: string | number);
  79080. /**
  79081. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  79082. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79083. */
  79084. get paddingRightInPixels(): number;
  79085. set paddingRightInPixels(value: number);
  79086. /**
  79087. * Gets or sets a value indicating the padding to use on the top of the control
  79088. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79089. */
  79090. get paddingTop(): string | number;
  79091. set paddingTop(value: string | number);
  79092. /**
  79093. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  79094. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79095. */
  79096. get paddingTopInPixels(): number;
  79097. set paddingTopInPixels(value: number);
  79098. /**
  79099. * Gets or sets a value indicating the padding to use on the bottom of the control
  79100. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79101. */
  79102. get paddingBottom(): string | number;
  79103. set paddingBottom(value: string | number);
  79104. /**
  79105. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  79106. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79107. */
  79108. get paddingBottomInPixels(): number;
  79109. set paddingBottomInPixels(value: number);
  79110. /**
  79111. * Gets or sets a value indicating the left coordinate of the control
  79112. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79113. */
  79114. get left(): string | number;
  79115. set left(value: string | number);
  79116. /**
  79117. * Gets or sets a value indicating the left coordinate in pixels of the control
  79118. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79119. */
  79120. get leftInPixels(): number;
  79121. set leftInPixels(value: number);
  79122. /**
  79123. * Gets or sets a value indicating the top coordinate of the control
  79124. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79125. */
  79126. get top(): string | number;
  79127. set top(value: string | number);
  79128. /**
  79129. * Gets or sets a value indicating the top coordinate in pixels of the control
  79130. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79131. */
  79132. get topInPixels(): number;
  79133. set topInPixels(value: number);
  79134. /**
  79135. * Gets or sets a value indicating the offset on X axis to the linked mesh
  79136. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79137. */
  79138. get linkOffsetX(): string | number;
  79139. set linkOffsetX(value: string | number);
  79140. /**
  79141. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  79142. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79143. */
  79144. get linkOffsetXInPixels(): number;
  79145. set linkOffsetXInPixels(value: number);
  79146. /**
  79147. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  79148. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79149. */
  79150. get linkOffsetY(): string | number;
  79151. set linkOffsetY(value: string | number);
  79152. /**
  79153. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  79154. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79155. */
  79156. get linkOffsetYInPixels(): number;
  79157. set linkOffsetYInPixels(value: number);
  79158. /** Gets the center coordinate on X axis */
  79159. get centerX(): number;
  79160. /** Gets the center coordinate on Y axis */
  79161. get centerY(): number;
  79162. /** Gets or sets if control is Enabled*/
  79163. get isEnabled(): boolean;
  79164. set isEnabled(value: boolean);
  79165. /** Gets or sets background color of control if it's disabled*/
  79166. get disabledColor(): string;
  79167. set disabledColor(value: string);
  79168. /** Gets or sets front color of control if it's disabled*/
  79169. get disabledColorItem(): string;
  79170. set disabledColorItem(value: string);
  79171. /**
  79172. * Creates a new control
  79173. * @param name defines the name of the control
  79174. */
  79175. constructor(
  79176. /** defines the name of the control */
  79177. name?: string | undefined);
  79178. /** @hidden */
  79179. protected _getTypeName(): string;
  79180. /**
  79181. * Gets the first ascendant in the hierarchy of the given type
  79182. * @param className defines the required type
  79183. * @returns the ascendant or null if not found
  79184. */
  79185. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  79186. /** @hidden */
  79187. _resetFontCache(): void;
  79188. /**
  79189. * Determines if a container is an ascendant of the current control
  79190. * @param container defines the container to look for
  79191. * @returns true if the container is one of the ascendant of the control
  79192. */
  79193. isAscendant(container: Control): boolean;
  79194. /**
  79195. * Gets coordinates in local control space
  79196. * @param globalCoordinates defines the coordinates to transform
  79197. * @returns the new coordinates in local space
  79198. */
  79199. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79200. /**
  79201. * Gets coordinates in local control space
  79202. * @param globalCoordinates defines the coordinates to transform
  79203. * @param result defines the target vector2 where to store the result
  79204. * @returns the current control
  79205. */
  79206. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  79207. /**
  79208. * Gets coordinates in parent local control space
  79209. * @param globalCoordinates defines the coordinates to transform
  79210. * @returns the new coordinates in parent local space
  79211. */
  79212. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  79213. /**
  79214. * Move the current control to a vector3 position projected onto the screen.
  79215. * @param position defines the target position
  79216. * @param scene defines the hosting scene
  79217. */
  79218. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  79219. /**
  79220. * Will store all controls that have this control as ascendant in a given array
  79221. * @param results defines the array where to store the descendants
  79222. * @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
  79223. * @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
  79224. */
  79225. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79226. /**
  79227. * Will return all controls that have this control as ascendant
  79228. * @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
  79229. * @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
  79230. * @return all child controls
  79231. */
  79232. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  79233. /**
  79234. * Link current control with a target mesh
  79235. * @param mesh defines the mesh to link with
  79236. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  79237. */
  79238. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  79239. /** @hidden */
  79240. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  79241. /** @hidden */
  79242. _offsetLeft(offset: number): void;
  79243. /** @hidden */
  79244. _offsetTop(offset: number): void;
  79245. /** @hidden */
  79246. _markMatrixAsDirty(): void;
  79247. /** @hidden */
  79248. _flagDescendantsAsMatrixDirty(): void;
  79249. /** @hidden */
  79250. _intersectsRect(rect: Measure): boolean;
  79251. /** @hidden */
  79252. protected invalidateRect(): void;
  79253. /** @hidden */
  79254. _markAsDirty(force?: boolean): void;
  79255. /** @hidden */
  79256. _markAllAsDirty(): void;
  79257. /** @hidden */
  79258. _link(host: AdvancedDynamicTexture): void;
  79259. /** @hidden */
  79260. protected _transform(context?: CanvasRenderingContext2D): void;
  79261. /** @hidden */
  79262. _renderHighlight(context: CanvasRenderingContext2D): void;
  79263. /** @hidden */
  79264. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79265. /** @hidden */
  79266. protected _applyStates(context: CanvasRenderingContext2D): void;
  79267. /** @hidden */
  79268. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79269. /** @hidden */
  79270. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79271. protected _evaluateClippingState(parentMeasure: Measure): void;
  79272. /** @hidden */
  79273. _measure(): void;
  79274. /** @hidden */
  79275. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79276. /** @hidden */
  79277. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79278. /** @hidden */
  79279. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79280. /** @hidden */
  79281. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79282. private static _ClipMeasure;
  79283. private _tmpMeasureA;
  79284. private _clip;
  79285. /** @hidden */
  79286. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  79287. /** @hidden */
  79288. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79289. /**
  79290. * Tests if a given coordinates belong to the current control
  79291. * @param x defines x coordinate to test
  79292. * @param y defines y coordinate to test
  79293. * @returns true if the coordinates are inside the control
  79294. */
  79295. contains(x: number, y: number): boolean;
  79296. /** @hidden */
  79297. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79298. /** @hidden */
  79299. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79300. /** @hidden */
  79301. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79302. /** @hidden */
  79303. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  79304. /** @hidden */
  79305. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79306. /** @hidden */
  79307. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  79308. /** @hidden */
  79309. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79310. /** @hidden */
  79311. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  79312. /** @hidden */
  79313. _onCanvasBlur(): void;
  79314. /** @hidden */
  79315. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79316. private _prepareFont;
  79317. /** Releases associated resources */
  79318. dispose(): void;
  79319. private static _HORIZONTAL_ALIGNMENT_LEFT;
  79320. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  79321. private static _HORIZONTAL_ALIGNMENT_CENTER;
  79322. private static _VERTICAL_ALIGNMENT_TOP;
  79323. private static _VERTICAL_ALIGNMENT_BOTTOM;
  79324. private static _VERTICAL_ALIGNMENT_CENTER;
  79325. /** HORIZONTAL_ALIGNMENT_LEFT */
  79326. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  79327. /** HORIZONTAL_ALIGNMENT_RIGHT */
  79328. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  79329. /** HORIZONTAL_ALIGNMENT_CENTER */
  79330. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  79331. /** VERTICAL_ALIGNMENT_TOP */
  79332. static get VERTICAL_ALIGNMENT_TOP(): number;
  79333. /** VERTICAL_ALIGNMENT_BOTTOM */
  79334. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  79335. /** VERTICAL_ALIGNMENT_CENTER */
  79336. static get VERTICAL_ALIGNMENT_CENTER(): number;
  79337. private static _FontHeightSizes;
  79338. /** @hidden */
  79339. static _GetFontOffset(font: string): {
  79340. ascent: number;
  79341. height: number;
  79342. descent: number;
  79343. };
  79344. /**
  79345. * Creates a stack panel that can be used to render headers
  79346. * @param control defines the control to associate with the header
  79347. * @param text defines the text of the header
  79348. * @param size defines the size of the header
  79349. * @param options defines options used to configure the header
  79350. * @returns a new StackPanel
  79351. * @ignore
  79352. * @hidden
  79353. */
  79354. static AddHeader: (control: Control, text: string, size: string | number, options: {
  79355. isHorizontal: boolean;
  79356. controlFirst: boolean;
  79357. }) => any;
  79358. /** @hidden */
  79359. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  79360. }
  79361. }
  79362. declare module BABYLON.GUI {
  79363. /**
  79364. * Root class for 2D containers
  79365. * @see https://doc.babylonjs.com/how_to/gui#containers
  79366. */
  79367. export class Container extends Control {
  79368. name?: string | undefined;
  79369. /** @hidden */
  79370. _children: Control[];
  79371. /** @hidden */
  79372. protected _measureForChildren: Measure;
  79373. /** @hidden */
  79374. protected _background: string;
  79375. /** @hidden */
  79376. protected _adaptWidthToChildren: boolean;
  79377. /** @hidden */
  79378. protected _adaptHeightToChildren: boolean;
  79379. /**
  79380. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  79381. */
  79382. logLayoutCycleErrors: boolean;
  79383. /**
  79384. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  79385. */
  79386. maxLayoutCycle: number;
  79387. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  79388. get adaptHeightToChildren(): boolean;
  79389. set adaptHeightToChildren(value: boolean);
  79390. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  79391. get adaptWidthToChildren(): boolean;
  79392. set adaptWidthToChildren(value: boolean);
  79393. /** Gets or sets background color */
  79394. get background(): string;
  79395. set background(value: string);
  79396. /** Gets the list of children */
  79397. get children(): Control[];
  79398. /**
  79399. * Creates a new Container
  79400. * @param name defines the name of the container
  79401. */
  79402. constructor(name?: string | undefined);
  79403. protected _getTypeName(): string;
  79404. _flagDescendantsAsMatrixDirty(): void;
  79405. /**
  79406. * Gets a child using its name
  79407. * @param name defines the child name to look for
  79408. * @returns the child control if found
  79409. */
  79410. getChildByName(name: string): BABYLON.Nullable<Control>;
  79411. /**
  79412. * Gets a child using its type and its name
  79413. * @param name defines the child name to look for
  79414. * @param type defines the child type to look for
  79415. * @returns the child control if found
  79416. */
  79417. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  79418. /**
  79419. * Search for a specific control in children
  79420. * @param control defines the control to look for
  79421. * @returns true if the control is in child list
  79422. */
  79423. containsControl(control: Control): boolean;
  79424. /**
  79425. * Adds a new control to the current container
  79426. * @param control defines the control to add
  79427. * @returns the current container
  79428. */
  79429. addControl(control: BABYLON.Nullable<Control>): Container;
  79430. /**
  79431. * Removes all controls from the current container
  79432. * @returns the current container
  79433. */
  79434. clearControls(): Container;
  79435. /**
  79436. * Removes a control from the current container
  79437. * @param control defines the control to remove
  79438. * @returns the current container
  79439. */
  79440. removeControl(control: Control): Container;
  79441. /** @hidden */
  79442. _reOrderControl(control: Control): void;
  79443. /** @hidden */
  79444. _offsetLeft(offset: number): void;
  79445. /** @hidden */
  79446. _offsetTop(offset: number): void;
  79447. /** @hidden */
  79448. _markAllAsDirty(): void;
  79449. /** @hidden */
  79450. protected _localDraw(context: CanvasRenderingContext2D): void;
  79451. /** @hidden */
  79452. _link(host: AdvancedDynamicTexture): void;
  79453. /** @hidden */
  79454. protected _beforeLayout(): void;
  79455. /** @hidden */
  79456. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79457. /** @hidden */
  79458. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79459. protected _postMeasure(): void;
  79460. /** @hidden */
  79461. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79462. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  79463. /** @hidden */
  79464. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79465. /** @hidden */
  79466. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79467. /** Releases associated resources */
  79468. dispose(): void;
  79469. }
  79470. }
  79471. declare module BABYLON.GUI {
  79472. /** Class used to create rectangle container */
  79473. export class Rectangle extends Container {
  79474. name?: string | undefined;
  79475. private _thickness;
  79476. private _cornerRadius;
  79477. /** Gets or sets border thickness */
  79478. get thickness(): number;
  79479. set thickness(value: number);
  79480. /** Gets or sets the corner radius angle */
  79481. get cornerRadius(): number;
  79482. set cornerRadius(value: number);
  79483. /**
  79484. * Creates a new Rectangle
  79485. * @param name defines the control name
  79486. */
  79487. constructor(name?: string | undefined);
  79488. protected _getTypeName(): string;
  79489. protected _localDraw(context: CanvasRenderingContext2D): void;
  79490. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79491. private _drawRoundedRect;
  79492. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79493. }
  79494. }
  79495. declare module BABYLON.GUI {
  79496. /**
  79497. * Enum that determines the text-wrapping mode to use.
  79498. */
  79499. export enum TextWrapping {
  79500. /**
  79501. * Clip the text when it's larger than Control.width; this is the default mode.
  79502. */
  79503. Clip = 0,
  79504. /**
  79505. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  79506. */
  79507. WordWrap = 1,
  79508. /**
  79509. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  79510. */
  79511. Ellipsis = 2
  79512. }
  79513. /**
  79514. * Class used to create text block control
  79515. */
  79516. export class TextBlock extends Control {
  79517. /**
  79518. * Defines the name of the control
  79519. */
  79520. name?: string | undefined;
  79521. private _text;
  79522. private _textWrapping;
  79523. private _textHorizontalAlignment;
  79524. private _textVerticalAlignment;
  79525. private _lines;
  79526. private _resizeToFit;
  79527. private _lineSpacing;
  79528. private _outlineWidth;
  79529. private _outlineColor;
  79530. private _underline;
  79531. private _lineThrough;
  79532. /**
  79533. * An event triggered after the text is changed
  79534. */
  79535. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  79536. /**
  79537. * An event triggered after the text was broken up into lines
  79538. */
  79539. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  79540. /**
  79541. * Function used to split a string into words. By default, a string is split at each space character found
  79542. */
  79543. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  79544. /**
  79545. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  79546. */
  79547. get lines(): any[];
  79548. /**
  79549. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79550. */
  79551. get resizeToFit(): boolean;
  79552. /**
  79553. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  79554. */
  79555. set resizeToFit(value: boolean);
  79556. /**
  79557. * Gets or sets a boolean indicating if text must be wrapped
  79558. */
  79559. get textWrapping(): TextWrapping | boolean;
  79560. /**
  79561. * Gets or sets a boolean indicating if text must be wrapped
  79562. */
  79563. set textWrapping(value: TextWrapping | boolean);
  79564. /**
  79565. * Gets or sets text to display
  79566. */
  79567. get text(): string;
  79568. /**
  79569. * Gets or sets text to display
  79570. */
  79571. set text(value: string);
  79572. /**
  79573. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79574. */
  79575. get textHorizontalAlignment(): number;
  79576. /**
  79577. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  79578. */
  79579. set textHorizontalAlignment(value: number);
  79580. /**
  79581. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79582. */
  79583. get textVerticalAlignment(): number;
  79584. /**
  79585. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  79586. */
  79587. set textVerticalAlignment(value: number);
  79588. /**
  79589. * Gets or sets line spacing value
  79590. */
  79591. set lineSpacing(value: string | number);
  79592. /**
  79593. * Gets or sets line spacing value
  79594. */
  79595. get lineSpacing(): string | number;
  79596. /**
  79597. * Gets or sets outlineWidth of the text to display
  79598. */
  79599. get outlineWidth(): number;
  79600. /**
  79601. * Gets or sets outlineWidth of the text to display
  79602. */
  79603. set outlineWidth(value: number);
  79604. /**
  79605. * Gets or sets a boolean indicating that text must have underline
  79606. */
  79607. get underline(): boolean;
  79608. /**
  79609. * Gets or sets a boolean indicating that text must have underline
  79610. */
  79611. set underline(value: boolean);
  79612. /**
  79613. * Gets or sets an boolean indicating that text must be crossed out
  79614. */
  79615. get lineThrough(): boolean;
  79616. /**
  79617. * Gets or sets an boolean indicating that text must be crossed out
  79618. */
  79619. set lineThrough(value: boolean);
  79620. /**
  79621. * Gets or sets outlineColor of the text to display
  79622. */
  79623. get outlineColor(): string;
  79624. /**
  79625. * Gets or sets outlineColor of the text to display
  79626. */
  79627. set outlineColor(value: string);
  79628. /**
  79629. * Creates a new TextBlock object
  79630. * @param name defines the name of the control
  79631. * @param text defines the text to display (emptry string by default)
  79632. */
  79633. constructor(
  79634. /**
  79635. * Defines the name of the control
  79636. */
  79637. name?: string | undefined, text?: string);
  79638. protected _getTypeName(): string;
  79639. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79640. private _drawText;
  79641. /** @hidden */
  79642. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79643. protected _applyStates(context: CanvasRenderingContext2D): void;
  79644. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  79645. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  79646. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  79647. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  79648. protected _renderLines(context: CanvasRenderingContext2D): void;
  79649. /**
  79650. * Given a width constraint applied on the text block, find the expected height
  79651. * @returns expected height
  79652. */
  79653. computeExpectedHeight(): number;
  79654. dispose(): void;
  79655. }
  79656. }
  79657. declare module BABYLON.GUI {
  79658. /**
  79659. * Class used to create 2D images
  79660. */
  79661. export class Image extends Control {
  79662. name?: string | undefined;
  79663. private _workingCanvas;
  79664. private _domImage;
  79665. private _imageWidth;
  79666. private _imageHeight;
  79667. private _loaded;
  79668. private _stretch;
  79669. private _source;
  79670. private _autoScale;
  79671. private _sourceLeft;
  79672. private _sourceTop;
  79673. private _sourceWidth;
  79674. private _sourceHeight;
  79675. private _svgAttributesComputationCompleted;
  79676. private _isSVG;
  79677. private _cellWidth;
  79678. private _cellHeight;
  79679. private _cellId;
  79680. private _populateNinePatchSlicesFromImage;
  79681. private _sliceLeft;
  79682. private _sliceRight;
  79683. private _sliceTop;
  79684. private _sliceBottom;
  79685. private _detectPointerOnOpaqueOnly;
  79686. private _imageDataCache;
  79687. /**
  79688. * BABYLON.Observable notified when the content is loaded
  79689. */
  79690. onImageLoadedObservable: BABYLON.Observable<Image>;
  79691. /**
  79692. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  79693. */
  79694. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  79695. /**
  79696. * Gets a boolean indicating that the content is loaded
  79697. */
  79698. get isLoaded(): boolean;
  79699. /**
  79700. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  79701. */
  79702. get populateNinePatchSlicesFromImage(): boolean;
  79703. set populateNinePatchSlicesFromImage(value: boolean);
  79704. /**
  79705. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  79706. * Beware using this as this will comsume more memory as the image has to be stored twice
  79707. */
  79708. get detectPointerOnOpaqueOnly(): boolean;
  79709. set detectPointerOnOpaqueOnly(value: boolean);
  79710. /**
  79711. * Gets or sets the left value for slicing (9-patch)
  79712. */
  79713. get sliceLeft(): number;
  79714. set sliceLeft(value: number);
  79715. /**
  79716. * Gets or sets the right value for slicing (9-patch)
  79717. */
  79718. get sliceRight(): number;
  79719. set sliceRight(value: number);
  79720. /**
  79721. * Gets or sets the top value for slicing (9-patch)
  79722. */
  79723. get sliceTop(): number;
  79724. set sliceTop(value: number);
  79725. /**
  79726. * Gets or sets the bottom value for slicing (9-patch)
  79727. */
  79728. get sliceBottom(): number;
  79729. set sliceBottom(value: number);
  79730. /**
  79731. * Gets or sets the left coordinate in the source image
  79732. */
  79733. get sourceLeft(): number;
  79734. set sourceLeft(value: number);
  79735. /**
  79736. * Gets or sets the top coordinate in the source image
  79737. */
  79738. get sourceTop(): number;
  79739. set sourceTop(value: number);
  79740. /**
  79741. * Gets or sets the width to capture in the source image
  79742. */
  79743. get sourceWidth(): number;
  79744. set sourceWidth(value: number);
  79745. /**
  79746. * Gets or sets the height to capture in the source image
  79747. */
  79748. get sourceHeight(): number;
  79749. set sourceHeight(value: number);
  79750. /** Indicates if the format of the image is SVG */
  79751. get isSVG(): boolean;
  79752. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  79753. get svgAttributesComputationCompleted(): boolean;
  79754. /**
  79755. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  79756. * @see https://doc.babylonjs.com/how_to/gui#image
  79757. */
  79758. get autoScale(): boolean;
  79759. set autoScale(value: boolean);
  79760. /** Gets or sets the streching mode used by the image */
  79761. get stretch(): number;
  79762. set stretch(value: number);
  79763. /** @hidden */
  79764. _rotate90(n: number, preserveProperties?: boolean): Image;
  79765. private _handleRotationForSVGImage;
  79766. private _rotate90SourceProperties;
  79767. /**
  79768. * Gets or sets the internal DOM image used to render the control
  79769. */
  79770. set domImage(value: HTMLImageElement);
  79771. get domImage(): HTMLImageElement;
  79772. private _onImageLoaded;
  79773. private _extractNinePatchSliceDataFromImage;
  79774. /**
  79775. * Gets or sets image source url
  79776. */
  79777. set source(value: BABYLON.Nullable<string>);
  79778. /**
  79779. * Checks for svg document with icon id present
  79780. */
  79781. private _svgCheck;
  79782. /**
  79783. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  79784. * given external svg file and icon id
  79785. */
  79786. private _getSVGAttribs;
  79787. /**
  79788. * Gets or sets the cell width to use when animation sheet is enabled
  79789. * @see https://doc.babylonjs.com/how_to/gui#image
  79790. */
  79791. get cellWidth(): number;
  79792. set cellWidth(value: number);
  79793. /**
  79794. * Gets or sets the cell height to use when animation sheet is enabled
  79795. * @see https://doc.babylonjs.com/how_to/gui#image
  79796. */
  79797. get cellHeight(): number;
  79798. set cellHeight(value: number);
  79799. /**
  79800. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  79801. * @see https://doc.babylonjs.com/how_to/gui#image
  79802. */
  79803. get cellId(): number;
  79804. set cellId(value: number);
  79805. /**
  79806. * Creates a new Image
  79807. * @param name defines the control name
  79808. * @param url defines the image url
  79809. */
  79810. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  79811. /**
  79812. * Tests if a given coordinates belong to the current control
  79813. * @param x defines x coordinate to test
  79814. * @param y defines y coordinate to test
  79815. * @returns true if the coordinates are inside the control
  79816. */
  79817. contains(x: number, y: number): boolean;
  79818. protected _getTypeName(): string;
  79819. /** Force the control to synchronize with its content */
  79820. synchronizeSizeWithContent(): void;
  79821. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79822. private _prepareWorkingCanvasForOpaqueDetection;
  79823. private _drawImage;
  79824. _draw(context: CanvasRenderingContext2D): void;
  79825. private _renderCornerPatch;
  79826. private _renderNinePatch;
  79827. dispose(): void;
  79828. /** STRETCH_NONE */
  79829. static readonly STRETCH_NONE: number;
  79830. /** STRETCH_FILL */
  79831. static readonly STRETCH_FILL: number;
  79832. /** STRETCH_UNIFORM */
  79833. static readonly STRETCH_UNIFORM: number;
  79834. /** STRETCH_EXTEND */
  79835. static readonly STRETCH_EXTEND: number;
  79836. /** NINE_PATCH */
  79837. static readonly STRETCH_NINE_PATCH: number;
  79838. }
  79839. }
  79840. declare module BABYLON.GUI {
  79841. /**
  79842. * Class used to create 2D buttons
  79843. */
  79844. export class Button extends Rectangle {
  79845. name?: string | undefined;
  79846. /**
  79847. * Function called to generate a pointer enter animation
  79848. */
  79849. pointerEnterAnimation: () => void;
  79850. /**
  79851. * Function called to generate a pointer out animation
  79852. */
  79853. pointerOutAnimation: () => void;
  79854. /**
  79855. * Function called to generate a pointer down animation
  79856. */
  79857. pointerDownAnimation: () => void;
  79858. /**
  79859. * Function called to generate a pointer up animation
  79860. */
  79861. pointerUpAnimation: () => void;
  79862. /**
  79863. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  79864. */
  79865. delegatePickingToChildren: boolean;
  79866. private _image;
  79867. /**
  79868. * Returns the image part of the button (if any)
  79869. */
  79870. get image(): BABYLON.Nullable<Image>;
  79871. private _textBlock;
  79872. /**
  79873. * Returns the image part of the button (if any)
  79874. */
  79875. get textBlock(): BABYLON.Nullable<TextBlock>;
  79876. /**
  79877. * Creates a new Button
  79878. * @param name defines the name of the button
  79879. */
  79880. constructor(name?: string | undefined);
  79881. protected _getTypeName(): string;
  79882. /** @hidden */
  79883. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  79884. /** @hidden */
  79885. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  79886. /** @hidden */
  79887. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  79888. /** @hidden */
  79889. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79890. /** @hidden */
  79891. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79892. /**
  79893. * Creates a new button made with an image and a text
  79894. * @param name defines the name of the button
  79895. * @param text defines the text of the button
  79896. * @param imageUrl defines the url of the image
  79897. * @returns a new Button
  79898. */
  79899. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  79900. /**
  79901. * Creates a new button made with an image
  79902. * @param name defines the name of the button
  79903. * @param imageUrl defines the url of the image
  79904. * @returns a new Button
  79905. */
  79906. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  79907. /**
  79908. * Creates a new button made with a text
  79909. * @param name defines the name of the button
  79910. * @param text defines the text of the button
  79911. * @returns a new Button
  79912. */
  79913. static CreateSimpleButton(name: string, text: string): Button;
  79914. /**
  79915. * Creates a new button made with an image and a centered text
  79916. * @param name defines the name of the button
  79917. * @param text defines the text of the button
  79918. * @param imageUrl defines the url of the image
  79919. * @returns a new Button
  79920. */
  79921. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  79922. }
  79923. }
  79924. declare module BABYLON.GUI {
  79925. /**
  79926. * Class used to create a 2D stack panel container
  79927. */
  79928. export class StackPanel extends Container {
  79929. name?: string | undefined;
  79930. private _isVertical;
  79931. private _manualWidth;
  79932. private _manualHeight;
  79933. private _doNotTrackManualChanges;
  79934. /**
  79935. * Gets or sets a boolean indicating that layou warnings should be ignored
  79936. */
  79937. ignoreLayoutWarnings: boolean;
  79938. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  79939. get isVertical(): boolean;
  79940. set isVertical(value: boolean);
  79941. /**
  79942. * Gets or sets panel width.
  79943. * This value should not be set when in horizontal mode as it will be computed automatically
  79944. */
  79945. set width(value: string | number);
  79946. get width(): string | number;
  79947. /**
  79948. * Gets or sets panel height.
  79949. * This value should not be set when in vertical mode as it will be computed automatically
  79950. */
  79951. set height(value: string | number);
  79952. get height(): string | number;
  79953. /**
  79954. * Creates a new StackPanel
  79955. * @param name defines control name
  79956. */
  79957. constructor(name?: string | undefined);
  79958. protected _getTypeName(): string;
  79959. /** @hidden */
  79960. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79961. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79962. protected _postMeasure(): void;
  79963. }
  79964. }
  79965. declare module BABYLON.GUI {
  79966. /**
  79967. * Class used to represent a 2D checkbox
  79968. */
  79969. export class Checkbox extends Control {
  79970. name?: string | undefined;
  79971. private _isChecked;
  79972. private _background;
  79973. private _checkSizeRatio;
  79974. private _thickness;
  79975. /** Gets or sets border thickness */
  79976. get thickness(): number;
  79977. set thickness(value: number);
  79978. /**
  79979. * BABYLON.Observable raised when isChecked property changes
  79980. */
  79981. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79982. /** Gets or sets a value indicating the ratio between overall size and check size */
  79983. get checkSizeRatio(): number;
  79984. set checkSizeRatio(value: number);
  79985. /** Gets or sets background color */
  79986. get background(): string;
  79987. set background(value: string);
  79988. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79989. get isChecked(): boolean;
  79990. set isChecked(value: boolean);
  79991. /**
  79992. * Creates a new CheckBox
  79993. * @param name defines the control name
  79994. */
  79995. constructor(name?: string | undefined);
  79996. protected _getTypeName(): string;
  79997. /** @hidden */
  79998. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79999. /** @hidden */
  80000. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80001. /**
  80002. * Utility function to easily create a checkbox with a header
  80003. * @param title defines the label to use for the header
  80004. * @param onValueChanged defines the callback to call when value changes
  80005. * @returns a StackPanel containing the checkbox and a textBlock
  80006. */
  80007. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  80008. }
  80009. }
  80010. declare module BABYLON.GUI {
  80011. /**
  80012. * Class used to store key control properties
  80013. */
  80014. export class KeyPropertySet {
  80015. /** Width */
  80016. width?: string;
  80017. /** Height */
  80018. height?: string;
  80019. /** Left padding */
  80020. paddingLeft?: string;
  80021. /** Right padding */
  80022. paddingRight?: string;
  80023. /** Top padding */
  80024. paddingTop?: string;
  80025. /** Bottom padding */
  80026. paddingBottom?: string;
  80027. /** Foreground color */
  80028. color?: string;
  80029. /** Background color */
  80030. background?: string;
  80031. }
  80032. /**
  80033. * Class used to create virtual keyboard
  80034. */
  80035. export class VirtualKeyboard extends StackPanel {
  80036. /** BABYLON.Observable raised when a key is pressed */
  80037. onKeyPressObservable: BABYLON.Observable<string>;
  80038. /** Gets or sets default key button width */
  80039. defaultButtonWidth: string;
  80040. /** Gets or sets default key button height */
  80041. defaultButtonHeight: string;
  80042. /** Gets or sets default key button left padding */
  80043. defaultButtonPaddingLeft: string;
  80044. /** Gets or sets default key button right padding */
  80045. defaultButtonPaddingRight: string;
  80046. /** Gets or sets default key button top padding */
  80047. defaultButtonPaddingTop: string;
  80048. /** Gets or sets default key button bottom padding */
  80049. defaultButtonPaddingBottom: string;
  80050. /** Gets or sets default key button foreground color */
  80051. defaultButtonColor: string;
  80052. /** Gets or sets default key button background color */
  80053. defaultButtonBackground: string;
  80054. /** Gets or sets shift button foreground color */
  80055. shiftButtonColor: string;
  80056. /** Gets or sets shift button thickness*/
  80057. selectedShiftThickness: number;
  80058. /** Gets shift key state */
  80059. shiftState: number;
  80060. protected _getTypeName(): string;
  80061. private _createKey;
  80062. /**
  80063. * Adds a new row of keys
  80064. * @param keys defines the list of keys to add
  80065. * @param propertySets defines the associated property sets
  80066. */
  80067. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  80068. /**
  80069. * Set the shift key to a specific state
  80070. * @param shiftState defines the new shift state
  80071. */
  80072. applyShiftState(shiftState: number): void;
  80073. private _currentlyConnectedInputText;
  80074. private _connectedInputTexts;
  80075. private _onKeyPressObserver;
  80076. /** Gets the input text control currently attached to the keyboard */
  80077. get connectedInputText(): BABYLON.Nullable<InputText>;
  80078. /**
  80079. * Connects the keyboard with an input text control
  80080. *
  80081. * @param input defines the target control
  80082. */
  80083. connect(input: InputText): void;
  80084. /**
  80085. * Disconnects the keyboard from connected InputText controls
  80086. *
  80087. * @param input optionally defines a target control, otherwise all are disconnected
  80088. */
  80089. disconnect(input?: InputText): void;
  80090. private _removeConnectedInputObservables;
  80091. /**
  80092. * Release all resources
  80093. */
  80094. dispose(): void;
  80095. /**
  80096. * Creates a new keyboard using a default layout
  80097. *
  80098. * @param name defines control name
  80099. * @returns a new VirtualKeyboard
  80100. */
  80101. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  80102. }
  80103. }
  80104. declare module BABYLON.GUI {
  80105. /** @hidden */
  80106. export class TextWrapper {
  80107. private _text;
  80108. private _characters;
  80109. get text(): string;
  80110. set text(txt: string);
  80111. get length(): number;
  80112. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  80113. charAt(idx: number): string;
  80114. substr(from: number, length?: number): string;
  80115. substring(from: number, to?: number): string;
  80116. isWord(index: number): boolean;
  80117. }
  80118. }
  80119. declare module BABYLON.GUI {
  80120. /**
  80121. * Class used to create input text control
  80122. */
  80123. export class InputText extends Control implements IFocusableControl {
  80124. name?: string | undefined;
  80125. private _textWrapper;
  80126. private _placeholderText;
  80127. private _background;
  80128. private _focusedBackground;
  80129. private _focusedColor;
  80130. private _placeholderColor;
  80131. private _thickness;
  80132. private _margin;
  80133. private _autoStretchWidth;
  80134. private _maxWidth;
  80135. private _isFocused;
  80136. private _blinkTimeout;
  80137. private _blinkIsEven;
  80138. private _cursorOffset;
  80139. private _scrollLeft;
  80140. private _textWidth;
  80141. private _clickedCoordinate;
  80142. private _deadKey;
  80143. private _addKey;
  80144. private _currentKey;
  80145. private _isTextHighlightOn;
  80146. private _textHighlightColor;
  80147. private _highligherOpacity;
  80148. private _highlightedText;
  80149. private _startHighlightIndex;
  80150. private _endHighlightIndex;
  80151. private _cursorIndex;
  80152. private _onFocusSelectAll;
  80153. private _isPointerDown;
  80154. private _onClipboardObserver;
  80155. private _onPointerDblTapObserver;
  80156. /** @hidden */
  80157. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  80158. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  80159. promptMessage: string;
  80160. /** Force disable prompt on mobile device */
  80161. disableMobilePrompt: boolean;
  80162. /** BABYLON.Observable raised when the text changes */
  80163. onTextChangedObservable: BABYLON.Observable<InputText>;
  80164. /** BABYLON.Observable raised just before an entered character is to be added */
  80165. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  80166. /** BABYLON.Observable raised when the control gets the focus */
  80167. onFocusObservable: BABYLON.Observable<InputText>;
  80168. /** BABYLON.Observable raised when the control loses the focus */
  80169. onBlurObservable: BABYLON.Observable<InputText>;
  80170. /**Observable raised when the text is highlighted */
  80171. onTextHighlightObservable: BABYLON.Observable<InputText>;
  80172. /**Observable raised when copy event is triggered */
  80173. onTextCopyObservable: BABYLON.Observable<InputText>;
  80174. /** BABYLON.Observable raised when cut event is triggered */
  80175. onTextCutObservable: BABYLON.Observable<InputText>;
  80176. /** BABYLON.Observable raised when paste event is triggered */
  80177. onTextPasteObservable: BABYLON.Observable<InputText>;
  80178. /** BABYLON.Observable raised when a key event was processed */
  80179. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  80180. /** Gets or sets the maximum width allowed by the control */
  80181. get maxWidth(): string | number;
  80182. /** Gets the maximum width allowed by the control in pixels */
  80183. get maxWidthInPixels(): number;
  80184. set maxWidth(value: string | number);
  80185. /** Gets or sets the text highlighter transparency; default: 0.4 */
  80186. get highligherOpacity(): number;
  80187. set highligherOpacity(value: number);
  80188. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  80189. get onFocusSelectAll(): boolean;
  80190. set onFocusSelectAll(value: boolean);
  80191. /** Gets or sets the text hightlight color */
  80192. get textHighlightColor(): string;
  80193. set textHighlightColor(value: string);
  80194. /** Gets or sets control margin */
  80195. get margin(): string;
  80196. /** Gets control margin in pixels */
  80197. get marginInPixels(): number;
  80198. set margin(value: string);
  80199. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  80200. get autoStretchWidth(): boolean;
  80201. set autoStretchWidth(value: boolean);
  80202. /** Gets or sets border thickness */
  80203. get thickness(): number;
  80204. set thickness(value: number);
  80205. /** Gets or sets the background color when focused */
  80206. get focusedBackground(): string;
  80207. set focusedBackground(value: string);
  80208. /** Gets or sets the background color when focused */
  80209. get focusedColor(): string;
  80210. set focusedColor(value: string);
  80211. /** Gets or sets the background color */
  80212. get background(): string;
  80213. set background(value: string);
  80214. /** Gets or sets the placeholder color */
  80215. get placeholderColor(): string;
  80216. set placeholderColor(value: string);
  80217. /** Gets or sets the text displayed when the control is empty */
  80218. get placeholderText(): string;
  80219. set placeholderText(value: string);
  80220. /** Gets or sets the dead key flag */
  80221. get deadKey(): boolean;
  80222. set deadKey(flag: boolean);
  80223. /** Gets or sets the highlight text */
  80224. get highlightedText(): string;
  80225. set highlightedText(text: string);
  80226. /** Gets or sets if the current key should be added */
  80227. get addKey(): boolean;
  80228. set addKey(flag: boolean);
  80229. /** Gets or sets the value of the current key being entered */
  80230. get currentKey(): string;
  80231. set currentKey(key: string);
  80232. /** Gets or sets the text displayed in the control */
  80233. get text(): string;
  80234. set text(value: string);
  80235. private _textHasChanged;
  80236. /** Gets or sets control width */
  80237. get width(): string | number;
  80238. set width(value: string | number);
  80239. /**
  80240. * Creates a new InputText
  80241. * @param name defines the control name
  80242. * @param text defines the text of the control
  80243. */
  80244. constructor(name?: string | undefined, text?: string);
  80245. /** @hidden */
  80246. onBlur(): void;
  80247. /** @hidden */
  80248. onFocus(): void;
  80249. /**
  80250. * Function to focus an inputText programmatically
  80251. */
  80252. focus(): void;
  80253. /**
  80254. * Function to unfocus an inputText programmatically
  80255. */
  80256. blur(): void;
  80257. protected _getTypeName(): string;
  80258. /**
  80259. * Function called to get the list of controls that should not steal the focus from this control
  80260. * @returns an array of controls
  80261. */
  80262. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80263. /** @hidden */
  80264. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  80265. /** @hidden */
  80266. private _updateValueFromCursorIndex;
  80267. /** @hidden */
  80268. private _processDblClick;
  80269. /** @hidden */
  80270. private _selectAllText;
  80271. /**
  80272. * Handles the keyboard event
  80273. * @param evt Defines the KeyboardEvent
  80274. */
  80275. processKeyboard(evt: KeyboardEvent): void;
  80276. /** @hidden */
  80277. private _onCopyText;
  80278. /** @hidden */
  80279. private _onCutText;
  80280. /** @hidden */
  80281. private _onPasteText;
  80282. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80283. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80284. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80285. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80286. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80287. dispose(): void;
  80288. }
  80289. }
  80290. declare module BABYLON.GUI {
  80291. /**
  80292. * Class used to create a 2D grid container
  80293. */
  80294. export class Grid extends Container {
  80295. name?: string | undefined;
  80296. private _rowDefinitions;
  80297. private _columnDefinitions;
  80298. private _cells;
  80299. private _childControls;
  80300. /**
  80301. * Gets the number of columns
  80302. */
  80303. get columnCount(): number;
  80304. /**
  80305. * Gets the number of rows
  80306. */
  80307. get rowCount(): number;
  80308. /** Gets the list of children */
  80309. get children(): Control[];
  80310. /** Gets the list of cells (e.g. the containers) */
  80311. get cells(): {
  80312. [key: string]: Container;
  80313. };
  80314. /**
  80315. * Gets the definition of a specific row
  80316. * @param index defines the index of the row
  80317. * @returns the row definition
  80318. */
  80319. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80320. /**
  80321. * Gets the definition of a specific column
  80322. * @param index defines the index of the column
  80323. * @returns the column definition
  80324. */
  80325. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  80326. /**
  80327. * Adds a new row to the grid
  80328. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80329. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  80330. * @returns the current grid
  80331. */
  80332. addRowDefinition(height: number, isPixel?: boolean): Grid;
  80333. /**
  80334. * Adds a new column to the grid
  80335. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80336. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80337. * @returns the current grid
  80338. */
  80339. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  80340. /**
  80341. * Update a row definition
  80342. * @param index defines the index of the row to update
  80343. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  80344. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  80345. * @returns the current grid
  80346. */
  80347. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  80348. /**
  80349. * Update a column definition
  80350. * @param index defines the index of the column to update
  80351. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  80352. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  80353. * @returns the current grid
  80354. */
  80355. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  80356. /**
  80357. * Gets the list of children stored in a specific cell
  80358. * @param row defines the row to check
  80359. * @param column defines the column to check
  80360. * @returns the list of controls
  80361. */
  80362. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  80363. /**
  80364. * Gets a string representing the child cell info (row x column)
  80365. * @param child defines the control to get info from
  80366. * @returns a string containing the child cell info (row x column)
  80367. */
  80368. getChildCellInfo(child: Control): string;
  80369. private _removeCell;
  80370. private _offsetCell;
  80371. /**
  80372. * Remove a column definition at specified index
  80373. * @param index defines the index of the column to remove
  80374. * @returns the current grid
  80375. */
  80376. removeColumnDefinition(index: number): Grid;
  80377. /**
  80378. * Remove a row definition at specified index
  80379. * @param index defines the index of the row to remove
  80380. * @returns the current grid
  80381. */
  80382. removeRowDefinition(index: number): Grid;
  80383. /**
  80384. * Adds a new control to the current grid
  80385. * @param control defines the control to add
  80386. * @param row defines the row where to add the control (0 by default)
  80387. * @param column defines the column where to add the control (0 by default)
  80388. * @returns the current grid
  80389. */
  80390. addControl(control: Control, row?: number, column?: number): Grid;
  80391. /**
  80392. * Removes a control from the current container
  80393. * @param control defines the control to remove
  80394. * @returns the current container
  80395. */
  80396. removeControl(control: Control): Container;
  80397. /**
  80398. * Creates a new Grid
  80399. * @param name defines control name
  80400. */
  80401. constructor(name?: string | undefined);
  80402. protected _getTypeName(): string;
  80403. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  80404. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80405. _flagDescendantsAsMatrixDirty(): void;
  80406. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80407. /** Releases associated resources */
  80408. dispose(): void;
  80409. }
  80410. }
  80411. declare module BABYLON.GUI {
  80412. /** Class used to create color pickers */
  80413. export class ColorPicker extends Control {
  80414. name?: string | undefined;
  80415. private static _Epsilon;
  80416. private _colorWheelCanvas;
  80417. private _value;
  80418. private _tmpColor;
  80419. private _pointerStartedOnSquare;
  80420. private _pointerStartedOnWheel;
  80421. private _squareLeft;
  80422. private _squareTop;
  80423. private _squareSize;
  80424. private _h;
  80425. private _s;
  80426. private _v;
  80427. private _lastPointerDownID;
  80428. /**
  80429. * BABYLON.Observable raised when the value changes
  80430. */
  80431. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  80432. /** Gets or sets the color of the color picker */
  80433. get value(): BABYLON.Color3;
  80434. set value(value: BABYLON.Color3);
  80435. /**
  80436. * Gets or sets control width
  80437. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80438. */
  80439. get width(): string | number;
  80440. set width(value: string | number);
  80441. /**
  80442. * Gets or sets control height
  80443. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  80444. */
  80445. get height(): string | number;
  80446. /** Gets or sets control height */
  80447. set height(value: string | number);
  80448. /** Gets or sets control size */
  80449. get size(): string | number;
  80450. set size(value: string | number);
  80451. /**
  80452. * Creates a new ColorPicker
  80453. * @param name defines the control name
  80454. */
  80455. constructor(name?: string | undefined);
  80456. protected _getTypeName(): string;
  80457. /** @hidden */
  80458. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80459. private _updateSquareProps;
  80460. private _drawGradientSquare;
  80461. private _drawCircle;
  80462. private _createColorWheelCanvas;
  80463. /** @hidden */
  80464. _draw(context: CanvasRenderingContext2D): void;
  80465. private _pointerIsDown;
  80466. private _updateValueFromPointer;
  80467. private _isPointOnSquare;
  80468. private _isPointOnWheel;
  80469. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80470. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80471. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  80472. _onCanvasBlur(): void;
  80473. /**
  80474. * This function expands the color picker by creating a color picker dialog with manual
  80475. * color value input and the ability to save colors into an array to be used later in
  80476. * subsequent launches of the dialogue.
  80477. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  80478. * @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.
  80479. * @returns picked color as a hex string and the saved colors array as hex strings.
  80480. */
  80481. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  80482. pickerWidth?: string;
  80483. pickerHeight?: string;
  80484. headerHeight?: string;
  80485. lastColor?: string;
  80486. swatchLimit?: number;
  80487. numSwatchesPerLine?: number;
  80488. savedColors?: Array<string>;
  80489. }): Promise<{
  80490. savedColors?: string[];
  80491. pickedColor: string;
  80492. }>;
  80493. }
  80494. }
  80495. declare module BABYLON.GUI {
  80496. /** Class used to create 2D ellipse containers */
  80497. export class Ellipse extends Container {
  80498. name?: string | undefined;
  80499. private _thickness;
  80500. /** Gets or sets border thickness */
  80501. get thickness(): number;
  80502. set thickness(value: number);
  80503. /**
  80504. * Creates a new Ellipse
  80505. * @param name defines the control name
  80506. */
  80507. constructor(name?: string | undefined);
  80508. protected _getTypeName(): string;
  80509. protected _localDraw(context: CanvasRenderingContext2D): void;
  80510. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80511. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  80512. }
  80513. }
  80514. declare module BABYLON.GUI {
  80515. /**
  80516. * Class used to create a focusable button that can easily handle keyboard events
  80517. */
  80518. export class FocusableButton extends Button implements IFocusableControl {
  80519. name?: string | undefined;
  80520. /** Highlight color when button is focused */
  80521. focusedColor: BABYLON.Nullable<string>;
  80522. private _isFocused;
  80523. private _unfocusedColor;
  80524. /** BABYLON.Observable raised when the control gets the focus */
  80525. onFocusObservable: BABYLON.Observable<Button>;
  80526. /** BABYLON.Observable raised when the control loses the focus */
  80527. onBlurObservable: BABYLON.Observable<Button>;
  80528. /** BABYLON.Observable raised when a key event was processed */
  80529. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  80530. constructor(name?: string | undefined);
  80531. /** @hidden */
  80532. onBlur(): void;
  80533. /** @hidden */
  80534. onFocus(): void;
  80535. /**
  80536. * Function called to get the list of controls that should not steal the focus from this control
  80537. * @returns an array of controls
  80538. */
  80539. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  80540. /**
  80541. * Function to focus a button programmatically
  80542. */
  80543. focus(): void;
  80544. /**
  80545. * Function to unfocus a button programmatically
  80546. */
  80547. blur(): void;
  80548. /**
  80549. * Handles the keyboard event
  80550. * @param evt Defines the KeyboardEvent
  80551. */
  80552. processKeyboard(evt: KeyboardEvent): void;
  80553. /** @hidden */
  80554. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80555. /** @hidden */
  80556. displose(): void;
  80557. }
  80558. }
  80559. declare module BABYLON.GUI {
  80560. /**
  80561. * Class used to create a password control
  80562. */
  80563. export class InputPassword extends InputText {
  80564. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  80565. }
  80566. }
  80567. declare module BABYLON.GUI {
  80568. /** Class used to render 2D lines */
  80569. export class Line extends Control {
  80570. name?: string | undefined;
  80571. private _lineWidth;
  80572. private _x1;
  80573. private _y1;
  80574. private _x2;
  80575. private _y2;
  80576. private _dash;
  80577. private _connectedControl;
  80578. private _connectedControlDirtyObserver;
  80579. /** Gets or sets the dash pattern */
  80580. get dash(): Array<number>;
  80581. set dash(value: Array<number>);
  80582. /** Gets or sets the control connected with the line end */
  80583. get connectedControl(): Control;
  80584. set connectedControl(value: Control);
  80585. /** Gets or sets start coordinates on X axis */
  80586. get x1(): string | number;
  80587. set x1(value: string | number);
  80588. /** Gets or sets start coordinates on Y axis */
  80589. get y1(): string | number;
  80590. set y1(value: string | number);
  80591. /** Gets or sets end coordinates on X axis */
  80592. get x2(): string | number;
  80593. set x2(value: string | number);
  80594. /** Gets or sets end coordinates on Y axis */
  80595. get y2(): string | number;
  80596. set y2(value: string | number);
  80597. /** Gets or sets line width */
  80598. get lineWidth(): number;
  80599. set lineWidth(value: number);
  80600. /** Gets or sets horizontal alignment */
  80601. set horizontalAlignment(value: number);
  80602. /** Gets or sets vertical alignment */
  80603. set verticalAlignment(value: number);
  80604. private get _effectiveX2();
  80605. private get _effectiveY2();
  80606. /**
  80607. * Creates a new Line
  80608. * @param name defines the control name
  80609. */
  80610. constructor(name?: string | undefined);
  80611. protected _getTypeName(): string;
  80612. _draw(context: CanvasRenderingContext2D): void;
  80613. _measure(): void;
  80614. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80615. /**
  80616. * Move one end of the line given 3D cartesian coordinates.
  80617. * @param position Targeted world position
  80618. * @param scene BABYLON.Scene
  80619. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80620. */
  80621. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  80622. /**
  80623. * Move one end of the line to a position in screen absolute space.
  80624. * @param projectedPosition Position in screen absolute space (X, Y)
  80625. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  80626. */
  80627. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  80628. }
  80629. }
  80630. declare module BABYLON.GUI {
  80631. /**
  80632. * Class used to store a point for a MultiLine object.
  80633. * The point can be pure 2D coordinates, a mesh or a control
  80634. */
  80635. export class MultiLinePoint {
  80636. private _multiLine;
  80637. private _x;
  80638. private _y;
  80639. private _control;
  80640. private _mesh;
  80641. private _controlObserver;
  80642. private _meshObserver;
  80643. /** @hidden */
  80644. _point: BABYLON.Vector3;
  80645. /**
  80646. * Creates a new MultiLinePoint
  80647. * @param multiLine defines the source MultiLine object
  80648. */
  80649. constructor(multiLine: MultiLine);
  80650. /** Gets or sets x coordinate */
  80651. get x(): string | number;
  80652. set x(value: string | number);
  80653. /** Gets or sets y coordinate */
  80654. get y(): string | number;
  80655. set y(value: string | number);
  80656. /** Gets or sets the control associated with this point */
  80657. get control(): BABYLON.Nullable<Control>;
  80658. set control(value: BABYLON.Nullable<Control>);
  80659. /** Gets or sets the mesh associated with this point */
  80660. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80661. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  80662. /** Resets links */
  80663. resetLinks(): void;
  80664. /**
  80665. * Gets a translation vector with Z component
  80666. * @returns the translation vector
  80667. */
  80668. translate(): BABYLON.Vector3;
  80669. private _translatePoint;
  80670. /** Release associated resources */
  80671. dispose(): void;
  80672. }
  80673. }
  80674. declare module BABYLON.GUI {
  80675. /**
  80676. * Class used to create multi line control
  80677. */
  80678. export class MultiLine extends Control {
  80679. name?: string | undefined;
  80680. private _lineWidth;
  80681. private _dash;
  80682. private _points;
  80683. private _minX;
  80684. private _minY;
  80685. private _maxX;
  80686. private _maxY;
  80687. /**
  80688. * Creates a new MultiLine
  80689. * @param name defines the control name
  80690. */
  80691. constructor(name?: string | undefined);
  80692. /** Gets or sets dash pattern */
  80693. get dash(): Array<number>;
  80694. set dash(value: Array<number>);
  80695. /**
  80696. * Gets point stored at specified index
  80697. * @param index defines the index to look for
  80698. * @returns the requested point if found
  80699. */
  80700. getAt(index: number): MultiLinePoint;
  80701. /** Function called when a point is updated */
  80702. onPointUpdate: () => void;
  80703. /**
  80704. * Adds new points to the point collection
  80705. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  80706. * @returns the list of created MultiLinePoint
  80707. */
  80708. add(...items: (AbstractMesh | Control | {
  80709. x: string | number;
  80710. y: string | number;
  80711. })[]): MultiLinePoint[];
  80712. /**
  80713. * Adds a new point to the point collection
  80714. * @param item defines the item (mesh, control or 2d coordiantes) to add
  80715. * @returns the created MultiLinePoint
  80716. */
  80717. push(item?: (AbstractMesh | Control | {
  80718. x: string | number;
  80719. y: string | number;
  80720. })): MultiLinePoint;
  80721. /**
  80722. * Remove a specific value or point from the active point collection
  80723. * @param value defines the value or point to remove
  80724. */
  80725. remove(value: number | MultiLinePoint): void;
  80726. /**
  80727. * Resets this object to initial state (no point)
  80728. */
  80729. reset(): void;
  80730. /**
  80731. * Resets all links
  80732. */
  80733. resetLinks(): void;
  80734. /** Gets or sets line width */
  80735. get lineWidth(): number;
  80736. set lineWidth(value: number);
  80737. set horizontalAlignment(value: number);
  80738. set verticalAlignment(value: number);
  80739. protected _getTypeName(): string;
  80740. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80741. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80742. _measure(): void;
  80743. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80744. dispose(): void;
  80745. }
  80746. }
  80747. declare module BABYLON.GUI {
  80748. /**
  80749. * Class used to create radio button controls
  80750. */
  80751. export class RadioButton extends Control {
  80752. name?: string | undefined;
  80753. private _isChecked;
  80754. private _background;
  80755. private _checkSizeRatio;
  80756. private _thickness;
  80757. /** Gets or sets border thickness */
  80758. get thickness(): number;
  80759. set thickness(value: number);
  80760. /** Gets or sets group name */
  80761. group: string;
  80762. /** BABYLON.Observable raised when isChecked is changed */
  80763. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  80764. /** Gets or sets a value indicating the ratio between overall size and check size */
  80765. get checkSizeRatio(): number;
  80766. set checkSizeRatio(value: number);
  80767. /** Gets or sets background color */
  80768. get background(): string;
  80769. set background(value: string);
  80770. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  80771. get isChecked(): boolean;
  80772. set isChecked(value: boolean);
  80773. /**
  80774. * Creates a new RadioButton
  80775. * @param name defines the control name
  80776. */
  80777. constructor(name?: string | undefined);
  80778. protected _getTypeName(): string;
  80779. _draw(context: CanvasRenderingContext2D): void;
  80780. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80781. /**
  80782. * Utility function to easily create a radio button with a header
  80783. * @param title defines the label to use for the header
  80784. * @param group defines the group to use for the radio button
  80785. * @param isChecked defines the initial state of the radio button
  80786. * @param onValueChanged defines the callback to call when value changes
  80787. * @returns a StackPanel containing the radio button and a textBlock
  80788. */
  80789. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  80790. }
  80791. }
  80792. declare module BABYLON.GUI {
  80793. /**
  80794. * Class used to create slider controls
  80795. */
  80796. export class BaseSlider extends Control {
  80797. name?: string | undefined;
  80798. protected _thumbWidth: ValueAndUnit;
  80799. private _minimum;
  80800. private _maximum;
  80801. private _value;
  80802. private _isVertical;
  80803. protected _barOffset: ValueAndUnit;
  80804. private _isThumbClamped;
  80805. protected _displayThumb: boolean;
  80806. private _step;
  80807. private _lastPointerDownID;
  80808. protected _effectiveBarOffset: number;
  80809. protected _renderLeft: number;
  80810. protected _renderTop: number;
  80811. protected _renderWidth: number;
  80812. protected _renderHeight: number;
  80813. protected _backgroundBoxLength: number;
  80814. protected _backgroundBoxThickness: number;
  80815. protected _effectiveThumbThickness: number;
  80816. /** BABYLON.Observable raised when the sldier value changes */
  80817. onValueChangedObservable: BABYLON.Observable<number>;
  80818. /** Gets or sets a boolean indicating if the thumb must be rendered */
  80819. get displayThumb(): boolean;
  80820. set displayThumb(value: boolean);
  80821. /** Gets or sets a step to apply to values (0 by default) */
  80822. get step(): number;
  80823. set step(value: number);
  80824. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  80825. get barOffset(): string | number;
  80826. /** Gets main bar offset in pixels*/
  80827. get barOffsetInPixels(): number;
  80828. set barOffset(value: string | number);
  80829. /** Gets or sets thumb width */
  80830. get thumbWidth(): string | number;
  80831. /** Gets thumb width in pixels */
  80832. get thumbWidthInPixels(): number;
  80833. set thumbWidth(value: string | number);
  80834. /** Gets or sets minimum value */
  80835. get minimum(): number;
  80836. set minimum(value: number);
  80837. /** Gets or sets maximum value */
  80838. get maximum(): number;
  80839. set maximum(value: number);
  80840. /** Gets or sets current value */
  80841. get value(): number;
  80842. set value(value: number);
  80843. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  80844. get isVertical(): boolean;
  80845. set isVertical(value: boolean);
  80846. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  80847. get isThumbClamped(): boolean;
  80848. set isThumbClamped(value: boolean);
  80849. /**
  80850. * Creates a new BaseSlider
  80851. * @param name defines the control name
  80852. */
  80853. constructor(name?: string | undefined);
  80854. protected _getTypeName(): string;
  80855. protected _getThumbPosition(): number;
  80856. protected _getThumbThickness(type: string): number;
  80857. protected _prepareRenderingData(type: string): void;
  80858. private _pointerIsDown;
  80859. /** @hidden */
  80860. protected _updateValueFromPointer(x: number, y: number): void;
  80861. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80862. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  80863. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80864. _onCanvasBlur(): void;
  80865. }
  80866. }
  80867. declare module BABYLON.GUI {
  80868. /**
  80869. * Class used to create slider controls
  80870. */
  80871. export class Slider extends BaseSlider {
  80872. name?: string | undefined;
  80873. private _background;
  80874. private _borderColor;
  80875. private _thumbColor;
  80876. private _isThumbCircle;
  80877. protected _displayValueBar: boolean;
  80878. /** Gets or sets a boolean indicating if the value bar must be rendered */
  80879. get displayValueBar(): boolean;
  80880. set displayValueBar(value: boolean);
  80881. /** Gets or sets border color */
  80882. get borderColor(): string;
  80883. set borderColor(value: string);
  80884. /** Gets or sets background color */
  80885. get background(): string;
  80886. set background(value: string);
  80887. /** Gets or sets thumb's color */
  80888. get thumbColor(): string;
  80889. set thumbColor(value: string);
  80890. /** Gets or sets a boolean indicating if the thumb should be round or square */
  80891. get isThumbCircle(): boolean;
  80892. set isThumbCircle(value: boolean);
  80893. /**
  80894. * Creates a new Slider
  80895. * @param name defines the control name
  80896. */
  80897. constructor(name?: string | undefined);
  80898. protected _getTypeName(): string;
  80899. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80900. }
  80901. }
  80902. declare module BABYLON.GUI {
  80903. /** Class used to create a RadioGroup
  80904. * which contains groups of radio buttons
  80905. */
  80906. export class SelectorGroup {
  80907. /** name of SelectorGroup */
  80908. name: string;
  80909. private _groupPanel;
  80910. private _selectors;
  80911. private _groupHeader;
  80912. /**
  80913. * Creates a new SelectorGroup
  80914. * @param name of group, used as a group heading
  80915. */
  80916. constructor(
  80917. /** name of SelectorGroup */
  80918. name: string);
  80919. /** Gets the groupPanel of the SelectorGroup */
  80920. get groupPanel(): StackPanel;
  80921. /** Gets the selectors array */
  80922. get selectors(): StackPanel[];
  80923. /** Gets and sets the group header */
  80924. get header(): string;
  80925. set header(label: string);
  80926. /** @hidden */
  80927. private _addGroupHeader;
  80928. /** @hidden*/
  80929. _getSelector(selectorNb: number): StackPanel | undefined;
  80930. /** Removes the selector at the given position
  80931. * @param selectorNb the position of the selector within the group
  80932. */
  80933. removeSelector(selectorNb: number): void;
  80934. }
  80935. /** Class used to create a CheckboxGroup
  80936. * which contains groups of checkbox buttons
  80937. */
  80938. export class CheckboxGroup extends SelectorGroup {
  80939. /** Adds a checkbox as a control
  80940. * @param text is the label for the selector
  80941. * @param func is the function called when the Selector is checked
  80942. * @param checked is true when Selector is checked
  80943. */
  80944. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  80945. /** @hidden */
  80946. _setSelectorLabel(selectorNb: number, label: string): void;
  80947. /** @hidden */
  80948. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80949. /** @hidden */
  80950. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80951. /** @hidden */
  80952. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80953. }
  80954. /** Class used to create a RadioGroup
  80955. * which contains groups of radio buttons
  80956. */
  80957. export class RadioGroup extends SelectorGroup {
  80958. private _selectNb;
  80959. /** Adds a radio button as a control
  80960. * @param label is the label for the selector
  80961. * @param func is the function called when the Selector is checked
  80962. * @param checked is true when Selector is checked
  80963. */
  80964. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  80965. /** @hidden */
  80966. _setSelectorLabel(selectorNb: number, label: string): void;
  80967. /** @hidden */
  80968. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80969. /** @hidden */
  80970. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80971. /** @hidden */
  80972. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80973. }
  80974. /** Class used to create a SliderGroup
  80975. * which contains groups of slider buttons
  80976. */
  80977. export class SliderGroup extends SelectorGroup {
  80978. /**
  80979. * Adds a slider to the SelectorGroup
  80980. * @param label is the label for the SliderBar
  80981. * @param func is the function called when the Slider moves
  80982. * @param unit is a string describing the units used, eg degrees or metres
  80983. * @param min is the minimum value for the Slider
  80984. * @param max is the maximum value for the Slider
  80985. * @param value is the start value for the Slider between min and max
  80986. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  80987. */
  80988. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  80989. /** @hidden */
  80990. _setSelectorLabel(selectorNb: number, label: string): void;
  80991. /** @hidden */
  80992. _setSelectorLabelColor(selectorNb: number, color: string): void;
  80993. /** @hidden */
  80994. _setSelectorButtonColor(selectorNb: number, color: string): void;
  80995. /** @hidden */
  80996. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  80997. }
  80998. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  80999. * @see https://doc.babylonjs.com/how_to/selector
  81000. */
  81001. export class SelectionPanel extends Rectangle {
  81002. /** name of SelectionPanel */
  81003. name: string;
  81004. /** an array of SelectionGroups */
  81005. groups: SelectorGroup[];
  81006. private _panel;
  81007. private _buttonColor;
  81008. private _buttonBackground;
  81009. private _headerColor;
  81010. private _barColor;
  81011. private _barHeight;
  81012. private _spacerHeight;
  81013. private _labelColor;
  81014. private _groups;
  81015. private _bars;
  81016. /**
  81017. * Creates a new SelectionPanel
  81018. * @param name of SelectionPanel
  81019. * @param groups is an array of SelectionGroups
  81020. */
  81021. constructor(
  81022. /** name of SelectionPanel */
  81023. name: string,
  81024. /** an array of SelectionGroups */
  81025. groups?: SelectorGroup[]);
  81026. protected _getTypeName(): string;
  81027. /** Gets the (stack) panel of the SelectionPanel */
  81028. get panel(): StackPanel;
  81029. /** Gets or sets the headerColor */
  81030. get headerColor(): string;
  81031. set headerColor(color: string);
  81032. private _setHeaderColor;
  81033. /** Gets or sets the button color */
  81034. get buttonColor(): string;
  81035. set buttonColor(color: string);
  81036. private _setbuttonColor;
  81037. /** Gets or sets the label color */
  81038. get labelColor(): string;
  81039. set labelColor(color: string);
  81040. private _setLabelColor;
  81041. /** Gets or sets the button background */
  81042. get buttonBackground(): string;
  81043. set buttonBackground(color: string);
  81044. private _setButtonBackground;
  81045. /** Gets or sets the color of separator bar */
  81046. get barColor(): string;
  81047. set barColor(color: string);
  81048. private _setBarColor;
  81049. /** Gets or sets the height of separator bar */
  81050. get barHeight(): string;
  81051. set barHeight(value: string);
  81052. private _setBarHeight;
  81053. /** Gets or sets the height of spacers*/
  81054. get spacerHeight(): string;
  81055. set spacerHeight(value: string);
  81056. private _setSpacerHeight;
  81057. /** Adds a bar between groups */
  81058. private _addSpacer;
  81059. /** Add a group to the selection panel
  81060. * @param group is the selector group to add
  81061. */
  81062. addGroup(group: SelectorGroup): void;
  81063. /** Remove the group from the given position
  81064. * @param groupNb is the position of the group in the list
  81065. */
  81066. removeGroup(groupNb: number): void;
  81067. /** Change a group header label
  81068. * @param label is the new group header label
  81069. * @param groupNb is the number of the group to relabel
  81070. * */
  81071. setHeaderName(label: string, groupNb: number): void;
  81072. /** Change selector label to the one given
  81073. * @param label is the new selector label
  81074. * @param groupNb is the number of the groupcontaining the selector
  81075. * @param selectorNb is the number of the selector within a group to relabel
  81076. * */
  81077. relabel(label: string, groupNb: number, selectorNb: number): void;
  81078. /** For a given group position remove the selector at the given position
  81079. * @param groupNb is the number of the group to remove the selector from
  81080. * @param selectorNb is the number of the selector within the group
  81081. */
  81082. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  81083. /** For a given group position of correct type add a checkbox button
  81084. * @param groupNb is the number of the group to remove the selector from
  81085. * @param label is the label for the selector
  81086. * @param func is the function called when the Selector is checked
  81087. * @param checked is true when Selector is checked
  81088. */
  81089. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  81090. /** For a given group position of correct type add a radio button
  81091. * @param groupNb is the number of the group to remove the selector from
  81092. * @param label is the label for the selector
  81093. * @param func is the function called when the Selector is checked
  81094. * @param checked is true when Selector is checked
  81095. */
  81096. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  81097. /**
  81098. * For a given slider group add a slider
  81099. * @param groupNb is the number of the group to add the slider to
  81100. * @param label is the label for the Slider
  81101. * @param func is the function called when the Slider moves
  81102. * @param unit is a string describing the units used, eg degrees or metres
  81103. * @param min is the minimum value for the Slider
  81104. * @param max is the maximum value for the Slider
  81105. * @param value is the start value for the Slider between min and max
  81106. * @param onVal is the function used to format the value displayed, eg radians to degrees
  81107. */
  81108. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  81109. }
  81110. }
  81111. declare module BABYLON.GUI {
  81112. /**
  81113. * Class used to hold a the container for ScrollViewer
  81114. * @hidden
  81115. */
  81116. export class _ScrollViewerWindow extends Container {
  81117. parentClientWidth: number;
  81118. parentClientHeight: number;
  81119. private _freezeControls;
  81120. private _parentMeasure;
  81121. private _oldLeft;
  81122. private _oldTop;
  81123. get freezeControls(): boolean;
  81124. set freezeControls(value: boolean);
  81125. private _bucketWidth;
  81126. private _bucketHeight;
  81127. private _buckets;
  81128. private _bucketLen;
  81129. get bucketWidth(): number;
  81130. get bucketHeight(): number;
  81131. setBucketSizes(width: number, height: number): void;
  81132. private _useBuckets;
  81133. private _makeBuckets;
  81134. private _dispatchInBuckets;
  81135. private _updateMeasures;
  81136. private _updateChildrenMeasures;
  81137. private _restoreMeasures;
  81138. /**
  81139. * Creates a new ScrollViewerWindow
  81140. * @param name of ScrollViewerWindow
  81141. */
  81142. constructor(name?: string);
  81143. protected _getTypeName(): string;
  81144. /** @hidden */
  81145. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81146. /** @hidden */
  81147. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  81148. private _scrollChildren;
  81149. private _scrollChildrenWithBuckets;
  81150. /** @hidden */
  81151. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  81152. protected _postMeasure(): void;
  81153. }
  81154. }
  81155. declare module BABYLON.GUI {
  81156. /**
  81157. * Class used to create slider controls
  81158. */
  81159. export class ScrollBar extends BaseSlider {
  81160. name?: string | undefined;
  81161. private _background;
  81162. private _borderColor;
  81163. private _tempMeasure;
  81164. /** Gets or sets border color */
  81165. get borderColor(): string;
  81166. set borderColor(value: string);
  81167. /** Gets or sets background color */
  81168. get background(): string;
  81169. set background(value: string);
  81170. /**
  81171. * Creates a new Slider
  81172. * @param name defines the control name
  81173. */
  81174. constructor(name?: string | undefined);
  81175. protected _getTypeName(): string;
  81176. protected _getThumbThickness(): number;
  81177. _draw(context: CanvasRenderingContext2D): void;
  81178. private _first;
  81179. private _originX;
  81180. private _originY;
  81181. /** @hidden */
  81182. protected _updateValueFromPointer(x: number, y: number): void;
  81183. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81184. }
  81185. }
  81186. declare module BABYLON.GUI {
  81187. /**
  81188. * Class used to create slider controls
  81189. */
  81190. export class ImageScrollBar extends BaseSlider {
  81191. name?: string | undefined;
  81192. private _backgroundBaseImage;
  81193. private _backgroundImage;
  81194. private _thumbImage;
  81195. private _thumbBaseImage;
  81196. private _thumbLength;
  81197. private _thumbHeight;
  81198. private _barImageHeight;
  81199. private _tempMeasure;
  81200. /** Number of 90° rotation to apply on the images when in vertical mode */
  81201. num90RotationInVerticalMode: number;
  81202. /**
  81203. * Gets or sets the image used to render the background for horizontal bar
  81204. */
  81205. get backgroundImage(): Image;
  81206. set backgroundImage(value: Image);
  81207. /**
  81208. * Gets or sets the image used to render the thumb
  81209. */
  81210. get thumbImage(): Image;
  81211. set thumbImage(value: Image);
  81212. /**
  81213. * Gets or sets the length of the thumb
  81214. */
  81215. get thumbLength(): number;
  81216. set thumbLength(value: number);
  81217. /**
  81218. * Gets or sets the height of the thumb
  81219. */
  81220. get thumbHeight(): number;
  81221. set thumbHeight(value: number);
  81222. /**
  81223. * Gets or sets the height of the bar image
  81224. */
  81225. get barImageHeight(): number;
  81226. set barImageHeight(value: number);
  81227. /**
  81228. * Creates a new ImageScrollBar
  81229. * @param name defines the control name
  81230. */
  81231. constructor(name?: string | undefined);
  81232. protected _getTypeName(): string;
  81233. protected _getThumbThickness(): number;
  81234. _draw(context: CanvasRenderingContext2D): void;
  81235. private _first;
  81236. private _originX;
  81237. private _originY;
  81238. /** @hidden */
  81239. protected _updateValueFromPointer(x: number, y: number): void;
  81240. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  81241. }
  81242. }
  81243. declare module BABYLON.GUI {
  81244. /**
  81245. * Class used to hold a viewer window and sliders in a grid
  81246. */
  81247. export class ScrollViewer extends Rectangle {
  81248. private _grid;
  81249. private _horizontalBarSpace;
  81250. private _verticalBarSpace;
  81251. private _dragSpace;
  81252. private _horizontalBar;
  81253. private _verticalBar;
  81254. private _barColor;
  81255. private _barBackground;
  81256. private _barImage;
  81257. private _horizontalBarImage;
  81258. private _verticalBarImage;
  81259. private _barBackgroundImage;
  81260. private _horizontalBarBackgroundImage;
  81261. private _verticalBarBackgroundImage;
  81262. private _barSize;
  81263. private _window;
  81264. private _pointerIsOver;
  81265. private _wheelPrecision;
  81266. private _onWheelObserver;
  81267. private _clientWidth;
  81268. private _clientHeight;
  81269. private _useImageBar;
  81270. private _thumbLength;
  81271. private _thumbHeight;
  81272. private _barImageHeight;
  81273. private _horizontalBarImageHeight;
  81274. private _verticalBarImageHeight;
  81275. private _oldWindowContentsWidth;
  81276. private _oldWindowContentsHeight;
  81277. /**
  81278. * Gets the horizontal scrollbar
  81279. */
  81280. get horizontalBar(): ScrollBar | ImageScrollBar;
  81281. /**
  81282. * Gets the vertical scrollbar
  81283. */
  81284. get verticalBar(): ScrollBar | ImageScrollBar;
  81285. /**
  81286. * Adds a new control to the current container
  81287. * @param control defines the control to add
  81288. * @returns the current container
  81289. */
  81290. addControl(control: BABYLON.Nullable<Control>): Container;
  81291. /**
  81292. * Removes a control from the current container
  81293. * @param control defines the control to remove
  81294. * @returns the current container
  81295. */
  81296. removeControl(control: Control): Container;
  81297. /** Gets the list of children */
  81298. get children(): Control[];
  81299. _flagDescendantsAsMatrixDirty(): void;
  81300. /**
  81301. * Freezes or unfreezes the controls in the window.
  81302. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  81303. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  81304. */
  81305. get freezeControls(): boolean;
  81306. set freezeControls(value: boolean);
  81307. /** Gets the bucket width */
  81308. get bucketWidth(): number;
  81309. /** Gets the bucket height */
  81310. get bucketHeight(): number;
  81311. /**
  81312. * Sets the bucket sizes.
  81313. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  81314. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  81315. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  81316. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  81317. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  81318. * used), that's why it is not enabled by default.
  81319. * @param width width of the bucket
  81320. * @param height height of the bucket
  81321. */
  81322. setBucketSizes(width: number, height: number): void;
  81323. private _forceHorizontalBar;
  81324. private _forceVerticalBar;
  81325. /**
  81326. * Forces the horizontal scroll bar to be displayed
  81327. */
  81328. get forceHorizontalBar(): boolean;
  81329. set forceHorizontalBar(value: boolean);
  81330. /**
  81331. * Forces the vertical scroll bar to be displayed
  81332. */
  81333. get forceVerticalBar(): boolean;
  81334. set forceVerticalBar(value: boolean);
  81335. /**
  81336. * Creates a new ScrollViewer
  81337. * @param name of ScrollViewer
  81338. */
  81339. constructor(name?: string, isImageBased?: boolean);
  81340. /** Reset the scroll viewer window to initial size */
  81341. resetWindow(): void;
  81342. protected _getTypeName(): string;
  81343. private _buildClientSizes;
  81344. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  81345. protected _postMeasure(): void;
  81346. /**
  81347. * Gets or sets the mouse wheel precision
  81348. * from 0 to 1 with a default value of 0.05
  81349. * */
  81350. get wheelPrecision(): number;
  81351. set wheelPrecision(value: number);
  81352. /** Gets or sets the scroll bar container background color */
  81353. get scrollBackground(): string;
  81354. set scrollBackground(color: string);
  81355. /** Gets or sets the bar color */
  81356. get barColor(): string;
  81357. set barColor(color: string);
  81358. /** Gets or sets the bar image */
  81359. get thumbImage(): Image;
  81360. set thumbImage(value: Image);
  81361. /** Gets or sets the horizontal bar image */
  81362. get horizontalThumbImage(): Image;
  81363. set horizontalThumbImage(value: Image);
  81364. /** Gets or sets the vertical bar image */
  81365. get verticalThumbImage(): Image;
  81366. set verticalThumbImage(value: Image);
  81367. /** Gets or sets the size of the bar */
  81368. get barSize(): number;
  81369. set barSize(value: number);
  81370. /** Gets or sets the length of the thumb */
  81371. get thumbLength(): number;
  81372. set thumbLength(value: number);
  81373. /** Gets or sets the height of the thumb */
  81374. get thumbHeight(): number;
  81375. set thumbHeight(value: number);
  81376. /** Gets or sets the height of the bar image */
  81377. get barImageHeight(): number;
  81378. set barImageHeight(value: number);
  81379. /** Gets or sets the height of the horizontal bar image */
  81380. get horizontalBarImageHeight(): number;
  81381. set horizontalBarImageHeight(value: number);
  81382. /** Gets or sets the height of the vertical bar image */
  81383. get verticalBarImageHeight(): number;
  81384. set verticalBarImageHeight(value: number);
  81385. /** Gets or sets the bar background */
  81386. get barBackground(): string;
  81387. set barBackground(color: string);
  81388. /** Gets or sets the bar background image */
  81389. get barImage(): Image;
  81390. set barImage(value: Image);
  81391. /** Gets or sets the horizontal bar background image */
  81392. get horizontalBarImage(): Image;
  81393. set horizontalBarImage(value: Image);
  81394. /** Gets or sets the vertical bar background image */
  81395. get verticalBarImage(): Image;
  81396. set verticalBarImage(value: Image);
  81397. private _setWindowPosition;
  81398. /** @hidden */
  81399. private _updateScroller;
  81400. _link(host: AdvancedDynamicTexture): void;
  81401. /** @hidden */
  81402. private _addBar;
  81403. /** @hidden */
  81404. private _attachWheel;
  81405. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  81406. /** Releases associated resources */
  81407. dispose(): void;
  81408. }
  81409. }
  81410. declare module BABYLON.GUI {
  81411. /** Class used to render a grid */
  81412. export class DisplayGrid extends Control {
  81413. name?: string | undefined;
  81414. private _cellWidth;
  81415. private _cellHeight;
  81416. private _minorLineTickness;
  81417. private _minorLineColor;
  81418. private _majorLineTickness;
  81419. private _majorLineColor;
  81420. private _majorLineFrequency;
  81421. private _background;
  81422. private _displayMajorLines;
  81423. private _displayMinorLines;
  81424. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  81425. get displayMinorLines(): boolean;
  81426. set displayMinorLines(value: boolean);
  81427. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  81428. get displayMajorLines(): boolean;
  81429. set displayMajorLines(value: boolean);
  81430. /** Gets or sets background color (Black by default) */
  81431. get background(): string;
  81432. set background(value: string);
  81433. /** Gets or sets the width of each cell (20 by default) */
  81434. get cellWidth(): number;
  81435. set cellWidth(value: number);
  81436. /** Gets or sets the height of each cell (20 by default) */
  81437. get cellHeight(): number;
  81438. set cellHeight(value: number);
  81439. /** Gets or sets the tickness of minor lines (1 by default) */
  81440. get minorLineTickness(): number;
  81441. set minorLineTickness(value: number);
  81442. /** Gets or sets the color of minor lines (DarkGray by default) */
  81443. get minorLineColor(): string;
  81444. set minorLineColor(value: string);
  81445. /** Gets or sets the tickness of major lines (2 by default) */
  81446. get majorLineTickness(): number;
  81447. set majorLineTickness(value: number);
  81448. /** Gets or sets the color of major lines (White by default) */
  81449. get majorLineColor(): string;
  81450. set majorLineColor(value: string);
  81451. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  81452. get majorLineFrequency(): number;
  81453. set majorLineFrequency(value: number);
  81454. /**
  81455. * Creates a new GridDisplayRectangle
  81456. * @param name defines the control name
  81457. */
  81458. constructor(name?: string | undefined);
  81459. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81460. protected _getTypeName(): string;
  81461. }
  81462. }
  81463. declare module BABYLON.GUI {
  81464. /**
  81465. * Class used to create slider controls based on images
  81466. */
  81467. export class ImageBasedSlider extends BaseSlider {
  81468. name?: string | undefined;
  81469. private _backgroundImage;
  81470. private _thumbImage;
  81471. private _valueBarImage;
  81472. private _tempMeasure;
  81473. get displayThumb(): boolean;
  81474. set displayThumb(value: boolean);
  81475. /**
  81476. * Gets or sets the image used to render the background
  81477. */
  81478. get backgroundImage(): Image;
  81479. set backgroundImage(value: Image);
  81480. /**
  81481. * Gets or sets the image used to render the value bar
  81482. */
  81483. get valueBarImage(): Image;
  81484. set valueBarImage(value: Image);
  81485. /**
  81486. * Gets or sets the image used to render the thumb
  81487. */
  81488. get thumbImage(): Image;
  81489. set thumbImage(value: Image);
  81490. /**
  81491. * Creates a new ImageBasedSlider
  81492. * @param name defines the control name
  81493. */
  81494. constructor(name?: string | undefined);
  81495. protected _getTypeName(): string;
  81496. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  81497. }
  81498. }
  81499. declare module BABYLON.GUI {
  81500. /**
  81501. * Forcing an export so that this code will execute
  81502. * @hidden
  81503. */
  81504. const name = "Statics";
  81505. }
  81506. declare module BABYLON.GUI {
  81507. /**
  81508. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  81509. */
  81510. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  81511. /**
  81512. * Define the instrumented AdvancedDynamicTexture.
  81513. */
  81514. texture: AdvancedDynamicTexture;
  81515. private _captureRenderTime;
  81516. private _renderTime;
  81517. private _captureLayoutTime;
  81518. private _layoutTime;
  81519. private _onBeginRenderObserver;
  81520. private _onEndRenderObserver;
  81521. private _onBeginLayoutObserver;
  81522. private _onEndLayoutObserver;
  81523. /**
  81524. * Gets the perf counter used to capture render time
  81525. */
  81526. get renderTimeCounter(): BABYLON.PerfCounter;
  81527. /**
  81528. * Gets the perf counter used to capture layout time
  81529. */
  81530. get layoutTimeCounter(): BABYLON.PerfCounter;
  81531. /**
  81532. * Enable or disable the render time capture
  81533. */
  81534. get captureRenderTime(): boolean;
  81535. set captureRenderTime(value: boolean);
  81536. /**
  81537. * Enable or disable the layout time capture
  81538. */
  81539. get captureLayoutTime(): boolean;
  81540. set captureLayoutTime(value: boolean);
  81541. /**
  81542. * Instantiates a new advanced dynamic texture instrumentation.
  81543. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  81544. * @param texture Defines the AdvancedDynamicTexture to instrument
  81545. */
  81546. constructor(
  81547. /**
  81548. * Define the instrumented AdvancedDynamicTexture.
  81549. */
  81550. texture: AdvancedDynamicTexture);
  81551. /**
  81552. * Dispose and release associated resources.
  81553. */
  81554. dispose(): void;
  81555. }
  81556. }
  81557. declare module BABYLON.GUI {
  81558. /**
  81559. * Class used to load GUI via XML.
  81560. */
  81561. export class XmlLoader {
  81562. private _nodes;
  81563. private _nodeTypes;
  81564. private _isLoaded;
  81565. private _objectAttributes;
  81566. private _parentClass;
  81567. /**
  81568. * Create a new xml loader
  81569. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  81570. */
  81571. constructor(parentClass?: null);
  81572. private _getChainElement;
  81573. private _getClassAttribute;
  81574. private _createGuiElement;
  81575. private _parseGrid;
  81576. private _parseElement;
  81577. private _prepareSourceElement;
  81578. private _parseElementsFromSource;
  81579. private _parseXml;
  81580. /**
  81581. * Gets if the loading has finished.
  81582. * @returns whether the loading has finished or not
  81583. */
  81584. isLoaded(): boolean;
  81585. /**
  81586. * Gets a loaded node / control by id.
  81587. * @param id the Controls id set in the xml
  81588. * @returns element of type Control
  81589. */
  81590. getNodeById(id: string): any;
  81591. /**
  81592. * Gets all loaded nodes / controls
  81593. * @returns Array of controls
  81594. */
  81595. getNodes(): any;
  81596. /**
  81597. * Initiates the xml layout loading
  81598. * @param xmlFile defines the xml layout to load
  81599. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  81600. * @param callback defines the callback called on layout load.
  81601. */
  81602. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  81603. }
  81604. }
  81605. declare module BABYLON.GUI {
  81606. /**
  81607. * Class used to create containers for controls
  81608. */
  81609. export class Container3D extends Control3D {
  81610. private _blockLayout;
  81611. /**
  81612. * Gets the list of child controls
  81613. */
  81614. protected _children: Control3D[];
  81615. /**
  81616. * Gets the list of child controls
  81617. */
  81618. get children(): Array<Control3D>;
  81619. /**
  81620. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  81621. * This is helpful to optimize layout operation when adding multiple children in a row
  81622. */
  81623. get blockLayout(): boolean;
  81624. set blockLayout(value: boolean);
  81625. /**
  81626. * Creates a new container
  81627. * @param name defines the container name
  81628. */
  81629. constructor(name?: string);
  81630. /**
  81631. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  81632. * @returns the current container
  81633. */
  81634. updateLayout(): Container3D;
  81635. /**
  81636. * Gets a boolean indicating if the given control is in the children of this control
  81637. * @param control defines the control to check
  81638. * @returns true if the control is in the child list
  81639. */
  81640. containsControl(control: Control3D): boolean;
  81641. /**
  81642. * Adds a control to the children of this control
  81643. * @param control defines the control to add
  81644. * @returns the current container
  81645. */
  81646. addControl(control: Control3D): Container3D;
  81647. /**
  81648. * This function will be called everytime a new control is added
  81649. */
  81650. protected _arrangeChildren(): void;
  81651. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81652. /**
  81653. * Removes a control from the children of this control
  81654. * @param control defines the control to remove
  81655. * @returns the current container
  81656. */
  81657. removeControl(control: Control3D): Container3D;
  81658. protected _getTypeName(): string;
  81659. /**
  81660. * Releases all associated resources
  81661. */
  81662. dispose(): void;
  81663. /** Control rotation will remain unchanged */
  81664. static readonly UNSET_ORIENTATION: number;
  81665. /** Control will rotate to make it look at sphere central axis */
  81666. static readonly FACEORIGIN_ORIENTATION: number;
  81667. /** Control will rotate to make it look back at sphere central axis */
  81668. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  81669. /** Control will rotate to look at z axis (0, 0, 1) */
  81670. static readonly FACEFORWARD_ORIENTATION: number;
  81671. /** Control will rotate to look at negative z axis (0, 0, -1) */
  81672. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  81673. }
  81674. }
  81675. declare module BABYLON.GUI {
  81676. /**
  81677. * Class used to manage 3D user interface
  81678. * @see https://doc.babylonjs.com/how_to/gui3d
  81679. */
  81680. export class GUI3DManager implements BABYLON.IDisposable {
  81681. private _scene;
  81682. private _sceneDisposeObserver;
  81683. private _utilityLayer;
  81684. private _rootContainer;
  81685. private _pointerObserver;
  81686. private _pointerOutObserver;
  81687. /** @hidden */
  81688. _lastPickedControl: Control3D;
  81689. /** @hidden */
  81690. _lastControlOver: {
  81691. [pointerId: number]: Control3D;
  81692. };
  81693. /** @hidden */
  81694. _lastControlDown: {
  81695. [pointerId: number]: Control3D;
  81696. };
  81697. /**
  81698. * BABYLON.Observable raised when the point picked by the pointer events changed
  81699. */
  81700. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  81701. /** @hidden */
  81702. _sharedMaterials: {
  81703. [key: string]: BABYLON.Material;
  81704. };
  81705. /** Gets the hosting scene */
  81706. get scene(): BABYLON.Scene;
  81707. /** Gets associated utility layer */
  81708. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  81709. /**
  81710. * Creates a new GUI3DManager
  81711. * @param scene
  81712. */
  81713. constructor(scene?: BABYLON.Scene);
  81714. private _handlePointerOut;
  81715. private _doPicking;
  81716. /**
  81717. * Gets the root container
  81718. */
  81719. get rootContainer(): Container3D;
  81720. /**
  81721. * Gets a boolean indicating if the given control is in the root child list
  81722. * @param control defines the control to check
  81723. * @returns true if the control is in the root child list
  81724. */
  81725. containsControl(control: Control3D): boolean;
  81726. /**
  81727. * Adds a control to the root child list
  81728. * @param control defines the control to add
  81729. * @returns the current manager
  81730. */
  81731. addControl(control: Control3D): GUI3DManager;
  81732. /**
  81733. * Removes a control from the root child list
  81734. * @param control defines the control to remove
  81735. * @returns the current container
  81736. */
  81737. removeControl(control: Control3D): GUI3DManager;
  81738. /**
  81739. * Releases all associated resources
  81740. */
  81741. dispose(): void;
  81742. }
  81743. }
  81744. declare module BABYLON.GUI {
  81745. /**
  81746. * Class used to transport BABYLON.Vector3 information for pointer events
  81747. */
  81748. export class Vector3WithInfo extends BABYLON.Vector3 {
  81749. /** defines the current mouse button index */
  81750. buttonIndex: number;
  81751. /**
  81752. * Creates a new Vector3WithInfo
  81753. * @param source defines the vector3 data to transport
  81754. * @param buttonIndex defines the current mouse button index
  81755. */
  81756. constructor(source: BABYLON.Vector3,
  81757. /** defines the current mouse button index */
  81758. buttonIndex?: number);
  81759. }
  81760. }
  81761. declare module BABYLON.GUI {
  81762. /**
  81763. * Class used as base class for controls
  81764. */
  81765. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  81766. /** Defines the control name */
  81767. name?: string | undefined;
  81768. /** @hidden */
  81769. _host: GUI3DManager;
  81770. private _node;
  81771. private _downCount;
  81772. private _enterCount;
  81773. private _downPointerIds;
  81774. private _isVisible;
  81775. /** Gets or sets the control position in world space */
  81776. get position(): BABYLON.Vector3;
  81777. set position(value: BABYLON.Vector3);
  81778. /** Gets or sets the control scaling in world space */
  81779. get scaling(): BABYLON.Vector3;
  81780. set scaling(value: BABYLON.Vector3);
  81781. /** Callback used to start pointer enter animation */
  81782. pointerEnterAnimation: () => void;
  81783. /** Callback used to start pointer out animation */
  81784. pointerOutAnimation: () => void;
  81785. /** Callback used to start pointer down animation */
  81786. pointerDownAnimation: () => void;
  81787. /** Callback used to start pointer up animation */
  81788. pointerUpAnimation: () => void;
  81789. /**
  81790. * An event triggered when the pointer move over the control
  81791. */
  81792. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  81793. /**
  81794. * An event triggered when the pointer move out of the control
  81795. */
  81796. onPointerOutObservable: BABYLON.Observable<Control3D>;
  81797. /**
  81798. * An event triggered when the pointer taps the control
  81799. */
  81800. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  81801. /**
  81802. * An event triggered when pointer is up
  81803. */
  81804. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  81805. /**
  81806. * An event triggered when a control is clicked on (with a mouse)
  81807. */
  81808. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  81809. /**
  81810. * An event triggered when pointer enters the control
  81811. */
  81812. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  81813. /**
  81814. * Gets or sets the parent container
  81815. */
  81816. parent: BABYLON.Nullable<Container3D>;
  81817. private _behaviors;
  81818. /**
  81819. * Gets the list of attached behaviors
  81820. * @see https://doc.babylonjs.com/features/behaviour
  81821. */
  81822. get behaviors(): BABYLON.Behavior<Control3D>[];
  81823. /**
  81824. * Attach a behavior to the control
  81825. * @see https://doc.babylonjs.com/features/behaviour
  81826. * @param behavior defines the behavior to attach
  81827. * @returns the current control
  81828. */
  81829. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81830. /**
  81831. * Remove an attached behavior
  81832. * @see https://doc.babylonjs.com/features/behaviour
  81833. * @param behavior defines the behavior to attach
  81834. * @returns the current control
  81835. */
  81836. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  81837. /**
  81838. * Gets an attached behavior by name
  81839. * @param name defines the name of the behavior to look for
  81840. * @see https://doc.babylonjs.com/features/behaviour
  81841. * @returns null if behavior was not found else the requested behavior
  81842. */
  81843. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  81844. /** Gets or sets a boolean indicating if the control is visible */
  81845. get isVisible(): boolean;
  81846. set isVisible(value: boolean);
  81847. /**
  81848. * Creates a new control
  81849. * @param name defines the control name
  81850. */
  81851. constructor(
  81852. /** Defines the control name */
  81853. name?: string | undefined);
  81854. /**
  81855. * Gets a string representing the class name
  81856. */
  81857. get typeName(): string;
  81858. /**
  81859. * Get the current class name of the control.
  81860. * @returns current class name
  81861. */
  81862. getClassName(): string;
  81863. protected _getTypeName(): string;
  81864. /**
  81865. * Gets the transform node used by this control
  81866. */
  81867. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  81868. /**
  81869. * Gets the mesh used to render this control
  81870. */
  81871. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  81872. /**
  81873. * Link the control as child of the given node
  81874. * @param node defines the node to link to. Use null to unlink the control
  81875. * @returns the current control
  81876. */
  81877. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  81878. /** @hidden **/
  81879. _prepareNode(scene: BABYLON.Scene): void;
  81880. /**
  81881. * Node creation.
  81882. * Can be overriden by children
  81883. * @param scene defines the scene where the node must be attached
  81884. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  81885. */
  81886. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  81887. /**
  81888. * Affect a material to the given mesh
  81889. * @param mesh defines the mesh which will represent the control
  81890. */
  81891. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81892. /** @hidden */
  81893. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  81894. /** @hidden */
  81895. _onPointerEnter(target: Control3D): boolean;
  81896. /** @hidden */
  81897. _onPointerOut(target: Control3D): void;
  81898. /** @hidden */
  81899. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81900. /** @hidden */
  81901. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  81902. /** @hidden */
  81903. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  81904. /** @hidden */
  81905. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  81906. /** @hidden */
  81907. _disposeNode(): void;
  81908. /**
  81909. * Releases all associated resources
  81910. */
  81911. dispose(): void;
  81912. }
  81913. }
  81914. declare module BABYLON.GUI {
  81915. /**
  81916. * Class used as a root to all buttons
  81917. */
  81918. export class AbstractButton3D extends Control3D {
  81919. /**
  81920. * Creates a new button
  81921. * @param name defines the control name
  81922. */
  81923. constructor(name?: string);
  81924. protected _getTypeName(): string;
  81925. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81926. }
  81927. }
  81928. declare module BABYLON.GUI {
  81929. /**
  81930. * Class used to create a button in 3D
  81931. */
  81932. export class Button3D extends AbstractButton3D {
  81933. /** @hidden */
  81934. protected _currentMaterial: BABYLON.Material;
  81935. private _facadeTexture;
  81936. private _content;
  81937. private _contentResolution;
  81938. private _contentScaleRatio;
  81939. /**
  81940. * Gets or sets the texture resolution used to render content (512 by default)
  81941. */
  81942. get contentResolution(): BABYLON.int;
  81943. set contentResolution(value: BABYLON.int);
  81944. /**
  81945. * Gets or sets the texture scale ratio used to render content (2 by default)
  81946. */
  81947. get contentScaleRatio(): number;
  81948. set contentScaleRatio(value: number);
  81949. protected _disposeFacadeTexture(): void;
  81950. protected _resetContent(): void;
  81951. /**
  81952. * Creates a new button
  81953. * @param name defines the control name
  81954. */
  81955. constructor(name?: string);
  81956. /**
  81957. * Gets or sets the GUI 2D content used to display the button's facade
  81958. */
  81959. get content(): Control;
  81960. set content(value: Control);
  81961. /**
  81962. * Apply the facade texture (created from the content property).
  81963. * This function can be overloaded by child classes
  81964. * @param facadeTexture defines the AdvancedDynamicTexture to use
  81965. */
  81966. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  81967. protected _getTypeName(): string;
  81968. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81969. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81970. /**
  81971. * Releases all associated resources
  81972. */
  81973. dispose(): void;
  81974. }
  81975. }
  81976. declare module BABYLON.GUI {
  81977. /**
  81978. * Abstract class used to create a container panel deployed on the surface of a volume
  81979. */
  81980. export abstract class VolumeBasedPanel extends Container3D {
  81981. private _columns;
  81982. private _rows;
  81983. private _rowThenColum;
  81984. private _orientation;
  81985. protected _cellWidth: number;
  81986. protected _cellHeight: number;
  81987. /**
  81988. * Gets or sets the distance between elements
  81989. */
  81990. margin: number;
  81991. /**
  81992. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  81993. * | Value | Type | Description |
  81994. * | ----- | ----------------------------------- | ----------- |
  81995. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  81996. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  81997. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  81998. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  81999. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  82000. */
  82001. get orientation(): number;
  82002. set orientation(value: number);
  82003. /**
  82004. * Gets or sets the number of columns requested (10 by default).
  82005. * The panel will automatically compute the number of rows based on number of child controls.
  82006. */
  82007. get columns(): BABYLON.int;
  82008. set columns(value: BABYLON.int);
  82009. /**
  82010. * Gets or sets a the number of rows requested.
  82011. * The panel will automatically compute the number of columns based on number of child controls.
  82012. */
  82013. get rows(): BABYLON.int;
  82014. set rows(value: BABYLON.int);
  82015. /**
  82016. * Creates new VolumeBasedPanel
  82017. */
  82018. constructor();
  82019. protected _arrangeChildren(): void;
  82020. /** Child classes must implement this function to provide correct control positioning */
  82021. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82022. /** Child classes can implement this function to provide additional processing */
  82023. protected _finalProcessing(): void;
  82024. }
  82025. }
  82026. declare module BABYLON.GUI {
  82027. /**
  82028. * Class used to create a container panel deployed on the surface of a cylinder
  82029. */
  82030. export class CylinderPanel extends VolumeBasedPanel {
  82031. private _radius;
  82032. /**
  82033. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  82034. */
  82035. get radius(): BABYLON.float;
  82036. set radius(value: BABYLON.float);
  82037. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82038. private _cylindricalMapping;
  82039. }
  82040. }
  82041. declare module BABYLON.GUI {
  82042. /** @hidden */
  82043. export var fluentVertexShader: {
  82044. name: string;
  82045. shader: string;
  82046. };
  82047. }
  82048. declare module BABYLON.GUI {
  82049. /** @hidden */
  82050. export var fluentPixelShader: {
  82051. name: string;
  82052. shader: string;
  82053. };
  82054. }
  82055. declare module BABYLON.GUI {
  82056. /** @hidden */
  82057. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  82058. INNERGLOW: boolean;
  82059. BORDER: boolean;
  82060. HOVERLIGHT: boolean;
  82061. TEXTURE: boolean;
  82062. constructor();
  82063. }
  82064. /**
  82065. * Class used to render controls with fluent desgin
  82066. */
  82067. export class FluentMaterial extends BABYLON.PushMaterial {
  82068. /**
  82069. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  82070. */
  82071. innerGlowColorIntensity: number;
  82072. /**
  82073. * Gets or sets the inner glow color (white by default)
  82074. */
  82075. innerGlowColor: BABYLON.Color3;
  82076. /**
  82077. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  82078. */
  82079. albedoColor: BABYLON.Color3;
  82080. /**
  82081. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  82082. */
  82083. renderBorders: boolean;
  82084. /**
  82085. * Gets or sets border width (default is 0.5)
  82086. */
  82087. borderWidth: number;
  82088. /**
  82089. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  82090. */
  82091. edgeSmoothingValue: number;
  82092. /**
  82093. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  82094. */
  82095. borderMinValue: number;
  82096. /**
  82097. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  82098. */
  82099. renderHoverLight: boolean;
  82100. /**
  82101. * Gets or sets the radius used to render the hover light (default is 1.0)
  82102. */
  82103. hoverRadius: number;
  82104. /**
  82105. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  82106. */
  82107. hoverColor: BABYLON.Color4;
  82108. /**
  82109. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  82110. */
  82111. hoverPosition: BABYLON.Vector3;
  82112. private _albedoTexture;
  82113. /** Gets or sets the texture to use for albedo color */
  82114. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  82115. /**
  82116. * Creates a new Fluent material
  82117. * @param name defines the name of the material
  82118. * @param scene defines the hosting scene
  82119. */
  82120. constructor(name: string, scene: BABYLON.Scene);
  82121. needAlphaBlending(): boolean;
  82122. needAlphaTesting(): boolean;
  82123. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82124. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82125. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82126. getActiveTextures(): BABYLON.BaseTexture[];
  82127. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82128. dispose(forceDisposeEffect?: boolean): void;
  82129. clone(name: string): FluentMaterial;
  82130. serialize(): any;
  82131. getClassName(): string;
  82132. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  82133. }
  82134. }
  82135. declare module BABYLON.GUI {
  82136. /**
  82137. * Class used to create a holographic button in 3D
  82138. */
  82139. export class HolographicButton extends Button3D {
  82140. private _backPlate;
  82141. private _textPlate;
  82142. private _frontPlate;
  82143. private _text;
  82144. private _imageUrl;
  82145. private _shareMaterials;
  82146. private _frontMaterial;
  82147. private _backMaterial;
  82148. private _plateMaterial;
  82149. private _pickedPointObserver;
  82150. private _tooltipFade;
  82151. private _tooltipTextBlock;
  82152. private _tooltipTexture;
  82153. private _tooltipMesh;
  82154. private _tooltipHoverObserver;
  82155. private _tooltipOutObserver;
  82156. private _disposeTooltip;
  82157. /**
  82158. * Rendering ground id of all the mesh in the button
  82159. */
  82160. set renderingGroupId(id: number);
  82161. get renderingGroupId(): number;
  82162. /**
  82163. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  82164. */
  82165. set tooltipText(text: BABYLON.Nullable<string>);
  82166. get tooltipText(): BABYLON.Nullable<string>;
  82167. /**
  82168. * Gets or sets text for the button
  82169. */
  82170. get text(): string;
  82171. set text(value: string);
  82172. /**
  82173. * Gets or sets the image url for the button
  82174. */
  82175. get imageUrl(): string;
  82176. set imageUrl(value: string);
  82177. /**
  82178. * Gets the back material used by this button
  82179. */
  82180. get backMaterial(): FluentMaterial;
  82181. /**
  82182. * Gets the front material used by this button
  82183. */
  82184. get frontMaterial(): FluentMaterial;
  82185. /**
  82186. * Gets the plate material used by this button
  82187. */
  82188. get plateMaterial(): BABYLON.StandardMaterial;
  82189. /**
  82190. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  82191. */
  82192. get shareMaterials(): boolean;
  82193. /**
  82194. * Creates a new button
  82195. * @param name defines the control name
  82196. */
  82197. constructor(name?: string, shareMaterials?: boolean);
  82198. protected _getTypeName(): string;
  82199. private _rebuildContent;
  82200. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82201. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  82202. private _createBackMaterial;
  82203. private _createFrontMaterial;
  82204. private _createPlateMaterial;
  82205. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  82206. /**
  82207. * Releases all associated resources
  82208. */
  82209. dispose(): void;
  82210. }
  82211. }
  82212. declare module BABYLON.GUI {
  82213. /**
  82214. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  82215. */
  82216. export class MeshButton3D extends Button3D {
  82217. /** @hidden */
  82218. protected _currentMesh: BABYLON.Mesh;
  82219. /**
  82220. * Creates a new 3D button based on a mesh
  82221. * @param mesh mesh to become a 3D button
  82222. * @param name defines the control name
  82223. */
  82224. constructor(mesh: BABYLON.Mesh, name?: string);
  82225. protected _getTypeName(): string;
  82226. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  82227. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  82228. }
  82229. }
  82230. declare module BABYLON.GUI {
  82231. /**
  82232. * Class used to create a container panel deployed on the surface of a plane
  82233. */
  82234. export class PlanePanel extends VolumeBasedPanel {
  82235. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82236. }
  82237. }
  82238. declare module BABYLON.GUI {
  82239. /**
  82240. * Class used to create a container panel where items get randomized planar mapping
  82241. */
  82242. export class ScatterPanel extends VolumeBasedPanel {
  82243. private _iteration;
  82244. /**
  82245. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  82246. */
  82247. get iteration(): BABYLON.float;
  82248. set iteration(value: BABYLON.float);
  82249. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82250. private _scatterMapping;
  82251. protected _finalProcessing(): void;
  82252. }
  82253. }
  82254. declare module BABYLON.GUI {
  82255. /**
  82256. * Class used to create a container panel deployed on the surface of a sphere
  82257. */
  82258. export class SpherePanel extends VolumeBasedPanel {
  82259. private _radius;
  82260. /**
  82261. * Gets or sets the radius of the sphere where to project controls (5 by default)
  82262. */
  82263. get radius(): BABYLON.float;
  82264. set radius(value: BABYLON.float);
  82265. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  82266. private _sphericalMapping;
  82267. }
  82268. }
  82269. declare module BABYLON.GUI {
  82270. /**
  82271. * Class used to create a stack panel in 3D on XY plane
  82272. */
  82273. export class StackPanel3D extends Container3D {
  82274. private _isVertical;
  82275. /**
  82276. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  82277. */
  82278. get isVertical(): boolean;
  82279. set isVertical(value: boolean);
  82280. /**
  82281. * Gets or sets the distance between elements
  82282. */
  82283. margin: number;
  82284. /**
  82285. * Creates new StackPanel
  82286. * @param isVertical
  82287. */
  82288. constructor(isVertical?: boolean);
  82289. protected _arrangeChildren(): void;
  82290. }
  82291. }
  82292. declare module BABYLON {
  82293. /**
  82294. * Configuration for glTF validation
  82295. */
  82296. export interface IGLTFValidationConfiguration {
  82297. /**
  82298. * The url of the glTF validator.
  82299. */
  82300. url: string;
  82301. }
  82302. /**
  82303. * glTF validation
  82304. */
  82305. export class GLTFValidation {
  82306. /**
  82307. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  82308. */
  82309. static Configuration: IGLTFValidationConfiguration;
  82310. private static _LoadScriptPromise;
  82311. /**
  82312. * Validate a glTF asset using the glTF-Validator.
  82313. * @param data The JSON of a glTF or the array buffer of a binary glTF
  82314. * @param rootUrl The root url for the glTF
  82315. * @param fileName The file name for the glTF
  82316. * @param getExternalResource The callback to get external resources for the glTF validator
  82317. * @returns A promise that resolves with the glTF validation results once complete
  82318. */
  82319. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  82320. }
  82321. }
  82322. declare module BABYLON {
  82323. /**
  82324. * Mode that determines the coordinate system to use.
  82325. */
  82326. export enum GLTFLoaderCoordinateSystemMode {
  82327. /**
  82328. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  82329. */
  82330. AUTO = 0,
  82331. /**
  82332. * Sets the useRightHandedSystem flag on the scene.
  82333. */
  82334. FORCE_RIGHT_HANDED = 1
  82335. }
  82336. /**
  82337. * Mode that determines what animations will start.
  82338. */
  82339. export enum GLTFLoaderAnimationStartMode {
  82340. /**
  82341. * No animation will start.
  82342. */
  82343. NONE = 0,
  82344. /**
  82345. * The first animation will start.
  82346. */
  82347. FIRST = 1,
  82348. /**
  82349. * All animations will start.
  82350. */
  82351. ALL = 2
  82352. }
  82353. /**
  82354. * Interface that contains the data for the glTF asset.
  82355. */
  82356. export interface IGLTFLoaderData {
  82357. /**
  82358. * The object that represents the glTF JSON.
  82359. */
  82360. json: Object;
  82361. /**
  82362. * The BIN chunk of a binary glTF.
  82363. */
  82364. bin: Nullable<IDataBuffer>;
  82365. }
  82366. /**
  82367. * Interface for extending the loader.
  82368. */
  82369. export interface IGLTFLoaderExtension {
  82370. /**
  82371. * The name of this extension.
  82372. */
  82373. readonly name: string;
  82374. /**
  82375. * Defines whether this extension is enabled.
  82376. */
  82377. enabled: boolean;
  82378. /**
  82379. * Defines the order of this extension.
  82380. * The loader sorts the extensions using these values when loading.
  82381. */
  82382. order?: number;
  82383. }
  82384. /**
  82385. * Loader state.
  82386. */
  82387. export enum GLTFLoaderState {
  82388. /**
  82389. * The asset is loading.
  82390. */
  82391. LOADING = 0,
  82392. /**
  82393. * The asset is ready for rendering.
  82394. */
  82395. READY = 1,
  82396. /**
  82397. * The asset is completely loaded.
  82398. */
  82399. COMPLETE = 2
  82400. }
  82401. /** @hidden */
  82402. export interface IGLTFLoader extends IDisposable {
  82403. readonly state: Nullable<GLTFLoaderState>;
  82404. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  82405. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  82406. }
  82407. /**
  82408. * File loader for loading glTF files into a scene.
  82409. */
  82410. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  82411. /** @hidden */
  82412. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82413. /** @hidden */
  82414. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  82415. /**
  82416. * Raised when the asset has been parsed
  82417. */
  82418. onParsedObservable: Observable<IGLTFLoaderData>;
  82419. private _onParsedObserver;
  82420. /**
  82421. * Raised when the asset has been parsed
  82422. */
  82423. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  82424. /**
  82425. * 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.
  82426. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  82427. * Defaults to true.
  82428. * @hidden
  82429. */
  82430. static IncrementalLoading: boolean;
  82431. /**
  82432. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  82433. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  82434. * @hidden
  82435. */
  82436. static HomogeneousCoordinates: boolean;
  82437. /**
  82438. * The coordinate system mode. Defaults to AUTO.
  82439. */
  82440. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  82441. /**
  82442. * The animation start mode. Defaults to FIRST.
  82443. */
  82444. animationStartMode: GLTFLoaderAnimationStartMode;
  82445. /**
  82446. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  82447. */
  82448. compileMaterials: boolean;
  82449. /**
  82450. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  82451. */
  82452. useClipPlane: boolean;
  82453. /**
  82454. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  82455. */
  82456. compileShadowGenerators: boolean;
  82457. /**
  82458. * Defines if the Alpha blended materials are only applied as coverage.
  82459. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  82460. * If true, no extra effects are applied to transparent pixels.
  82461. */
  82462. transparencyAsCoverage: boolean;
  82463. /**
  82464. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  82465. * Enabling will disable offline support and glTF validator.
  82466. * Defaults to false.
  82467. */
  82468. useRangeRequests: boolean;
  82469. /**
  82470. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  82471. */
  82472. createInstances: boolean;
  82473. /**
  82474. * 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.
  82475. */
  82476. alwaysComputeBoundingBox: boolean;
  82477. /**
  82478. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  82479. */
  82480. loadAllMaterials: boolean;
  82481. /**
  82482. * Function called before loading a url referenced by the asset.
  82483. */
  82484. preprocessUrlAsync: (url: string) => Promise<string>;
  82485. /**
  82486. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82487. * 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, ...)
  82488. */
  82489. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  82490. private _onMeshLoadedObserver;
  82491. /**
  82492. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  82493. * 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, ...)
  82494. */
  82495. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  82496. /**
  82497. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  82498. */
  82499. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  82500. private _onTextureLoadedObserver;
  82501. /**
  82502. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  82503. */
  82504. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  82505. /**
  82506. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  82507. */
  82508. readonly onMaterialLoadedObservable: Observable<Material>;
  82509. private _onMaterialLoadedObserver;
  82510. /**
  82511. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  82512. */
  82513. set onMaterialLoaded(callback: (material: Material) => void);
  82514. /**
  82515. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  82516. */
  82517. readonly onCameraLoadedObservable: Observable<Camera>;
  82518. private _onCameraLoadedObserver;
  82519. /**
  82520. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  82521. */
  82522. set onCameraLoaded(callback: (camera: Camera) => void);
  82523. /**
  82524. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  82525. * For assets with LODs, raised when all of the LODs are complete.
  82526. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82527. */
  82528. readonly onCompleteObservable: Observable<void>;
  82529. private _onCompleteObserver;
  82530. /**
  82531. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  82532. * For assets with LODs, raised when all of the LODs are complete.
  82533. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  82534. */
  82535. set onComplete(callback: () => void);
  82536. /**
  82537. * Observable raised when an error occurs.
  82538. */
  82539. readonly onErrorObservable: Observable<any>;
  82540. private _onErrorObserver;
  82541. /**
  82542. * Callback raised when an error occurs.
  82543. */
  82544. set onError(callback: (reason: any) => void);
  82545. /**
  82546. * Observable raised after the loader is disposed.
  82547. */
  82548. readonly onDisposeObservable: Observable<void>;
  82549. private _onDisposeObserver;
  82550. /**
  82551. * Callback raised after the loader is disposed.
  82552. */
  82553. set onDispose(callback: () => void);
  82554. /**
  82555. * Observable raised after a loader extension is created.
  82556. * Set additional options for a loader extension in this event.
  82557. */
  82558. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  82559. private _onExtensionLoadedObserver;
  82560. /**
  82561. * Callback raised after a loader extension is created.
  82562. */
  82563. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  82564. /**
  82565. * Defines if the loader logging is enabled.
  82566. */
  82567. get loggingEnabled(): boolean;
  82568. set loggingEnabled(value: boolean);
  82569. /**
  82570. * Defines if the loader should capture performance counters.
  82571. */
  82572. get capturePerformanceCounters(): boolean;
  82573. set capturePerformanceCounters(value: boolean);
  82574. /**
  82575. * Defines if the loader should validate the asset.
  82576. */
  82577. validate: boolean;
  82578. /**
  82579. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  82580. */
  82581. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  82582. private _onValidatedObserver;
  82583. /**
  82584. * Callback raised after a loader extension is created.
  82585. */
  82586. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  82587. private _loader;
  82588. private _progressCallback?;
  82589. private _requests;
  82590. private static magicBase64Encoded;
  82591. /**
  82592. * Name of the loader ("gltf")
  82593. */
  82594. name: string;
  82595. /** @hidden */
  82596. extensions: ISceneLoaderPluginExtensions;
  82597. /**
  82598. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  82599. */
  82600. dispose(): void;
  82601. /** @hidden */
  82602. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82603. /** @hidden */
  82604. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  82605. /** @hidden */
  82606. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  82607. /** @hidden */
  82608. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82609. /** @hidden */
  82610. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  82611. /** @hidden */
  82612. canDirectLoad(data: string): boolean;
  82613. /** @hidden */
  82614. directLoad(scene: Scene, data: string): Promise<any>;
  82615. /**
  82616. * The callback that allows custom handling of the root url based on the response url.
  82617. * @param rootUrl the original root url
  82618. * @param responseURL the response url if available
  82619. * @returns the new root url
  82620. */
  82621. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  82622. /** @hidden */
  82623. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  82624. /**
  82625. * The loader state or null if the loader is not active.
  82626. */
  82627. get loaderState(): Nullable<GLTFLoaderState>;
  82628. /**
  82629. * Returns a promise that resolves when the asset is completely loaded.
  82630. * @returns a promise that resolves when the asset is completely loaded.
  82631. */
  82632. whenCompleteAsync(): Promise<void>;
  82633. /** @hidden */
  82634. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  82635. /** @hidden */
  82636. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  82637. private _onProgress;
  82638. private _validate;
  82639. private _getLoader;
  82640. private _parseJson;
  82641. private _unpackBinaryAsync;
  82642. private _unpackBinaryV1Async;
  82643. private _unpackBinaryV2Async;
  82644. private static _parseVersion;
  82645. private static _compareVersion;
  82646. private static readonly _logSpaces;
  82647. private _logIndentLevel;
  82648. private _loggingEnabled;
  82649. /** @hidden */
  82650. _log: (message: string) => void;
  82651. /** @hidden */
  82652. _logOpen(message: string): void;
  82653. /** @hidden */
  82654. _logClose(): void;
  82655. private _logEnabled;
  82656. private _logDisabled;
  82657. private _capturePerformanceCounters;
  82658. /** @hidden */
  82659. _startPerformanceCounter: (counterName: string) => void;
  82660. /** @hidden */
  82661. _endPerformanceCounter: (counterName: string) => void;
  82662. private _startPerformanceCounterEnabled;
  82663. private _startPerformanceCounterDisabled;
  82664. private _endPerformanceCounterEnabled;
  82665. private _endPerformanceCounterDisabled;
  82666. }
  82667. }
  82668. declare module BABYLON.GLTF1 {
  82669. /**
  82670. * Enums
  82671. * @hidden
  82672. */
  82673. export enum EComponentType {
  82674. BYTE = 5120,
  82675. UNSIGNED_BYTE = 5121,
  82676. SHORT = 5122,
  82677. UNSIGNED_SHORT = 5123,
  82678. FLOAT = 5126
  82679. }
  82680. /** @hidden */
  82681. export enum EShaderType {
  82682. FRAGMENT = 35632,
  82683. VERTEX = 35633
  82684. }
  82685. /** @hidden */
  82686. export enum EParameterType {
  82687. BYTE = 5120,
  82688. UNSIGNED_BYTE = 5121,
  82689. SHORT = 5122,
  82690. UNSIGNED_SHORT = 5123,
  82691. INT = 5124,
  82692. UNSIGNED_INT = 5125,
  82693. FLOAT = 5126,
  82694. FLOAT_VEC2 = 35664,
  82695. FLOAT_VEC3 = 35665,
  82696. FLOAT_VEC4 = 35666,
  82697. INT_VEC2 = 35667,
  82698. INT_VEC3 = 35668,
  82699. INT_VEC4 = 35669,
  82700. BOOL = 35670,
  82701. BOOL_VEC2 = 35671,
  82702. BOOL_VEC3 = 35672,
  82703. BOOL_VEC4 = 35673,
  82704. FLOAT_MAT2 = 35674,
  82705. FLOAT_MAT3 = 35675,
  82706. FLOAT_MAT4 = 35676,
  82707. SAMPLER_2D = 35678
  82708. }
  82709. /** @hidden */
  82710. export enum ETextureWrapMode {
  82711. CLAMP_TO_EDGE = 33071,
  82712. MIRRORED_REPEAT = 33648,
  82713. REPEAT = 10497
  82714. }
  82715. /** @hidden */
  82716. export enum ETextureFilterType {
  82717. NEAREST = 9728,
  82718. LINEAR = 9728,
  82719. NEAREST_MIPMAP_NEAREST = 9984,
  82720. LINEAR_MIPMAP_NEAREST = 9985,
  82721. NEAREST_MIPMAP_LINEAR = 9986,
  82722. LINEAR_MIPMAP_LINEAR = 9987
  82723. }
  82724. /** @hidden */
  82725. export enum ETextureFormat {
  82726. ALPHA = 6406,
  82727. RGB = 6407,
  82728. RGBA = 6408,
  82729. LUMINANCE = 6409,
  82730. LUMINANCE_ALPHA = 6410
  82731. }
  82732. /** @hidden */
  82733. export enum ECullingType {
  82734. FRONT = 1028,
  82735. BACK = 1029,
  82736. FRONT_AND_BACK = 1032
  82737. }
  82738. /** @hidden */
  82739. export enum EBlendingFunction {
  82740. ZERO = 0,
  82741. ONE = 1,
  82742. SRC_COLOR = 768,
  82743. ONE_MINUS_SRC_COLOR = 769,
  82744. DST_COLOR = 774,
  82745. ONE_MINUS_DST_COLOR = 775,
  82746. SRC_ALPHA = 770,
  82747. ONE_MINUS_SRC_ALPHA = 771,
  82748. DST_ALPHA = 772,
  82749. ONE_MINUS_DST_ALPHA = 773,
  82750. CONSTANT_COLOR = 32769,
  82751. ONE_MINUS_CONSTANT_COLOR = 32770,
  82752. CONSTANT_ALPHA = 32771,
  82753. ONE_MINUS_CONSTANT_ALPHA = 32772,
  82754. SRC_ALPHA_SATURATE = 776
  82755. }
  82756. /** @hidden */
  82757. export interface IGLTFProperty {
  82758. extensions?: {
  82759. [key: string]: any;
  82760. };
  82761. extras?: Object;
  82762. }
  82763. /** @hidden */
  82764. export interface IGLTFChildRootProperty extends IGLTFProperty {
  82765. name?: string;
  82766. }
  82767. /** @hidden */
  82768. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  82769. bufferView: string;
  82770. byteOffset: number;
  82771. byteStride: number;
  82772. count: number;
  82773. type: string;
  82774. componentType: EComponentType;
  82775. max?: number[];
  82776. min?: number[];
  82777. name?: string;
  82778. }
  82779. /** @hidden */
  82780. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  82781. buffer: string;
  82782. byteOffset: number;
  82783. byteLength: number;
  82784. byteStride: number;
  82785. target?: number;
  82786. }
  82787. /** @hidden */
  82788. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  82789. uri: string;
  82790. byteLength?: number;
  82791. type?: string;
  82792. }
  82793. /** @hidden */
  82794. export interface IGLTFShader extends IGLTFChildRootProperty {
  82795. uri: string;
  82796. type: EShaderType;
  82797. }
  82798. /** @hidden */
  82799. export interface IGLTFProgram extends IGLTFChildRootProperty {
  82800. attributes: string[];
  82801. fragmentShader: string;
  82802. vertexShader: string;
  82803. }
  82804. /** @hidden */
  82805. export interface IGLTFTechniqueParameter {
  82806. type: number;
  82807. count?: number;
  82808. semantic?: string;
  82809. node?: string;
  82810. value?: number | boolean | string | Array<any>;
  82811. source?: string;
  82812. babylonValue?: any;
  82813. }
  82814. /** @hidden */
  82815. export interface IGLTFTechniqueCommonProfile {
  82816. lightingModel: string;
  82817. texcoordBindings: Object;
  82818. parameters?: Array<any>;
  82819. }
  82820. /** @hidden */
  82821. export interface IGLTFTechniqueStatesFunctions {
  82822. blendColor?: number[];
  82823. blendEquationSeparate?: number[];
  82824. blendFuncSeparate?: number[];
  82825. colorMask: boolean[];
  82826. cullFace: number[];
  82827. }
  82828. /** @hidden */
  82829. export interface IGLTFTechniqueStates {
  82830. enable: number[];
  82831. functions: IGLTFTechniqueStatesFunctions;
  82832. }
  82833. /** @hidden */
  82834. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  82835. parameters: {
  82836. [key: string]: IGLTFTechniqueParameter;
  82837. };
  82838. program: string;
  82839. attributes: {
  82840. [key: string]: string;
  82841. };
  82842. uniforms: {
  82843. [key: string]: string;
  82844. };
  82845. states: IGLTFTechniqueStates;
  82846. }
  82847. /** @hidden */
  82848. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  82849. technique?: string;
  82850. values: string[];
  82851. }
  82852. /** @hidden */
  82853. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  82854. attributes: {
  82855. [key: string]: string;
  82856. };
  82857. indices: string;
  82858. material: string;
  82859. mode?: number;
  82860. }
  82861. /** @hidden */
  82862. export interface IGLTFMesh extends IGLTFChildRootProperty {
  82863. primitives: IGLTFMeshPrimitive[];
  82864. }
  82865. /** @hidden */
  82866. export interface IGLTFImage extends IGLTFChildRootProperty {
  82867. uri: string;
  82868. }
  82869. /** @hidden */
  82870. export interface IGLTFSampler extends IGLTFChildRootProperty {
  82871. magFilter?: number;
  82872. minFilter?: number;
  82873. wrapS?: number;
  82874. wrapT?: number;
  82875. }
  82876. /** @hidden */
  82877. export interface IGLTFTexture extends IGLTFChildRootProperty {
  82878. sampler: string;
  82879. source: string;
  82880. format?: ETextureFormat;
  82881. internalFormat?: ETextureFormat;
  82882. target?: number;
  82883. type?: number;
  82884. babylonTexture?: Texture;
  82885. }
  82886. /** @hidden */
  82887. export interface IGLTFAmbienLight {
  82888. color?: number[];
  82889. }
  82890. /** @hidden */
  82891. export interface IGLTFDirectionalLight {
  82892. color?: number[];
  82893. }
  82894. /** @hidden */
  82895. export interface IGLTFPointLight {
  82896. color?: number[];
  82897. constantAttenuation?: number;
  82898. linearAttenuation?: number;
  82899. quadraticAttenuation?: number;
  82900. }
  82901. /** @hidden */
  82902. export interface IGLTFSpotLight {
  82903. color?: number[];
  82904. constantAttenuation?: number;
  82905. fallOfAngle?: number;
  82906. fallOffExponent?: number;
  82907. linearAttenuation?: number;
  82908. quadraticAttenuation?: number;
  82909. }
  82910. /** @hidden */
  82911. export interface IGLTFLight extends IGLTFChildRootProperty {
  82912. type: string;
  82913. }
  82914. /** @hidden */
  82915. export interface IGLTFCameraOrthographic {
  82916. xmag: number;
  82917. ymag: number;
  82918. zfar: number;
  82919. znear: number;
  82920. }
  82921. /** @hidden */
  82922. export interface IGLTFCameraPerspective {
  82923. aspectRatio: number;
  82924. yfov: number;
  82925. zfar: number;
  82926. znear: number;
  82927. }
  82928. /** @hidden */
  82929. export interface IGLTFCamera extends IGLTFChildRootProperty {
  82930. type: string;
  82931. }
  82932. /** @hidden */
  82933. export interface IGLTFAnimationChannelTarget {
  82934. id: string;
  82935. path: string;
  82936. }
  82937. /** @hidden */
  82938. export interface IGLTFAnimationChannel {
  82939. sampler: string;
  82940. target: IGLTFAnimationChannelTarget;
  82941. }
  82942. /** @hidden */
  82943. export interface IGLTFAnimationSampler {
  82944. input: string;
  82945. output: string;
  82946. interpolation?: string;
  82947. }
  82948. /** @hidden */
  82949. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  82950. channels?: IGLTFAnimationChannel[];
  82951. parameters?: {
  82952. [key: string]: string;
  82953. };
  82954. samplers?: {
  82955. [key: string]: IGLTFAnimationSampler;
  82956. };
  82957. }
  82958. /** @hidden */
  82959. export interface IGLTFNodeInstanceSkin {
  82960. skeletons: string[];
  82961. skin: string;
  82962. meshes: string[];
  82963. }
  82964. /** @hidden */
  82965. export interface IGLTFSkins extends IGLTFChildRootProperty {
  82966. bindShapeMatrix: number[];
  82967. inverseBindMatrices: string;
  82968. jointNames: string[];
  82969. babylonSkeleton?: Skeleton;
  82970. }
  82971. /** @hidden */
  82972. export interface IGLTFNode extends IGLTFChildRootProperty {
  82973. camera?: string;
  82974. children: string[];
  82975. skin?: string;
  82976. jointName?: string;
  82977. light?: string;
  82978. matrix: number[];
  82979. mesh?: string;
  82980. meshes?: string[];
  82981. rotation?: number[];
  82982. scale?: number[];
  82983. translation?: number[];
  82984. babylonNode?: Node;
  82985. }
  82986. /** @hidden */
  82987. export interface IGLTFScene extends IGLTFChildRootProperty {
  82988. nodes: string[];
  82989. }
  82990. /** @hidden */
  82991. export interface IGLTFRuntime {
  82992. extensions: {
  82993. [key: string]: any;
  82994. };
  82995. accessors: {
  82996. [key: string]: IGLTFAccessor;
  82997. };
  82998. buffers: {
  82999. [key: string]: IGLTFBuffer;
  83000. };
  83001. bufferViews: {
  83002. [key: string]: IGLTFBufferView;
  83003. };
  83004. meshes: {
  83005. [key: string]: IGLTFMesh;
  83006. };
  83007. lights: {
  83008. [key: string]: IGLTFLight;
  83009. };
  83010. cameras: {
  83011. [key: string]: IGLTFCamera;
  83012. };
  83013. nodes: {
  83014. [key: string]: IGLTFNode;
  83015. };
  83016. images: {
  83017. [key: string]: IGLTFImage;
  83018. };
  83019. textures: {
  83020. [key: string]: IGLTFTexture;
  83021. };
  83022. shaders: {
  83023. [key: string]: IGLTFShader;
  83024. };
  83025. programs: {
  83026. [key: string]: IGLTFProgram;
  83027. };
  83028. samplers: {
  83029. [key: string]: IGLTFSampler;
  83030. };
  83031. techniques: {
  83032. [key: string]: IGLTFTechnique;
  83033. };
  83034. materials: {
  83035. [key: string]: IGLTFMaterial;
  83036. };
  83037. animations: {
  83038. [key: string]: IGLTFAnimation;
  83039. };
  83040. skins: {
  83041. [key: string]: IGLTFSkins;
  83042. };
  83043. currentScene?: Object;
  83044. scenes: {
  83045. [key: string]: IGLTFScene;
  83046. };
  83047. extensionsUsed: string[];
  83048. extensionsRequired?: string[];
  83049. buffersCount: number;
  83050. shaderscount: number;
  83051. scene: Scene;
  83052. rootUrl: string;
  83053. loadedBufferCount: number;
  83054. loadedBufferViews: {
  83055. [name: string]: ArrayBufferView;
  83056. };
  83057. loadedShaderCount: number;
  83058. importOnlyMeshes: boolean;
  83059. importMeshesNames?: string[];
  83060. dummyNodes: Node[];
  83061. forAssetContainer: boolean;
  83062. }
  83063. /** @hidden */
  83064. export interface INodeToRoot {
  83065. bone: Bone;
  83066. node: IGLTFNode;
  83067. id: string;
  83068. }
  83069. /** @hidden */
  83070. export interface IJointNode {
  83071. node: IGLTFNode;
  83072. id: string;
  83073. }
  83074. }
  83075. declare module BABYLON.GLTF1 {
  83076. /**
  83077. * Utils functions for GLTF
  83078. * @hidden
  83079. */
  83080. export class GLTFUtils {
  83081. /**
  83082. * Sets the given "parameter" matrix
  83083. * @param scene: the Scene object
  83084. * @param source: the source node where to pick the matrix
  83085. * @param parameter: the GLTF technique parameter
  83086. * @param uniformName: the name of the shader's uniform
  83087. * @param shaderMaterial: the shader material
  83088. */
  83089. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  83090. /**
  83091. * Sets the given "parameter" matrix
  83092. * @param shaderMaterial: the shader material
  83093. * @param uniform: the name of the shader's uniform
  83094. * @param value: the value of the uniform
  83095. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  83096. */
  83097. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  83098. /**
  83099. * Returns the wrap mode of the texture
  83100. * @param mode: the mode value
  83101. */
  83102. static GetWrapMode(mode: number): number;
  83103. /**
  83104. * Returns the byte stride giving an accessor
  83105. * @param accessor: the GLTF accessor objet
  83106. */
  83107. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  83108. /**
  83109. * Returns the texture filter mode giving a mode value
  83110. * @param mode: the filter mode value
  83111. */
  83112. static GetTextureFilterMode(mode: number): ETextureFilterType;
  83113. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  83114. /**
  83115. * Returns a buffer from its accessor
  83116. * @param gltfRuntime: the GLTF runtime
  83117. * @param accessor: the GLTF accessor
  83118. */
  83119. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  83120. /**
  83121. * Decodes a buffer view into a string
  83122. * @param view: the buffer view
  83123. */
  83124. static DecodeBufferToText(view: ArrayBufferView): string;
  83125. /**
  83126. * Returns the default material of gltf. Related to
  83127. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  83128. * @param scene: the Babylon.js scene
  83129. */
  83130. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  83131. private static _DefaultMaterial;
  83132. }
  83133. }
  83134. declare module BABYLON.GLTF1 {
  83135. /**
  83136. * Implementation of the base glTF spec
  83137. * @hidden
  83138. */
  83139. export class GLTFLoaderBase {
  83140. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  83141. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  83142. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  83143. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  83144. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: 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. }
  83147. /**
  83148. * glTF V1 Loader
  83149. * @hidden
  83150. */
  83151. export class GLTFLoader implements IGLTFLoader {
  83152. static Extensions: {
  83153. [name: string]: GLTFLoaderExtension;
  83154. };
  83155. static RegisterExtension(extension: GLTFLoaderExtension): void;
  83156. state: Nullable<GLTFLoaderState>;
  83157. dispose(): void;
  83158. private _importMeshAsync;
  83159. /**
  83160. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  83161. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83162. * @param scene the scene the meshes should be added to
  83163. * @param forAssetContainer defines if the entities must be stored in the scene
  83164. * @param data gltf data containing information of the meshes in a loaded file
  83165. * @param rootUrl root url to load from
  83166. * @param onProgress event that fires when loading progress has occured
  83167. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83168. */
  83169. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  83170. private _loadAsync;
  83171. /**
  83172. * Imports all objects from a loaded gltf file and adds them to the scene
  83173. * @param scene the scene the objects should be added to
  83174. * @param data gltf data containing information of the meshes in a loaded file
  83175. * @param rootUrl root url to load from
  83176. * @param onProgress event that fires when loading progress has occured
  83177. * @returns a promise which completes when objects have been loaded to the scene
  83178. */
  83179. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  83180. private _loadShadersAsync;
  83181. private _loadBuffersAsync;
  83182. private _createNodes;
  83183. }
  83184. /** @hidden */
  83185. export abstract class GLTFLoaderExtension {
  83186. private _name;
  83187. constructor(name: string);
  83188. get name(): string;
  83189. /**
  83190. * Defines an override for loading the runtime
  83191. * Return true to stop further extensions from loading the runtime
  83192. */
  83193. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  83194. /**
  83195. * Defines an onverride for creating gltf runtime
  83196. * Return true to stop further extensions from creating the runtime
  83197. */
  83198. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  83199. /**
  83200. * Defines an override for loading buffers
  83201. * Return true to stop further extensions from loading this buffer
  83202. */
  83203. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  83204. /**
  83205. * Defines an override for loading texture buffers
  83206. * Return true to stop further extensions from loading this texture data
  83207. */
  83208. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83209. /**
  83210. * Defines an override for creating textures
  83211. * Return true to stop further extensions from loading this texture
  83212. */
  83213. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  83214. /**
  83215. * Defines an override for loading shader strings
  83216. * Return true to stop further extensions from loading this shader data
  83217. */
  83218. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83219. /**
  83220. * Defines an override for loading materials
  83221. * Return true to stop further extensions from loading this material
  83222. */
  83223. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83224. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  83225. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  83226. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  83227. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  83228. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  83229. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  83230. private static LoadTextureBufferAsync;
  83231. private static CreateTextureAsync;
  83232. private static ApplyExtensions;
  83233. }
  83234. }
  83235. declare module BABYLON.GLTF1 {
  83236. /** @hidden */
  83237. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  83238. private _bin;
  83239. constructor();
  83240. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  83241. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83242. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  83243. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  83244. }
  83245. }
  83246. declare module BABYLON.GLTF1 {
  83247. /** @hidden */
  83248. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  83249. constructor();
  83250. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  83251. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  83252. private _loadTexture;
  83253. }
  83254. }
  83255. declare module BABYLON.GLTF2.Loader {
  83256. /**
  83257. * Loader interface with an index field.
  83258. */
  83259. export interface IArrayItem {
  83260. /**
  83261. * The index of this item in the array.
  83262. */
  83263. index: number;
  83264. }
  83265. /**
  83266. * Loader interface with additional members.
  83267. */
  83268. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  83269. /** @hidden */
  83270. _data?: Promise<ArrayBufferView>;
  83271. /** @hidden */
  83272. _babylonVertexBuffer?: Promise<VertexBuffer>;
  83273. }
  83274. /**
  83275. * Loader interface with additional members.
  83276. */
  83277. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  83278. }
  83279. /** @hidden */
  83280. export interface _IAnimationSamplerData {
  83281. input: Float32Array;
  83282. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  83283. output: Float32Array;
  83284. }
  83285. /**
  83286. * Loader interface with additional members.
  83287. */
  83288. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  83289. /** @hidden */
  83290. _data?: Promise<_IAnimationSamplerData>;
  83291. }
  83292. /**
  83293. * Loader interface with additional members.
  83294. */
  83295. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  83296. channels: IAnimationChannel[];
  83297. samplers: IAnimationSampler[];
  83298. /** @hidden */
  83299. _babylonAnimationGroup?: AnimationGroup;
  83300. }
  83301. /**
  83302. * Loader interface with additional members.
  83303. */
  83304. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  83305. /** @hidden */
  83306. _data?: Promise<ArrayBufferView>;
  83307. }
  83308. /**
  83309. * Loader interface with additional members.
  83310. */
  83311. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  83312. /** @hidden */
  83313. _data?: Promise<ArrayBufferView>;
  83314. /** @hidden */
  83315. _babylonBuffer?: Promise<Buffer>;
  83316. }
  83317. /**
  83318. * Loader interface with additional members.
  83319. */
  83320. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  83321. }
  83322. /**
  83323. * Loader interface with additional members.
  83324. */
  83325. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  83326. /** @hidden */
  83327. _data?: Promise<ArrayBufferView>;
  83328. }
  83329. /**
  83330. * Loader interface with additional members.
  83331. */
  83332. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  83333. }
  83334. /**
  83335. * Loader interface with additional members.
  83336. */
  83337. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  83338. }
  83339. /**
  83340. * Loader interface with additional members.
  83341. */
  83342. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  83343. baseColorTexture?: ITextureInfo;
  83344. metallicRoughnessTexture?: ITextureInfo;
  83345. }
  83346. /**
  83347. * Loader interface with additional members.
  83348. */
  83349. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  83350. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83351. normalTexture?: IMaterialNormalTextureInfo;
  83352. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83353. emissiveTexture?: ITextureInfo;
  83354. /** @hidden */
  83355. _data?: {
  83356. [babylonDrawMode: number]: {
  83357. babylonMaterial: Material;
  83358. babylonMeshes: AbstractMesh[];
  83359. promise: Promise<void>;
  83360. };
  83361. };
  83362. }
  83363. /**
  83364. * Loader interface with additional members.
  83365. */
  83366. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  83367. primitives: IMeshPrimitive[];
  83368. }
  83369. /**
  83370. * Loader interface with additional members.
  83371. */
  83372. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  83373. /** @hidden */
  83374. _instanceData?: {
  83375. babylonSourceMesh: Mesh;
  83376. promise: Promise<any>;
  83377. };
  83378. }
  83379. /**
  83380. * Loader interface with additional members.
  83381. */
  83382. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  83383. /**
  83384. * The parent glTF node.
  83385. */
  83386. parent?: INode;
  83387. /** @hidden */
  83388. _babylonTransformNode?: TransformNode;
  83389. /** @hidden */
  83390. _primitiveBabylonMeshes?: AbstractMesh[];
  83391. /** @hidden */
  83392. _babylonBones?: Bone[];
  83393. /** @hidden */
  83394. _numMorphTargets?: number;
  83395. }
  83396. /** @hidden */
  83397. export interface _ISamplerData {
  83398. noMipMaps: boolean;
  83399. samplingMode: number;
  83400. wrapU: number;
  83401. wrapV: number;
  83402. }
  83403. /**
  83404. * Loader interface with additional members.
  83405. */
  83406. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  83407. /** @hidden */
  83408. _data?: _ISamplerData;
  83409. }
  83410. /**
  83411. * Loader interface with additional members.
  83412. */
  83413. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  83414. }
  83415. /**
  83416. * Loader interface with additional members.
  83417. */
  83418. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  83419. /** @hidden */
  83420. _data?: {
  83421. babylonSkeleton: Skeleton;
  83422. promise: Promise<void>;
  83423. };
  83424. }
  83425. /**
  83426. * Loader interface with additional members.
  83427. */
  83428. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  83429. /** @hidden */
  83430. _textureInfo: ITextureInfo;
  83431. }
  83432. /**
  83433. * Loader interface with additional members.
  83434. */
  83435. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  83436. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  83437. nonColorData?: boolean;
  83438. }
  83439. /**
  83440. * Loader interface with additional members.
  83441. */
  83442. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  83443. accessors?: IAccessor[];
  83444. animations?: IAnimation[];
  83445. buffers?: IBuffer[];
  83446. bufferViews?: IBufferView[];
  83447. cameras?: ICamera[];
  83448. images?: IImage[];
  83449. materials?: IMaterial[];
  83450. meshes?: IMesh[];
  83451. nodes?: INode[];
  83452. samplers?: ISampler[];
  83453. scenes?: IScene[];
  83454. skins?: ISkin[];
  83455. textures?: ITexture[];
  83456. }
  83457. }
  83458. declare module BABYLON.GLTF2 {
  83459. /**
  83460. * Interface for a glTF loader extension.
  83461. */
  83462. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  83463. /**
  83464. * Called after the loader state changes to LOADING.
  83465. */
  83466. onLoading?(): void;
  83467. /**
  83468. * Called after the loader state changes to READY.
  83469. */
  83470. onReady?(): void;
  83471. /**
  83472. * Define this method to modify the default behavior when loading scenes.
  83473. * @param context The context when loading the asset
  83474. * @param scene The glTF scene property
  83475. * @returns A promise that resolves when the load is complete or null if not handled
  83476. */
  83477. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  83478. /**
  83479. * Define this method to modify the default behavior when loading nodes.
  83480. * @param context The context when loading the asset
  83481. * @param node The glTF node property
  83482. * @param assign A function called synchronously after parsing the glTF properties
  83483. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  83484. */
  83485. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83486. /**
  83487. * Define this method to modify the default behavior when loading cameras.
  83488. * @param context The context when loading the asset
  83489. * @param camera The glTF camera property
  83490. * @param assign A function called synchronously after parsing the glTF properties
  83491. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  83492. */
  83493. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83494. /**
  83495. * @hidden
  83496. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  83497. * @param context The context when loading the asset
  83498. * @param primitive The glTF mesh primitive property
  83499. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  83500. */
  83501. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  83502. /**
  83503. * @hidden
  83504. * Define this method to modify the default behavior when loading data for mesh primitives.
  83505. * @param context The context when loading the asset
  83506. * @param name The mesh name when loading the asset
  83507. * @param node The glTF node when loading the asset
  83508. * @param mesh The glTF mesh when loading the asset
  83509. * @param primitive The glTF mesh primitive property
  83510. * @param assign A function called synchronously after parsing the glTF properties
  83511. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83512. */
  83513. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83514. /**
  83515. * @hidden
  83516. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  83517. * @param context The context when loading the asset
  83518. * @param material The glTF material property
  83519. * @param assign A function called synchronously after parsing the glTF properties
  83520. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  83521. */
  83522. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83523. /**
  83524. * Define this method to modify the default behavior when creating materials.
  83525. * @param context The context when loading the asset
  83526. * @param material The glTF material property
  83527. * @param babylonDrawMode The draw mode for the Babylon material
  83528. * @returns The Babylon material or null if not handled
  83529. */
  83530. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83531. /**
  83532. * Define this method to modify the default behavior when loading material properties.
  83533. * @param context The context when loading the asset
  83534. * @param material The glTF material property
  83535. * @param babylonMaterial The Babylon material
  83536. * @returns A promise that resolves when the load is complete or null if not handled
  83537. */
  83538. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83539. /**
  83540. * Define this method to modify the default behavior when loading texture infos.
  83541. * @param context The context when loading the asset
  83542. * @param textureInfo The glTF texture info property
  83543. * @param assign A function called synchronously after parsing the glTF properties
  83544. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83545. */
  83546. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83547. /**
  83548. * @hidden
  83549. * Define this method to modify the default behavior when loading textures.
  83550. * @param context The context when loading the asset
  83551. * @param texture The glTF texture property
  83552. * @param assign A function called synchronously after parsing the glTF properties
  83553. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  83554. */
  83555. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83556. /**
  83557. * Define this method to modify the default behavior when loading animations.
  83558. * @param context The context when loading the asset
  83559. * @param animation The glTF animation property
  83560. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  83561. */
  83562. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83563. /**
  83564. * @hidden
  83565. * Define this method to modify the default behavior when loading skins.
  83566. * @param context The context when loading the asset
  83567. * @param node The glTF node property
  83568. * @param skin The glTF skin property
  83569. * @returns A promise that resolves when the load is complete or null if not handled
  83570. */
  83571. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  83572. /**
  83573. * @hidden
  83574. * Define this method to modify the default behavior when loading uris.
  83575. * @param context The context when loading the asset
  83576. * @param property The glTF property associated with the uri
  83577. * @param uri The uri to load
  83578. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83579. */
  83580. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83581. /**
  83582. * Define this method to modify the default behavior when loading buffer views.
  83583. * @param context The context when loading the asset
  83584. * @param bufferView The glTF buffer view property
  83585. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83586. */
  83587. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  83588. /**
  83589. * Define this method to modify the default behavior when loading buffers.
  83590. * @param context The context when loading the asset
  83591. * @param buffer The glTF buffer property
  83592. * @param byteOffset The byte offset to load
  83593. * @param byteLength The byte length to load
  83594. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  83595. */
  83596. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83597. }
  83598. }
  83599. declare module BABYLON.GLTF2 {
  83600. /**
  83601. * Helper class for working with arrays when loading the glTF asset
  83602. */
  83603. export class ArrayItem {
  83604. /**
  83605. * Gets an item from the given array.
  83606. * @param context The context when loading the asset
  83607. * @param array The array to get the item from
  83608. * @param index The index to the array
  83609. * @returns The array item
  83610. */
  83611. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  83612. /**
  83613. * Assign an `index` field to each item of the given array.
  83614. * @param array The array of items
  83615. */
  83616. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  83617. }
  83618. /**
  83619. * The glTF 2.0 loader
  83620. */
  83621. export class GLTFLoader implements IGLTFLoader {
  83622. /** @hidden */
  83623. _completePromises: Promise<any>[];
  83624. /** @hidden */
  83625. _forAssetContainer: boolean;
  83626. /** Storage */
  83627. _babylonLights: Light[];
  83628. /** @hidden */
  83629. _disableInstancedMesh: number;
  83630. private _disposed;
  83631. private _parent;
  83632. private _state;
  83633. private _extensions;
  83634. private _rootUrl;
  83635. private _fileName;
  83636. private _uniqueRootUrl;
  83637. private _gltf;
  83638. private _bin;
  83639. private _babylonScene;
  83640. private _rootBabylonMesh;
  83641. private _defaultBabylonMaterialData;
  83642. private static _RegisteredExtensions;
  83643. /**
  83644. * The default glTF sampler.
  83645. */
  83646. static readonly DefaultSampler: ISampler;
  83647. /**
  83648. * Registers a loader extension.
  83649. * @param name The name of the loader extension.
  83650. * @param factory The factory function that creates the loader extension.
  83651. */
  83652. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  83653. /**
  83654. * Unregisters a loader extension.
  83655. * @param name The name of the loader extension.
  83656. * @returns A boolean indicating whether the extension has been unregistered
  83657. */
  83658. static UnregisterExtension(name: string): boolean;
  83659. /**
  83660. * The loader state.
  83661. */
  83662. get state(): Nullable<GLTFLoaderState>;
  83663. /**
  83664. * The object that represents the glTF JSON.
  83665. */
  83666. get gltf(): IGLTF;
  83667. /**
  83668. * The BIN chunk of a binary glTF.
  83669. */
  83670. get bin(): Nullable<IDataBuffer>;
  83671. /**
  83672. * The parent file loader.
  83673. */
  83674. get parent(): GLTFFileLoader;
  83675. /**
  83676. * The Babylon scene when loading the asset.
  83677. */
  83678. get babylonScene(): Scene;
  83679. /**
  83680. * The root Babylon mesh when loading the asset.
  83681. */
  83682. get rootBabylonMesh(): Mesh;
  83683. /** @hidden */
  83684. constructor(parent: GLTFFileLoader);
  83685. /** @hidden */
  83686. dispose(): void;
  83687. /** @hidden */
  83688. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  83689. /** @hidden */
  83690. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83691. private _loadAsync;
  83692. private _loadData;
  83693. private _setupData;
  83694. private _loadExtensions;
  83695. private _checkExtensions;
  83696. private _setState;
  83697. private _createRootNode;
  83698. /**
  83699. * Loads a glTF scene.
  83700. * @param context The context when loading the asset
  83701. * @param scene The glTF scene property
  83702. * @returns A promise that resolves when the load is complete
  83703. */
  83704. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  83705. private _forEachPrimitive;
  83706. private _getGeometries;
  83707. private _getMeshes;
  83708. private _getTransformNodes;
  83709. private _getSkeletons;
  83710. private _getAnimationGroups;
  83711. private _startAnimations;
  83712. /**
  83713. * Loads a glTF node.
  83714. * @param context The context when loading the asset
  83715. * @param node The glTF node property
  83716. * @param assign A function called synchronously after parsing the glTF properties
  83717. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  83718. */
  83719. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  83720. private _loadMeshAsync;
  83721. /**
  83722. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  83723. * @param context The context when loading the asset
  83724. * @param name The mesh name when loading the asset
  83725. * @param node The glTF node when loading the asset
  83726. * @param mesh The glTF mesh when loading the asset
  83727. * @param primitive The glTF mesh primitive property
  83728. * @param assign A function called synchronously after parsing the glTF properties
  83729. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  83730. */
  83731. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  83732. private _loadVertexDataAsync;
  83733. private _createMorphTargets;
  83734. private _loadMorphTargetsAsync;
  83735. private _loadMorphTargetVertexDataAsync;
  83736. private static _LoadTransform;
  83737. private _loadSkinAsync;
  83738. private _loadBones;
  83739. private _loadBone;
  83740. private _loadSkinInverseBindMatricesDataAsync;
  83741. private _updateBoneMatrices;
  83742. private _getNodeMatrix;
  83743. /**
  83744. * Loads a glTF camera.
  83745. * @param context The context when loading the asset
  83746. * @param camera The glTF camera property
  83747. * @param assign A function called synchronously after parsing the glTF properties
  83748. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  83749. */
  83750. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  83751. private _loadAnimationsAsync;
  83752. /**
  83753. * Loads a glTF animation.
  83754. * @param context The context when loading the asset
  83755. * @param animation The glTF animation property
  83756. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  83757. */
  83758. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  83759. /**
  83760. * @hidden Loads a glTF animation channel.
  83761. * @param context The context when loading the asset
  83762. * @param animationContext The context of the animation when loading the asset
  83763. * @param animation The glTF animation property
  83764. * @param channel The glTF animation channel property
  83765. * @param babylonAnimationGroup The babylon animation group property
  83766. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  83767. * @returns A void promise when the channel load is complete
  83768. */
  83769. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  83770. private _loadAnimationSamplerAsync;
  83771. private _loadBufferAsync;
  83772. /**
  83773. * Loads a glTF buffer view.
  83774. * @param context The context when loading the asset
  83775. * @param bufferView The glTF buffer view property
  83776. * @returns A promise that resolves with the loaded data when the load is complete
  83777. */
  83778. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  83779. private _loadAccessorAsync;
  83780. /** @hidden */
  83781. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  83782. private _loadIndicesAccessorAsync;
  83783. private _loadVertexBufferViewAsync;
  83784. private _loadVertexAccessorAsync;
  83785. private _loadMaterialMetallicRoughnessPropertiesAsync;
  83786. /** @hidden */
  83787. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  83788. private _createDefaultMaterial;
  83789. /**
  83790. * Creates a Babylon material from a glTF material.
  83791. * @param context The context when loading the asset
  83792. * @param material The glTF material property
  83793. * @param babylonDrawMode The draw mode for the Babylon material
  83794. * @returns The Babylon material
  83795. */
  83796. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  83797. /**
  83798. * Loads properties from a glTF material into a Babylon material.
  83799. * @param context The context when loading the asset
  83800. * @param material The glTF material property
  83801. * @param babylonMaterial The Babylon material
  83802. * @returns A promise that resolves when the load is complete
  83803. */
  83804. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83805. /**
  83806. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  83807. * @param context The context when loading the asset
  83808. * @param material The glTF material property
  83809. * @param babylonMaterial The Babylon material
  83810. * @returns A promise that resolves when the load is complete
  83811. */
  83812. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  83813. /**
  83814. * Loads the alpha properties from a glTF material into a Babylon material.
  83815. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  83816. * @param context The context when loading the asset
  83817. * @param material The glTF material property
  83818. * @param babylonMaterial The Babylon material
  83819. */
  83820. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  83821. /**
  83822. * Loads a glTF texture info.
  83823. * @param context The context when loading the asset
  83824. * @param textureInfo The glTF texture info property
  83825. * @param assign A function called synchronously after parsing the glTF properties
  83826. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  83827. */
  83828. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83829. /** @hidden */
  83830. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  83831. /** @hidden */
  83832. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  83833. private _loadSampler;
  83834. /**
  83835. * Loads a glTF image.
  83836. * @param context The context when loading the asset
  83837. * @param image The glTF image property
  83838. * @returns A promise that resolves with the loaded data when the load is complete
  83839. */
  83840. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  83841. /**
  83842. * Loads a glTF uri.
  83843. * @param context The context when loading the asset
  83844. * @param property The glTF property associated with the uri
  83845. * @param uri The base64 or relative uri
  83846. * @returns A promise that resolves with the loaded data when the load is complete
  83847. */
  83848. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  83849. /**
  83850. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  83851. * @param babylonObject the Babylon object with metadata
  83852. * @param pointer the JSON pointer
  83853. */
  83854. static AddPointerMetadata(babylonObject: {
  83855. metadata: any;
  83856. }, pointer: string): void;
  83857. private static _GetTextureWrapMode;
  83858. private static _GetTextureSamplingMode;
  83859. private static _GetTypedArrayConstructor;
  83860. private static _GetTypedArray;
  83861. private static _GetNumComponents;
  83862. private static _ValidateUri;
  83863. /** @hidden */
  83864. static _GetDrawMode(context: string, mode: number | undefined): number;
  83865. private _compileMaterialsAsync;
  83866. private _compileShadowGeneratorsAsync;
  83867. private _forEachExtensions;
  83868. private _applyExtensions;
  83869. private _extensionsOnLoading;
  83870. private _extensionsOnReady;
  83871. private _extensionsLoadSceneAsync;
  83872. private _extensionsLoadNodeAsync;
  83873. private _extensionsLoadCameraAsync;
  83874. private _extensionsLoadVertexDataAsync;
  83875. private _extensionsLoadMeshPrimitiveAsync;
  83876. private _extensionsLoadMaterialAsync;
  83877. private _extensionsCreateMaterial;
  83878. private _extensionsLoadMaterialPropertiesAsync;
  83879. private _extensionsLoadTextureInfoAsync;
  83880. private _extensionsLoadTextureAsync;
  83881. private _extensionsLoadAnimationAsync;
  83882. private _extensionsLoadSkinAsync;
  83883. private _extensionsLoadUriAsync;
  83884. private _extensionsLoadBufferViewAsync;
  83885. private _extensionsLoadBufferAsync;
  83886. /**
  83887. * Helper method called by a loader extension to load an glTF extension.
  83888. * @param context The context when loading the asset
  83889. * @param property The glTF property to load the extension from
  83890. * @param extensionName The name of the extension to load
  83891. * @param actionAsync The action to run
  83892. * @returns The promise returned by actionAsync or null if the extension does not exist
  83893. */
  83894. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83895. /**
  83896. * Helper method called by a loader extension to load a glTF extra.
  83897. * @param context The context when loading the asset
  83898. * @param property The glTF property to load the extra from
  83899. * @param extensionName The name of the extension to load
  83900. * @param actionAsync The action to run
  83901. * @returns The promise returned by actionAsync or null if the extra does not exist
  83902. */
  83903. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  83904. /**
  83905. * Checks for presence of an extension.
  83906. * @param name The name of the extension to check
  83907. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  83908. */
  83909. isExtensionUsed(name: string): boolean;
  83910. /**
  83911. * Increments the indentation level and logs a message.
  83912. * @param message The message to log
  83913. */
  83914. logOpen(message: string): void;
  83915. /**
  83916. * Decrements the indentation level.
  83917. */
  83918. logClose(): void;
  83919. /**
  83920. * Logs a message
  83921. * @param message The message to log
  83922. */
  83923. log(message: string): void;
  83924. /**
  83925. * Starts a performance counter.
  83926. * @param counterName The name of the performance counter
  83927. */
  83928. startPerformanceCounter(counterName: string): void;
  83929. /**
  83930. * Ends a performance counter.
  83931. * @param counterName The name of the performance counter
  83932. */
  83933. endPerformanceCounter(counterName: string): void;
  83934. }
  83935. }
  83936. declare module BABYLON.GLTF2.Loader.Extensions {
  83937. /** @hidden */
  83938. interface IEXTLightsImageBased_LightImageBased {
  83939. _babylonTexture?: BaseTexture;
  83940. _loaded?: Promise<void>;
  83941. }
  83942. /**
  83943. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  83944. */
  83945. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  83946. /**
  83947. * The name of this extension.
  83948. */
  83949. readonly name: string;
  83950. /**
  83951. * Defines whether this extension is enabled.
  83952. */
  83953. enabled: boolean;
  83954. private _loader;
  83955. private _lights?;
  83956. /** @hidden */
  83957. constructor(loader: GLTFLoader);
  83958. /** @hidden */
  83959. dispose(): void;
  83960. /** @hidden */
  83961. onLoading(): void;
  83962. /** @hidden */
  83963. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83964. private _loadLightAsync;
  83965. }
  83966. }
  83967. declare module BABYLON.GLTF2.Loader.Extensions {
  83968. /**
  83969. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  83970. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  83971. * !!! Experimental Extension Subject to Changes !!!
  83972. */
  83973. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  83974. /**
  83975. * The name of this extension.
  83976. */
  83977. readonly name: string;
  83978. /**
  83979. * Defines whether this extension is enabled.
  83980. */
  83981. enabled: boolean;
  83982. private _loader;
  83983. /** @hidden */
  83984. constructor(loader: GLTFLoader);
  83985. /** @hidden */
  83986. dispose(): void;
  83987. /** @hidden */
  83988. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83989. }
  83990. }
  83991. declare module BABYLON.GLTF2.Loader.Extensions {
  83992. /**
  83993. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  83994. *
  83995. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  83996. */
  83997. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  83998. /**
  83999. * The name of this extension.
  84000. */
  84001. readonly name: string;
  84002. /**
  84003. * Defines whether this extension is enabled.
  84004. */
  84005. enabled: boolean;
  84006. /**
  84007. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.module.js
  84008. */
  84009. static DecoderPath: string;
  84010. private _loader;
  84011. private _decoder;
  84012. /** @hidden */
  84013. constructor(loader: GLTFLoader);
  84014. /** @hidden */
  84015. dispose(): void;
  84016. /** @hidden */
  84017. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  84018. }
  84019. }
  84020. declare module BABYLON.GLTF2.Loader.Extensions {
  84021. /**
  84022. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  84023. */
  84024. export class EXT_texture_webp implements IGLTFLoaderExtension {
  84025. /** The name of this extension. */
  84026. readonly name: string;
  84027. /** Defines whether this extension is enabled. */
  84028. enabled: boolean;
  84029. private _loader;
  84030. /** @hidden */
  84031. constructor(loader: GLTFLoader);
  84032. /** @hidden */
  84033. dispose(): void;
  84034. /** @hidden */
  84035. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84036. }
  84037. }
  84038. declare module BABYLON.GLTF2.Loader.Extensions {
  84039. /**
  84040. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  84041. */
  84042. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  84043. /**
  84044. * The name of this extension.
  84045. */
  84046. readonly name: string;
  84047. /**
  84048. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  84049. */
  84050. dracoCompression?: DracoCompression;
  84051. /**
  84052. * Defines whether this extension is enabled.
  84053. */
  84054. enabled: boolean;
  84055. private _loader;
  84056. /** @hidden */
  84057. constructor(loader: GLTFLoader);
  84058. /** @hidden */
  84059. dispose(): void;
  84060. /** @hidden */
  84061. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  84062. }
  84063. }
  84064. declare module BABYLON.GLTF2.Loader.Extensions {
  84065. /**
  84066. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  84067. */
  84068. export class KHR_lights implements IGLTFLoaderExtension {
  84069. /**
  84070. * The name of this extension.
  84071. */
  84072. readonly name: string;
  84073. /**
  84074. * Defines whether this extension is enabled.
  84075. */
  84076. enabled: boolean;
  84077. private _loader;
  84078. private _lights?;
  84079. /** @hidden */
  84080. constructor(loader: GLTFLoader);
  84081. /** @hidden */
  84082. dispose(): void;
  84083. /** @hidden */
  84084. onLoading(): void;
  84085. /** @hidden */
  84086. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84087. }
  84088. }
  84089. declare module BABYLON.GLTF2.Loader.Extensions {
  84090. /**
  84091. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  84092. */
  84093. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  84094. /**
  84095. * The name of this extension.
  84096. */
  84097. readonly name: string;
  84098. /**
  84099. * Defines whether this extension is enabled.
  84100. */
  84101. enabled: boolean;
  84102. /**
  84103. * Defines a number that determines the order the extensions are applied.
  84104. */
  84105. order: number;
  84106. private _loader;
  84107. /** @hidden */
  84108. constructor(loader: GLTFLoader);
  84109. /** @hidden */
  84110. dispose(): void;
  84111. /** @hidden */
  84112. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84113. private _loadSpecularGlossinessPropertiesAsync;
  84114. }
  84115. }
  84116. declare module BABYLON.GLTF2.Loader.Extensions {
  84117. /**
  84118. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  84119. */
  84120. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  84121. /**
  84122. * The name of this extension.
  84123. */
  84124. readonly name: string;
  84125. /**
  84126. * Defines whether this extension is enabled.
  84127. */
  84128. enabled: boolean;
  84129. /**
  84130. * Defines a number that determines the order the extensions are applied.
  84131. */
  84132. order: number;
  84133. private _loader;
  84134. /** @hidden */
  84135. constructor(loader: GLTFLoader);
  84136. /** @hidden */
  84137. dispose(): void;
  84138. /** @hidden */
  84139. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84140. private _loadUnlitPropertiesAsync;
  84141. }
  84142. }
  84143. declare module BABYLON.GLTF2.Loader.Extensions {
  84144. /**
  84145. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  84146. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  84147. */
  84148. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  84149. /**
  84150. * The name of this extension.
  84151. */
  84152. readonly name: string;
  84153. /**
  84154. * Defines whether this extension is enabled.
  84155. */
  84156. enabled: boolean;
  84157. /**
  84158. * Defines a number that determines the order the extensions are applied.
  84159. */
  84160. order: number;
  84161. private _loader;
  84162. /** @hidden */
  84163. constructor(loader: GLTFLoader);
  84164. /** @hidden */
  84165. dispose(): void;
  84166. /** @hidden */
  84167. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84168. private _loadClearCoatPropertiesAsync;
  84169. }
  84170. }
  84171. declare module BABYLON.GLTF2.Loader.Extensions {
  84172. /**
  84173. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  84174. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  84175. * !!! Experimental Extension Subject to Changes !!!
  84176. */
  84177. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  84178. /**
  84179. * The name of this extension.
  84180. */
  84181. readonly name: string;
  84182. /**
  84183. * Defines whether this extension is enabled.
  84184. */
  84185. enabled: boolean;
  84186. /**
  84187. * Defines a number that determines the order the extensions are applied.
  84188. */
  84189. order: number;
  84190. private _loader;
  84191. /** @hidden */
  84192. constructor(loader: GLTFLoader);
  84193. /** @hidden */
  84194. dispose(): void;
  84195. /** @hidden */
  84196. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84197. private _loadSheenPropertiesAsync;
  84198. }
  84199. }
  84200. declare module BABYLON.GLTF2.Loader.Extensions {
  84201. /**
  84202. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  84203. * !!! Experimental Extension Subject to Changes !!!
  84204. */
  84205. export class KHR_materials_specular implements IGLTFLoaderExtension {
  84206. /**
  84207. * The name of this extension.
  84208. */
  84209. readonly name: string;
  84210. /**
  84211. * Defines whether this extension is enabled.
  84212. */
  84213. enabled: boolean;
  84214. /**
  84215. * Defines a number that determines the order the extensions are applied.
  84216. */
  84217. order: number;
  84218. private _loader;
  84219. /** @hidden */
  84220. constructor(loader: GLTFLoader);
  84221. /** @hidden */
  84222. dispose(): void;
  84223. /** @hidden */
  84224. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84225. private _loadSpecularPropertiesAsync;
  84226. }
  84227. }
  84228. declare module BABYLON.GLTF2.Loader.Extensions {
  84229. /**
  84230. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  84231. * !!! Experimental Extension Subject to Changes !!!
  84232. */
  84233. export class KHR_materials_ior implements IGLTFLoaderExtension {
  84234. /**
  84235. * Default ior Value from the spec.
  84236. */
  84237. private static readonly _DEFAULT_IOR;
  84238. /**
  84239. * The name of this extension.
  84240. */
  84241. readonly name: string;
  84242. /**
  84243. * Defines whether this extension is enabled.
  84244. */
  84245. enabled: boolean;
  84246. /**
  84247. * Defines a number that determines the order the extensions are applied.
  84248. */
  84249. order: number;
  84250. private _loader;
  84251. /** @hidden */
  84252. constructor(loader: GLTFLoader);
  84253. /** @hidden */
  84254. dispose(): void;
  84255. /** @hidden */
  84256. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84257. private _loadIorPropertiesAsync;
  84258. }
  84259. }
  84260. declare module BABYLON.GLTF2.Loader.Extensions {
  84261. /**
  84262. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  84263. */
  84264. export class KHR_materials_variants implements IGLTFLoaderExtension {
  84265. /**
  84266. * The name of this extension.
  84267. */
  84268. readonly name: string;
  84269. /**
  84270. * Defines whether this extension is enabled.
  84271. */
  84272. enabled: boolean;
  84273. private _loader;
  84274. private _variants?;
  84275. /** @hidden */
  84276. constructor(loader: GLTFLoader);
  84277. /** @hidden */
  84278. dispose(): void;
  84279. /**
  84280. * Gets the list of available variant names for this asset.
  84281. * @param rootMesh The glTF root mesh
  84282. * @returns the list of all the variant names for this model
  84283. */
  84284. static GetAvailableVariants(rootMesh: Mesh): string[];
  84285. /**
  84286. * Gets the list of available variant names for this asset.
  84287. * @param rootMesh The glTF root mesh
  84288. * @returns the list of all the variant names for this model
  84289. */
  84290. getAvailableVariants(rootMesh: Mesh): string[];
  84291. /**
  84292. * Select a variant given a variant name or a list of variant names.
  84293. * @param rootMesh The glTF root mesh
  84294. * @param variantName The variant name(s) to select.
  84295. */
  84296. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84297. /**
  84298. * Select a variant given a variant name or a list of variant names.
  84299. * @param rootMesh The glTF root mesh
  84300. * @param variantName The variant name(s) to select.
  84301. */
  84302. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  84303. /**
  84304. * Reset back to the original before selecting a variant.
  84305. * @param rootMesh The glTF root mesh
  84306. */
  84307. static Reset(rootMesh: Mesh): void;
  84308. /**
  84309. * Reset back to the original before selecting a variant.
  84310. * @param rootMesh The glTF root mesh
  84311. */
  84312. reset(rootMesh: Mesh): void;
  84313. /**
  84314. * Gets the last selected variant name(s) or null if original.
  84315. * @param rootMesh The glTF root mesh
  84316. * @returns The selected variant name(s).
  84317. */
  84318. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84319. /**
  84320. * Gets the last selected variant name(s) or null if original.
  84321. * @param rootMesh The glTF root mesh
  84322. * @returns The selected variant name(s).
  84323. */
  84324. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  84325. private static _GetExtensionMetadata;
  84326. /** @hidden */
  84327. onLoading(): void;
  84328. /** @hidden */
  84329. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  84330. }
  84331. }
  84332. declare module BABYLON.GLTF2.Loader.Extensions {
  84333. /**
  84334. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  84335. */
  84336. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  84337. /**
  84338. * The name of this extension.
  84339. */
  84340. readonly name: string;
  84341. /**
  84342. * Defines whether this extension is enabled.
  84343. */
  84344. enabled: boolean;
  84345. /**
  84346. * Defines a number that determines the order the extensions are applied.
  84347. */
  84348. order: number;
  84349. private _loader;
  84350. /** @hidden */
  84351. constructor(loader: GLTFLoader);
  84352. /** @hidden */
  84353. dispose(): void;
  84354. /** @hidden */
  84355. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84356. private _loadTransparentPropertiesAsync;
  84357. }
  84358. }
  84359. declare module BABYLON.GLTF2.Loader.Extensions {
  84360. /**
  84361. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  84362. * !!! Experimental Extension Subject to Changes !!!
  84363. */
  84364. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  84365. /**
  84366. * The name of this extension.
  84367. */
  84368. readonly name: string;
  84369. /**
  84370. * Defines whether this extension is enabled.
  84371. */
  84372. enabled: boolean;
  84373. /**
  84374. * Defines a number that determines the order the extensions are applied.
  84375. */
  84376. order: number;
  84377. private _loader;
  84378. /** @hidden */
  84379. constructor(loader: GLTFLoader);
  84380. /** @hidden */
  84381. dispose(): void;
  84382. /** @hidden */
  84383. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84384. private _loadTranslucentPropertiesAsync;
  84385. }
  84386. }
  84387. declare module BABYLON.GLTF2.Loader.Extensions {
  84388. /**
  84389. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  84390. */
  84391. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  84392. /**
  84393. * The name of this extension.
  84394. */
  84395. readonly name: string;
  84396. /**
  84397. * Defines whether this extension is enabled.
  84398. */
  84399. enabled: boolean;
  84400. /** @hidden */
  84401. constructor(loader: GLTFLoader);
  84402. /** @hidden */
  84403. dispose(): void;
  84404. }
  84405. }
  84406. declare module BABYLON.GLTF2.Loader.Extensions {
  84407. /**
  84408. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  84409. * !!! Experimental Extension Subject to Changes !!!
  84410. */
  84411. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  84412. /** The name of this extension. */
  84413. readonly name: string;
  84414. /** Defines whether this extension is enabled. */
  84415. enabled: boolean;
  84416. private _loader;
  84417. /** @hidden */
  84418. constructor(loader: GLTFLoader);
  84419. /** @hidden */
  84420. dispose(): void;
  84421. /** @hidden */
  84422. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84423. }
  84424. }
  84425. declare module BABYLON.GLTF2.Loader.Extensions {
  84426. /**
  84427. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  84428. */
  84429. export class KHR_texture_transform implements IGLTFLoaderExtension {
  84430. /**
  84431. * The name of this extension.
  84432. */
  84433. readonly name: string;
  84434. /**
  84435. * Defines whether this extension is enabled.
  84436. */
  84437. enabled: boolean;
  84438. private _loader;
  84439. /** @hidden */
  84440. constructor(loader: GLTFLoader);
  84441. /** @hidden */
  84442. dispose(): void;
  84443. /** @hidden */
  84444. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  84445. }
  84446. }
  84447. declare module BABYLON.GLTF2.Loader.Extensions {
  84448. /**
  84449. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  84450. */
  84451. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  84452. /**
  84453. * The name of this extension.
  84454. */
  84455. readonly name: string;
  84456. /**
  84457. * Defines whether this extension is enabled.
  84458. */
  84459. enabled: boolean;
  84460. private _loader;
  84461. private _clips;
  84462. private _emitters;
  84463. /** @hidden */
  84464. constructor(loader: GLTFLoader);
  84465. /** @hidden */
  84466. dispose(): void;
  84467. /** @hidden */
  84468. onLoading(): void;
  84469. /** @hidden */
  84470. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84471. /** @hidden */
  84472. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84473. /** @hidden */
  84474. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  84475. private _loadClipAsync;
  84476. private _loadEmitterAsync;
  84477. private _getEventAction;
  84478. private _loadAnimationEventAsync;
  84479. }
  84480. }
  84481. declare module BABYLON.GLTF2.Loader.Extensions {
  84482. /**
  84483. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  84484. */
  84485. export class MSFT_lod implements IGLTFLoaderExtension {
  84486. /**
  84487. * The name of this extension.
  84488. */
  84489. readonly name: string;
  84490. /**
  84491. * Defines whether this extension is enabled.
  84492. */
  84493. enabled: boolean;
  84494. /**
  84495. * Defines a number that determines the order the extensions are applied.
  84496. */
  84497. order: number;
  84498. /**
  84499. * Maximum number of LODs to load, starting from the lowest LOD.
  84500. */
  84501. maxLODsToLoad: number;
  84502. /**
  84503. * Observable raised when all node LODs of one level are loaded.
  84504. * The event data is the index of the loaded LOD starting from zero.
  84505. * Dispose the loader to cancel the loading of the next level of LODs.
  84506. */
  84507. onNodeLODsLoadedObservable: Observable<number>;
  84508. /**
  84509. * Observable raised when all material LODs of one level are loaded.
  84510. * The event data is the index of the loaded LOD starting from zero.
  84511. * Dispose the loader to cancel the loading of the next level of LODs.
  84512. */
  84513. onMaterialLODsLoadedObservable: Observable<number>;
  84514. private _loader;
  84515. private _bufferLODs;
  84516. private _nodeIndexLOD;
  84517. private _nodeSignalLODs;
  84518. private _nodePromiseLODs;
  84519. private _nodeBufferLODs;
  84520. private _materialIndexLOD;
  84521. private _materialSignalLODs;
  84522. private _materialPromiseLODs;
  84523. private _materialBufferLODs;
  84524. /** @hidden */
  84525. constructor(loader: GLTFLoader);
  84526. /** @hidden */
  84527. dispose(): void;
  84528. /** @hidden */
  84529. onReady(): void;
  84530. /** @hidden */
  84531. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  84532. /** @hidden */
  84533. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84534. /** @hidden */
  84535. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  84536. /** @hidden */
  84537. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  84538. /** @hidden */
  84539. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  84540. private _loadBufferLOD;
  84541. /**
  84542. * Gets an array of LOD properties from lowest to highest.
  84543. */
  84544. private _getLODs;
  84545. private _disposeTransformNode;
  84546. private _disposeMaterials;
  84547. }
  84548. }
  84549. declare module BABYLON.GLTF2.Loader.Extensions {
  84550. /** @hidden */
  84551. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  84552. readonly name: string;
  84553. enabled: boolean;
  84554. private _loader;
  84555. constructor(loader: GLTFLoader);
  84556. dispose(): void;
  84557. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84558. }
  84559. }
  84560. declare module BABYLON.GLTF2.Loader.Extensions {
  84561. /** @hidden */
  84562. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  84563. readonly name: string;
  84564. enabled: boolean;
  84565. private _loader;
  84566. constructor(loader: GLTFLoader);
  84567. dispose(): void;
  84568. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  84569. }
  84570. }
  84571. declare module BABYLON.GLTF2.Loader.Extensions {
  84572. /**
  84573. * Store glTF extras (if present) in BJS objects' metadata
  84574. */
  84575. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  84576. /**
  84577. * The name of this extension.
  84578. */
  84579. readonly name: string;
  84580. /**
  84581. * Defines whether this extension is enabled.
  84582. */
  84583. enabled: boolean;
  84584. private _loader;
  84585. private _assignExtras;
  84586. /** @hidden */
  84587. constructor(loader: GLTFLoader);
  84588. /** @hidden */
  84589. dispose(): void;
  84590. /** @hidden */
  84591. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  84592. /** @hidden */
  84593. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  84594. /** @hidden */
  84595. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  84596. }
  84597. }
  84598. declare module BABYLON {
  84599. /**
  84600. * Class reading and parsing the MTL file bundled with the obj file.
  84601. */
  84602. export class MTLFileLoader {
  84603. /**
  84604. * Invert Y-Axis of referenced textures on load
  84605. */
  84606. static INVERT_TEXTURE_Y: boolean;
  84607. /**
  84608. * All material loaded from the mtl will be set here
  84609. */
  84610. materials: StandardMaterial[];
  84611. /**
  84612. * This function will read the mtl file and create each material described inside
  84613. * This function could be improve by adding :
  84614. * -some component missing (Ni, Tf...)
  84615. * -including the specific options available
  84616. *
  84617. * @param scene defines the scene the material will be created in
  84618. * @param data defines the mtl data to parse
  84619. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  84620. * @param forAssetContainer defines if the material should be registered in the scene
  84621. */
  84622. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  84623. /**
  84624. * Gets the texture for the material.
  84625. *
  84626. * If the material is imported from input file,
  84627. * We sanitize the url to ensure it takes the textre from aside the material.
  84628. *
  84629. * @param rootUrl The root url to load from
  84630. * @param value The value stored in the mtl
  84631. * @return The Texture
  84632. */
  84633. private static _getTexture;
  84634. }
  84635. }
  84636. declare module BABYLON {
  84637. /**
  84638. * Options for loading OBJ/MTL files
  84639. */
  84640. type MeshLoadOptions = {
  84641. /**
  84642. * Defines if UVs are optimized by default during load.
  84643. */
  84644. OptimizeWithUV: boolean;
  84645. /**
  84646. * Defines custom scaling of UV coordinates of loaded meshes.
  84647. */
  84648. UVScaling: Vector2;
  84649. /**
  84650. * Invert model on y-axis (does a model scaling inversion)
  84651. */
  84652. InvertY: boolean;
  84653. /**
  84654. * Invert Y-Axis of referenced textures on load
  84655. */
  84656. InvertTextureY: boolean;
  84657. /**
  84658. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84659. */
  84660. ImportVertexColors: boolean;
  84661. /**
  84662. * Compute the normals for the model, even if normals are present in the file.
  84663. */
  84664. ComputeNormals: boolean;
  84665. /**
  84666. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84667. */
  84668. SkipMaterials: boolean;
  84669. /**
  84670. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84671. */
  84672. MaterialLoadingFailsSilently: boolean;
  84673. };
  84674. /**
  84675. * OBJ file type loader.
  84676. * This is a babylon scene loader plugin.
  84677. */
  84678. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  84679. /**
  84680. * Defines if UVs are optimized by default during load.
  84681. */
  84682. static OPTIMIZE_WITH_UV: boolean;
  84683. /**
  84684. * Invert model on y-axis (does a model scaling inversion)
  84685. */
  84686. static INVERT_Y: boolean;
  84687. /**
  84688. * Invert Y-Axis of referenced textures on load
  84689. */
  84690. static get INVERT_TEXTURE_Y(): boolean;
  84691. static set INVERT_TEXTURE_Y(value: boolean);
  84692. /**
  84693. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  84694. */
  84695. static IMPORT_VERTEX_COLORS: boolean;
  84696. /**
  84697. * Compute the normals for the model, even if normals are present in the file.
  84698. */
  84699. static COMPUTE_NORMALS: boolean;
  84700. /**
  84701. * Defines custom scaling of UV coordinates of loaded meshes.
  84702. */
  84703. static UV_SCALING: Vector2;
  84704. /**
  84705. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  84706. */
  84707. static SKIP_MATERIALS: boolean;
  84708. /**
  84709. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  84710. *
  84711. * Defaults to true for backwards compatibility.
  84712. */
  84713. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  84714. /**
  84715. * Defines the name of the plugin.
  84716. */
  84717. name: string;
  84718. /**
  84719. * Defines the extension the plugin is able to load.
  84720. */
  84721. extensions: string;
  84722. /** @hidden */
  84723. obj: RegExp;
  84724. /** @hidden */
  84725. group: RegExp;
  84726. /** @hidden */
  84727. mtllib: RegExp;
  84728. /** @hidden */
  84729. usemtl: RegExp;
  84730. /** @hidden */
  84731. smooth: RegExp;
  84732. /** @hidden */
  84733. vertexPattern: RegExp;
  84734. /** @hidden */
  84735. normalPattern: RegExp;
  84736. /** @hidden */
  84737. uvPattern: RegExp;
  84738. /** @hidden */
  84739. facePattern1: RegExp;
  84740. /** @hidden */
  84741. facePattern2: RegExp;
  84742. /** @hidden */
  84743. facePattern3: RegExp;
  84744. /** @hidden */
  84745. facePattern4: RegExp;
  84746. /** @hidden */
  84747. facePattern5: RegExp;
  84748. private _forAssetContainer;
  84749. private _meshLoadOptions;
  84750. /**
  84751. * Creates loader for .OBJ files
  84752. *
  84753. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  84754. */
  84755. constructor(meshLoadOptions?: MeshLoadOptions);
  84756. private static get currentMeshLoadOptions();
  84757. /**
  84758. * Calls synchronously the MTL file attached to this obj.
  84759. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  84760. * Without this function materials are not displayed in the first frame (but displayed after).
  84761. * In consequence it is impossible to get material information in your HTML file
  84762. *
  84763. * @param url The URL of the MTL file
  84764. * @param rootUrl
  84765. * @param onSuccess Callback function to be called when the MTL file is loaded
  84766. * @private
  84767. */
  84768. private _loadMTL;
  84769. /**
  84770. * Instantiates a OBJ file loader plugin.
  84771. * @returns the created plugin
  84772. */
  84773. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  84774. /**
  84775. * If the data string can be loaded directly.
  84776. *
  84777. * @param data string containing the file data
  84778. * @returns if the data can be loaded directly
  84779. */
  84780. canDirectLoad(data: string): boolean;
  84781. /**
  84782. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  84783. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  84784. * @param scene the scene the meshes should be added to
  84785. * @param data the OBJ data to load
  84786. * @param rootUrl root url to load from
  84787. * @param onProgress event that fires when loading progress has occured
  84788. * @param fileName Defines the name of the file to load
  84789. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  84790. */
  84791. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  84792. /**
  84793. * Imports all objects from the loaded OBJ data and adds them to the scene
  84794. * @param scene the scene the objects should be added to
  84795. * @param data the OBJ data to load
  84796. * @param rootUrl root url to load from
  84797. * @param onProgress event that fires when loading progress has occured
  84798. * @param fileName Defines the name of the file to load
  84799. * @returns a promise which completes when objects have been loaded to the scene
  84800. */
  84801. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  84802. /**
  84803. * Load into an asset container.
  84804. * @param scene The scene to load into
  84805. * @param data The data to import
  84806. * @param rootUrl The root url for scene and resources
  84807. * @param onProgress The callback when the load progresses
  84808. * @param fileName Defines the name of the file to load
  84809. * @returns The loaded asset container
  84810. */
  84811. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  84812. /**
  84813. * Read the OBJ file and create an Array of meshes.
  84814. * Each mesh contains all information given by the OBJ and the MTL file.
  84815. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  84816. *
  84817. * @param meshesNames
  84818. * @param scene Scene The scene where are displayed the data
  84819. * @param data String The content of the obj file
  84820. * @param rootUrl String The path to the folder
  84821. * @returns Array<AbstractMesh>
  84822. * @private
  84823. */
  84824. private _parseSolid;
  84825. }
  84826. }
  84827. declare module BABYLON {
  84828. /**
  84829. * STL file type loader.
  84830. * This is a babylon scene loader plugin.
  84831. */
  84832. export class STLFileLoader implements ISceneLoaderPlugin {
  84833. /** @hidden */
  84834. solidPattern: RegExp;
  84835. /** @hidden */
  84836. facetsPattern: RegExp;
  84837. /** @hidden */
  84838. normalPattern: RegExp;
  84839. /** @hidden */
  84840. vertexPattern: RegExp;
  84841. /**
  84842. * Defines the name of the plugin.
  84843. */
  84844. name: string;
  84845. /**
  84846. * Defines the extensions the stl loader is able to load.
  84847. * force data to come in as an ArrayBuffer
  84848. * we'll convert to string if it looks like it's an ASCII .stl
  84849. */
  84850. extensions: ISceneLoaderPluginExtensions;
  84851. /**
  84852. * Import meshes into a scene.
  84853. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  84854. * @param scene The scene to import into
  84855. * @param data The data to import
  84856. * @param rootUrl The root url for scene and resources
  84857. * @param meshes The meshes array to import into
  84858. * @param particleSystems The particle systems array to import into
  84859. * @param skeletons The skeletons array to import into
  84860. * @param onError The callback when import fails
  84861. * @returns True if successful or false otherwise
  84862. */
  84863. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  84864. /**
  84865. * Load into a scene.
  84866. * @param scene The scene to load into
  84867. * @param data The data to import
  84868. * @param rootUrl The root url for scene and resources
  84869. * @param onError The callback when import fails
  84870. * @returns true if successful or false otherwise
  84871. */
  84872. load(scene: Scene, data: any, rootUrl: string): boolean;
  84873. /**
  84874. * Load into an asset container.
  84875. * @param scene The scene to load into
  84876. * @param data The data to import
  84877. * @param rootUrl The root url for scene and resources
  84878. * @param onError The callback when import fails
  84879. * @returns The loaded asset container
  84880. */
  84881. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  84882. private _isBinary;
  84883. private _parseBinary;
  84884. private _parseASCII;
  84885. }
  84886. }
  84887. declare module BABYLON {
  84888. /**
  84889. * Class for generating OBJ data from a Babylon scene.
  84890. */
  84891. export class OBJExport {
  84892. /**
  84893. * Exports the geometry of a Mesh array in .OBJ file format (text)
  84894. * @param mesh defines the list of meshes to serialize
  84895. * @param materials defines if materials should be exported
  84896. * @param matlibname defines the name of the associated mtl file
  84897. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  84898. * @returns the OBJ content
  84899. */
  84900. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  84901. /**
  84902. * Exports the material(s) of a mesh in .MTL file format (text)
  84903. * @param mesh defines the mesh to extract the material from
  84904. * @returns the mtl content
  84905. */
  84906. static MTL(mesh: Mesh): string;
  84907. }
  84908. }
  84909. declare module BABYLON {
  84910. /** @hidden */
  84911. export var __IGLTFExporterExtension: number;
  84912. /**
  84913. * Interface for extending the exporter
  84914. * @hidden
  84915. */
  84916. export interface IGLTFExporterExtension {
  84917. /**
  84918. * The name of this extension
  84919. */
  84920. readonly name: string;
  84921. /**
  84922. * Defines whether this extension is enabled
  84923. */
  84924. enabled: boolean;
  84925. /**
  84926. * Defines whether this extension is required
  84927. */
  84928. required: boolean;
  84929. }
  84930. }
  84931. declare module BABYLON.GLTF2.Exporter {
  84932. /** @hidden */
  84933. export var __IGLTFExporterExtensionV2: number;
  84934. /**
  84935. * Interface for a glTF exporter extension
  84936. * @hidden
  84937. */
  84938. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  84939. /**
  84940. * Define this method to modify the default behavior before exporting a texture
  84941. * @param context The context when loading the asset
  84942. * @param babylonTexture The Babylon.js texture
  84943. * @param mimeType The mime-type of the generated image
  84944. * @returns A promise that resolves with the exported texture
  84945. */
  84946. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  84947. /**
  84948. * Define this method to get notified when a texture info is created
  84949. * @param context The context when loading the asset
  84950. * @param textureInfo The glTF texture info
  84951. * @param babylonTexture The Babylon.js texture
  84952. */
  84953. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84954. /**
  84955. * Define this method to modify the default behavior when exporting texture info
  84956. * @param context The context when loading the asset
  84957. * @param meshPrimitive glTF mesh primitive
  84958. * @param babylonSubMesh Babylon submesh
  84959. * @param binaryWriter glTF serializer binary writer instance
  84960. * @returns nullable IMeshPrimitive promise
  84961. */
  84962. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  84963. /**
  84964. * Define this method to modify the default behavior when exporting a node
  84965. * @param context The context when exporting the node
  84966. * @param node glTF node
  84967. * @param babylonNode BabylonJS node
  84968. * @returns nullable INode promise
  84969. */
  84970. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84971. [key: number]: number;
  84972. }): Promise<Nullable<INode>>;
  84973. /**
  84974. * Define this method to modify the default behavior when exporting a material
  84975. * @param material glTF material
  84976. * @param babylonMaterial BabylonJS material
  84977. * @returns nullable IMaterial promise
  84978. */
  84979. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  84980. /**
  84981. * Define this method to return additional textures to export from a material
  84982. * @param material glTF material
  84983. * @param babylonMaterial BabylonJS material
  84984. * @returns List of textures
  84985. */
  84986. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84987. /** Gets a boolean indicating that this extension was used */
  84988. wasUsed: boolean;
  84989. /** Gets a boolean indicating that this extension is required for the file to work */
  84990. required: boolean;
  84991. /**
  84992. * Called after the exporter state changes to EXPORTING
  84993. */
  84994. onExporting?(): void;
  84995. }
  84996. }
  84997. declare module BABYLON.GLTF2.Exporter {
  84998. /**
  84999. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  85000. * @hidden
  85001. */
  85002. export class _GLTFMaterialExporter {
  85003. /**
  85004. * Represents the dielectric specular values for R, G and B
  85005. */
  85006. private static readonly _DielectricSpecular;
  85007. /**
  85008. * Allows the maximum specular power to be defined for material calculations
  85009. */
  85010. private static readonly _MaxSpecularPower;
  85011. /**
  85012. * Mapping to store textures
  85013. */
  85014. private _textureMap;
  85015. /**
  85016. * Numeric tolerance value
  85017. */
  85018. private static readonly _Epsilon;
  85019. /**
  85020. * Reference to the glTF Exporter
  85021. */
  85022. private _exporter;
  85023. constructor(exporter: _Exporter);
  85024. /**
  85025. * Specifies if two colors are approximately equal in value
  85026. * @param color1 first color to compare to
  85027. * @param color2 second color to compare to
  85028. * @param epsilon threshold value
  85029. */
  85030. private static FuzzyEquals;
  85031. /**
  85032. * Gets the materials from a Babylon scene and converts them to glTF materials
  85033. * @param scene babylonjs scene
  85034. * @param mimeType texture mime type
  85035. * @param images array of images
  85036. * @param textures array of textures
  85037. * @param materials array of materials
  85038. * @param imageData mapping of texture names to base64 textures
  85039. * @param hasTextureCoords specifies if texture coordinates are present on the material
  85040. */
  85041. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  85042. /**
  85043. * Makes a copy of the glTF material without the texture parameters
  85044. * @param originalMaterial original glTF material
  85045. * @returns glTF material without texture parameters
  85046. */
  85047. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  85048. /**
  85049. * Specifies if the material has any texture parameters present
  85050. * @param material glTF Material
  85051. * @returns boolean specifying if texture parameters are present
  85052. */
  85053. _hasTexturesPresent(material: IMaterial): boolean;
  85054. /**
  85055. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  85056. * @param babylonStandardMaterial
  85057. * @returns glTF Metallic Roughness Material representation
  85058. */
  85059. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  85060. /**
  85061. * Computes the metallic factor
  85062. * @param diffuse diffused value
  85063. * @param specular specular value
  85064. * @param oneMinusSpecularStrength one minus the specular strength
  85065. * @returns metallic value
  85066. */
  85067. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  85068. /**
  85069. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  85070. * @param glTFMaterial glTF material
  85071. * @param babylonMaterial Babylon material
  85072. */
  85073. private static _SetAlphaMode;
  85074. /**
  85075. * Converts a Babylon Standard Material to a glTF Material
  85076. * @param babylonStandardMaterial BJS Standard 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. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  85085. private _finishMaterial;
  85086. /**
  85087. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  85088. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  85089. * @param mimeType mime type to use for the textures
  85090. * @param images array of glTF image interfaces
  85091. * @param textures array of glTF texture interfaces
  85092. * @param materials array of glTF material interfaces
  85093. * @param imageData map of image file name to data
  85094. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85095. */
  85096. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  85097. /**
  85098. * Converts an image typed array buffer to a base64 image
  85099. * @param buffer typed array buffer
  85100. * @param width width of the image
  85101. * @param height height of the image
  85102. * @param mimeType mimetype of the image
  85103. * @returns base64 image string
  85104. */
  85105. private _createBase64FromCanvasAsync;
  85106. /**
  85107. * Generates a white texture based on the specified width and height
  85108. * @param width width of the texture in pixels
  85109. * @param height height of the texture in pixels
  85110. * @param scene babylonjs scene
  85111. * @returns white texture
  85112. */
  85113. private _createWhiteTexture;
  85114. /**
  85115. * 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
  85116. * @param texture1 first texture to resize
  85117. * @param texture2 second texture to resize
  85118. * @param scene babylonjs scene
  85119. * @returns resized textures or null
  85120. */
  85121. private _resizeTexturesToSameDimensions;
  85122. /**
  85123. * Converts an array of pixels to a Float32Array
  85124. * Throws an error if the pixel format is not supported
  85125. * @param pixels - array buffer containing pixel values
  85126. * @returns Float32 of pixels
  85127. */
  85128. private _convertPixelArrayToFloat32;
  85129. /**
  85130. * Convert Specular Glossiness Textures to Metallic Roughness
  85131. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  85132. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  85133. * @param diffuseTexture texture used to store diffuse information
  85134. * @param specularGlossinessTexture texture used to store specular and glossiness information
  85135. * @param factors specular glossiness material factors
  85136. * @param mimeType the mime type to use for the texture
  85137. * @returns pbr metallic roughness interface or null
  85138. */
  85139. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  85140. /**
  85141. * Converts specular glossiness material properties to metallic roughness
  85142. * @param specularGlossiness interface with specular glossiness material properties
  85143. * @returns interface with metallic roughness material properties
  85144. */
  85145. private _convertSpecularGlossinessToMetallicRoughness;
  85146. /**
  85147. * Calculates the surface reflectance, independent of lighting conditions
  85148. * @param color Color source to calculate brightness from
  85149. * @returns number representing the perceived brightness, or zero if color is undefined
  85150. */
  85151. private _getPerceivedBrightness;
  85152. /**
  85153. * Returns the maximum color component value
  85154. * @param color
  85155. * @returns maximum color component value, or zero if color is null or undefined
  85156. */
  85157. private _getMaxComponent;
  85158. /**
  85159. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  85160. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85161. * @param mimeType mime type to use for the textures
  85162. * @param images array of glTF image interfaces
  85163. * @param textures array of glTF texture interfaces
  85164. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  85165. * @param imageData map of image file name to data
  85166. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85167. * @returns glTF PBR Metallic Roughness factors
  85168. */
  85169. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  85170. private _getGLTFTextureSampler;
  85171. private _getGLTFTextureWrapMode;
  85172. private _getGLTFTextureWrapModesSampler;
  85173. /**
  85174. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  85175. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85176. * @param mimeType mime type to use for the textures
  85177. * @param images array of glTF image interfaces
  85178. * @param textures array of glTF texture interfaces
  85179. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  85180. * @param imageData map of image file name to data
  85181. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85182. * @returns glTF PBR Metallic Roughness factors
  85183. */
  85184. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  85185. /**
  85186. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  85187. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  85188. * @param mimeType mime type to use for the textures
  85189. * @param images array of glTF image interfaces
  85190. * @param textures array of glTF texture interfaces
  85191. * @param materials array of glTF material interfaces
  85192. * @param imageData map of image file name to data
  85193. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  85194. */
  85195. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  85196. private setMetallicRoughnessPbrMaterial;
  85197. private getPixelsFromTexture;
  85198. /**
  85199. * Extracts a texture from a Babylon texture into file data and glTF data
  85200. * @param babylonTexture Babylon texture to extract
  85201. * @param mimeType Mime Type of the babylonTexture
  85202. * @return glTF texture info, or null if the texture format is not supported
  85203. */
  85204. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  85205. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  85206. /**
  85207. * Builds a texture from base64 string
  85208. * @param base64Texture base64 texture string
  85209. * @param baseTextureName Name to use for the texture
  85210. * @param mimeType image mime type for the texture
  85211. * @param images array of images
  85212. * @param textures array of textures
  85213. * @param imageData map of image data
  85214. * @returns glTF texture info, or null if the texture format is not supported
  85215. */
  85216. private _getTextureInfoFromBase64;
  85217. }
  85218. }
  85219. declare module BABYLON {
  85220. /**
  85221. * Class for holding and downloading glTF file data
  85222. */
  85223. export class GLTFData {
  85224. /**
  85225. * Object which contains the file name as the key and its data as the value
  85226. */
  85227. glTFFiles: {
  85228. [fileName: string]: string | Blob;
  85229. };
  85230. /**
  85231. * Initializes the glTF file object
  85232. */
  85233. constructor();
  85234. /**
  85235. * Downloads the glTF data as files based on their names and data
  85236. */
  85237. downloadFiles(): void;
  85238. }
  85239. }
  85240. declare module BABYLON {
  85241. /**
  85242. * Holds a collection of exporter options and parameters
  85243. */
  85244. export interface IExportOptions {
  85245. /**
  85246. * Function which indicates whether a babylon node should be exported or not
  85247. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  85248. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  85249. */
  85250. shouldExportNode?(node: Node): boolean;
  85251. /**
  85252. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  85253. * @param metadata source metadata to read from
  85254. * @returns the data to store to glTF node extras
  85255. */
  85256. metadataSelector?(metadata: any): any;
  85257. /**
  85258. * The sample rate to bake animation curves
  85259. */
  85260. animationSampleRate?: number;
  85261. /**
  85262. * Begin serialization without waiting for the scene to be ready
  85263. */
  85264. exportWithoutWaitingForScene?: boolean;
  85265. /**
  85266. * Indicates if coordinate system swapping root nodes should be included in export
  85267. */
  85268. includeCoordinateSystemConversionNodes?: boolean;
  85269. }
  85270. /**
  85271. * Class for generating glTF data from a Babylon scene.
  85272. */
  85273. export class GLTF2Export {
  85274. /**
  85275. * Exports the geometry of the scene to .gltf file format asynchronously
  85276. * @param scene Babylon scene with scene hierarchy information
  85277. * @param filePrefix File prefix to use when generating the glTF file
  85278. * @param options Exporter options
  85279. * @returns Returns an object with a .gltf file and associates texture names
  85280. * as keys and their data and paths as values
  85281. */
  85282. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85283. private static _PreExportAsync;
  85284. private static _PostExportAsync;
  85285. /**
  85286. * Exports the geometry of the scene to .glb file format asychronously
  85287. * @param scene Babylon scene with scene hierarchy information
  85288. * @param filePrefix File prefix to use when generating glb file
  85289. * @param options Exporter options
  85290. * @returns Returns an object with a .glb filename as key and data as value
  85291. */
  85292. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  85293. }
  85294. }
  85295. declare module BABYLON.GLTF2.Exporter {
  85296. /**
  85297. * @hidden
  85298. */
  85299. export class _GLTFUtilities {
  85300. /**
  85301. * Creates a buffer view based on the supplied arguments
  85302. * @param bufferIndex index value of the specified buffer
  85303. * @param byteOffset byte offset value
  85304. * @param byteLength byte length of the bufferView
  85305. * @param byteStride byte distance between conequential elements
  85306. * @param name name of the buffer view
  85307. * @returns bufferView for glTF
  85308. */
  85309. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  85310. /**
  85311. * Creates an accessor based on the supplied arguments
  85312. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  85313. * @param name The name of the accessor
  85314. * @param type The type of the accessor
  85315. * @param componentType The datatype of components in the attribute
  85316. * @param count The number of attributes referenced by this accessor
  85317. * @param byteOffset The offset relative to the start of the bufferView in bytes
  85318. * @param min Minimum value of each component in this attribute
  85319. * @param max Maximum value of each component in this attribute
  85320. * @returns accessor for glTF
  85321. */
  85322. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  85323. /**
  85324. * Calculates the minimum and maximum values of an array of position floats
  85325. * @param positions Positions array of a mesh
  85326. * @param vertexStart Starting vertex offset to calculate min and max values
  85327. * @param vertexCount Number of vertices to check for min and max values
  85328. * @returns min number array and max number array
  85329. */
  85330. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  85331. min: number[];
  85332. max: number[];
  85333. };
  85334. /**
  85335. * Converts a new right-handed Vector3
  85336. * @param vector vector3 array
  85337. * @returns right-handed Vector3
  85338. */
  85339. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  85340. /**
  85341. * Converts a Vector3 to right-handed
  85342. * @param vector Vector3 to convert to right-handed
  85343. */
  85344. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  85345. /**
  85346. * Converts a three element number array to right-handed
  85347. * @param vector number array to convert to right-handed
  85348. */
  85349. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  85350. /**
  85351. * Converts a new right-handed Vector3
  85352. * @param vector vector3 array
  85353. * @returns right-handed Vector3
  85354. */
  85355. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  85356. /**
  85357. * Converts a Vector3 to right-handed
  85358. * @param vector Vector3 to convert to right-handed
  85359. */
  85360. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  85361. /**
  85362. * Converts a three element number array to right-handed
  85363. * @param vector number array to convert to right-handed
  85364. */
  85365. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  85366. /**
  85367. * Converts a Vector4 to right-handed
  85368. * @param vector Vector4 to convert to right-handed
  85369. */
  85370. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  85371. /**
  85372. * Converts a Vector4 to right-handed
  85373. * @param vector Vector4 to convert to right-handed
  85374. */
  85375. static _GetRightHandedArray4FromRef(vector: number[]): void;
  85376. /**
  85377. * Converts a Quaternion to right-handed
  85378. * @param quaternion Source quaternion to convert to right-handed
  85379. */
  85380. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  85381. /**
  85382. * Converts a Quaternion to right-handed
  85383. * @param quaternion Source quaternion to convert to right-handed
  85384. */
  85385. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  85386. static _NormalizeTangentFromRef(tangent: Vector4): void;
  85387. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  85388. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  85389. }
  85390. }
  85391. declare module BABYLON.GLTF2.Exporter {
  85392. /**
  85393. * Converts Babylon Scene into glTF 2.0.
  85394. * @hidden
  85395. */
  85396. export class _Exporter {
  85397. /**
  85398. * Stores the glTF to export
  85399. */
  85400. _glTF: IGLTF;
  85401. /**
  85402. * Stores all generated buffer views, which represents views into the main glTF buffer data
  85403. */
  85404. _bufferViews: IBufferView[];
  85405. /**
  85406. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  85407. */
  85408. _accessors: IAccessor[];
  85409. /**
  85410. * Stores all the generated nodes, which contains transform and/or mesh information per node
  85411. */
  85412. _nodes: INode[];
  85413. /**
  85414. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  85415. */
  85416. private _scenes;
  85417. /**
  85418. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  85419. */
  85420. private _meshes;
  85421. /**
  85422. * Stores all the generated material information, which represents the appearance of each primitive
  85423. */
  85424. _materials: IMaterial[];
  85425. _materialMap: {
  85426. [materialID: number]: number;
  85427. };
  85428. /**
  85429. * Stores all the generated texture information, which is referenced by glTF materials
  85430. */
  85431. _textures: ITexture[];
  85432. /**
  85433. * Stores all the generated image information, which is referenced by glTF textures
  85434. */
  85435. _images: IImage[];
  85436. /**
  85437. * Stores all the texture samplers
  85438. */
  85439. _samplers: ISampler[];
  85440. /**
  85441. * Stores all the generated glTF skins
  85442. */
  85443. _skins: ISkin[];
  85444. /**
  85445. * Stores all the generated animation samplers, which is referenced by glTF animations
  85446. */
  85447. /**
  85448. * Stores the animations for glTF models
  85449. */
  85450. private _animations;
  85451. /**
  85452. * Stores the total amount of bytes stored in the glTF buffer
  85453. */
  85454. private _totalByteLength;
  85455. /**
  85456. * Stores a reference to the Babylon scene containing the source geometry and material information
  85457. */
  85458. _babylonScene: Scene;
  85459. /**
  85460. * Stores a map of the image data, where the key is the file name and the value
  85461. * is the image data
  85462. */
  85463. _imageData: {
  85464. [fileName: string]: {
  85465. data: Uint8Array;
  85466. mimeType: ImageMimeType;
  85467. };
  85468. };
  85469. protected _orderedImageData: Array<{
  85470. data: Uint8Array;
  85471. mimeType: ImageMimeType;
  85472. }>;
  85473. /**
  85474. * Stores a map of the unique id of a node to its index in the node array
  85475. */
  85476. _nodeMap: {
  85477. [key: number]: number;
  85478. };
  85479. /**
  85480. * Specifies if the source Babylon scene was left handed, and needed conversion.
  85481. */
  85482. _convertToRightHandedSystem: boolean;
  85483. /**
  85484. * Specifies if a Babylon node should be converted to right-handed on export
  85485. */
  85486. _convertToRightHandedSystemMap: {
  85487. [nodeId: number]: boolean;
  85488. };
  85489. _includeCoordinateSystemConversionNodes: boolean;
  85490. /**
  85491. * Baked animation sample rate
  85492. */
  85493. private _animationSampleRate;
  85494. private _options;
  85495. private _localEngine;
  85496. _glTFMaterialExporter: _GLTFMaterialExporter;
  85497. private _extensions;
  85498. private static _ExtensionNames;
  85499. private static _ExtensionFactories;
  85500. private _applyExtension;
  85501. private _applyExtensions;
  85502. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  85503. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  85504. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  85505. [key: number]: number;
  85506. }): Promise<Nullable<INode>>;
  85507. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  85508. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  85509. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  85510. private _forEachExtensions;
  85511. private _extensionsOnExporting;
  85512. /**
  85513. * Load glTF serializer extensions
  85514. */
  85515. private _loadExtensions;
  85516. /**
  85517. * Creates a glTF Exporter instance, which can accept optional exporter options
  85518. * @param babylonScene Babylon scene object
  85519. * @param options Options to modify the behavior of the exporter
  85520. */
  85521. constructor(babylonScene: Scene, options?: IExportOptions);
  85522. dispose(): void;
  85523. /**
  85524. * Registers a glTF exporter extension
  85525. * @param name Name of the extension to export
  85526. * @param factory The factory function that creates the exporter extension
  85527. */
  85528. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  85529. /**
  85530. * Un-registers an exporter extension
  85531. * @param name The name fo the exporter extension
  85532. * @returns A boolean indicating whether the extension has been un-registered
  85533. */
  85534. static UnregisterExtension(name: string): boolean;
  85535. /**
  85536. * Lazy load a local engine
  85537. */
  85538. _getLocalEngine(): Engine;
  85539. private reorderIndicesBasedOnPrimitiveMode;
  85540. /**
  85541. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  85542. * clock-wise during export to glTF
  85543. * @param submesh BabylonJS submesh
  85544. * @param primitiveMode Primitive mode of the mesh
  85545. * @param sideOrientation the winding order of the submesh
  85546. * @param vertexBufferKind The type of vertex attribute
  85547. * @param meshAttributeArray The vertex attribute data
  85548. * @param byteOffset The offset to the binary data
  85549. * @param binaryWriter The binary data for the glTF file
  85550. * @param convertToRightHandedSystem Converts the values to right-handed
  85551. */
  85552. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  85553. /**
  85554. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  85555. * clock-wise during export to glTF
  85556. * @param submesh BabylonJS submesh
  85557. * @param primitiveMode Primitive mode of the mesh
  85558. * @param sideOrientation the winding order of the submesh
  85559. * @param vertexBufferKind The type of vertex attribute
  85560. * @param meshAttributeArray The vertex attribute data
  85561. * @param byteOffset The offset to the binary data
  85562. * @param binaryWriter The binary data for the glTF file
  85563. * @param convertToRightHandedSystem Converts the values to right-handed
  85564. */
  85565. private reorderTriangleFillMode;
  85566. /**
  85567. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  85568. * clock-wise during export to glTF
  85569. * @param submesh BabylonJS submesh
  85570. * @param primitiveMode Primitive mode of the mesh
  85571. * @param sideOrientation the winding order of the submesh
  85572. * @param vertexBufferKind The type of vertex attribute
  85573. * @param meshAttributeArray The vertex attribute data
  85574. * @param byteOffset The offset to the binary data
  85575. * @param binaryWriter The binary data for the glTF file
  85576. * @param convertToRightHandedSystem Converts the values to right-handed
  85577. */
  85578. private reorderTriangleStripDrawMode;
  85579. /**
  85580. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  85581. * clock-wise during export to glTF
  85582. * @param submesh BabylonJS submesh
  85583. * @param primitiveMode Primitive mode of the mesh
  85584. * @param sideOrientation the winding order of the submesh
  85585. * @param vertexBufferKind The type of vertex attribute
  85586. * @param meshAttributeArray The vertex attribute data
  85587. * @param byteOffset The offset to the binary data
  85588. * @param binaryWriter The binary data for the glTF file
  85589. * @param convertToRightHandedSystem Converts the values to right-handed
  85590. */
  85591. private reorderTriangleFanMode;
  85592. /**
  85593. * Writes the vertex attribute data to binary
  85594. * @param vertices The vertices to write to the binary writer
  85595. * @param byteOffset The offset into the binary writer to overwrite binary data
  85596. * @param vertexAttributeKind The vertex attribute type
  85597. * @param meshAttributeArray The vertex attribute data
  85598. * @param binaryWriter The writer containing the binary data
  85599. * @param convertToRightHandedSystem Converts the values to right-handed
  85600. */
  85601. private writeVertexAttributeData;
  85602. /**
  85603. * Writes mesh attribute data to a data buffer
  85604. * Returns the bytelength of the data
  85605. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85606. * @param meshAttributeArray Array containing the attribute data
  85607. * @param byteStride Specifies the space between data
  85608. * @param binaryWriter The buffer to write the binary data to
  85609. * @param convertToRightHandedSystem Converts the values to right-handed
  85610. */
  85611. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  85612. /**
  85613. * Writes mesh attribute data to a data buffer
  85614. * Returns the bytelength of the data
  85615. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  85616. * @param meshAttributeArray Array containing the attribute data
  85617. * @param byteStride Specifies the space between data
  85618. * @param binaryWriter The buffer to write the binary data to
  85619. * @param convertToRightHandedSystem Converts the values to right-handed
  85620. */
  85621. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  85622. /**
  85623. * Generates glTF json data
  85624. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  85625. * @param glTFPrefix Text to use when prefixing a glTF file
  85626. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  85627. * @returns json data as string
  85628. */
  85629. private generateJSON;
  85630. /**
  85631. * Generates data for .gltf and .bin files based on the glTF prefix string
  85632. * @param glTFPrefix Text to use when prefixing a glTF file
  85633. * @param dispose Dispose the exporter
  85634. * @returns GLTFData with glTF file data
  85635. */
  85636. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85637. /**
  85638. * Creates a binary buffer for glTF
  85639. * @returns array buffer for binary data
  85640. */
  85641. private _generateBinaryAsync;
  85642. /**
  85643. * Pads the number to a multiple of 4
  85644. * @param num number to pad
  85645. * @returns padded number
  85646. */
  85647. private _getPadding;
  85648. /**
  85649. * @hidden
  85650. */
  85651. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  85652. /**
  85653. * Sets the TRS for each node
  85654. * @param node glTF Node for storing the transformation data
  85655. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  85656. * @param convertToRightHandedSystem Converts the values to right-handed
  85657. */
  85658. private setNodeTransformation;
  85659. private getVertexBufferFromMesh;
  85660. /**
  85661. * Creates a bufferview based on the vertices type for the Babylon mesh
  85662. * @param kind Indicates the type of vertices data
  85663. * @param componentType Indicates the numerical type used to store the data
  85664. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  85665. * @param binaryWriter The buffer to write the bufferview data to
  85666. * @param convertToRightHandedSystem Converts the values to right-handed
  85667. */
  85668. private createBufferViewKind;
  85669. /**
  85670. * Creates a bufferview based on the vertices type for the Babylon mesh
  85671. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  85672. * @param babylonMorphTarget the morph target to be exported
  85673. * @param binaryWriter The buffer to write the bufferview data to
  85674. * @param convertToRightHandedSystem Converts the values to right-handed
  85675. */
  85676. private setMorphTargetAttributes;
  85677. /**
  85678. * The primitive mode of the Babylon mesh
  85679. * @param babylonMesh The BabylonJS mesh
  85680. */
  85681. private getMeshPrimitiveMode;
  85682. /**
  85683. * Sets the primitive mode of the glTF mesh primitive
  85684. * @param meshPrimitive glTF mesh primitive
  85685. * @param primitiveMode The primitive mode
  85686. */
  85687. private setPrimitiveMode;
  85688. /**
  85689. * Sets the vertex attribute accessor based of the glTF mesh primitive
  85690. * @param meshPrimitive glTF mesh primitive
  85691. * @param attributeKind vertex attribute
  85692. * @returns boolean specifying if uv coordinates are present
  85693. */
  85694. private setAttributeKind;
  85695. /**
  85696. * Sets data for the primitive attributes of each submesh
  85697. * @param mesh glTF Mesh object to store the primitive attribute information
  85698. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  85699. * @param binaryWriter Buffer to write the attribute data to
  85700. * @param convertToRightHandedSystem Converts the values to right-handed
  85701. */
  85702. private setPrimitiveAttributesAsync;
  85703. /**
  85704. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  85705. * @param node The node to check
  85706. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  85707. */
  85708. private isBabylonCoordinateSystemConvertingNode;
  85709. /**
  85710. * Creates a glTF scene based on the array of meshes
  85711. * Returns the the total byte offset
  85712. * @param babylonScene Babylon scene to get the mesh data from
  85713. * @param binaryWriter Buffer to write binary data to
  85714. */
  85715. private createSceneAsync;
  85716. /**
  85717. * Creates a mapping of Node unique id to node index and handles animations
  85718. * @param babylonScene Babylon Scene
  85719. * @param nodes Babylon transform nodes
  85720. * @param binaryWriter Buffer to write binary data to
  85721. * @returns Node mapping of unique id to index
  85722. */
  85723. private createNodeMapAndAnimationsAsync;
  85724. /**
  85725. * Creates a glTF node from a Babylon mesh
  85726. * @param babylonMesh Source Babylon mesh
  85727. * @param binaryWriter Buffer for storing geometry data
  85728. * @param convertToRightHandedSystem Converts the values to right-handed
  85729. * @param nodeMap Node mapping of unique id to glTF node index
  85730. * @returns glTF node
  85731. */
  85732. private createNodeAsync;
  85733. /**
  85734. * Creates a glTF skin from a Babylon skeleton
  85735. * @param babylonScene Babylon Scene
  85736. * @param nodes Babylon transform nodes
  85737. * @param binaryWriter Buffer to write binary data to
  85738. * @returns Node mapping of unique id to index
  85739. */
  85740. private createSkinsAsync;
  85741. }
  85742. /**
  85743. * @hidden
  85744. *
  85745. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  85746. */
  85747. export class _BinaryWriter {
  85748. /**
  85749. * Array buffer which stores all binary data
  85750. */
  85751. private _arrayBuffer;
  85752. /**
  85753. * View of the array buffer
  85754. */
  85755. private _dataView;
  85756. /**
  85757. * byte offset of data in array buffer
  85758. */
  85759. private _byteOffset;
  85760. /**
  85761. * Initialize binary writer with an initial byte length
  85762. * @param byteLength Initial byte length of the array buffer
  85763. */
  85764. constructor(byteLength: number);
  85765. /**
  85766. * Resize the array buffer to the specified byte length
  85767. * @param byteLength
  85768. */
  85769. private resizeBuffer;
  85770. /**
  85771. * Get an array buffer with the length of the byte offset
  85772. * @returns ArrayBuffer resized to the byte offset
  85773. */
  85774. getArrayBuffer(): ArrayBuffer;
  85775. /**
  85776. * Get the byte offset of the array buffer
  85777. * @returns byte offset
  85778. */
  85779. getByteOffset(): number;
  85780. /**
  85781. * Stores an UInt8 in the array buffer
  85782. * @param entry
  85783. * @param byteOffset If defined, specifies where to set the value as an offset.
  85784. */
  85785. setUInt8(entry: number, byteOffset?: number): void;
  85786. /**
  85787. * Stores an UInt16 in the array buffer
  85788. * @param entry
  85789. * @param byteOffset If defined, specifies where to set the value as an offset.
  85790. */
  85791. setUInt16(entry: number, byteOffset?: number): void;
  85792. /**
  85793. * Gets an UInt32 in the array buffer
  85794. * @param entry
  85795. * @param byteOffset If defined, specifies where to set the value as an offset.
  85796. */
  85797. getUInt32(byteOffset: number): number;
  85798. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85799. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  85800. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85801. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  85802. /**
  85803. * Stores a Float32 in the array buffer
  85804. * @param entry
  85805. */
  85806. setFloat32(entry: number, byteOffset?: number): void;
  85807. /**
  85808. * Stores an UInt32 in the array buffer
  85809. * @param entry
  85810. * @param byteOffset If defined, specifies where to set the value as an offset.
  85811. */
  85812. setUInt32(entry: number, byteOffset?: number): void;
  85813. }
  85814. }
  85815. declare module BABYLON.GLTF2.Exporter {
  85816. /**
  85817. * @hidden
  85818. * Interface to store animation data.
  85819. */
  85820. export interface _IAnimationData {
  85821. /**
  85822. * Keyframe data.
  85823. */
  85824. inputs: number[];
  85825. /**
  85826. * Value data.
  85827. */
  85828. outputs: number[][];
  85829. /**
  85830. * Animation interpolation data.
  85831. */
  85832. samplerInterpolation: AnimationSamplerInterpolation;
  85833. /**
  85834. * Minimum keyframe value.
  85835. */
  85836. inputsMin: number;
  85837. /**
  85838. * Maximum keyframe value.
  85839. */
  85840. inputsMax: number;
  85841. }
  85842. /**
  85843. * @hidden
  85844. */
  85845. export interface _IAnimationInfo {
  85846. /**
  85847. * The target channel for the animation
  85848. */
  85849. animationChannelTargetPath: AnimationChannelTargetPath;
  85850. /**
  85851. * The glTF accessor type for the data.
  85852. */
  85853. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  85854. /**
  85855. * Specifies if quaternions should be used.
  85856. */
  85857. useQuaternion: boolean;
  85858. }
  85859. /**
  85860. * @hidden
  85861. * Utility class for generating glTF animation data from BabylonJS.
  85862. */
  85863. export class _GLTFAnimation {
  85864. /**
  85865. * @ignore
  85866. *
  85867. * Creates glTF channel animation from BabylonJS animation.
  85868. * @param babylonTransformNode - BabylonJS mesh.
  85869. * @param animation - animation.
  85870. * @param animationChannelTargetPath - The target animation channel.
  85871. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  85872. * @param useQuaternion - Specifies if quaternions are used.
  85873. * @returns nullable IAnimationData
  85874. */
  85875. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  85876. private static _DeduceAnimationInfo;
  85877. /**
  85878. * @ignore
  85879. * Create node animations from the transform node animations
  85880. * @param babylonNode
  85881. * @param runtimeGLTFAnimation
  85882. * @param idleGLTFAnimations
  85883. * @param nodeMap
  85884. * @param nodes
  85885. * @param binaryWriter
  85886. * @param bufferViews
  85887. * @param accessors
  85888. * @param convertToRightHandedSystem
  85889. * @param animationSampleRate
  85890. */
  85891. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85892. [key: number]: number;
  85893. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85894. /**
  85895. * @ignore
  85896. * Create individual morph animations from the mesh's morph target animation tracks
  85897. * @param babylonNode
  85898. * @param runtimeGLTFAnimation
  85899. * @param idleGLTFAnimations
  85900. * @param nodeMap
  85901. * @param nodes
  85902. * @param binaryWriter
  85903. * @param bufferViews
  85904. * @param accessors
  85905. * @param convertToRightHandedSystem
  85906. * @param animationSampleRate
  85907. */
  85908. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  85909. [key: number]: number;
  85910. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  85911. /**
  85912. * @ignore
  85913. * Create node and morph animations from the animation groups
  85914. * @param babylonScene
  85915. * @param glTFAnimations
  85916. * @param nodeMap
  85917. * @param nodes
  85918. * @param binaryWriter
  85919. * @param bufferViews
  85920. * @param accessors
  85921. * @param convertToRightHandedSystemMap
  85922. * @param animationSampleRate
  85923. */
  85924. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  85925. [key: number]: number;
  85926. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  85927. [nodeId: number]: boolean;
  85928. }, animationSampleRate: number): void;
  85929. private static AddAnimation;
  85930. /**
  85931. * Create a baked animation
  85932. * @param babylonTransformNode BabylonJS mesh
  85933. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  85934. * @param animationChannelTargetPath animation target channel
  85935. * @param minFrame minimum animation frame
  85936. * @param maxFrame maximum animation frame
  85937. * @param fps frames per second of the animation
  85938. * @param inputs input key frames of the animation
  85939. * @param outputs output key frame data of the animation
  85940. * @param convertToRightHandedSystem converts the values to right-handed
  85941. * @param useQuaternion specifies if quaternions should be used
  85942. */
  85943. private static _CreateBakedAnimation;
  85944. private static _ConvertFactorToVector3OrQuaternion;
  85945. private static _SetInterpolatedValue;
  85946. /**
  85947. * Creates linear animation from the animation key frames
  85948. * @param babylonTransformNode BabylonJS mesh
  85949. * @param animation BabylonJS animation
  85950. * @param animationChannelTargetPath The target animation channel
  85951. * @param frameDelta The difference between the last and first frame of the animation
  85952. * @param inputs Array to store the key frame times
  85953. * @param outputs Array to store the key frame data
  85954. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85955. * @param useQuaternion Specifies if quaternions are used in the animation
  85956. */
  85957. private static _CreateLinearOrStepAnimation;
  85958. /**
  85959. * Creates cubic spline animation from the animation key frames
  85960. * @param babylonTransformNode BabylonJS mesh
  85961. * @param animation BabylonJS animation
  85962. * @param animationChannelTargetPath The target animation channel
  85963. * @param frameDelta The difference between the last and first frame of the animation
  85964. * @param inputs Array to store the key frame times
  85965. * @param outputs Array to store the key frame data
  85966. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  85967. * @param useQuaternion Specifies if quaternions are used in the animation
  85968. */
  85969. private static _CreateCubicSplineAnimation;
  85970. private static _GetBasePositionRotationOrScale;
  85971. /**
  85972. * Adds a key frame value
  85973. * @param keyFrame
  85974. * @param animation
  85975. * @param outputs
  85976. * @param animationChannelTargetPath
  85977. * @param basePositionRotationOrScale
  85978. * @param convertToRightHandedSystem
  85979. * @param useQuaternion
  85980. */
  85981. private static _AddKeyframeValue;
  85982. /**
  85983. * Determine the interpolation based on the key frames
  85984. * @param keyFrames
  85985. * @param animationChannelTargetPath
  85986. * @param useQuaternion
  85987. */
  85988. private static _DeduceInterpolation;
  85989. /**
  85990. * Adds an input tangent or output tangent to the output data
  85991. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  85992. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  85993. * @param outputs The animation data by keyframe
  85994. * @param animationChannelTargetPath The target animation channel
  85995. * @param interpolation The interpolation type
  85996. * @param keyFrame The key frame with the animation data
  85997. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  85998. * @param useQuaternion Specifies if quaternions are used
  85999. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  86000. */
  86001. private static AddSplineTangent;
  86002. /**
  86003. * Get the minimum and maximum key frames' frame values
  86004. * @param keyFrames animation key frames
  86005. * @returns the minimum and maximum key frame value
  86006. */
  86007. private static calculateMinMaxKeyFrames;
  86008. }
  86009. }
  86010. declare module BABYLON.GLTF2.Exporter {
  86011. /** @hidden */
  86012. export var textureTransformPixelShader: {
  86013. name: string;
  86014. shader: string;
  86015. };
  86016. }
  86017. declare module BABYLON.GLTF2.Exporter.Extensions {
  86018. /**
  86019. * @hidden
  86020. */
  86021. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  86022. private _recordedTextures;
  86023. /** Name of this extension */
  86024. readonly name: string;
  86025. /** Defines whether this extension is enabled */
  86026. enabled: boolean;
  86027. /** Defines whether this extension is required */
  86028. required: boolean;
  86029. /** Reference to the glTF exporter */
  86030. private _wasUsed;
  86031. constructor(exporter: _Exporter);
  86032. dispose(): void;
  86033. /** @hidden */
  86034. get wasUsed(): boolean;
  86035. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  86036. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  86037. /**
  86038. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  86039. * @param babylonTexture
  86040. * @param offset
  86041. * @param rotation
  86042. * @param scale
  86043. * @param scene
  86044. */
  86045. private _textureTransformTextureAsync;
  86046. }
  86047. }
  86048. declare module BABYLON.GLTF2.Exporter.Extensions {
  86049. /**
  86050. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  86051. */
  86052. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  86053. /** The name of this extension. */
  86054. readonly name: string;
  86055. /** Defines whether this extension is enabled. */
  86056. enabled: boolean;
  86057. /** Defines whether this extension is required */
  86058. required: boolean;
  86059. /** Reference to the glTF exporter */
  86060. private _exporter;
  86061. private _lights;
  86062. /** @hidden */
  86063. constructor(exporter: _Exporter);
  86064. /** @hidden */
  86065. dispose(): void;
  86066. /** @hidden */
  86067. get wasUsed(): boolean;
  86068. /** @hidden */
  86069. onExporting(): void;
  86070. /**
  86071. * Define this method to modify the default behavior when exporting a node
  86072. * @param context The context when exporting the node
  86073. * @param node glTF node
  86074. * @param babylonNode BabylonJS node
  86075. * @param nodeMap Node mapping of unique id to glTF node index
  86076. * @returns nullable INode promise
  86077. */
  86078. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  86079. [key: number]: number;
  86080. }): Promise<Nullable<INode>>;
  86081. }
  86082. }
  86083. declare module BABYLON.GLTF2.Exporter.Extensions {
  86084. /**
  86085. * @hidden
  86086. */
  86087. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  86088. /** Name of this extension */
  86089. readonly name: string;
  86090. /** Defines whether this extension is enabled */
  86091. enabled: boolean;
  86092. /** Defines whether this extension is required */
  86093. required: boolean;
  86094. /** Reference to the glTF exporter */
  86095. private _textureInfos;
  86096. private _exportedTextures;
  86097. private _wasUsed;
  86098. constructor(exporter: _Exporter);
  86099. dispose(): void;
  86100. /** @hidden */
  86101. get wasUsed(): boolean;
  86102. private _getTextureIndex;
  86103. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  86104. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  86105. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  86106. }
  86107. }
  86108. declare module BABYLON.GLTF2.Exporter.Extensions {
  86109. /**
  86110. * @hidden
  86111. */
  86112. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  86113. /** Name of this extension */
  86114. readonly name: string;
  86115. /** Defines whether this extension is enabled */
  86116. enabled: boolean;
  86117. /** Defines whether this extension is required */
  86118. required: boolean;
  86119. private _wasUsed;
  86120. constructor(exporter: _Exporter);
  86121. /** @hidden */
  86122. get wasUsed(): boolean;
  86123. dispose(): void;
  86124. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  86125. }
  86126. }
  86127. declare module BABYLON {
  86128. /**
  86129. * Class for generating STL data from a Babylon scene.
  86130. */
  86131. export class STLExport {
  86132. /**
  86133. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  86134. * @param meshes list defines the mesh to serialize
  86135. * @param download triggers the automatic download of the file.
  86136. * @param fileName changes the downloads fileName.
  86137. * @param binary changes the STL to a binary type.
  86138. * @param isLittleEndian toggle for binary type exporter.
  86139. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  86140. * @returns the STL as UTF8 string
  86141. */
  86142. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  86143. }
  86144. }
  86145. declare module "babylonjs-gltf2interface" {
  86146. export = BABYLON.GLTF2;
  86147. }
  86148. /**
  86149. * Module for glTF 2.0 Interface
  86150. */
  86151. declare module BABYLON.GLTF2 {
  86152. /**
  86153. * The datatype of the components in the attribute
  86154. */
  86155. const enum AccessorComponentType {
  86156. /**
  86157. * Byte
  86158. */
  86159. BYTE = 5120,
  86160. /**
  86161. * Unsigned Byte
  86162. */
  86163. UNSIGNED_BYTE = 5121,
  86164. /**
  86165. * Short
  86166. */
  86167. SHORT = 5122,
  86168. /**
  86169. * Unsigned Short
  86170. */
  86171. UNSIGNED_SHORT = 5123,
  86172. /**
  86173. * Unsigned Int
  86174. */
  86175. UNSIGNED_INT = 5125,
  86176. /**
  86177. * Float
  86178. */
  86179. FLOAT = 5126,
  86180. }
  86181. /**
  86182. * Specifies if the attirbute is a scalar, vector, or matrix
  86183. */
  86184. const enum AccessorType {
  86185. /**
  86186. * Scalar
  86187. */
  86188. SCALAR = "SCALAR",
  86189. /**
  86190. * Vector2
  86191. */
  86192. VEC2 = "VEC2",
  86193. /**
  86194. * Vector3
  86195. */
  86196. VEC3 = "VEC3",
  86197. /**
  86198. * Vector4
  86199. */
  86200. VEC4 = "VEC4",
  86201. /**
  86202. * Matrix2x2
  86203. */
  86204. MAT2 = "MAT2",
  86205. /**
  86206. * Matrix3x3
  86207. */
  86208. MAT3 = "MAT3",
  86209. /**
  86210. * Matrix4x4
  86211. */
  86212. MAT4 = "MAT4",
  86213. }
  86214. /**
  86215. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86216. */
  86217. const enum AnimationChannelTargetPath {
  86218. /**
  86219. * Translation
  86220. */
  86221. TRANSLATION = "translation",
  86222. /**
  86223. * Rotation
  86224. */
  86225. ROTATION = "rotation",
  86226. /**
  86227. * Scale
  86228. */
  86229. SCALE = "scale",
  86230. /**
  86231. * Weights
  86232. */
  86233. WEIGHTS = "weights",
  86234. }
  86235. /**
  86236. * Interpolation algorithm
  86237. */
  86238. const enum AnimationSamplerInterpolation {
  86239. /**
  86240. * The animated values are linearly interpolated between keyframes
  86241. */
  86242. LINEAR = "LINEAR",
  86243. /**
  86244. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  86245. */
  86246. STEP = "STEP",
  86247. /**
  86248. * The animation's interpolation is computed using a cubic spline with specified tangents
  86249. */
  86250. CUBICSPLINE = "CUBICSPLINE",
  86251. }
  86252. /**
  86253. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86254. */
  86255. const enum CameraType {
  86256. /**
  86257. * A perspective camera containing properties to create a perspective projection matrix
  86258. */
  86259. PERSPECTIVE = "perspective",
  86260. /**
  86261. * An orthographic camera containing properties to create an orthographic projection matrix
  86262. */
  86263. ORTHOGRAPHIC = "orthographic",
  86264. }
  86265. /**
  86266. * The mime-type of the image
  86267. */
  86268. const enum ImageMimeType {
  86269. /**
  86270. * JPEG Mime-type
  86271. */
  86272. JPEG = "image/jpeg",
  86273. /**
  86274. * PNG Mime-type
  86275. */
  86276. PNG = "image/png",
  86277. }
  86278. /**
  86279. * The alpha rendering mode of the material
  86280. */
  86281. const enum MaterialAlphaMode {
  86282. /**
  86283. * The alpha value is ignored and the rendered output is fully opaque
  86284. */
  86285. OPAQUE = "OPAQUE",
  86286. /**
  86287. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  86288. */
  86289. MASK = "MASK",
  86290. /**
  86291. * 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)
  86292. */
  86293. BLEND = "BLEND",
  86294. }
  86295. /**
  86296. * The type of the primitives to render
  86297. */
  86298. const enum MeshPrimitiveMode {
  86299. /**
  86300. * Points
  86301. */
  86302. POINTS = 0,
  86303. /**
  86304. * Lines
  86305. */
  86306. LINES = 1,
  86307. /**
  86308. * Line Loop
  86309. */
  86310. LINE_LOOP = 2,
  86311. /**
  86312. * Line Strip
  86313. */
  86314. LINE_STRIP = 3,
  86315. /**
  86316. * Triangles
  86317. */
  86318. TRIANGLES = 4,
  86319. /**
  86320. * Triangle Strip
  86321. */
  86322. TRIANGLE_STRIP = 5,
  86323. /**
  86324. * Triangle Fan
  86325. */
  86326. TRIANGLE_FAN = 6,
  86327. }
  86328. /**
  86329. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86330. */
  86331. const enum TextureMagFilter {
  86332. /**
  86333. * Nearest
  86334. */
  86335. NEAREST = 9728,
  86336. /**
  86337. * Linear
  86338. */
  86339. LINEAR = 9729,
  86340. }
  86341. /**
  86342. * Minification filter. All valid values correspond to WebGL enums
  86343. */
  86344. const enum TextureMinFilter {
  86345. /**
  86346. * Nearest
  86347. */
  86348. NEAREST = 9728,
  86349. /**
  86350. * Linear
  86351. */
  86352. LINEAR = 9729,
  86353. /**
  86354. * Nearest Mip-Map Nearest
  86355. */
  86356. NEAREST_MIPMAP_NEAREST = 9984,
  86357. /**
  86358. * Linear Mipmap Nearest
  86359. */
  86360. LINEAR_MIPMAP_NEAREST = 9985,
  86361. /**
  86362. * Nearest Mipmap Linear
  86363. */
  86364. NEAREST_MIPMAP_LINEAR = 9986,
  86365. /**
  86366. * Linear Mipmap Linear
  86367. */
  86368. LINEAR_MIPMAP_LINEAR = 9987,
  86369. }
  86370. /**
  86371. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86372. */
  86373. const enum TextureWrapMode {
  86374. /**
  86375. * Clamp to Edge
  86376. */
  86377. CLAMP_TO_EDGE = 33071,
  86378. /**
  86379. * Mirrored Repeat
  86380. */
  86381. MIRRORED_REPEAT = 33648,
  86382. /**
  86383. * Repeat
  86384. */
  86385. REPEAT = 10497,
  86386. }
  86387. /**
  86388. * glTF Property
  86389. */
  86390. interface IProperty {
  86391. /**
  86392. * Dictionary object with extension-specific objects
  86393. */
  86394. extensions?: {
  86395. [key: string]: any;
  86396. };
  86397. /**
  86398. * Application-Specific data
  86399. */
  86400. extras?: any;
  86401. }
  86402. /**
  86403. * glTF Child of Root Property
  86404. */
  86405. interface IChildRootProperty extends IProperty {
  86406. /**
  86407. * The user-defined name of this object
  86408. */
  86409. name?: string;
  86410. }
  86411. /**
  86412. * Indices of those attributes that deviate from their initialization value
  86413. */
  86414. interface IAccessorSparseIndices extends IProperty {
  86415. /**
  86416. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86417. */
  86418. bufferView: number;
  86419. /**
  86420. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86421. */
  86422. byteOffset?: number;
  86423. /**
  86424. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  86425. */
  86426. componentType: AccessorComponentType;
  86427. }
  86428. /**
  86429. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  86430. */
  86431. interface IAccessorSparseValues extends IProperty {
  86432. /**
  86433. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  86434. */
  86435. bufferView: number;
  86436. /**
  86437. * The offset relative to the start of the bufferView in bytes. Must be aligned
  86438. */
  86439. byteOffset?: number;
  86440. }
  86441. /**
  86442. * Sparse storage of attributes that deviate from their initialization value
  86443. */
  86444. interface IAccessorSparse extends IProperty {
  86445. /**
  86446. * The number of attributes encoded in this sparse accessor
  86447. */
  86448. count: number;
  86449. /**
  86450. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  86451. */
  86452. indices: IAccessorSparseIndices;
  86453. /**
  86454. * 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
  86455. */
  86456. values: IAccessorSparseValues;
  86457. }
  86458. /**
  86459. * 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
  86460. */
  86461. interface IAccessor extends IChildRootProperty {
  86462. /**
  86463. * The index of the bufferview
  86464. */
  86465. bufferView?: number;
  86466. /**
  86467. * The offset relative to the start of the bufferView in bytes
  86468. */
  86469. byteOffset?: number;
  86470. /**
  86471. * The datatype of components in the attribute
  86472. */
  86473. componentType: AccessorComponentType;
  86474. /**
  86475. * Specifies whether integer data values should be normalized
  86476. */
  86477. normalized?: boolean;
  86478. /**
  86479. * The number of attributes referenced by this accessor
  86480. */
  86481. count: number;
  86482. /**
  86483. * Specifies if the attribute is a scalar, vector, or matrix
  86484. */
  86485. type: AccessorType;
  86486. /**
  86487. * Maximum value of each component in this attribute
  86488. */
  86489. max?: number[];
  86490. /**
  86491. * Minimum value of each component in this attribute
  86492. */
  86493. min?: number[];
  86494. /**
  86495. * Sparse storage of attributes that deviate from their initialization value
  86496. */
  86497. sparse?: IAccessorSparse;
  86498. }
  86499. /**
  86500. * Targets an animation's sampler at a node's property
  86501. */
  86502. interface IAnimationChannel extends IProperty {
  86503. /**
  86504. * The index of a sampler in this animation used to compute the value for the target
  86505. */
  86506. sampler: number;
  86507. /**
  86508. * The index of the node and TRS property to target
  86509. */
  86510. target: IAnimationChannelTarget;
  86511. }
  86512. /**
  86513. * The index of the node and TRS property that an animation channel targets
  86514. */
  86515. interface IAnimationChannelTarget extends IProperty {
  86516. /**
  86517. * The index of the node to target
  86518. */
  86519. node: number;
  86520. /**
  86521. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  86522. */
  86523. path: AnimationChannelTargetPath;
  86524. }
  86525. /**
  86526. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86527. */
  86528. interface IAnimationSampler extends IProperty {
  86529. /**
  86530. * The index of an accessor containing keyframe input values, e.g., time
  86531. */
  86532. input: number;
  86533. /**
  86534. * Interpolation algorithm
  86535. */
  86536. interpolation?: AnimationSamplerInterpolation;
  86537. /**
  86538. * The index of an accessor, containing keyframe output values
  86539. */
  86540. output: number;
  86541. }
  86542. /**
  86543. * A keyframe animation
  86544. */
  86545. interface IAnimation extends IChildRootProperty {
  86546. /**
  86547. * An array of channels, each of which targets an animation's sampler at a node's property
  86548. */
  86549. channels: IAnimationChannel[];
  86550. /**
  86551. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  86552. */
  86553. samplers: IAnimationSampler[];
  86554. }
  86555. /**
  86556. * Metadata about the glTF asset
  86557. */
  86558. interface IAsset extends IChildRootProperty {
  86559. /**
  86560. * A copyright message suitable for display to credit the content creator
  86561. */
  86562. copyright?: string;
  86563. /**
  86564. * Tool that generated this glTF model. Useful for debugging
  86565. */
  86566. generator?: string;
  86567. /**
  86568. * The glTF version that this asset targets
  86569. */
  86570. version: string;
  86571. /**
  86572. * The minimum glTF version that this asset targets
  86573. */
  86574. minVersion?: string;
  86575. }
  86576. /**
  86577. * A buffer points to binary geometry, animation, or skins
  86578. */
  86579. interface IBuffer extends IChildRootProperty {
  86580. /**
  86581. * 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
  86582. */
  86583. uri?: string;
  86584. /**
  86585. * The length of the buffer in bytes
  86586. */
  86587. byteLength: number;
  86588. }
  86589. /**
  86590. * A view into a buffer generally representing a subset of the buffer
  86591. */
  86592. interface IBufferView extends IChildRootProperty {
  86593. /**
  86594. * The index of the buffer
  86595. */
  86596. buffer: number;
  86597. /**
  86598. * The offset into the buffer in bytes
  86599. */
  86600. byteOffset?: number;
  86601. /**
  86602. * The lenth of the bufferView in bytes
  86603. */
  86604. byteLength: number;
  86605. /**
  86606. * The stride, in bytes
  86607. */
  86608. byteStride?: number;
  86609. }
  86610. /**
  86611. * An orthographic camera containing properties to create an orthographic projection matrix
  86612. */
  86613. interface ICameraOrthographic extends IProperty {
  86614. /**
  86615. * The floating-point horizontal magnification of the view. Must not be zero
  86616. */
  86617. xmag: number;
  86618. /**
  86619. * The floating-point vertical magnification of the view. Must not be zero
  86620. */
  86621. ymag: number;
  86622. /**
  86623. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  86624. */
  86625. zfar: number;
  86626. /**
  86627. * The floating-point distance to the near clipping plane
  86628. */
  86629. znear: number;
  86630. }
  86631. /**
  86632. * A perspective camera containing properties to create a perspective projection matrix
  86633. */
  86634. interface ICameraPerspective extends IProperty {
  86635. /**
  86636. * The floating-point aspect ratio of the field of view
  86637. */
  86638. aspectRatio?: number;
  86639. /**
  86640. * The floating-point vertical field of view in radians
  86641. */
  86642. yfov: number;
  86643. /**
  86644. * The floating-point distance to the far clipping plane
  86645. */
  86646. zfar?: number;
  86647. /**
  86648. * The floating-point distance to the near clipping plane
  86649. */
  86650. znear: number;
  86651. }
  86652. /**
  86653. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  86654. */
  86655. interface ICamera extends IChildRootProperty {
  86656. /**
  86657. * An orthographic camera containing properties to create an orthographic projection matrix
  86658. */
  86659. orthographic?: ICameraOrthographic;
  86660. /**
  86661. * A perspective camera containing properties to create a perspective projection matrix
  86662. */
  86663. perspective?: ICameraPerspective;
  86664. /**
  86665. * Specifies if the camera uses a perspective or orthographic projection
  86666. */
  86667. type: CameraType;
  86668. }
  86669. /**
  86670. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  86671. */
  86672. interface IImage extends IChildRootProperty {
  86673. /**
  86674. * 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
  86675. */
  86676. uri?: string;
  86677. /**
  86678. * The image's MIME type
  86679. */
  86680. mimeType?: ImageMimeType;
  86681. /**
  86682. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  86683. */
  86684. bufferView?: number;
  86685. }
  86686. /**
  86687. * Material Normal Texture Info
  86688. */
  86689. interface IMaterialNormalTextureInfo extends ITextureInfo {
  86690. /**
  86691. * The scalar multiplier applied to each normal vector of the normal texture
  86692. */
  86693. scale?: number;
  86694. }
  86695. /**
  86696. * Material Occlusion Texture Info
  86697. */
  86698. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  86699. /**
  86700. * A scalar multiplier controlling the amount of occlusion applied
  86701. */
  86702. strength?: number;
  86703. }
  86704. /**
  86705. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  86706. */
  86707. interface IMaterialPbrMetallicRoughness {
  86708. /**
  86709. * The material's base color factor
  86710. */
  86711. baseColorFactor?: number[];
  86712. /**
  86713. * The base color texture
  86714. */
  86715. baseColorTexture?: ITextureInfo;
  86716. /**
  86717. * The metalness of the material
  86718. */
  86719. metallicFactor?: number;
  86720. /**
  86721. * The roughness of the material
  86722. */
  86723. roughnessFactor?: number;
  86724. /**
  86725. * The metallic-roughness texture
  86726. */
  86727. metallicRoughnessTexture?: ITextureInfo;
  86728. }
  86729. /**
  86730. * The material appearance of a primitive
  86731. */
  86732. interface IMaterial extends IChildRootProperty {
  86733. /**
  86734. * 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
  86735. */
  86736. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86737. /**
  86738. * The normal map texture
  86739. */
  86740. normalTexture?: IMaterialNormalTextureInfo;
  86741. /**
  86742. * The occlusion map texture
  86743. */
  86744. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86745. /**
  86746. * The emissive map texture
  86747. */
  86748. emissiveTexture?: ITextureInfo;
  86749. /**
  86750. * 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
  86751. */
  86752. emissiveFactor?: number[];
  86753. /**
  86754. * The alpha rendering mode of the material
  86755. */
  86756. alphaMode?: MaterialAlphaMode;
  86757. /**
  86758. * The alpha cutoff value of the material
  86759. */
  86760. alphaCutoff?: number;
  86761. /**
  86762. * Specifies whether the material is double sided
  86763. */
  86764. doubleSided?: boolean;
  86765. }
  86766. /**
  86767. * Geometry to be rendered with the given material
  86768. */
  86769. interface IMeshPrimitive extends IProperty {
  86770. /**
  86771. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  86772. */
  86773. attributes: {
  86774. [name: string]: number;
  86775. };
  86776. /**
  86777. * The index of the accessor that contains the indices
  86778. */
  86779. indices?: number;
  86780. /**
  86781. * The index of the material to apply to this primitive when rendering
  86782. */
  86783. material?: number;
  86784. /**
  86785. * The type of primitives to render. All valid values correspond to WebGL enums
  86786. */
  86787. mode?: MeshPrimitiveMode;
  86788. /**
  86789. * 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
  86790. */
  86791. targets?: {
  86792. [name: string]: number;
  86793. }[];
  86794. }
  86795. /**
  86796. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  86797. */
  86798. interface IMesh extends IChildRootProperty {
  86799. /**
  86800. * An array of primitives, each defining geometry to be rendered with a material
  86801. */
  86802. primitives: IMeshPrimitive[];
  86803. /**
  86804. * Array of weights to be applied to the Morph Targets
  86805. */
  86806. weights?: number[];
  86807. }
  86808. /**
  86809. * A node in the node hierarchy
  86810. */
  86811. interface INode extends IChildRootProperty {
  86812. /**
  86813. * The index of the camera referenced by this node
  86814. */
  86815. camera?: number;
  86816. /**
  86817. * The indices of this node's children
  86818. */
  86819. children?: number[];
  86820. /**
  86821. * The index of the skin referenced by this node
  86822. */
  86823. skin?: number;
  86824. /**
  86825. * A floating-point 4x4 transformation matrix stored in column-major order
  86826. */
  86827. matrix?: number[];
  86828. /**
  86829. * The index of the mesh in this node
  86830. */
  86831. mesh?: number;
  86832. /**
  86833. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  86834. */
  86835. rotation?: number[];
  86836. /**
  86837. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  86838. */
  86839. scale?: number[];
  86840. /**
  86841. * The node's translation along the x, y, and z axes
  86842. */
  86843. translation?: number[];
  86844. /**
  86845. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  86846. */
  86847. weights?: number[];
  86848. }
  86849. /**
  86850. * Texture sampler properties for filtering and wrapping modes
  86851. */
  86852. interface ISampler extends IChildRootProperty {
  86853. /**
  86854. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  86855. */
  86856. magFilter?: TextureMagFilter;
  86857. /**
  86858. * Minification filter. All valid values correspond to WebGL enums
  86859. */
  86860. minFilter?: TextureMinFilter;
  86861. /**
  86862. * S (U) wrapping mode. All valid values correspond to WebGL enums
  86863. */
  86864. wrapS?: TextureWrapMode;
  86865. /**
  86866. * T (V) wrapping mode. All valid values correspond to WebGL enums
  86867. */
  86868. wrapT?: TextureWrapMode;
  86869. }
  86870. /**
  86871. * The root nodes of a scene
  86872. */
  86873. interface IScene extends IChildRootProperty {
  86874. /**
  86875. * The indices of each root node
  86876. */
  86877. nodes: number[];
  86878. }
  86879. /**
  86880. * Joints and matrices defining a skin
  86881. */
  86882. interface ISkin extends IChildRootProperty {
  86883. /**
  86884. * 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
  86885. */
  86886. inverseBindMatrices?: number;
  86887. /**
  86888. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  86889. */
  86890. skeleton?: number;
  86891. /**
  86892. * 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)
  86893. */
  86894. joints: number[];
  86895. }
  86896. /**
  86897. * A texture and its sampler
  86898. */
  86899. interface ITexture extends IChildRootProperty {
  86900. /**
  86901. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  86902. */
  86903. sampler?: number;
  86904. /**
  86905. * The index of the image used by this texture
  86906. */
  86907. source: number;
  86908. }
  86909. /**
  86910. * Reference to a texture
  86911. */
  86912. interface ITextureInfo extends IProperty {
  86913. /**
  86914. * The index of the texture
  86915. */
  86916. index: number;
  86917. /**
  86918. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  86919. */
  86920. texCoord?: number;
  86921. }
  86922. /**
  86923. * The root object for a glTF asset
  86924. */
  86925. interface IGLTF extends IProperty {
  86926. /**
  86927. * An array of accessors. An accessor is a typed view into a bufferView
  86928. */
  86929. accessors?: IAccessor[];
  86930. /**
  86931. * An array of keyframe animations
  86932. */
  86933. animations?: IAnimation[];
  86934. /**
  86935. * Metadata about the glTF asset
  86936. */
  86937. asset: IAsset;
  86938. /**
  86939. * An array of buffers. A buffer points to binary geometry, animation, or skins
  86940. */
  86941. buffers?: IBuffer[];
  86942. /**
  86943. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  86944. */
  86945. bufferViews?: IBufferView[];
  86946. /**
  86947. * An array of cameras
  86948. */
  86949. cameras?: ICamera[];
  86950. /**
  86951. * Names of glTF extensions used somewhere in this asset
  86952. */
  86953. extensionsUsed?: string[];
  86954. /**
  86955. * Names of glTF extensions required to properly load this asset
  86956. */
  86957. extensionsRequired?: string[];
  86958. /**
  86959. * An array of images. An image defines data used to create a texture
  86960. */
  86961. images?: IImage[];
  86962. /**
  86963. * An array of materials. A material defines the appearance of a primitive
  86964. */
  86965. materials?: IMaterial[];
  86966. /**
  86967. * An array of meshes. A mesh is a set of primitives to be rendered
  86968. */
  86969. meshes?: IMesh[];
  86970. /**
  86971. * An array of nodes
  86972. */
  86973. nodes?: INode[];
  86974. /**
  86975. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  86976. */
  86977. samplers?: ISampler[];
  86978. /**
  86979. * The index of the default scene
  86980. */
  86981. scene?: number;
  86982. /**
  86983. * An array of scenes
  86984. */
  86985. scenes?: IScene[];
  86986. /**
  86987. * An array of skins. A skin is defined by joints and matrices
  86988. */
  86989. skins?: ISkin[];
  86990. /**
  86991. * An array of textures
  86992. */
  86993. textures?: ITexture[];
  86994. }
  86995. /**
  86996. * The glTF validation results
  86997. * @ignore
  86998. */
  86999. interface IGLTFValidationResults {
  87000. info: {
  87001. generator: string;
  87002. hasAnimations: boolean;
  87003. hasDefaultScene: boolean;
  87004. hasMaterials: boolean;
  87005. hasMorphTargets: boolean;
  87006. hasSkins: boolean;
  87007. hasTextures: boolean;
  87008. maxAttributesUsed: number;
  87009. primitivesCount: number
  87010. };
  87011. issues: {
  87012. messages: Array<string>;
  87013. numErrors: number;
  87014. numHints: number;
  87015. numInfos: number;
  87016. numWarnings: number;
  87017. truncated: boolean
  87018. };
  87019. mimeType: string;
  87020. uri: string;
  87021. validatedAt: string;
  87022. validatorVersion: string;
  87023. }
  87024. /**
  87025. * The glTF validation options
  87026. */
  87027. interface IGLTFValidationOptions {
  87028. /** Uri to use */
  87029. uri?: string;
  87030. /** Function used to load external resources */
  87031. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  87032. /** Boolean indicating that we need to validate accessor data */
  87033. validateAccessorData?: boolean;
  87034. /** max number of issues allowed */
  87035. maxIssues?: number;
  87036. /** Ignored issues */
  87037. ignoredIssues?: Array<string>;
  87038. /** Value to override severy settings */
  87039. severityOverrides?: Object;
  87040. }
  87041. /**
  87042. * The glTF validator object
  87043. * @ignore
  87044. */
  87045. interface IGLTFValidator {
  87046. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  87047. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  87048. }
  87049. /**
  87050. * Interfaces from the EXT_lights_image_based extension
  87051. */
  87052. /** @hidden */
  87053. interface IEXTLightsImageBased_LightReferenceImageBased {
  87054. light: number;
  87055. }
  87056. /** @hidden */
  87057. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  87058. intensity: number;
  87059. rotation: number[];
  87060. specularImageSize: number;
  87061. specularImages: number[][];
  87062. irradianceCoefficients: number[][];
  87063. }
  87064. /** @hidden */
  87065. interface IEXTLightsImageBased {
  87066. lights: IEXTLightsImageBased_LightImageBased[];
  87067. }
  87068. /**
  87069. * Interfaces from the EXT_mesh_gpu_instancing extension
  87070. * !!! Experimental Extension Subject to Changes !!!
  87071. */
  87072. /** @hidden */
  87073. interface IEXTMeshGpuInstancing {
  87074. mesh?: number;
  87075. attributes: { [name: string]: number };
  87076. }
  87077. /**
  87078. * Interfaces from the KHR_draco_mesh_compression extension
  87079. */
  87080. /** @hidden */
  87081. interface IKHRDracoMeshCompression {
  87082. bufferView: number;
  87083. attributes: { [name: string]: number };
  87084. }
  87085. /**
  87086. * Interfaces from the KHR_lights_punctual extension
  87087. */
  87088. /** @hidden */
  87089. const enum IKHRLightsPunctual_LightType {
  87090. DIRECTIONAL = "directional",
  87091. POINT = "point",
  87092. SPOT = "spot"
  87093. }
  87094. /** @hidden */
  87095. interface IKHRLightsPunctual_LightReference {
  87096. light: number;
  87097. }
  87098. /** @hidden */
  87099. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  87100. type: IKHRLightsPunctual_LightType;
  87101. color?: number[];
  87102. intensity?: number;
  87103. range?: number;
  87104. spot?: {
  87105. innerConeAngle?: number;
  87106. outerConeAngle?: number;
  87107. };
  87108. }
  87109. /** @hidden */
  87110. interface IKHRLightsPunctual {
  87111. lights: IKHRLightsPunctual_Light[];
  87112. }
  87113. /**
  87114. * Interfaces from the KHR_materials_clearcoat extension
  87115. * !!! Experimental Extension Subject to Changes !!!
  87116. */
  87117. /** @hidden */
  87118. interface IKHRMaterialsClearcoat {
  87119. clearcoatFactor: number;
  87120. clearcoatTexture: ITextureInfo;
  87121. clearcoatRoughnessFactor: number;
  87122. clearcoatRoughnessTexture: ITextureInfo;
  87123. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  87124. }
  87125. /**
  87126. * Interfaces from the KHR_materials_ior extension
  87127. * !!! Experimental Extension Subject to Changes !!!
  87128. */
  87129. /** @hidden */
  87130. interface IKHRMaterialsIor {
  87131. ior: number;
  87132. }
  87133. /**
  87134. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  87135. */
  87136. /** @hidden */
  87137. interface IKHRMaterialsPbrSpecularGlossiness {
  87138. diffuseFactor: number[];
  87139. diffuseTexture: ITextureInfo;
  87140. specularFactor: number[];
  87141. glossinessFactor: number;
  87142. specularGlossinessTexture: ITextureInfo;
  87143. }
  87144. /**
  87145. * Interfaces from the KHR_materials_sheen extension
  87146. * !!! Experimental Extension Subject to Changes !!!
  87147. */
  87148. /** @hidden */
  87149. interface IKHRMaterialsSheen {
  87150. sheenColorFactor?: number[];
  87151. sheenColorTexture?: ITextureInfo;
  87152. sheenRoughnessFactor?: number;
  87153. sheenRoughnessTexture?: ITextureInfo;
  87154. }
  87155. /**
  87156. * Interfaces from the KHR_materials_specular extension
  87157. * !!! Experimental Extension Subject to Changes !!!
  87158. */
  87159. /** @hidden */
  87160. interface IKHRMaterialsSpecular {
  87161. specularFactor: number;
  87162. specularColorFactor: number[];
  87163. specularTexture: ITextureInfo;
  87164. }
  87165. /**
  87166. * Interfaces from the KHR_materials_transmission extension
  87167. * !!! Experimental Extension Subject to Changes !!!
  87168. */
  87169. /** @hidden */
  87170. interface IKHRMaterialsTransmission {
  87171. transmissionFactor?: number;
  87172. transmissionTexture?: ITextureInfo;
  87173. }
  87174. /**
  87175. * Interfaces from the KHR_materials_translucency extension
  87176. * !!! Experimental Extension Subject to Changes !!!
  87177. */
  87178. /** @hidden */
  87179. interface IKHRMaterialsTranslucency {
  87180. translucencyFactor?: number;
  87181. translucencyTexture?: ITextureInfo;
  87182. }
  87183. /**
  87184. * Interfaces from the KHR_materials_variants extension
  87185. * !!! Experimental Extension Subject to Changes !!!
  87186. */
  87187. /** @hidden */
  87188. interface IKHRMaterialVariants_Mapping extends IProperty {
  87189. mappings: Array<{
  87190. variants: number[];
  87191. material: number;
  87192. }>;
  87193. }
  87194. /** @hidden */
  87195. interface IKHRMaterialVariants_Variant extends IProperty {
  87196. name: string;
  87197. }
  87198. /** @hidden */
  87199. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  87200. variants: Array<IKHRMaterialVariants_Variant>;
  87201. }
  87202. /**
  87203. * Interfaces from the KHR_texture_basisu extension
  87204. * !!! Experimental Extension Subject to Changes !!!
  87205. */
  87206. /** @hidden */
  87207. interface IKHRTextureBasisU {
  87208. source: number;
  87209. }
  87210. /**
  87211. * Interfaces from the EXT_texture_webp extension
  87212. */
  87213. /** @hidden */
  87214. interface IEXTTextureWebP {
  87215. source: number;
  87216. }
  87217. /**
  87218. * Interfaces from the KHR_texture_transform extension
  87219. */
  87220. /** @hidden */
  87221. interface IKHRTextureTransform {
  87222. offset?: number[];
  87223. rotation?: number;
  87224. scale?: number[];
  87225. texCoord?: number;
  87226. }
  87227. /**
  87228. * Interfaces from the KHR_xmp extension
  87229. * !!! Experimental Extension Subject to Changes !!!
  87230. */
  87231. /** @hidden */
  87232. interface IKHRXmp_Data {
  87233. [key: string]: unknown;
  87234. }
  87235. /** @hidden */
  87236. interface IKHRXmp_Gltf {
  87237. packets: IKHRXmp_Data[];
  87238. }
  87239. /** @hidden */
  87240. interface IKHRXmp_Node {
  87241. packet: number;
  87242. }
  87243. /**
  87244. * Interfaces from the MSFT_audio_emitter extension
  87245. */
  87246. /** @hidden */
  87247. interface IMSFTAudioEmitter_ClipReference {
  87248. clip: number;
  87249. weight?: number;
  87250. }
  87251. /** @hidden */
  87252. interface IMSFTAudioEmitter_EmittersReference {
  87253. emitters: number[];
  87254. }
  87255. /** @hidden */
  87256. const enum IMSFTAudioEmitter_DistanceModel {
  87257. linear = "linear",
  87258. inverse = "inverse",
  87259. exponential = "exponential",
  87260. }
  87261. /** @hidden */
  87262. interface IMSFTAudioEmitter_Emitter {
  87263. name?: string;
  87264. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  87265. refDistance?: number;
  87266. maxDistance?: number;
  87267. rolloffFactor?: number;
  87268. innerAngle?: number;
  87269. outerAngle?: number;
  87270. loop?: boolean;
  87271. volume?: number;
  87272. clips: IMSFTAudioEmitter_ClipReference[];
  87273. }
  87274. /** @hidden */
  87275. const enum IMSFTAudioEmitter_AudioMimeType {
  87276. WAV = "audio/wav",
  87277. }
  87278. /** @hidden */
  87279. interface IMSFTAudioEmitter_Clip extends IProperty {
  87280. uri?: string;
  87281. bufferView?: number;
  87282. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  87283. }
  87284. /** @hidden */
  87285. const enum IMSFTAudioEmitter_AnimationEventAction {
  87286. play = "play",
  87287. pause = "pause",
  87288. stop = "stop",
  87289. }
  87290. /** @hidden */
  87291. interface IMSFTAudioEmitter_AnimationEvent {
  87292. action: IMSFTAudioEmitter_AnimationEventAction;
  87293. emitter: number;
  87294. time: number;
  87295. startOffset?: number;
  87296. }
  87297. /**
  87298. * Interfaces from the MSFT_lod extension
  87299. */
  87300. /** @hidden */
  87301. interface IMSFTLOD {
  87302. ids: number[];
  87303. }
  87304. }
  87305. declare module BABYLON {
  87306. /** @hidden */
  87307. export var cellPixelShader: {
  87308. name: string;
  87309. shader: string;
  87310. };
  87311. }
  87312. declare module BABYLON {
  87313. /** @hidden */
  87314. export var cellVertexShader: {
  87315. name: string;
  87316. shader: string;
  87317. };
  87318. }
  87319. declare module BABYLON {
  87320. export class CellMaterial extends BABYLON.PushMaterial {
  87321. private _diffuseTexture;
  87322. diffuseTexture: BABYLON.BaseTexture;
  87323. diffuseColor: BABYLON.Color3;
  87324. _computeHighLevel: boolean;
  87325. computeHighLevel: boolean;
  87326. private _disableLighting;
  87327. disableLighting: boolean;
  87328. private _maxSimultaneousLights;
  87329. maxSimultaneousLights: number;
  87330. constructor(name: string, scene: BABYLON.Scene);
  87331. needAlphaBlending(): boolean;
  87332. needAlphaTesting(): boolean;
  87333. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87334. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87335. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87336. getAnimatables(): BABYLON.IAnimatable[];
  87337. getActiveTextures(): BABYLON.BaseTexture[];
  87338. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87339. dispose(forceDisposeEffect?: boolean): void;
  87340. getClassName(): string;
  87341. clone(name: string): CellMaterial;
  87342. serialize(): any;
  87343. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  87344. }
  87345. }
  87346. declare module BABYLON {
  87347. export class CustomShaderStructure {
  87348. FragmentStore: string;
  87349. VertexStore: string;
  87350. constructor();
  87351. }
  87352. export class ShaderSpecialParts {
  87353. constructor();
  87354. Fragment_Begin: string;
  87355. Fragment_Definitions: string;
  87356. Fragment_MainBegin: string;
  87357. Fragment_Custom_Diffuse: string;
  87358. Fragment_Before_Lights: string;
  87359. Fragment_Before_Fog: string;
  87360. Fragment_Custom_Alpha: string;
  87361. Fragment_Before_FragColor: string;
  87362. Vertex_Begin: string;
  87363. Vertex_Definitions: string;
  87364. Vertex_MainBegin: string;
  87365. Vertex_Before_PositionUpdated: string;
  87366. Vertex_Before_NormalUpdated: string;
  87367. Vertex_After_WorldPosComputed: string;
  87368. Vertex_MainEnd: string;
  87369. }
  87370. export class CustomMaterial extends BABYLON.StandardMaterial {
  87371. static ShaderIndexer: number;
  87372. CustomParts: ShaderSpecialParts;
  87373. _isCreatedShader: boolean;
  87374. _createdShaderName: string;
  87375. _customUniform: string[];
  87376. _newUniforms: string[];
  87377. _newUniformInstances: {
  87378. [name: string]: any;
  87379. };
  87380. _newSamplerInstances: {
  87381. [name: string]: BABYLON.Texture;
  87382. };
  87383. _customAttributes: string[];
  87384. FragmentShader: string;
  87385. VertexShader: string;
  87386. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87387. ReviewUniform(name: string, arr: string[]): string[];
  87388. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87389. constructor(name: string, scene: BABYLON.Scene);
  87390. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  87391. AddAttribute(name: string): CustomMaterial;
  87392. Fragment_Begin(shaderPart: string): CustomMaterial;
  87393. Fragment_Definitions(shaderPart: string): CustomMaterial;
  87394. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  87395. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  87396. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  87397. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  87398. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  87399. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  87400. Vertex_Begin(shaderPart: string): CustomMaterial;
  87401. Vertex_Definitions(shaderPart: string): CustomMaterial;
  87402. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  87403. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  87404. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  87405. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  87406. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  87407. }
  87408. }
  87409. declare module BABYLON {
  87410. export class ShaderAlebdoParts {
  87411. constructor();
  87412. Fragment_Begin: string;
  87413. Fragment_Definitions: string;
  87414. Fragment_MainBegin: string;
  87415. Fragment_Custom_Albedo: string;
  87416. Fragment_Before_Lights: string;
  87417. Fragment_Custom_MetallicRoughness: string;
  87418. Fragment_Custom_MicroSurface: string;
  87419. Fragment_Before_Fog: string;
  87420. Fragment_Custom_Alpha: string;
  87421. Fragment_Before_FragColor: string;
  87422. Vertex_Begin: string;
  87423. Vertex_Definitions: string;
  87424. Vertex_MainBegin: string;
  87425. Vertex_Before_PositionUpdated: string;
  87426. Vertex_Before_NormalUpdated: string;
  87427. Vertex_After_WorldPosComputed: string;
  87428. Vertex_MainEnd: string;
  87429. }
  87430. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  87431. static ShaderIndexer: number;
  87432. CustomParts: ShaderAlebdoParts;
  87433. _isCreatedShader: boolean;
  87434. _createdShaderName: string;
  87435. _customUniform: string[];
  87436. _newUniforms: string[];
  87437. _newUniformInstances: {
  87438. [name: string]: any;
  87439. };
  87440. _newSamplerInstances: {
  87441. [name: string]: BABYLON.Texture;
  87442. };
  87443. _customAttributes: string[];
  87444. FragmentShader: string;
  87445. VertexShader: string;
  87446. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  87447. ReviewUniform(name: string, arr: string[]): string[];
  87448. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  87449. constructor(name: string, scene: BABYLON.Scene);
  87450. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  87451. AddAttribute(name: string): PBRCustomMaterial;
  87452. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  87453. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  87454. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  87455. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  87456. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  87457. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  87458. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  87459. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  87460. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  87461. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  87462. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  87463. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  87464. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  87465. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  87466. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  87467. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  87468. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  87469. }
  87470. }
  87471. declare module BABYLON {
  87472. /** @hidden */
  87473. export var firePixelShader: {
  87474. name: string;
  87475. shader: string;
  87476. };
  87477. }
  87478. declare module BABYLON {
  87479. /** @hidden */
  87480. export var fireVertexShader: {
  87481. name: string;
  87482. shader: string;
  87483. };
  87484. }
  87485. declare module BABYLON {
  87486. export class FireMaterial extends BABYLON.PushMaterial {
  87487. private _diffuseTexture;
  87488. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87489. private _distortionTexture;
  87490. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87491. private _opacityTexture;
  87492. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  87493. diffuseColor: BABYLON.Color3;
  87494. speed: number;
  87495. private _scaledDiffuse;
  87496. private _lastTime;
  87497. constructor(name: string, scene: BABYLON.Scene);
  87498. needAlphaBlending(): boolean;
  87499. needAlphaTesting(): boolean;
  87500. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87501. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87502. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87503. getAnimatables(): BABYLON.IAnimatable[];
  87504. getActiveTextures(): BABYLON.BaseTexture[];
  87505. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87506. getClassName(): string;
  87507. dispose(forceDisposeEffect?: boolean): void;
  87508. clone(name: string): FireMaterial;
  87509. serialize(): any;
  87510. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  87511. }
  87512. }
  87513. declare module BABYLON {
  87514. /** @hidden */
  87515. export var furPixelShader: {
  87516. name: string;
  87517. shader: string;
  87518. };
  87519. }
  87520. declare module BABYLON {
  87521. /** @hidden */
  87522. export var furVertexShader: {
  87523. name: string;
  87524. shader: string;
  87525. };
  87526. }
  87527. declare module BABYLON {
  87528. export class FurMaterial extends BABYLON.PushMaterial {
  87529. private _diffuseTexture;
  87530. diffuseTexture: BABYLON.BaseTexture;
  87531. private _heightTexture;
  87532. heightTexture: BABYLON.BaseTexture;
  87533. diffuseColor: BABYLON.Color3;
  87534. furLength: number;
  87535. furAngle: number;
  87536. furColor: BABYLON.Color3;
  87537. furOffset: number;
  87538. furSpacing: number;
  87539. furGravity: BABYLON.Vector3;
  87540. furSpeed: number;
  87541. furDensity: number;
  87542. furOcclusion: number;
  87543. furTexture: BABYLON.DynamicTexture;
  87544. private _disableLighting;
  87545. disableLighting: boolean;
  87546. private _maxSimultaneousLights;
  87547. maxSimultaneousLights: number;
  87548. highLevelFur: boolean;
  87549. _meshes: BABYLON.AbstractMesh[];
  87550. private _furTime;
  87551. constructor(name: string, scene: BABYLON.Scene);
  87552. get furTime(): number;
  87553. set furTime(furTime: number);
  87554. needAlphaBlending(): boolean;
  87555. needAlphaTesting(): boolean;
  87556. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87557. updateFur(): void;
  87558. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87559. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87560. getAnimatables(): BABYLON.IAnimatable[];
  87561. getActiveTextures(): BABYLON.BaseTexture[];
  87562. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87563. dispose(forceDisposeEffect?: boolean): void;
  87564. clone(name: string): FurMaterial;
  87565. serialize(): any;
  87566. getClassName(): string;
  87567. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  87568. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  87569. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  87570. }
  87571. }
  87572. declare module BABYLON {
  87573. /** @hidden */
  87574. export var gradientPixelShader: {
  87575. name: string;
  87576. shader: string;
  87577. };
  87578. }
  87579. declare module BABYLON {
  87580. /** @hidden */
  87581. export var gradientVertexShader: {
  87582. name: string;
  87583. shader: string;
  87584. };
  87585. }
  87586. declare module BABYLON {
  87587. export class GradientMaterial extends BABYLON.PushMaterial {
  87588. private _maxSimultaneousLights;
  87589. maxSimultaneousLights: number;
  87590. topColor: BABYLON.Color3;
  87591. topColorAlpha: number;
  87592. bottomColor: BABYLON.Color3;
  87593. bottomColorAlpha: number;
  87594. offset: number;
  87595. scale: number;
  87596. smoothness: number;
  87597. private _disableLighting;
  87598. disableLighting: boolean;
  87599. constructor(name: string, scene: BABYLON.Scene);
  87600. needAlphaBlending(): boolean;
  87601. needAlphaTesting(): boolean;
  87602. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87603. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87604. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87605. getAnimatables(): BABYLON.IAnimatable[];
  87606. dispose(forceDisposeEffect?: boolean): void;
  87607. clone(name: string): GradientMaterial;
  87608. serialize(): any;
  87609. getClassName(): string;
  87610. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  87611. }
  87612. }
  87613. declare module BABYLON {
  87614. /** @hidden */
  87615. export var gridPixelShader: {
  87616. name: string;
  87617. shader: string;
  87618. };
  87619. }
  87620. declare module BABYLON {
  87621. /** @hidden */
  87622. export var gridVertexShader: {
  87623. name: string;
  87624. shader: string;
  87625. };
  87626. }
  87627. declare module BABYLON {
  87628. /**
  87629. * The grid materials allows you to wrap any shape with a grid.
  87630. * Colors are customizable.
  87631. */
  87632. export class GridMaterial extends BABYLON.PushMaterial {
  87633. /**
  87634. * Main color of the grid (e.g. between lines)
  87635. */
  87636. mainColor: BABYLON.Color3;
  87637. /**
  87638. * Color of the grid lines.
  87639. */
  87640. lineColor: BABYLON.Color3;
  87641. /**
  87642. * The scale of the grid compared to unit.
  87643. */
  87644. gridRatio: number;
  87645. /**
  87646. * Allows setting an offset for the grid lines.
  87647. */
  87648. gridOffset: BABYLON.Vector3;
  87649. /**
  87650. * The frequency of thicker lines.
  87651. */
  87652. majorUnitFrequency: number;
  87653. /**
  87654. * The visibility of minor units in the grid.
  87655. */
  87656. minorUnitVisibility: number;
  87657. /**
  87658. * The grid opacity outside of the lines.
  87659. */
  87660. opacity: number;
  87661. /**
  87662. * Determine RBG output is premultiplied by alpha value.
  87663. */
  87664. preMultiplyAlpha: boolean;
  87665. private _opacityTexture;
  87666. opacityTexture: BABYLON.BaseTexture;
  87667. private _gridControl;
  87668. /**
  87669. * constructor
  87670. * @param name The name given to the material in order to identify it afterwards.
  87671. * @param scene The scene the material is used in.
  87672. */
  87673. constructor(name: string, scene: BABYLON.Scene);
  87674. /**
  87675. * Returns wehter or not the grid requires alpha blending.
  87676. */
  87677. needAlphaBlending(): boolean;
  87678. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87679. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87680. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87681. /**
  87682. * Dispose the material and its associated resources.
  87683. * @param forceDisposeEffect will also dispose the used effect when true
  87684. */
  87685. dispose(forceDisposeEffect?: boolean): void;
  87686. clone(name: string): GridMaterial;
  87687. serialize(): any;
  87688. getClassName(): string;
  87689. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  87690. }
  87691. }
  87692. declare module BABYLON {
  87693. /** @hidden */
  87694. export var lavaPixelShader: {
  87695. name: string;
  87696. shader: string;
  87697. };
  87698. }
  87699. declare module BABYLON {
  87700. /** @hidden */
  87701. export var lavaVertexShader: {
  87702. name: string;
  87703. shader: string;
  87704. };
  87705. }
  87706. declare module BABYLON {
  87707. export class LavaMaterial extends BABYLON.PushMaterial {
  87708. private _diffuseTexture;
  87709. diffuseTexture: BABYLON.BaseTexture;
  87710. noiseTexture: BABYLON.BaseTexture;
  87711. fogColor: BABYLON.Color3;
  87712. speed: number;
  87713. movingSpeed: number;
  87714. lowFrequencySpeed: number;
  87715. fogDensity: number;
  87716. private _lastTime;
  87717. diffuseColor: BABYLON.Color3;
  87718. private _disableLighting;
  87719. disableLighting: boolean;
  87720. private _unlit;
  87721. unlit: boolean;
  87722. private _maxSimultaneousLights;
  87723. maxSimultaneousLights: number;
  87724. private _scaledDiffuse;
  87725. constructor(name: string, scene: BABYLON.Scene);
  87726. needAlphaBlending(): boolean;
  87727. needAlphaTesting(): boolean;
  87728. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87729. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87730. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87731. getAnimatables(): BABYLON.IAnimatable[];
  87732. getActiveTextures(): BABYLON.BaseTexture[];
  87733. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87734. dispose(forceDisposeEffect?: boolean): void;
  87735. clone(name: string): LavaMaterial;
  87736. serialize(): any;
  87737. getClassName(): string;
  87738. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  87739. }
  87740. }
  87741. declare module BABYLON {
  87742. /** @hidden */
  87743. export var mixPixelShader: {
  87744. name: string;
  87745. shader: string;
  87746. };
  87747. }
  87748. declare module BABYLON {
  87749. /** @hidden */
  87750. export var mixVertexShader: {
  87751. name: string;
  87752. shader: string;
  87753. };
  87754. }
  87755. declare module BABYLON {
  87756. export class MixMaterial extends BABYLON.PushMaterial {
  87757. /**
  87758. * Mix textures
  87759. */
  87760. private _mixTexture1;
  87761. mixTexture1: BABYLON.BaseTexture;
  87762. private _mixTexture2;
  87763. mixTexture2: BABYLON.BaseTexture;
  87764. /**
  87765. * Diffuse textures
  87766. */
  87767. private _diffuseTexture1;
  87768. diffuseTexture1: BABYLON.Texture;
  87769. private _diffuseTexture2;
  87770. diffuseTexture2: BABYLON.Texture;
  87771. private _diffuseTexture3;
  87772. diffuseTexture3: BABYLON.Texture;
  87773. private _diffuseTexture4;
  87774. diffuseTexture4: BABYLON.Texture;
  87775. private _diffuseTexture5;
  87776. diffuseTexture5: BABYLON.Texture;
  87777. private _diffuseTexture6;
  87778. diffuseTexture6: BABYLON.Texture;
  87779. private _diffuseTexture7;
  87780. diffuseTexture7: BABYLON.Texture;
  87781. private _diffuseTexture8;
  87782. diffuseTexture8: BABYLON.Texture;
  87783. /**
  87784. * Uniforms
  87785. */
  87786. diffuseColor: BABYLON.Color3;
  87787. specularColor: BABYLON.Color3;
  87788. specularPower: number;
  87789. private _disableLighting;
  87790. disableLighting: boolean;
  87791. private _maxSimultaneousLights;
  87792. maxSimultaneousLights: number;
  87793. constructor(name: string, scene: BABYLON.Scene);
  87794. needAlphaBlending(): boolean;
  87795. needAlphaTesting(): boolean;
  87796. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87797. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87798. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87799. getAnimatables(): BABYLON.IAnimatable[];
  87800. getActiveTextures(): BABYLON.BaseTexture[];
  87801. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87802. dispose(forceDisposeEffect?: boolean): void;
  87803. clone(name: string): MixMaterial;
  87804. serialize(): any;
  87805. getClassName(): string;
  87806. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  87807. }
  87808. }
  87809. declare module BABYLON {
  87810. /** @hidden */
  87811. export var normalPixelShader: {
  87812. name: string;
  87813. shader: string;
  87814. };
  87815. }
  87816. declare module BABYLON {
  87817. /** @hidden */
  87818. export var normalVertexShader: {
  87819. name: string;
  87820. shader: string;
  87821. };
  87822. }
  87823. declare module BABYLON {
  87824. export class NormalMaterial extends BABYLON.PushMaterial {
  87825. private _diffuseTexture;
  87826. diffuseTexture: BABYLON.BaseTexture;
  87827. diffuseColor: BABYLON.Color3;
  87828. private _disableLighting;
  87829. disableLighting: boolean;
  87830. private _maxSimultaneousLights;
  87831. maxSimultaneousLights: number;
  87832. constructor(name: string, scene: BABYLON.Scene);
  87833. needAlphaBlending(): boolean;
  87834. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  87835. needAlphaTesting(): boolean;
  87836. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87837. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87838. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87839. getAnimatables(): BABYLON.IAnimatable[];
  87840. getActiveTextures(): BABYLON.BaseTexture[];
  87841. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87842. dispose(forceDisposeEffect?: boolean): void;
  87843. clone(name: string): NormalMaterial;
  87844. serialize(): any;
  87845. getClassName(): string;
  87846. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  87847. }
  87848. }
  87849. declare module BABYLON {
  87850. /** @hidden */
  87851. export var shadowOnlyPixelShader: {
  87852. name: string;
  87853. shader: string;
  87854. };
  87855. }
  87856. declare module BABYLON {
  87857. /** @hidden */
  87858. export var shadowOnlyVertexShader: {
  87859. name: string;
  87860. shader: string;
  87861. };
  87862. }
  87863. declare module BABYLON {
  87864. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  87865. private _activeLight;
  87866. private _needAlphaBlending;
  87867. constructor(name: string, scene: BABYLON.Scene);
  87868. shadowColor: BABYLON.Color3;
  87869. needAlphaBlending(): boolean;
  87870. needAlphaTesting(): boolean;
  87871. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87872. get activeLight(): BABYLON.IShadowLight;
  87873. set activeLight(light: BABYLON.IShadowLight);
  87874. private _getFirstShadowLightForMesh;
  87875. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87876. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87877. clone(name: string): ShadowOnlyMaterial;
  87878. serialize(): any;
  87879. getClassName(): string;
  87880. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  87881. }
  87882. }
  87883. declare module BABYLON {
  87884. /** @hidden */
  87885. export var simplePixelShader: {
  87886. name: string;
  87887. shader: string;
  87888. };
  87889. }
  87890. declare module BABYLON {
  87891. /** @hidden */
  87892. export var simpleVertexShader: {
  87893. name: string;
  87894. shader: string;
  87895. };
  87896. }
  87897. declare module BABYLON {
  87898. export class SimpleMaterial extends BABYLON.PushMaterial {
  87899. private _diffuseTexture;
  87900. diffuseTexture: BABYLON.BaseTexture;
  87901. diffuseColor: BABYLON.Color3;
  87902. private _disableLighting;
  87903. disableLighting: boolean;
  87904. private _maxSimultaneousLights;
  87905. maxSimultaneousLights: number;
  87906. constructor(name: string, scene: BABYLON.Scene);
  87907. needAlphaBlending(): boolean;
  87908. needAlphaTesting(): boolean;
  87909. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87910. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87911. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87912. getAnimatables(): BABYLON.IAnimatable[];
  87913. getActiveTextures(): BABYLON.BaseTexture[];
  87914. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87915. dispose(forceDisposeEffect?: boolean): void;
  87916. clone(name: string): SimpleMaterial;
  87917. serialize(): any;
  87918. getClassName(): string;
  87919. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  87920. }
  87921. }
  87922. declare module BABYLON {
  87923. /** @hidden */
  87924. export var skyPixelShader: {
  87925. name: string;
  87926. shader: string;
  87927. };
  87928. }
  87929. declare module BABYLON {
  87930. /** @hidden */
  87931. export var skyVertexShader: {
  87932. name: string;
  87933. shader: string;
  87934. };
  87935. }
  87936. declare module BABYLON {
  87937. /**
  87938. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  87939. * @see https://doc.babylonjs.com/extensions/sky
  87940. */
  87941. export class SkyMaterial extends BABYLON.PushMaterial {
  87942. /**
  87943. * Defines the overall luminance of sky in interval ]0, 1[.
  87944. */
  87945. luminance: number;
  87946. /**
  87947. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  87948. */
  87949. turbidity: number;
  87950. /**
  87951. * Defines the sky appearance (light intensity).
  87952. */
  87953. rayleigh: number;
  87954. /**
  87955. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  87956. */
  87957. mieCoefficient: number;
  87958. /**
  87959. * Defines the amount of haze particles following the Mie scattering theory.
  87960. */
  87961. mieDirectionalG: number;
  87962. /**
  87963. * Defines the distance of the sun according to the active scene camera.
  87964. */
  87965. distance: number;
  87966. /**
  87967. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  87968. * "inclined".
  87969. */
  87970. inclination: number;
  87971. /**
  87972. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  87973. * an object direction and a reference direction.
  87974. */
  87975. azimuth: number;
  87976. /**
  87977. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  87978. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  87979. */
  87980. sunPosition: BABYLON.Vector3;
  87981. /**
  87982. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  87983. * .sunPosition property.
  87984. */
  87985. useSunPosition: boolean;
  87986. /**
  87987. * Defines an offset vector used to get a horizon offset.
  87988. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  87989. */
  87990. cameraOffset: BABYLON.Vector3;
  87991. private _cameraPosition;
  87992. /**
  87993. * Instantiates a new sky material.
  87994. * This material allows to create dynamic and texture free
  87995. * effects for skyboxes by taking care of the atmosphere state.
  87996. * @see https://doc.babylonjs.com/extensions/sky
  87997. * @param name Define the name of the material in the scene
  87998. * @param scene Define the scene the material belong to
  87999. */
  88000. constructor(name: string, scene: BABYLON.Scene);
  88001. /**
  88002. * Specifies if the material will require alpha blending
  88003. * @returns a boolean specifying if alpha blending is needed
  88004. */
  88005. needAlphaBlending(): boolean;
  88006. /**
  88007. * Specifies if this material should be rendered in alpha test mode
  88008. * @returns false as the sky material doesn't need alpha testing.
  88009. */
  88010. needAlphaTesting(): boolean;
  88011. /**
  88012. * Get the texture used for alpha test purpose.
  88013. * @returns null as the sky material has no texture.
  88014. */
  88015. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88016. /**
  88017. * Get if the submesh is ready to be used and all its information available.
  88018. * Child classes can use it to update shaders
  88019. * @param mesh defines the mesh to check
  88020. * @param subMesh defines which submesh to check
  88021. * @param useInstances specifies that instances should be used
  88022. * @returns a boolean indicating that the submesh is ready or not
  88023. */
  88024. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88025. /**
  88026. * Binds the submesh to this material by preparing the effect and shader to draw
  88027. * @param world defines the world transformation matrix
  88028. * @param mesh defines the mesh containing the submesh
  88029. * @param subMesh defines the submesh to bind the material to
  88030. */
  88031. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88032. /**
  88033. * Get the list of animatables in the material.
  88034. * @returns the list of animatables object used in the material
  88035. */
  88036. getAnimatables(): BABYLON.IAnimatable[];
  88037. /**
  88038. * Disposes the material
  88039. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88040. */
  88041. dispose(forceDisposeEffect?: boolean): void;
  88042. /**
  88043. * Makes a duplicate of the material, and gives it a new name
  88044. * @param name defines the new name for the duplicated material
  88045. * @returns the cloned material
  88046. */
  88047. clone(name: string): SkyMaterial;
  88048. /**
  88049. * Serializes this material in a JSON representation
  88050. * @returns the serialized material object
  88051. */
  88052. serialize(): any;
  88053. /**
  88054. * Gets the current class name of the material e.g. "SkyMaterial"
  88055. * Mainly use in serialization.
  88056. * @returns the class name
  88057. */
  88058. getClassName(): string;
  88059. /**
  88060. * Creates a sky material from parsed material data
  88061. * @param source defines the JSON representation of the material
  88062. * @param scene defines the hosting scene
  88063. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88064. * @returns a new sky material
  88065. */
  88066. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  88067. }
  88068. }
  88069. declare module BABYLON {
  88070. /** @hidden */
  88071. export var terrainPixelShader: {
  88072. name: string;
  88073. shader: string;
  88074. };
  88075. }
  88076. declare module BABYLON {
  88077. /** @hidden */
  88078. export var terrainVertexShader: {
  88079. name: string;
  88080. shader: string;
  88081. };
  88082. }
  88083. declare module BABYLON {
  88084. export class TerrainMaterial extends BABYLON.PushMaterial {
  88085. private _mixTexture;
  88086. mixTexture: BABYLON.BaseTexture;
  88087. private _diffuseTexture1;
  88088. diffuseTexture1: BABYLON.Texture;
  88089. private _diffuseTexture2;
  88090. diffuseTexture2: BABYLON.Texture;
  88091. private _diffuseTexture3;
  88092. diffuseTexture3: BABYLON.Texture;
  88093. private _bumpTexture1;
  88094. bumpTexture1: BABYLON.Texture;
  88095. private _bumpTexture2;
  88096. bumpTexture2: BABYLON.Texture;
  88097. private _bumpTexture3;
  88098. bumpTexture3: BABYLON.Texture;
  88099. diffuseColor: BABYLON.Color3;
  88100. specularColor: BABYLON.Color3;
  88101. specularPower: number;
  88102. private _disableLighting;
  88103. disableLighting: boolean;
  88104. private _maxSimultaneousLights;
  88105. maxSimultaneousLights: number;
  88106. constructor(name: string, scene: BABYLON.Scene);
  88107. needAlphaBlending(): boolean;
  88108. needAlphaTesting(): boolean;
  88109. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88110. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88111. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88112. getAnimatables(): BABYLON.IAnimatable[];
  88113. getActiveTextures(): BABYLON.BaseTexture[];
  88114. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88115. dispose(forceDisposeEffect?: boolean): void;
  88116. clone(name: string): TerrainMaterial;
  88117. serialize(): any;
  88118. getClassName(): string;
  88119. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  88120. }
  88121. }
  88122. declare module BABYLON {
  88123. /** @hidden */
  88124. export var triplanarPixelShader: {
  88125. name: string;
  88126. shader: string;
  88127. };
  88128. }
  88129. declare module BABYLON {
  88130. /** @hidden */
  88131. export var triplanarVertexShader: {
  88132. name: string;
  88133. shader: string;
  88134. };
  88135. }
  88136. declare module BABYLON {
  88137. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  88138. mixTexture: BABYLON.BaseTexture;
  88139. private _diffuseTextureX;
  88140. diffuseTextureX: BABYLON.BaseTexture;
  88141. private _diffuseTextureY;
  88142. diffuseTextureY: BABYLON.BaseTexture;
  88143. private _diffuseTextureZ;
  88144. diffuseTextureZ: BABYLON.BaseTexture;
  88145. private _normalTextureX;
  88146. normalTextureX: BABYLON.BaseTexture;
  88147. private _normalTextureY;
  88148. normalTextureY: BABYLON.BaseTexture;
  88149. private _normalTextureZ;
  88150. normalTextureZ: BABYLON.BaseTexture;
  88151. tileSize: number;
  88152. diffuseColor: BABYLON.Color3;
  88153. specularColor: BABYLON.Color3;
  88154. specularPower: number;
  88155. private _disableLighting;
  88156. disableLighting: boolean;
  88157. private _maxSimultaneousLights;
  88158. maxSimultaneousLights: number;
  88159. constructor(name: string, scene: BABYLON.Scene);
  88160. needAlphaBlending(): boolean;
  88161. needAlphaTesting(): boolean;
  88162. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88163. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88164. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88165. getAnimatables(): BABYLON.IAnimatable[];
  88166. getActiveTextures(): BABYLON.BaseTexture[];
  88167. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88168. dispose(forceDisposeEffect?: boolean): void;
  88169. clone(name: string): TriPlanarMaterial;
  88170. serialize(): any;
  88171. getClassName(): string;
  88172. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  88173. }
  88174. }
  88175. declare module BABYLON {
  88176. /** @hidden */
  88177. export var waterPixelShader: {
  88178. name: string;
  88179. shader: string;
  88180. };
  88181. }
  88182. declare module BABYLON {
  88183. /** @hidden */
  88184. export var waterVertexShader: {
  88185. name: string;
  88186. shader: string;
  88187. };
  88188. }
  88189. declare module BABYLON {
  88190. export class WaterMaterial extends BABYLON.PushMaterial {
  88191. renderTargetSize: BABYLON.Vector2;
  88192. private _bumpTexture;
  88193. bumpTexture: BABYLON.BaseTexture;
  88194. diffuseColor: BABYLON.Color3;
  88195. specularColor: BABYLON.Color3;
  88196. specularPower: number;
  88197. private _disableLighting;
  88198. disableLighting: boolean;
  88199. private _maxSimultaneousLights;
  88200. maxSimultaneousLights: number;
  88201. /**
  88202. * Defines the wind force.
  88203. */
  88204. windForce: number;
  88205. /**
  88206. * Defines the direction of the wind in the plane (X, Z).
  88207. */
  88208. windDirection: BABYLON.Vector2;
  88209. /**
  88210. * Defines the height of the waves.
  88211. */
  88212. waveHeight: number;
  88213. /**
  88214. * Defines the bump height related to the bump map.
  88215. */
  88216. bumpHeight: number;
  88217. /**
  88218. * Defines wether or not: to add a smaller moving bump to less steady waves.
  88219. */
  88220. private _bumpSuperimpose;
  88221. bumpSuperimpose: boolean;
  88222. /**
  88223. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  88224. */
  88225. private _fresnelSeparate;
  88226. fresnelSeparate: boolean;
  88227. /**
  88228. * Defines wether or not bump Wwves modify the reflection.
  88229. */
  88230. private _bumpAffectsReflection;
  88231. bumpAffectsReflection: boolean;
  88232. /**
  88233. * Defines the water color blended with the refraction (near).
  88234. */
  88235. waterColor: BABYLON.Color3;
  88236. /**
  88237. * Defines the blend factor related to the water color.
  88238. */
  88239. colorBlendFactor: number;
  88240. /**
  88241. * Defines the water color blended with the reflection (far).
  88242. */
  88243. waterColor2: BABYLON.Color3;
  88244. /**
  88245. * Defines the blend factor related to the water color (reflection, far).
  88246. */
  88247. colorBlendFactor2: number;
  88248. /**
  88249. * Defines the maximum length of a wave.
  88250. */
  88251. waveLength: number;
  88252. /**
  88253. * Defines the waves speed.
  88254. */
  88255. waveSpeed: number;
  88256. /**
  88257. * 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.
  88258. */
  88259. waveCount: number;
  88260. /**
  88261. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  88262. * will avoid calculating useless pixels in the pixel shader of the water material.
  88263. */
  88264. disableClipPlane: boolean;
  88265. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  88266. private _mesh;
  88267. private _refractionRTT;
  88268. private _reflectionRTT;
  88269. private _reflectionTransform;
  88270. private _lastTime;
  88271. private _lastDeltaTime;
  88272. private _useLogarithmicDepth;
  88273. private _waitingRenderList;
  88274. private _imageProcessingConfiguration;
  88275. private _imageProcessingObserver;
  88276. /**
  88277. * Gets a boolean indicating that current material needs to register RTT
  88278. */
  88279. get hasRenderTargetTextures(): boolean;
  88280. /**
  88281. * Constructor
  88282. */
  88283. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  88284. get useLogarithmicDepth(): boolean;
  88285. set useLogarithmicDepth(value: boolean);
  88286. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88287. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  88288. addToRenderList(node: any): void;
  88289. enableRenderTargets(enable: boolean): void;
  88290. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  88291. get renderTargetsEnabled(): boolean;
  88292. needAlphaBlending(): boolean;
  88293. needAlphaTesting(): boolean;
  88294. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  88295. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  88296. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  88297. private _createRenderTargets;
  88298. getAnimatables(): BABYLON.IAnimatable[];
  88299. getActiveTextures(): BABYLON.BaseTexture[];
  88300. hasTexture(texture: BABYLON.BaseTexture): boolean;
  88301. dispose(forceDisposeEffect?: boolean): void;
  88302. clone(name: string): WaterMaterial;
  88303. serialize(): any;
  88304. getClassName(): string;
  88305. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  88306. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  88307. }
  88308. }
  88309. declare module BABYLON {
  88310. /** @hidden */
  88311. export var asciiartPixelShader: {
  88312. name: string;
  88313. shader: string;
  88314. };
  88315. }
  88316. declare module BABYLON {
  88317. /**
  88318. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  88319. *
  88320. * It basically takes care rendering the font front the given font size to a texture.
  88321. * This is used later on in the postprocess.
  88322. */
  88323. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  88324. private _font;
  88325. private _text;
  88326. private _charSize;
  88327. /**
  88328. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88329. */
  88330. get charSize(): number;
  88331. /**
  88332. * Create a new instance of the Ascii Art FontTexture class
  88333. * @param name the name of the texture
  88334. * @param font the font to use, use the W3C CSS notation
  88335. * @param text the caracter set to use in the rendering.
  88336. * @param scene the scene that owns the texture
  88337. */
  88338. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88339. /**
  88340. * Gets the max char width of a font.
  88341. * @param font the font to use, use the W3C CSS notation
  88342. * @return the max char width
  88343. */
  88344. private getFontWidth;
  88345. /**
  88346. * Gets the max char height of a font.
  88347. * @param font the font to use, use the W3C CSS notation
  88348. * @return the max char height
  88349. */
  88350. private getFontHeight;
  88351. /**
  88352. * Clones the current AsciiArtTexture.
  88353. * @return the clone of the texture.
  88354. */
  88355. clone(): AsciiArtFontTexture;
  88356. /**
  88357. * Parses a json object representing the texture and returns an instance of it.
  88358. * @param source the source JSON representation
  88359. * @param scene the scene to create the texture for
  88360. * @return the parsed texture
  88361. */
  88362. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  88363. }
  88364. /**
  88365. * Option available in the Ascii Art Post Process.
  88366. */
  88367. export interface IAsciiArtPostProcessOptions {
  88368. /**
  88369. * The font to use following the w3c font definition.
  88370. */
  88371. font?: string;
  88372. /**
  88373. * The character set to use in the postprocess.
  88374. */
  88375. characterSet?: string;
  88376. /**
  88377. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88378. * This number is defined between 0 and 1;
  88379. */
  88380. mixToTile?: number;
  88381. /**
  88382. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88383. * This number is defined between 0 and 1;
  88384. */
  88385. mixToNormal?: number;
  88386. }
  88387. /**
  88388. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  88389. *
  88390. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88391. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  88392. */
  88393. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  88394. /**
  88395. * The font texture used to render the char in the post process.
  88396. */
  88397. private _asciiArtFontTexture;
  88398. /**
  88399. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  88400. * This number is defined between 0 and 1;
  88401. */
  88402. mixToTile: number;
  88403. /**
  88404. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  88405. * This number is defined between 0 and 1;
  88406. */
  88407. mixToNormal: number;
  88408. /**
  88409. * Instantiates a new Ascii Art Post Process.
  88410. * @param name the name to give to the postprocess
  88411. * @camera the camera to apply the post process to.
  88412. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  88413. */
  88414. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  88415. }
  88416. }
  88417. declare module BABYLON {
  88418. /** @hidden */
  88419. export var digitalrainPixelShader: {
  88420. name: string;
  88421. shader: string;
  88422. };
  88423. }
  88424. declare module BABYLON {
  88425. /**
  88426. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  88427. *
  88428. * It basically takes care rendering the font front the given font size to a texture.
  88429. * This is used later on in the postprocess.
  88430. */
  88431. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  88432. private _font;
  88433. private _text;
  88434. private _charSize;
  88435. /**
  88436. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  88437. */
  88438. get charSize(): number;
  88439. /**
  88440. * Create a new instance of the Digital Rain FontTexture class
  88441. * @param name the name of the texture
  88442. * @param font the font to use, use the W3C CSS notation
  88443. * @param text the caracter set to use in the rendering.
  88444. * @param scene the scene that owns the texture
  88445. */
  88446. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  88447. /**
  88448. * Gets the max char width of a font.
  88449. * @param font the font to use, use the W3C CSS notation
  88450. * @return the max char width
  88451. */
  88452. private getFontWidth;
  88453. /**
  88454. * Gets the max char height of a font.
  88455. * @param font the font to use, use the W3C CSS notation
  88456. * @return the max char height
  88457. */
  88458. private getFontHeight;
  88459. /**
  88460. * Clones the current DigitalRainFontTexture.
  88461. * @return the clone of the texture.
  88462. */
  88463. clone(): DigitalRainFontTexture;
  88464. /**
  88465. * Parses a json object representing the texture and returns an instance of it.
  88466. * @param source the source JSON representation
  88467. * @param scene the scene to create the texture for
  88468. * @return the parsed texture
  88469. */
  88470. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  88471. }
  88472. /**
  88473. * Option available in the Digital Rain Post Process.
  88474. */
  88475. export interface IDigitalRainPostProcessOptions {
  88476. /**
  88477. * The font to use following the w3c font definition.
  88478. */
  88479. font?: string;
  88480. /**
  88481. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88482. * This number is defined between 0 and 1;
  88483. */
  88484. mixToTile?: number;
  88485. /**
  88486. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88487. * This number is defined between 0 and 1;
  88488. */
  88489. mixToNormal?: number;
  88490. }
  88491. /**
  88492. * DigitalRainPostProcess helps rendering everithing in digital rain.
  88493. *
  88494. * Simmply add it to your scene and let the nerd that lives in you have fun.
  88495. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  88496. */
  88497. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  88498. /**
  88499. * The font texture used to render the char in the post process.
  88500. */
  88501. private _digitalRainFontTexture;
  88502. /**
  88503. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  88504. * This number is defined between 0 and 1;
  88505. */
  88506. mixToTile: number;
  88507. /**
  88508. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  88509. * This number is defined between 0 and 1;
  88510. */
  88511. mixToNormal: number;
  88512. /**
  88513. * Instantiates a new Digital Rain Post Process.
  88514. * @param name the name to give to the postprocess
  88515. * @camera the camera to apply the post process to.
  88516. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  88517. */
  88518. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  88519. }
  88520. }
  88521. declare module BABYLON {
  88522. /** @hidden */
  88523. export var brickProceduralTexturePixelShader: {
  88524. name: string;
  88525. shader: string;
  88526. };
  88527. }
  88528. declare module BABYLON {
  88529. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  88530. private _numberOfBricksHeight;
  88531. private _numberOfBricksWidth;
  88532. private _jointColor;
  88533. private _brickColor;
  88534. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88535. updateShaderUniforms(): void;
  88536. get numberOfBricksHeight(): number;
  88537. set numberOfBricksHeight(value: number);
  88538. get numberOfBricksWidth(): number;
  88539. set numberOfBricksWidth(value: number);
  88540. get jointColor(): BABYLON.Color3;
  88541. set jointColor(value: BABYLON.Color3);
  88542. get brickColor(): BABYLON.Color3;
  88543. set brickColor(value: BABYLON.Color3);
  88544. /**
  88545. * Serializes this brick procedural texture
  88546. * @returns a serialized brick procedural texture object
  88547. */
  88548. serialize(): any;
  88549. /**
  88550. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  88551. * @param parsedTexture defines parsed texture data
  88552. * @param scene defines the current scene
  88553. * @param rootUrl defines the root URL containing brick procedural texture information
  88554. * @returns a parsed Brick Procedural BABYLON.Texture
  88555. */
  88556. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  88557. }
  88558. }
  88559. declare module BABYLON {
  88560. /** @hidden */
  88561. export var cloudProceduralTexturePixelShader: {
  88562. name: string;
  88563. shader: string;
  88564. };
  88565. }
  88566. declare module BABYLON {
  88567. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  88568. private _skyColor;
  88569. private _cloudColor;
  88570. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88571. updateShaderUniforms(): void;
  88572. get skyColor(): BABYLON.Color4;
  88573. set skyColor(value: BABYLON.Color4);
  88574. get cloudColor(): BABYLON.Color4;
  88575. set cloudColor(value: BABYLON.Color4);
  88576. /**
  88577. * Serializes this cloud procedural texture
  88578. * @returns a serialized cloud procedural texture object
  88579. */
  88580. serialize(): any;
  88581. /**
  88582. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  88583. * @param parsedTexture defines parsed texture data
  88584. * @param scene defines the current scene
  88585. * @param rootUrl defines the root URL containing cloud procedural texture information
  88586. * @returns a parsed Cloud Procedural BABYLON.Texture
  88587. */
  88588. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  88589. }
  88590. }
  88591. declare module BABYLON {
  88592. /** @hidden */
  88593. export var fireProceduralTexturePixelShader: {
  88594. name: string;
  88595. shader: string;
  88596. };
  88597. }
  88598. declare module BABYLON {
  88599. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  88600. private _time;
  88601. private _speed;
  88602. private _autoGenerateTime;
  88603. private _fireColors;
  88604. private _alphaThreshold;
  88605. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88606. updateShaderUniforms(): void;
  88607. render(useCameraPostProcess?: boolean): void;
  88608. static get PurpleFireColors(): BABYLON.Color3[];
  88609. static get GreenFireColors(): BABYLON.Color3[];
  88610. static get RedFireColors(): BABYLON.Color3[];
  88611. static get BlueFireColors(): BABYLON.Color3[];
  88612. get autoGenerateTime(): boolean;
  88613. set autoGenerateTime(value: boolean);
  88614. get fireColors(): BABYLON.Color3[];
  88615. set fireColors(value: BABYLON.Color3[]);
  88616. get time(): number;
  88617. set time(value: number);
  88618. get speed(): BABYLON.Vector2;
  88619. set speed(value: BABYLON.Vector2);
  88620. get alphaThreshold(): number;
  88621. set alphaThreshold(value: number);
  88622. /**
  88623. * Serializes this fire procedural texture
  88624. * @returns a serialized fire procedural texture object
  88625. */
  88626. serialize(): any;
  88627. /**
  88628. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  88629. * @param parsedTexture defines parsed texture data
  88630. * @param scene defines the current scene
  88631. * @param rootUrl defines the root URL containing fire procedural texture information
  88632. * @returns a parsed Fire Procedural BABYLON.Texture
  88633. */
  88634. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  88635. }
  88636. }
  88637. declare module BABYLON {
  88638. /** @hidden */
  88639. export var grassProceduralTexturePixelShader: {
  88640. name: string;
  88641. shader: string;
  88642. };
  88643. }
  88644. declare module BABYLON {
  88645. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  88646. private _grassColors;
  88647. private _groundColor;
  88648. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88649. updateShaderUniforms(): void;
  88650. get grassColors(): BABYLON.Color3[];
  88651. set grassColors(value: BABYLON.Color3[]);
  88652. get groundColor(): BABYLON.Color3;
  88653. set groundColor(value: BABYLON.Color3);
  88654. /**
  88655. * Serializes this grass procedural texture
  88656. * @returns a serialized grass procedural texture object
  88657. */
  88658. serialize(): any;
  88659. /**
  88660. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  88661. * @param parsedTexture defines parsed texture data
  88662. * @param scene defines the current scene
  88663. * @param rootUrl defines the root URL containing grass procedural texture information
  88664. * @returns a parsed Grass Procedural BABYLON.Texture
  88665. */
  88666. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  88667. }
  88668. }
  88669. declare module BABYLON {
  88670. /** @hidden */
  88671. export var marbleProceduralTexturePixelShader: {
  88672. name: string;
  88673. shader: string;
  88674. };
  88675. }
  88676. declare module BABYLON {
  88677. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  88678. private _numberOfTilesHeight;
  88679. private _numberOfTilesWidth;
  88680. private _amplitude;
  88681. private _jointColor;
  88682. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88683. updateShaderUniforms(): void;
  88684. get numberOfTilesHeight(): number;
  88685. set numberOfTilesHeight(value: number);
  88686. get amplitude(): number;
  88687. set amplitude(value: number);
  88688. get numberOfTilesWidth(): number;
  88689. set numberOfTilesWidth(value: number);
  88690. get jointColor(): BABYLON.Color3;
  88691. set jointColor(value: BABYLON.Color3);
  88692. /**
  88693. * Serializes this marble procedural texture
  88694. * @returns a serialized marble procedural texture object
  88695. */
  88696. serialize(): any;
  88697. /**
  88698. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  88699. * @param parsedTexture defines parsed texture data
  88700. * @param scene defines the current scene
  88701. * @param rootUrl defines the root URL containing marble procedural texture information
  88702. * @returns a parsed Marble Procedural BABYLON.Texture
  88703. */
  88704. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  88705. }
  88706. }
  88707. declare module BABYLON {
  88708. /** @hidden */
  88709. export var normalMapProceduralTexturePixelShader: {
  88710. name: string;
  88711. shader: string;
  88712. };
  88713. }
  88714. declare module BABYLON {
  88715. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  88716. private _baseTexture;
  88717. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88718. updateShaderUniforms(): void;
  88719. render(useCameraPostProcess?: boolean): void;
  88720. resize(size: any, generateMipMaps: any): void;
  88721. get baseTexture(): BABYLON.Texture;
  88722. set baseTexture(texture: BABYLON.Texture);
  88723. /**
  88724. * Serializes this normal map procedural texture
  88725. * @returns a serialized normal map procedural texture object
  88726. */
  88727. serialize(): any;
  88728. /**
  88729. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  88730. * @param parsedTexture defines parsed texture data
  88731. * @param scene defines the current scene
  88732. * @param rootUrl defines the root URL containing normal map procedural texture information
  88733. * @returns a parsed Normal Map Procedural BABYLON.Texture
  88734. */
  88735. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  88736. }
  88737. }
  88738. declare module BABYLON {
  88739. /** @hidden */
  88740. export var perlinNoiseProceduralTexturePixelShader: {
  88741. name: string;
  88742. shader: string;
  88743. };
  88744. }
  88745. declare module BABYLON {
  88746. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  88747. time: number;
  88748. timeScale: number;
  88749. translationSpeed: number;
  88750. private _currentTranslation;
  88751. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88752. updateShaderUniforms(): void;
  88753. render(useCameraPostProcess?: boolean): void;
  88754. resize(size: any, generateMipMaps: any): void;
  88755. /**
  88756. * Serializes this perlin noise procedural texture
  88757. * @returns a serialized perlin noise procedural texture object
  88758. */
  88759. serialize(): any;
  88760. /**
  88761. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  88762. * @param parsedTexture defines parsed texture data
  88763. * @param scene defines the current scene
  88764. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  88765. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  88766. */
  88767. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  88768. }
  88769. }
  88770. declare module BABYLON {
  88771. /** @hidden */
  88772. export var roadProceduralTexturePixelShader: {
  88773. name: string;
  88774. shader: string;
  88775. };
  88776. }
  88777. declare module BABYLON {
  88778. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  88779. private _roadColor;
  88780. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88781. updateShaderUniforms(): void;
  88782. get roadColor(): BABYLON.Color3;
  88783. set roadColor(value: BABYLON.Color3);
  88784. /**
  88785. * Serializes this road procedural texture
  88786. * @returns a serialized road procedural texture object
  88787. */
  88788. serialize(): any;
  88789. /**
  88790. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  88791. * @param parsedTexture defines parsed texture data
  88792. * @param scene defines the current scene
  88793. * @param rootUrl defines the root URL containing road procedural texture information
  88794. * @returns a parsed Road Procedural BABYLON.Texture
  88795. */
  88796. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  88797. }
  88798. }
  88799. declare module BABYLON {
  88800. /** @hidden */
  88801. export var starfieldProceduralTexturePixelShader: {
  88802. name: string;
  88803. shader: string;
  88804. };
  88805. }
  88806. declare module BABYLON {
  88807. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  88808. private _time;
  88809. private _alpha;
  88810. private _beta;
  88811. private _zoom;
  88812. private _formuparam;
  88813. private _stepsize;
  88814. private _tile;
  88815. private _brightness;
  88816. private _darkmatter;
  88817. private _distfading;
  88818. private _saturation;
  88819. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88820. updateShaderUniforms(): void;
  88821. get time(): number;
  88822. set time(value: number);
  88823. get alpha(): number;
  88824. set alpha(value: number);
  88825. get beta(): number;
  88826. set beta(value: number);
  88827. get formuparam(): number;
  88828. set formuparam(value: number);
  88829. get stepsize(): number;
  88830. set stepsize(value: number);
  88831. get zoom(): number;
  88832. set zoom(value: number);
  88833. get tile(): number;
  88834. set tile(value: number);
  88835. get brightness(): number;
  88836. set brightness(value: number);
  88837. get darkmatter(): number;
  88838. set darkmatter(value: number);
  88839. get distfading(): number;
  88840. set distfading(value: number);
  88841. get saturation(): number;
  88842. set saturation(value: number);
  88843. /**
  88844. * Serializes this starfield procedural texture
  88845. * @returns a serialized starfield procedural texture object
  88846. */
  88847. serialize(): any;
  88848. /**
  88849. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  88850. * @param parsedTexture defines parsed texture data
  88851. * @param scene defines the current scene
  88852. * @param rootUrl defines the root URL containing startfield procedural texture information
  88853. * @returns a parsed Starfield Procedural BABYLON.Texture
  88854. */
  88855. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  88856. }
  88857. }
  88858. declare module BABYLON {
  88859. /** @hidden */
  88860. export var woodProceduralTexturePixelShader: {
  88861. name: string;
  88862. shader: string;
  88863. };
  88864. }
  88865. declare module BABYLON {
  88866. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  88867. private _ampScale;
  88868. private _woodColor;
  88869. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  88870. updateShaderUniforms(): void;
  88871. get ampScale(): number;
  88872. set ampScale(value: number);
  88873. get woodColor(): BABYLON.Color3;
  88874. set woodColor(value: BABYLON.Color3);
  88875. /**
  88876. * Serializes this wood procedural texture
  88877. * @returns a serialized wood procedural texture object
  88878. */
  88879. serialize(): any;
  88880. /**
  88881. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  88882. * @param parsedTexture defines parsed texture data
  88883. * @param scene defines the current scene
  88884. * @param rootUrl defines the root URL containing wood procedural texture information
  88885. * @returns a parsed Wood Procedural BABYLON.Texture
  88886. */
  88887. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  88888. }
  88889. }