documentation.d.ts 3.5 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /**
  2041. * Class representing a vector containing 2 coordinates
  2042. */
  2043. export class Vector2 {
  2044. /** defines the first coordinate */
  2045. x: number;
  2046. /** defines the second coordinate */
  2047. y: number;
  2048. /**
  2049. * Creates a new Vector2 from the given x and y coordinates
  2050. * @param x defines the first coordinate
  2051. * @param y defines the second coordinate
  2052. */
  2053. constructor(
  2054. /** defines the first coordinate */
  2055. x?: number,
  2056. /** defines the second coordinate */
  2057. y?: number);
  2058. /**
  2059. * Gets a string with the Vector2 coordinates
  2060. * @returns a string with the Vector2 coordinates
  2061. */
  2062. toString(): string;
  2063. /**
  2064. * Gets class name
  2065. * @returns the string "Vector2"
  2066. */
  2067. getClassName(): string;
  2068. /**
  2069. * Gets current vector hash code
  2070. * @returns the Vector2 hash code as a number
  2071. */
  2072. getHashCode(): number;
  2073. /**
  2074. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2075. * @param array defines the source array
  2076. * @param index defines the offset in source array
  2077. * @returns the current Vector2
  2078. */
  2079. toArray(array: FloatArray, index?: number): Vector2;
  2080. /**
  2081. * Copy the current vector to an array
  2082. * @returns a new array with 2 elements: the Vector2 coordinates.
  2083. */
  2084. asArray(): number[];
  2085. /**
  2086. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2087. * @param source defines the source Vector2
  2088. * @returns the current updated Vector2
  2089. */
  2090. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2091. /**
  2092. * Sets the Vector2 coordinates with the given floats
  2093. * @param x defines the first coordinate
  2094. * @param y defines the second coordinate
  2095. * @returns the current updated Vector2
  2096. */
  2097. copyFromFloats(x: number, y: number): Vector2;
  2098. /**
  2099. * Sets the Vector2 coordinates with the given floats
  2100. * @param x defines the first coordinate
  2101. * @param y defines the second coordinate
  2102. * @returns the current updated Vector2
  2103. */
  2104. set(x: number, y: number): Vector2;
  2105. /**
  2106. * Add another vector with the current one
  2107. * @param otherVector defines the other vector
  2108. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2109. */
  2110. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2111. /**
  2112. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2113. * @param otherVector defines the other vector
  2114. * @param result defines the target vector
  2115. * @returns the unmodified current Vector2
  2116. */
  2117. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2118. /**
  2119. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2120. * @param otherVector defines the other vector
  2121. * @returns the current updated Vector2
  2122. */
  2123. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2124. /**
  2125. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2126. * @param otherVector defines the other vector
  2127. * @returns a new Vector2
  2128. */
  2129. addVector3(otherVector: Vector3): Vector2;
  2130. /**
  2131. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2132. * @param otherVector defines the other vector
  2133. * @returns a new Vector2
  2134. */
  2135. subtract(otherVector: Vector2): Vector2;
  2136. /**
  2137. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2138. * @param otherVector defines the other vector
  2139. * @param result defines the target vector
  2140. * @returns the unmodified current Vector2
  2141. */
  2142. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2143. /**
  2144. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2145. * @param otherVector defines the other vector
  2146. * @returns the current updated Vector2
  2147. */
  2148. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2149. /**
  2150. * Multiplies in place the current Vector2 coordinates by the given ones
  2151. * @param otherVector defines the other vector
  2152. * @returns the current updated Vector2
  2153. */
  2154. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2155. /**
  2156. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2157. * @param otherVector defines the other vector
  2158. * @returns a new Vector2
  2159. */
  2160. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2161. /**
  2162. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2163. * @param otherVector defines the other vector
  2164. * @param result defines the target vector
  2165. * @returns the unmodified current Vector2
  2166. */
  2167. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2168. /**
  2169. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2170. * @param x defines the first coordinate
  2171. * @param y defines the second coordinate
  2172. * @returns a new Vector2
  2173. */
  2174. multiplyByFloats(x: number, y: number): Vector2;
  2175. /**
  2176. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. divide(otherVector: Vector2): Vector2;
  2181. /**
  2182. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2183. * @param otherVector defines the other vector
  2184. * @param result defines the target vector
  2185. * @returns the unmodified current Vector2
  2186. */
  2187. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2188. /**
  2189. * Divides the current Vector2 coordinates by the given ones
  2190. * @param otherVector defines the other vector
  2191. * @returns the current updated Vector2
  2192. */
  2193. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2194. /**
  2195. * Gets a new Vector2 with current Vector2 negated coordinates
  2196. * @returns a new Vector2
  2197. */
  2198. negate(): Vector2;
  2199. /**
  2200. * Negate this vector in place
  2201. * @returns this
  2202. */
  2203. negateInPlace(): Vector2;
  2204. /**
  2205. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2206. * @param result defines the Vector3 object where to store the result
  2207. * @returns the current Vector2
  2208. */
  2209. negateToRef(result: Vector2): Vector2;
  2210. /**
  2211. * Multiply the Vector2 coordinates by scale
  2212. * @param scale defines the scaling factor
  2213. * @returns the current updated Vector2
  2214. */
  2215. scaleInPlace(scale: number): Vector2;
  2216. /**
  2217. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2218. * @param scale defines the scaling factor
  2219. * @returns a new Vector2
  2220. */
  2221. scale(scale: number): Vector2;
  2222. /**
  2223. * Scale the current Vector2 values by a factor to a given Vector2
  2224. * @param scale defines the scale factor
  2225. * @param result defines the Vector2 object where to store the result
  2226. * @returns the unmodified current Vector2
  2227. */
  2228. scaleToRef(scale: number, result: Vector2): Vector2;
  2229. /**
  2230. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2231. * @param scale defines the scale factor
  2232. * @param result defines the Vector2 object where to store the result
  2233. * @returns the unmodified current Vector2
  2234. */
  2235. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2236. /**
  2237. * Gets a boolean if two vectors are equals
  2238. * @param otherVector defines the other vector
  2239. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2240. */
  2241. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2242. /**
  2243. * Gets a boolean if two vectors are equals (using an epsilon value)
  2244. * @param otherVector defines the other vector
  2245. * @param epsilon defines the minimal distance to consider equality
  2246. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2247. */
  2248. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2249. /**
  2250. * Gets a new Vector2 from current Vector2 floored values
  2251. * @returns a new Vector2
  2252. */
  2253. floor(): Vector2;
  2254. /**
  2255. * Gets a new Vector2 from current Vector2 floored values
  2256. * @returns a new Vector2
  2257. */
  2258. fract(): Vector2;
  2259. /**
  2260. * Gets the length of the vector
  2261. * @returns the vector length (float)
  2262. */
  2263. length(): number;
  2264. /**
  2265. * Gets the vector squared length
  2266. * @returns the vector squared length (float)
  2267. */
  2268. lengthSquared(): number;
  2269. /**
  2270. * Normalize the vector
  2271. * @returns the current updated Vector2
  2272. */
  2273. normalize(): Vector2;
  2274. /**
  2275. * Gets a new Vector2 copied from the Vector2
  2276. * @returns a new Vector2
  2277. */
  2278. clone(): Vector2;
  2279. /**
  2280. * Gets a new Vector2(0, 0)
  2281. * @returns a new Vector2
  2282. */
  2283. static Zero(): Vector2;
  2284. /**
  2285. * Gets a new Vector2(1, 1)
  2286. * @returns a new Vector2
  2287. */
  2288. static One(): Vector2;
  2289. /**
  2290. * Gets a new Vector2 set from the given index element of the given array
  2291. * @param array defines the data source
  2292. * @param offset defines the offset in the data source
  2293. * @returns a new Vector2
  2294. */
  2295. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2296. /**
  2297. * Sets "result" from the given index element of the given array
  2298. * @param array defines the data source
  2299. * @param offset defines the offset in the data source
  2300. * @param result defines the target vector
  2301. */
  2302. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2303. /**
  2304. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2305. * @param value1 defines 1st point of control
  2306. * @param value2 defines 2nd point of control
  2307. * @param value3 defines 3rd point of control
  2308. * @param value4 defines 4th point of control
  2309. * @param amount defines the interpolation factor
  2310. * @returns a new Vector2
  2311. */
  2312. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2313. /**
  2314. * 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".
  2315. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2316. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2317. * @param value defines the value to clamp
  2318. * @param min defines the lower limit
  2319. * @param max defines the upper limit
  2320. * @returns a new Vector2
  2321. */
  2322. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2323. /**
  2324. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2325. * @param value1 defines the 1st control point
  2326. * @param tangent1 defines the outgoing tangent
  2327. * @param value2 defines the 2nd control point
  2328. * @param tangent2 defines the incoming tangent
  2329. * @param amount defines the interpolation factor
  2330. * @returns a new Vector2
  2331. */
  2332. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2333. /**
  2334. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2335. * @param start defines the start vector
  2336. * @param end defines the end vector
  2337. * @param amount defines the interpolation factor
  2338. * @returns a new Vector2
  2339. */
  2340. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2341. /**
  2342. * Gets the dot product of the vector "left" and the vector "right"
  2343. * @param left defines first vector
  2344. * @param right defines second vector
  2345. * @returns the dot product (float)
  2346. */
  2347. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2348. /**
  2349. * Returns a new Vector2 equal to the normalized given vector
  2350. * @param vector defines the vector to normalize
  2351. * @returns a new Vector2
  2352. */
  2353. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2354. /**
  2355. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2356. * @param left defines 1st vector
  2357. * @param right defines 2nd vector
  2358. * @returns a new Vector2
  2359. */
  2360. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2361. /**
  2362. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2363. * @param left defines 1st vector
  2364. * @param right defines 2nd vector
  2365. * @returns a new Vector2
  2366. */
  2367. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2368. /**
  2369. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2370. * @param vector defines the vector to transform
  2371. * @param transformation defines the matrix to apply
  2372. * @returns a new Vector2
  2373. */
  2374. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2375. /**
  2376. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2377. * @param vector defines the vector to transform
  2378. * @param transformation defines the matrix to apply
  2379. * @param result defines the target vector
  2380. */
  2381. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2382. /**
  2383. * Determines if a given vector is included in a triangle
  2384. * @param p defines the vector to test
  2385. * @param p0 defines 1st triangle point
  2386. * @param p1 defines 2nd triangle point
  2387. * @param p2 defines 3rd triangle point
  2388. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2389. */
  2390. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2391. /**
  2392. * Gets the distance between the vectors "value1" and "value2"
  2393. * @param value1 defines first vector
  2394. * @param value2 defines second vector
  2395. * @returns the distance between vectors
  2396. */
  2397. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2398. /**
  2399. * Returns the squared distance between the vectors "value1" and "value2"
  2400. * @param value1 defines first vector
  2401. * @param value2 defines second vector
  2402. * @returns the squared distance between vectors
  2403. */
  2404. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2405. /**
  2406. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2407. * @param value1 defines first vector
  2408. * @param value2 defines second vector
  2409. * @returns a new Vector2
  2410. */
  2411. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2414. * @param p defines the middle point
  2415. * @param segA defines one point of the segment
  2416. * @param segB defines the other point of the segment
  2417. * @returns the shortest distance
  2418. */
  2419. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2420. }
  2421. /**
  2422. * Class used to store (x,y,z) vector representation
  2423. * A Vector3 is the main object used in 3D geometry
  2424. * It can represent etiher the coordinates of a point the space, either a direction
  2425. * Reminder: js uses a left handed forward facing system
  2426. */
  2427. export class Vector3 {
  2428. private static _UpReadOnly;
  2429. private static _ZeroReadOnly;
  2430. /** @hidden */
  2431. _x: number;
  2432. /** @hidden */
  2433. _y: number;
  2434. /** @hidden */
  2435. _z: number;
  2436. /** @hidden */
  2437. _isDirty: boolean;
  2438. /** Gets or sets the x coordinate */
  2439. get x(): number;
  2440. set x(value: number);
  2441. /** Gets or sets the y coordinate */
  2442. get y(): number;
  2443. set y(value: number);
  2444. /** Gets or sets the z coordinate */
  2445. get z(): number;
  2446. set z(value: number);
  2447. /**
  2448. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2449. * @param x defines the first coordinates (on X axis)
  2450. * @param y defines the second coordinates (on Y axis)
  2451. * @param z defines the third coordinates (on Z axis)
  2452. */
  2453. constructor(x?: number, y?: number, z?: number);
  2454. /**
  2455. * Creates a string representation of the Vector3
  2456. * @returns a string with the Vector3 coordinates.
  2457. */
  2458. toString(): string;
  2459. /**
  2460. * Gets the class name
  2461. * @returns the string "Vector3"
  2462. */
  2463. getClassName(): string;
  2464. /**
  2465. * Creates the Vector3 hash code
  2466. * @returns a number which tends to be unique between Vector3 instances
  2467. */
  2468. getHashCode(): number;
  2469. /**
  2470. * Creates an array containing three elements : the coordinates of the Vector3
  2471. * @returns a new array of numbers
  2472. */
  2473. asArray(): number[];
  2474. /**
  2475. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2476. * @param array defines the destination array
  2477. * @param index defines the offset in the destination array
  2478. * @returns the current Vector3
  2479. */
  2480. toArray(array: FloatArray, index?: number): Vector3;
  2481. /**
  2482. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2483. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2484. */
  2485. toQuaternion(): Quaternion;
  2486. /**
  2487. * Adds the given vector to the current Vector3
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Adds the given coordinates to the current Vector3
  2494. * @param x defines the x coordinate of the operand
  2495. * @param y defines the y coordinate of the operand
  2496. * @param z defines the z coordinate of the operand
  2497. * @returns the current updated Vector3
  2498. */
  2499. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2500. /**
  2501. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2502. * @param otherVector defines the second operand
  2503. * @returns the resulting Vector3
  2504. */
  2505. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2506. /**
  2507. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2508. * @param otherVector defines the second operand
  2509. * @param result defines the Vector3 object where to store the result
  2510. * @returns the current Vector3
  2511. */
  2512. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2513. /**
  2514. * Subtract the given vector from the current Vector3
  2515. * @param otherVector defines the second operand
  2516. * @returns the current updated Vector3
  2517. */
  2518. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2521. * @param otherVector defines the second operand
  2522. * @returns the resulting Vector3
  2523. */
  2524. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2525. /**
  2526. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2527. * @param otherVector defines the second operand
  2528. * @param result defines the Vector3 object where to store the result
  2529. * @returns the current Vector3
  2530. */
  2531. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2532. /**
  2533. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2534. * @param x defines the x coordinate of the operand
  2535. * @param y defines the y coordinate of the operand
  2536. * @param z defines the z coordinate of the operand
  2537. * @returns the resulting Vector3
  2538. */
  2539. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2540. /**
  2541. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2542. * @param x defines the x coordinate of the operand
  2543. * @param y defines the y coordinate of the operand
  2544. * @param z defines the z coordinate of the operand
  2545. * @param result defines the Vector3 object where to store the result
  2546. * @returns the current Vector3
  2547. */
  2548. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2549. /**
  2550. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2551. * @returns a new Vector3
  2552. */
  2553. negate(): Vector3;
  2554. /**
  2555. * Negate this vector in place
  2556. * @returns this
  2557. */
  2558. negateInPlace(): Vector3;
  2559. /**
  2560. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2561. * @param result defines the Vector3 object where to store the result
  2562. * @returns the current Vector3
  2563. */
  2564. negateToRef(result: Vector3): Vector3;
  2565. /**
  2566. * Multiplies the Vector3 coordinates by the float "scale"
  2567. * @param scale defines the multiplier factor
  2568. * @returns the current updated Vector3
  2569. */
  2570. scaleInPlace(scale: number): Vector3;
  2571. /**
  2572. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2573. * @param scale defines the multiplier factor
  2574. * @returns a new Vector3
  2575. */
  2576. scale(scale: number): Vector3;
  2577. /**
  2578. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2579. * @param scale defines the multiplier factor
  2580. * @param result defines the Vector3 object where to store the result
  2581. * @returns the current Vector3
  2582. */
  2583. scaleToRef(scale: number, result: Vector3): Vector3;
  2584. /**
  2585. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2586. * @param scale defines the scale factor
  2587. * @param result defines the Vector3 object where to store the result
  2588. * @returns the unmodified current Vector3
  2589. */
  2590. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2591. /**
  2592. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2593. * @param origin defines the origin of the projection ray
  2594. * @param plane defines the plane to project to
  2595. * @returns the projected vector3
  2596. */
  2597. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2598. /**
  2599. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2600. * @param origin defines the origin of the projection ray
  2601. * @param plane defines the plane to project to
  2602. * @param result defines the Vector3 where to store the result
  2603. */
  2604. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2605. /**
  2606. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2607. * @param otherVector defines the second operand
  2608. * @returns true if both vectors are equals
  2609. */
  2610. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2611. /**
  2612. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2613. * @param otherVector defines the second operand
  2614. * @param epsilon defines the minimal distance to define values as equals
  2615. * @returns true if both vectors are distant less than epsilon
  2616. */
  2617. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2618. /**
  2619. * Returns true if the current Vector3 coordinates equals the given floats
  2620. * @param x defines the x coordinate of the operand
  2621. * @param y defines the y coordinate of the operand
  2622. * @param z defines the z coordinate of the operand
  2623. * @returns true if both vectors are equals
  2624. */
  2625. equalsToFloats(x: number, y: number, z: number): boolean;
  2626. /**
  2627. * Multiplies the current Vector3 coordinates by the given ones
  2628. * @param otherVector defines the second operand
  2629. * @returns the current updated Vector3
  2630. */
  2631. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2632. /**
  2633. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2634. * @param otherVector defines the second operand
  2635. * @returns the new Vector3
  2636. */
  2637. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2638. /**
  2639. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2640. * @param otherVector defines the second operand
  2641. * @param result defines the Vector3 object where to store the result
  2642. * @returns the current Vector3
  2643. */
  2644. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2645. /**
  2646. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2647. * @param x defines the x coordinate of the operand
  2648. * @param y defines the y coordinate of the operand
  2649. * @param z defines the z coordinate of the operand
  2650. * @returns the new Vector3
  2651. */
  2652. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2653. /**
  2654. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2655. * @param otherVector defines the second operand
  2656. * @returns the new Vector3
  2657. */
  2658. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2659. /**
  2660. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2661. * @param otherVector defines the second operand
  2662. * @param result defines the Vector3 object where to store the result
  2663. * @returns the current Vector3
  2664. */
  2665. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2666. /**
  2667. * Divides the current Vector3 coordinates by the given ones.
  2668. * @param otherVector defines the second operand
  2669. * @returns the current updated Vector3
  2670. */
  2671. divideInPlace(otherVector: Vector3): Vector3;
  2672. /**
  2673. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2674. * @param other defines the second operand
  2675. * @returns the current updated Vector3
  2676. */
  2677. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2678. /**
  2679. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2680. * @param other defines the second operand
  2681. * @returns the current updated Vector3
  2682. */
  2683. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2684. /**
  2685. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2686. * @param x defines the x coordinate of the operand
  2687. * @param y defines the y coordinate of the operand
  2688. * @param z defines the z coordinate of the operand
  2689. * @returns the current updated Vector3
  2690. */
  2691. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2692. /**
  2693. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2694. * @param x defines the x coordinate of the operand
  2695. * @param y defines the y coordinate of the operand
  2696. * @param z defines the z coordinate of the operand
  2697. * @returns the current updated Vector3
  2698. */
  2699. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2700. /**
  2701. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2702. * Check if is non uniform within a certain amount of decimal places to account for this
  2703. * @param epsilon the amount the values can differ
  2704. * @returns if the the vector is non uniform to a certain number of decimal places
  2705. */
  2706. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2707. /**
  2708. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2709. */
  2710. get isNonUniform(): boolean;
  2711. /**
  2712. * Gets a new Vector3 from current Vector3 floored values
  2713. * @returns a new Vector3
  2714. */
  2715. floor(): Vector3;
  2716. /**
  2717. * Gets a new Vector3 from current Vector3 floored values
  2718. * @returns a new Vector3
  2719. */
  2720. fract(): Vector3;
  2721. /**
  2722. * Gets the length of the Vector3
  2723. * @returns the length of the Vector3
  2724. */
  2725. length(): number;
  2726. /**
  2727. * Gets the squared length of the Vector3
  2728. * @returns squared length of the Vector3
  2729. */
  2730. lengthSquared(): number;
  2731. /**
  2732. * Normalize the current Vector3.
  2733. * Please note that this is an in place operation.
  2734. * @returns the current updated Vector3
  2735. */
  2736. normalize(): Vector3;
  2737. /**
  2738. * Reorders the x y z properties of the vector in place
  2739. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2740. * @returns the current updated vector
  2741. */
  2742. reorderInPlace(order: string): this;
  2743. /**
  2744. * Rotates the vector around 0,0,0 by a quaternion
  2745. * @param quaternion the rotation quaternion
  2746. * @param result vector to store the result
  2747. * @returns the resulting vector
  2748. */
  2749. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2750. /**
  2751. * Rotates a vector around a given point
  2752. * @param quaternion the rotation quaternion
  2753. * @param point the point to rotate around
  2754. * @param result vector to store the result
  2755. * @returns the resulting vector
  2756. */
  2757. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2758. /**
  2759. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2760. * The cross product is then orthogonal to both current and "other"
  2761. * @param other defines the right operand
  2762. * @returns the cross product
  2763. */
  2764. cross(other: Vector3): Vector3;
  2765. /**
  2766. * Normalize the current Vector3 with the given input length.
  2767. * Please note that this is an in place operation.
  2768. * @param len the length of the vector
  2769. * @returns the current updated Vector3
  2770. */
  2771. normalizeFromLength(len: number): Vector3;
  2772. /**
  2773. * Normalize the current Vector3 to a new vector
  2774. * @returns the new Vector3
  2775. */
  2776. normalizeToNew(): Vector3;
  2777. /**
  2778. * Normalize the current Vector3 to the reference
  2779. * @param reference define the Vector3 to update
  2780. * @returns the updated Vector3
  2781. */
  2782. normalizeToRef(reference: Vector3): Vector3;
  2783. /**
  2784. * Creates a new Vector3 copied from the current Vector3
  2785. * @returns the new Vector3
  2786. */
  2787. clone(): Vector3;
  2788. /**
  2789. * Copies the given vector coordinates to the current Vector3 ones
  2790. * @param source defines the source Vector3
  2791. * @returns the current updated Vector3
  2792. */
  2793. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2794. /**
  2795. * Copies the given floats to the current Vector3 coordinates
  2796. * @param x defines the x coordinate of the operand
  2797. * @param y defines the y coordinate of the operand
  2798. * @param z defines the z coordinate of the operand
  2799. * @returns the current updated Vector3
  2800. */
  2801. copyFromFloats(x: number, y: number, z: number): Vector3;
  2802. /**
  2803. * Copies the given floats to the current Vector3 coordinates
  2804. * @param x defines the x coordinate of the operand
  2805. * @param y defines the y coordinate of the operand
  2806. * @param z defines the z coordinate of the operand
  2807. * @returns the current updated Vector3
  2808. */
  2809. set(x: number, y: number, z: number): Vector3;
  2810. /**
  2811. * Copies the given float to the current Vector3 coordinates
  2812. * @param v defines the x, y and z coordinates of the operand
  2813. * @returns the current updated Vector3
  2814. */
  2815. setAll(v: number): Vector3;
  2816. /**
  2817. * Get the clip factor between two vectors
  2818. * @param vector0 defines the first operand
  2819. * @param vector1 defines the second operand
  2820. * @param axis defines the axis to use
  2821. * @param size defines the size along the axis
  2822. * @returns the clip factor
  2823. */
  2824. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2825. /**
  2826. * Get angle between two vectors
  2827. * @param vector0 angle between vector0 and vector1
  2828. * @param vector1 angle between vector0 and vector1
  2829. * @param normal direction of the normal
  2830. * @return the angle between vector0 and vector1
  2831. */
  2832. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2833. /**
  2834. * Returns a new Vector3 set from the index "offset" of the given array
  2835. * @param array defines the source array
  2836. * @param offset defines the offset in the source array
  2837. * @returns the new Vector3
  2838. */
  2839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2840. /**
  2841. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2842. * @param array defines the source array
  2843. * @param offset defines the offset in the source array
  2844. * @returns the new Vector3
  2845. * @deprecated Please use FromArray instead.
  2846. */
  2847. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2848. /**
  2849. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2850. * @param array defines the source array
  2851. * @param offset defines the offset in the source array
  2852. * @param result defines the Vector3 where to store the result
  2853. */
  2854. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2855. /**
  2856. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2857. * @param array defines the source array
  2858. * @param offset defines the offset in the source array
  2859. * @param result defines the Vector3 where to store the result
  2860. * @deprecated Please use FromArrayToRef instead.
  2861. */
  2862. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2863. /**
  2864. * Sets the given vector "result" with the given floats.
  2865. * @param x defines the x coordinate of the source
  2866. * @param y defines the y coordinate of the source
  2867. * @param z defines the z coordinate of the source
  2868. * @param result defines the Vector3 where to store the result
  2869. */
  2870. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2871. /**
  2872. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2873. * @returns a new empty Vector3
  2874. */
  2875. static Zero(): Vector3;
  2876. /**
  2877. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2878. * @returns a new unit Vector3
  2879. */
  2880. static One(): Vector3;
  2881. /**
  2882. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2883. * @returns a new up Vector3
  2884. */
  2885. static Up(): Vector3;
  2886. /**
  2887. * Gets a up Vector3 that must not be updated
  2888. */
  2889. static get UpReadOnly(): DeepImmutable<Vector3>;
  2890. /**
  2891. * Gets a zero Vector3 that must not be updated
  2892. */
  2893. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2894. /**
  2895. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2896. * @returns a new down Vector3
  2897. */
  2898. static Down(): Vector3;
  2899. /**
  2900. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2901. * @param rightHandedSystem is the scene right-handed (negative z)
  2902. * @returns a new forward Vector3
  2903. */
  2904. static Forward(rightHandedSystem?: boolean): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2907. * @param rightHandedSystem is the scene right-handed (negative-z)
  2908. * @returns a new forward Vector3
  2909. */
  2910. static Backward(rightHandedSystem?: boolean): Vector3;
  2911. /**
  2912. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2913. * @returns a new right Vector3
  2914. */
  2915. static Right(): Vector3;
  2916. /**
  2917. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2918. * @returns a new left Vector3
  2919. */
  2920. static Left(): Vector3;
  2921. /**
  2922. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2923. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2924. * @param vector defines the Vector3 to transform
  2925. * @param transformation defines the transformation matrix
  2926. * @returns the transformed Vector3
  2927. */
  2928. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2929. /**
  2930. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2931. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2932. * @param vector defines the Vector3 to transform
  2933. * @param transformation defines the transformation matrix
  2934. * @param result defines the Vector3 where to store the result
  2935. */
  2936. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2937. /**
  2938. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2939. * This method computes tranformed coordinates only, not transformed direction vectors
  2940. * @param x define the x coordinate of the source vector
  2941. * @param y define the y coordinate of the source vector
  2942. * @param z define the z coordinate of the source vector
  2943. * @param transformation defines the transformation matrix
  2944. * @param result defines the Vector3 where to store the result
  2945. */
  2946. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2947. /**
  2948. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2949. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2950. * @param vector defines the Vector3 to transform
  2951. * @param transformation defines the transformation matrix
  2952. * @returns the new Vector3
  2953. */
  2954. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2955. /**
  2956. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2957. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2958. * @param vector defines the Vector3 to transform
  2959. * @param transformation defines the transformation matrix
  2960. * @param result defines the Vector3 where to store the result
  2961. */
  2962. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2963. /**
  2964. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2965. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2966. * @param x define the x coordinate of the source vector
  2967. * @param y define the y coordinate of the source vector
  2968. * @param z define the z coordinate of the source vector
  2969. * @param transformation defines the transformation matrix
  2970. * @param result defines the Vector3 where to store the result
  2971. */
  2972. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2973. /**
  2974. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2975. * @param value1 defines the first control point
  2976. * @param value2 defines the second control point
  2977. * @param value3 defines the third control point
  2978. * @param value4 defines the fourth control point
  2979. * @param amount defines the amount on the spline to use
  2980. * @returns the new Vector3
  2981. */
  2982. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2983. /**
  2984. * 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"
  2985. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2986. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2987. * @param value defines the current value
  2988. * @param min defines the lower range value
  2989. * @param max defines the upper range value
  2990. * @returns the new Vector3
  2991. */
  2992. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2993. /**
  2994. * 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"
  2995. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2996. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2997. * @param value defines the current value
  2998. * @param min defines the lower range value
  2999. * @param max defines the upper range value
  3000. * @param result defines the Vector3 where to store the result
  3001. */
  3002. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3003. /**
  3004. * Checks if a given vector is inside a specific range
  3005. * @param v defines the vector to test
  3006. * @param min defines the minimum range
  3007. * @param max defines the maximum range
  3008. */
  3009. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3010. /**
  3011. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3012. * @param value1 defines the first control point
  3013. * @param tangent1 defines the first tangent vector
  3014. * @param value2 defines the second control point
  3015. * @param tangent2 defines the second tangent vector
  3016. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3017. * @returns the new Vector3
  3018. */
  3019. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3020. /**
  3021. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3022. * @param start defines the start value
  3023. * @param end defines the end value
  3024. * @param amount max defines amount between both (between 0 and 1)
  3025. * @returns the new Vector3
  3026. */
  3027. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3028. /**
  3029. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3030. * @param start defines the start value
  3031. * @param end defines the end value
  3032. * @param amount max defines amount between both (between 0 and 1)
  3033. * @param result defines the Vector3 where to store the result
  3034. */
  3035. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3036. /**
  3037. * Returns the dot product (float) between the vectors "left" and "right"
  3038. * @param left defines the left operand
  3039. * @param right defines the right operand
  3040. * @returns the dot product
  3041. */
  3042. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3043. /**
  3044. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3045. * The cross product is then orthogonal to both "left" and "right"
  3046. * @param left defines the left operand
  3047. * @param right defines the right operand
  3048. * @returns the cross product
  3049. */
  3050. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3051. /**
  3052. * Sets the given vector "result" with the cross product of "left" and "right"
  3053. * The cross product is then orthogonal to both "left" and "right"
  3054. * @param left defines the left operand
  3055. * @param right defines the right operand
  3056. * @param result defines the Vector3 where to store the result
  3057. */
  3058. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3059. /**
  3060. * Returns a new Vector3 as the normalization of the given vector
  3061. * @param vector defines the Vector3 to normalize
  3062. * @returns the new Vector3
  3063. */
  3064. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3065. /**
  3066. * Sets the given vector "result" with the normalization of the given first vector
  3067. * @param vector defines the Vector3 to normalize
  3068. * @param result defines the Vector3 where to store the result
  3069. */
  3070. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3071. /**
  3072. * Project a Vector3 onto screen space
  3073. * @param vector defines the Vector3 to project
  3074. * @param world defines the world matrix to use
  3075. * @param transform defines the transform (view x projection) matrix to use
  3076. * @param viewport defines the screen viewport to use
  3077. * @returns the new Vector3
  3078. */
  3079. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3080. /** @hidden */
  3081. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3082. /**
  3083. * Unproject from screen space to object space
  3084. * @param source defines the screen space Vector3 to use
  3085. * @param viewportWidth defines the current width of the viewport
  3086. * @param viewportHeight defines the current height of the viewport
  3087. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3088. * @param transform defines the transform (view x projection) matrix to use
  3089. * @returns the new Vector3
  3090. */
  3091. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3092. /**
  3093. * Unproject from screen space to object space
  3094. * @param source defines the screen space Vector3 to use
  3095. * @param viewportWidth defines the current width of the viewport
  3096. * @param viewportHeight defines the current height of the viewport
  3097. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3098. * @param view defines the view matrix to use
  3099. * @param projection defines the projection matrix to use
  3100. * @returns the new Vector3
  3101. */
  3102. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3103. /**
  3104. * Unproject from screen space to object space
  3105. * @param source defines the screen space Vector3 to use
  3106. * @param viewportWidth defines the current width of the viewport
  3107. * @param viewportHeight defines the current height of the viewport
  3108. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3109. * @param view defines the view matrix to use
  3110. * @param projection defines the projection matrix to use
  3111. * @param result defines the Vector3 where to store the result
  3112. */
  3113. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3114. /**
  3115. * Unproject from screen space to object space
  3116. * @param sourceX defines the screen space x coordinate to use
  3117. * @param sourceY defines the screen space y coordinate to use
  3118. * @param sourceZ defines the screen space z coordinate to use
  3119. * @param viewportWidth defines the current width of the viewport
  3120. * @param viewportHeight defines the current height of the viewport
  3121. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3122. * @param view defines the view matrix to use
  3123. * @param projection defines the projection matrix to use
  3124. * @param result defines the Vector3 where to store the result
  3125. */
  3126. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3127. /**
  3128. * Gets the minimal coordinate values between two Vector3
  3129. * @param left defines the first operand
  3130. * @param right defines the second operand
  3131. * @returns the new Vector3
  3132. */
  3133. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3134. /**
  3135. * Gets the maximal coordinate values between two Vector3
  3136. * @param left defines the first operand
  3137. * @param right defines the second operand
  3138. * @returns the new Vector3
  3139. */
  3140. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3141. /**
  3142. * Returns the distance between the vectors "value1" and "value2"
  3143. * @param value1 defines the first operand
  3144. * @param value2 defines the second operand
  3145. * @returns the distance
  3146. */
  3147. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3148. /**
  3149. * Returns the squared distance between the vectors "value1" and "value2"
  3150. * @param value1 defines the first operand
  3151. * @param value2 defines the second operand
  3152. * @returns the squared distance
  3153. */
  3154. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3155. /**
  3156. * Returns a new Vector3 located at the center between "value1" and "value2"
  3157. * @param value1 defines the first operand
  3158. * @param value2 defines the second operand
  3159. * @returns the new Vector3
  3160. */
  3161. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3162. /**
  3163. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3164. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3165. * to something in order to rotate it from its local system to the given target system
  3166. * Note: axis1, axis2 and axis3 are normalized during this operation
  3167. * @param axis1 defines the first axis
  3168. * @param axis2 defines the second axis
  3169. * @param axis3 defines the third axis
  3170. * @returns a new Vector3
  3171. */
  3172. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3173. /**
  3174. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3175. * @param axis1 defines the first axis
  3176. * @param axis2 defines the second axis
  3177. * @param axis3 defines the third axis
  3178. * @param ref defines the Vector3 where to store the result
  3179. */
  3180. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3181. }
  3182. /**
  3183. * Vector4 class created for EulerAngle class conversion to Quaternion
  3184. */
  3185. export class Vector4 {
  3186. /** x value of the vector */
  3187. x: number;
  3188. /** y value of the vector */
  3189. y: number;
  3190. /** z value of the vector */
  3191. z: number;
  3192. /** w value of the vector */
  3193. w: number;
  3194. /**
  3195. * Creates a Vector4 object from the given floats.
  3196. * @param x x value of the vector
  3197. * @param y y value of the vector
  3198. * @param z z value of the vector
  3199. * @param w w value of the vector
  3200. */
  3201. constructor(
  3202. /** x value of the vector */
  3203. x: number,
  3204. /** y value of the vector */
  3205. y: number,
  3206. /** z value of the vector */
  3207. z: number,
  3208. /** w value of the vector */
  3209. w: number);
  3210. /**
  3211. * Returns the string with the Vector4 coordinates.
  3212. * @returns a string containing all the vector values
  3213. */
  3214. toString(): string;
  3215. /**
  3216. * Returns the string "Vector4".
  3217. * @returns "Vector4"
  3218. */
  3219. getClassName(): string;
  3220. /**
  3221. * Returns the Vector4 hash code.
  3222. * @returns a unique hash code
  3223. */
  3224. getHashCode(): number;
  3225. /**
  3226. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3227. * @returns the resulting array
  3228. */
  3229. asArray(): number[];
  3230. /**
  3231. * Populates the given array from the given index with the Vector4 coordinates.
  3232. * @param array array to populate
  3233. * @param index index of the array to start at (default: 0)
  3234. * @returns the Vector4.
  3235. */
  3236. toArray(array: FloatArray, index?: number): Vector4;
  3237. /**
  3238. * Adds the given vector to the current Vector4.
  3239. * @param otherVector the vector to add
  3240. * @returns the updated Vector4.
  3241. */
  3242. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3243. /**
  3244. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3245. * @param otherVector the vector to add
  3246. * @returns the resulting vector
  3247. */
  3248. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3249. /**
  3250. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3251. * @param otherVector the vector to add
  3252. * @param result the vector to store the result
  3253. * @returns the current Vector4.
  3254. */
  3255. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3256. /**
  3257. * Subtract in place the given vector from the current Vector4.
  3258. * @param otherVector the vector to subtract
  3259. * @returns the updated Vector4.
  3260. */
  3261. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3264. * @param otherVector the vector to add
  3265. * @returns the new vector with the result
  3266. */
  3267. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3270. * @param otherVector the vector to subtract
  3271. * @param result the vector to store the result
  3272. * @returns the current Vector4.
  3273. */
  3274. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3275. /**
  3276. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3277. */
  3278. /**
  3279. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3280. * @param x value to subtract
  3281. * @param y value to subtract
  3282. * @param z value to subtract
  3283. * @param w value to subtract
  3284. * @returns new vector containing the result
  3285. */
  3286. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3287. /**
  3288. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3289. * @param x value to subtract
  3290. * @param y value to subtract
  3291. * @param z value to subtract
  3292. * @param w value to subtract
  3293. * @param result the vector to store the result in
  3294. * @returns the current Vector4.
  3295. */
  3296. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3297. /**
  3298. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3299. * @returns a new vector with the negated values
  3300. */
  3301. negate(): Vector4;
  3302. /**
  3303. * Negate this vector in place
  3304. * @returns this
  3305. */
  3306. negateInPlace(): Vector4;
  3307. /**
  3308. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3309. * @param result defines the Vector3 object where to store the result
  3310. * @returns the current Vector4
  3311. */
  3312. negateToRef(result: Vector4): Vector4;
  3313. /**
  3314. * Multiplies the current Vector4 coordinates by scale (float).
  3315. * @param scale the number to scale with
  3316. * @returns the updated Vector4.
  3317. */
  3318. scaleInPlace(scale: number): Vector4;
  3319. /**
  3320. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3321. * @param scale the number to scale with
  3322. * @returns a new vector with the result
  3323. */
  3324. scale(scale: number): Vector4;
  3325. /**
  3326. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3327. * @param scale the number to scale with
  3328. * @param result a vector to store the result in
  3329. * @returns the current Vector4.
  3330. */
  3331. scaleToRef(scale: number, result: Vector4): Vector4;
  3332. /**
  3333. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3334. * @param scale defines the scale factor
  3335. * @param result defines the Vector4 object where to store the result
  3336. * @returns the unmodified current Vector4
  3337. */
  3338. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3339. /**
  3340. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3341. * @param otherVector the vector to compare against
  3342. * @returns true if they are equal
  3343. */
  3344. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3345. /**
  3346. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3347. * @param otherVector vector to compare against
  3348. * @param epsilon (Default: very small number)
  3349. * @returns true if they are equal
  3350. */
  3351. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3352. /**
  3353. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3354. * @param x x value to compare against
  3355. * @param y y value to compare against
  3356. * @param z z value to compare against
  3357. * @param w w value to compare against
  3358. * @returns true if equal
  3359. */
  3360. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3361. /**
  3362. * Multiplies in place the current Vector4 by the given one.
  3363. * @param otherVector vector to multiple with
  3364. * @returns the updated Vector4.
  3365. */
  3366. multiplyInPlace(otherVector: Vector4): Vector4;
  3367. /**
  3368. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3369. * @param otherVector vector to multiple with
  3370. * @returns resulting new vector
  3371. */
  3372. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3373. /**
  3374. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3375. * @param otherVector vector to multiple with
  3376. * @param result vector to store the result
  3377. * @returns the current Vector4.
  3378. */
  3379. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3380. /**
  3381. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3382. * @param x x value multiply with
  3383. * @param y y value multiply with
  3384. * @param z z value multiply with
  3385. * @param w w value multiply with
  3386. * @returns resulting new vector
  3387. */
  3388. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3389. /**
  3390. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3391. * @param otherVector vector to devide with
  3392. * @returns resulting new vector
  3393. */
  3394. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3395. /**
  3396. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3397. * @param otherVector vector to devide with
  3398. * @param result vector to store the result
  3399. * @returns the current Vector4.
  3400. */
  3401. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3402. /**
  3403. * Divides the current Vector3 coordinates by the given ones.
  3404. * @param otherVector vector to devide with
  3405. * @returns the updated Vector3.
  3406. */
  3407. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3408. /**
  3409. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3410. * @param other defines the second operand
  3411. * @returns the current updated Vector4
  3412. */
  3413. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3414. /**
  3415. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3416. * @param other defines the second operand
  3417. * @returns the current updated Vector4
  3418. */
  3419. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3420. /**
  3421. * Gets a new Vector4 from current Vector4 floored values
  3422. * @returns a new Vector4
  3423. */
  3424. floor(): Vector4;
  3425. /**
  3426. * Gets a new Vector4 from current Vector3 floored values
  3427. * @returns a new Vector4
  3428. */
  3429. fract(): Vector4;
  3430. /**
  3431. * Returns the Vector4 length (float).
  3432. * @returns the length
  3433. */
  3434. length(): number;
  3435. /**
  3436. * Returns the Vector4 squared length (float).
  3437. * @returns the length squared
  3438. */
  3439. lengthSquared(): number;
  3440. /**
  3441. * Normalizes in place the Vector4.
  3442. * @returns the updated Vector4.
  3443. */
  3444. normalize(): Vector4;
  3445. /**
  3446. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3447. * @returns this converted to a new vector3
  3448. */
  3449. toVector3(): Vector3;
  3450. /**
  3451. * Returns a new Vector4 copied from the current one.
  3452. * @returns the new cloned vector
  3453. */
  3454. clone(): Vector4;
  3455. /**
  3456. * Updates the current Vector4 with the given one coordinates.
  3457. * @param source the source vector to copy from
  3458. * @returns the updated Vector4.
  3459. */
  3460. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3461. /**
  3462. * Updates the current Vector4 coordinates with the given floats.
  3463. * @param x float to copy from
  3464. * @param y float to copy from
  3465. * @param z float to copy from
  3466. * @param w float to copy from
  3467. * @returns the updated Vector4.
  3468. */
  3469. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3470. /**
  3471. * Updates the current Vector4 coordinates with the given floats.
  3472. * @param x float to set from
  3473. * @param y float to set from
  3474. * @param z float to set from
  3475. * @param w float to set from
  3476. * @returns the updated Vector4.
  3477. */
  3478. set(x: number, y: number, z: number, w: number): Vector4;
  3479. /**
  3480. * Copies the given float to the current Vector3 coordinates
  3481. * @param v defines the x, y, z and w coordinates of the operand
  3482. * @returns the current updated Vector3
  3483. */
  3484. setAll(v: number): Vector4;
  3485. /**
  3486. * Returns a new Vector4 set from the starting index of the given array.
  3487. * @param array the array to pull values from
  3488. * @param offset the offset into the array to start at
  3489. * @returns the new vector
  3490. */
  3491. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3492. /**
  3493. * Updates the given vector "result" from the starting index of the given array.
  3494. * @param array the array to pull values from
  3495. * @param offset the offset into the array to start at
  3496. * @param result the vector to store the result in
  3497. */
  3498. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3499. /**
  3500. * Updates the given vector "result" from the starting index of the given Float32Array.
  3501. * @param array the array to pull values from
  3502. * @param offset the offset into the array to start at
  3503. * @param result the vector to store the result in
  3504. */
  3505. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3506. /**
  3507. * Updates the given vector "result" coordinates from the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @param result the vector to the floats in
  3513. */
  3514. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3515. /**
  3516. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3517. * @returns the new vector
  3518. */
  3519. static Zero(): Vector4;
  3520. /**
  3521. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3522. * @returns the new vector
  3523. */
  3524. static One(): Vector4;
  3525. /**
  3526. * Returns a new normalized Vector4 from the given one.
  3527. * @param vector the vector to normalize
  3528. * @returns the vector
  3529. */
  3530. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3531. /**
  3532. * Updates the given vector "result" from the normalization of the given one.
  3533. * @param vector the vector to normalize
  3534. * @param result the vector to store the result in
  3535. */
  3536. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3537. /**
  3538. * Returns a vector with the minimum values from the left and right vectors
  3539. * @param left left vector to minimize
  3540. * @param right right vector to minimize
  3541. * @returns a new vector with the minimum of the left and right vector values
  3542. */
  3543. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3544. /**
  3545. * Returns a vector with the maximum values from the left and right vectors
  3546. * @param left left vector to maximize
  3547. * @param right right vector to maximize
  3548. * @returns a new vector with the maximum of the left and right vector values
  3549. */
  3550. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3551. /**
  3552. * Returns the distance (float) between the vectors "value1" and "value2".
  3553. * @param value1 value to calulate the distance between
  3554. * @param value2 value to calulate the distance between
  3555. * @return the distance between the two vectors
  3556. */
  3557. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3558. /**
  3559. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3560. * @param value1 value to calulate the distance between
  3561. * @param value2 value to calulate the distance between
  3562. * @return the distance between the two vectors squared
  3563. */
  3564. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3565. /**
  3566. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3567. * @param value1 value to calulate the center between
  3568. * @param value2 value to calulate the center between
  3569. * @return the center between the two vectors
  3570. */
  3571. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3572. /**
  3573. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3574. * This methods computes transformed normalized direction vectors only.
  3575. * @param vector the vector to transform
  3576. * @param transformation the transformation matrix to apply
  3577. * @returns the new vector
  3578. */
  3579. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3580. /**
  3581. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3582. * This methods computes transformed normalized direction vectors only.
  3583. * @param vector the vector to transform
  3584. * @param transformation the transformation matrix to apply
  3585. * @param result the vector to store the result in
  3586. */
  3587. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3588. /**
  3589. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3590. * This methods computes transformed normalized direction vectors only.
  3591. * @param x value to transform
  3592. * @param y value to transform
  3593. * @param z value to transform
  3594. * @param w value to transform
  3595. * @param transformation the transformation matrix to apply
  3596. * @param result the vector to store the results in
  3597. */
  3598. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3599. /**
  3600. * Creates a new Vector4 from a Vector3
  3601. * @param source defines the source data
  3602. * @param w defines the 4th component (default is 0)
  3603. * @returns a new Vector4
  3604. */
  3605. static FromVector3(source: Vector3, w?: number): Vector4;
  3606. }
  3607. /**
  3608. * Class used to store quaternion data
  3609. * @see https://en.wikipedia.org/wiki/Quaternion
  3610. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3611. */
  3612. export class Quaternion {
  3613. /** @hidden */
  3614. _x: number;
  3615. /** @hidden */
  3616. _y: number;
  3617. /** @hidden */
  3618. _z: number;
  3619. /** @hidden */
  3620. _w: number;
  3621. /** @hidden */
  3622. _isDirty: boolean;
  3623. /** Gets or sets the x coordinate */
  3624. get x(): number;
  3625. set x(value: number);
  3626. /** Gets or sets the y coordinate */
  3627. get y(): number;
  3628. set y(value: number);
  3629. /** Gets or sets the z coordinate */
  3630. get z(): number;
  3631. set z(value: number);
  3632. /** Gets or sets the w coordinate */
  3633. get w(): number;
  3634. set w(value: number);
  3635. /**
  3636. * Creates a new Quaternion from the given floats
  3637. * @param x defines the first component (0 by default)
  3638. * @param y defines the second component (0 by default)
  3639. * @param z defines the third component (0 by default)
  3640. * @param w defines the fourth component (1.0 by default)
  3641. */
  3642. constructor(x?: number, y?: number, z?: number, w?: number);
  3643. /**
  3644. * Gets a string representation for the current quaternion
  3645. * @returns a string with the Quaternion coordinates
  3646. */
  3647. toString(): string;
  3648. /**
  3649. * Gets the class name of the quaternion
  3650. * @returns the string "Quaternion"
  3651. */
  3652. getClassName(): string;
  3653. /**
  3654. * Gets a hash code for this quaternion
  3655. * @returns the quaternion hash code
  3656. */
  3657. getHashCode(): number;
  3658. /**
  3659. * Copy the quaternion to an array
  3660. * @returns a new array populated with 4 elements from the quaternion coordinates
  3661. */
  3662. asArray(): number[];
  3663. /**
  3664. * Check if two quaternions are equals
  3665. * @param otherQuaternion defines the second operand
  3666. * @return true if the current quaternion and the given one coordinates are strictly equals
  3667. */
  3668. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3669. /**
  3670. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3671. * @param otherQuaternion defines the other quaternion
  3672. * @param epsilon defines the minimal distance to consider equality
  3673. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3674. */
  3675. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3676. /**
  3677. * Clone the current quaternion
  3678. * @returns a new quaternion copied from the current one
  3679. */
  3680. clone(): Quaternion;
  3681. /**
  3682. * Copy a quaternion to the current one
  3683. * @param other defines the other quaternion
  3684. * @returns the updated current quaternion
  3685. */
  3686. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3687. /**
  3688. * Updates the current quaternion with the given float coordinates
  3689. * @param x defines the x coordinate
  3690. * @param y defines the y coordinate
  3691. * @param z defines the z coordinate
  3692. * @param w defines the w coordinate
  3693. * @returns the updated current quaternion
  3694. */
  3695. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3696. /**
  3697. * Updates the current quaternion from the given float coordinates
  3698. * @param x defines the x coordinate
  3699. * @param y defines the y coordinate
  3700. * @param z defines the z coordinate
  3701. * @param w defines the w coordinate
  3702. * @returns the updated current quaternion
  3703. */
  3704. set(x: number, y: number, z: number, w: number): Quaternion;
  3705. /**
  3706. * Adds two quaternions
  3707. * @param other defines the second operand
  3708. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3709. */
  3710. add(other: DeepImmutable<Quaternion>): Quaternion;
  3711. /**
  3712. * Add a quaternion to the current one
  3713. * @param other defines the quaternion to add
  3714. * @returns the current quaternion
  3715. */
  3716. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3717. /**
  3718. * Subtract two quaternions
  3719. * @param other defines the second operand
  3720. * @returns a new quaternion as the subtraction result of the given one from the current one
  3721. */
  3722. subtract(other: Quaternion): Quaternion;
  3723. /**
  3724. * Multiplies the current quaternion by a scale factor
  3725. * @param value defines the scale factor
  3726. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3727. */
  3728. scale(value: number): Quaternion;
  3729. /**
  3730. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3731. * @param scale defines the scale factor
  3732. * @param result defines the Quaternion object where to store the result
  3733. * @returns the unmodified current quaternion
  3734. */
  3735. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3736. /**
  3737. * Multiplies in place the current quaternion by a scale factor
  3738. * @param value defines the scale factor
  3739. * @returns the current modified quaternion
  3740. */
  3741. scaleInPlace(value: number): Quaternion;
  3742. /**
  3743. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3744. * @param scale defines the scale factor
  3745. * @param result defines the Quaternion object where to store the result
  3746. * @returns the unmodified current quaternion
  3747. */
  3748. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3749. /**
  3750. * Multiplies two quaternions
  3751. * @param q1 defines the second operand
  3752. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3753. */
  3754. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3755. /**
  3756. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3757. * @param q1 defines the second operand
  3758. * @param result defines the target quaternion
  3759. * @returns the current quaternion
  3760. */
  3761. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3762. /**
  3763. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3764. * @param q1 defines the second operand
  3765. * @returns the currentupdated quaternion
  3766. */
  3767. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3768. /**
  3769. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3770. * @param ref defines the target quaternion
  3771. * @returns the current quaternion
  3772. */
  3773. conjugateToRef(ref: Quaternion): Quaternion;
  3774. /**
  3775. * Conjugates in place (1-q) the current quaternion
  3776. * @returns the current updated quaternion
  3777. */
  3778. conjugateInPlace(): Quaternion;
  3779. /**
  3780. * Conjugates in place (1-q) the current quaternion
  3781. * @returns a new quaternion
  3782. */
  3783. conjugate(): Quaternion;
  3784. /**
  3785. * Gets length of current quaternion
  3786. * @returns the quaternion length (float)
  3787. */
  3788. length(): number;
  3789. /**
  3790. * Normalize in place the current quaternion
  3791. * @returns the current updated quaternion
  3792. */
  3793. normalize(): Quaternion;
  3794. /**
  3795. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3796. * @param order is a reserved parameter and is ignore for now
  3797. * @returns a new Vector3 containing the Euler angles
  3798. */
  3799. toEulerAngles(order?: string): Vector3;
  3800. /**
  3801. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3802. * @param result defines the vector which will be filled with the Euler angles
  3803. * @param order is a reserved parameter and is ignore for now
  3804. * @returns the current unchanged quaternion
  3805. */
  3806. toEulerAnglesToRef(result: Vector3): Quaternion;
  3807. /**
  3808. * Updates the given rotation matrix with the current quaternion values
  3809. * @param result defines the target matrix
  3810. * @returns the current unchanged quaternion
  3811. */
  3812. toRotationMatrix(result: Matrix): Quaternion;
  3813. /**
  3814. * Updates the current quaternion from the given rotation matrix values
  3815. * @param matrix defines the source matrix
  3816. * @returns the current updated quaternion
  3817. */
  3818. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3819. /**
  3820. * Creates a new quaternion from a rotation matrix
  3821. * @param matrix defines the source matrix
  3822. * @returns a new quaternion created from the given rotation matrix values
  3823. */
  3824. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3825. /**
  3826. * Updates the given quaternion with the given rotation matrix values
  3827. * @param matrix defines the source matrix
  3828. * @param result defines the target quaternion
  3829. */
  3830. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3831. /**
  3832. * Returns the dot product (float) between the quaternions "left" and "right"
  3833. * @param left defines the left operand
  3834. * @param right defines the right operand
  3835. * @returns the dot product
  3836. */
  3837. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3838. /**
  3839. * Checks if the two quaternions are close to each other
  3840. * @param quat0 defines the first quaternion to check
  3841. * @param quat1 defines the second quaternion to check
  3842. * @returns true if the two quaternions are close to each other
  3843. */
  3844. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3845. /**
  3846. * Creates an empty quaternion
  3847. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3848. */
  3849. static Zero(): Quaternion;
  3850. /**
  3851. * Inverse a given quaternion
  3852. * @param q defines the source quaternion
  3853. * @returns a new quaternion as the inverted current quaternion
  3854. */
  3855. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3856. /**
  3857. * Inverse a given quaternion
  3858. * @param q defines the source quaternion
  3859. * @param result the quaternion the result will be stored in
  3860. * @returns the result quaternion
  3861. */
  3862. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3863. /**
  3864. * Creates an identity quaternion
  3865. * @returns the identity quaternion
  3866. */
  3867. static Identity(): Quaternion;
  3868. /**
  3869. * Gets a boolean indicating if the given quaternion is identity
  3870. * @param quaternion defines the quaternion to check
  3871. * @returns true if the quaternion is identity
  3872. */
  3873. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3874. /**
  3875. * Creates a quaternion from a rotation around an axis
  3876. * @param axis defines the axis to use
  3877. * @param angle defines the angle to use
  3878. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3879. */
  3880. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3881. /**
  3882. * Creates a rotation around an axis and stores it into the given quaternion
  3883. * @param axis defines the axis to use
  3884. * @param angle defines the angle to use
  3885. * @param result defines the target quaternion
  3886. * @returns the target quaternion
  3887. */
  3888. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3889. /**
  3890. * Creates a new quaternion from data stored into an array
  3891. * @param array defines the data source
  3892. * @param offset defines the offset in the source array where the data starts
  3893. * @returns a new quaternion
  3894. */
  3895. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3896. /**
  3897. * Updates the given quaternion "result" from the starting index of the given array.
  3898. * @param array the array to pull values from
  3899. * @param offset the offset into the array to start at
  3900. * @param result the quaternion to store the result in
  3901. */
  3902. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3903. /**
  3904. * Create a quaternion from Euler rotation angles
  3905. * @param x Pitch
  3906. * @param y Yaw
  3907. * @param z Roll
  3908. * @returns the new Quaternion
  3909. */
  3910. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3911. /**
  3912. * Updates a quaternion from Euler rotation angles
  3913. * @param x Pitch
  3914. * @param y Yaw
  3915. * @param z Roll
  3916. * @param result the quaternion to store the result
  3917. * @returns the updated quaternion
  3918. */
  3919. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3920. /**
  3921. * Create a quaternion from Euler rotation vector
  3922. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3923. * @returns the new Quaternion
  3924. */
  3925. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3926. /**
  3927. * Updates a quaternion from Euler rotation vector
  3928. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3929. * @param result the quaternion to store the result
  3930. * @returns the updated quaternion
  3931. */
  3932. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3935. * @param yaw defines the rotation around Y axis
  3936. * @param pitch defines the rotation around X axis
  3937. * @param roll defines the rotation around Z axis
  3938. * @returns the new quaternion
  3939. */
  3940. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3941. /**
  3942. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3943. * @param yaw defines the rotation around Y axis
  3944. * @param pitch defines the rotation around X axis
  3945. * @param roll defines the rotation around Z axis
  3946. * @param result defines the target quaternion
  3947. */
  3948. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3949. /**
  3950. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3951. * @param alpha defines the rotation around first axis
  3952. * @param beta defines the rotation around second axis
  3953. * @param gamma defines the rotation around third axis
  3954. * @returns the new quaternion
  3955. */
  3956. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3957. /**
  3958. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3959. * @param alpha defines the rotation around first axis
  3960. * @param beta defines the rotation around second axis
  3961. * @param gamma defines the rotation around third axis
  3962. * @param result defines the target quaternion
  3963. */
  3964. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3965. /**
  3966. * 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)
  3967. * @param axis1 defines the first axis
  3968. * @param axis2 defines the second axis
  3969. * @param axis3 defines the third axis
  3970. * @returns the new quaternion
  3971. */
  3972. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3973. /**
  3974. * 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
  3975. * @param axis1 defines the first axis
  3976. * @param axis2 defines the second axis
  3977. * @param axis3 defines the third axis
  3978. * @param ref defines the target quaternion
  3979. */
  3980. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3981. /**
  3982. * Interpolates between two quaternions
  3983. * @param left defines first quaternion
  3984. * @param right defines second quaternion
  3985. * @param amount defines the gradient to use
  3986. * @returns the new interpolated quaternion
  3987. */
  3988. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3989. /**
  3990. * Interpolates between two quaternions and stores it into a target quaternion
  3991. * @param left defines first quaternion
  3992. * @param right defines second quaternion
  3993. * @param amount defines the gradient to use
  3994. * @param result defines the target quaternion
  3995. */
  3996. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3997. /**
  3998. * Interpolate between two quaternions using Hermite interpolation
  3999. * @param value1 defines first quaternion
  4000. * @param tangent1 defines the incoming tangent
  4001. * @param value2 defines second quaternion
  4002. * @param tangent2 defines the outgoing tangent
  4003. * @param amount defines the target quaternion
  4004. * @returns the new interpolated quaternion
  4005. */
  4006. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4007. }
  4008. /**
  4009. * Class used to store matrix data (4x4)
  4010. */
  4011. export class Matrix {
  4012. private static _updateFlagSeed;
  4013. private static _identityReadOnly;
  4014. private _isIdentity;
  4015. private _isIdentityDirty;
  4016. private _isIdentity3x2;
  4017. private _isIdentity3x2Dirty;
  4018. /**
  4019. * Gets the update flag of the matrix which is an unique number for the matrix.
  4020. * It will be incremented every time the matrix data change.
  4021. * You can use it to speed the comparison between two versions of the same matrix.
  4022. */
  4023. updateFlag: number;
  4024. private readonly _m;
  4025. /**
  4026. * Gets the internal data of the matrix
  4027. */
  4028. get m(): DeepImmutable<Float32Array>;
  4029. /** @hidden */
  4030. _markAsUpdated(): void;
  4031. /** @hidden */
  4032. private _updateIdentityStatus;
  4033. /**
  4034. * Creates an empty matrix (filled with zeros)
  4035. */
  4036. constructor();
  4037. /**
  4038. * Check if the current matrix is identity
  4039. * @returns true is the matrix is the identity matrix
  4040. */
  4041. isIdentity(): boolean;
  4042. /**
  4043. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4044. * @returns true is the matrix is the identity matrix
  4045. */
  4046. isIdentityAs3x2(): boolean;
  4047. /**
  4048. * Gets the determinant of the matrix
  4049. * @returns the matrix determinant
  4050. */
  4051. determinant(): number;
  4052. /**
  4053. * Returns the matrix as a Float32Array
  4054. * @returns the matrix underlying array
  4055. */
  4056. toArray(): DeepImmutable<Float32Array>;
  4057. /**
  4058. * Returns the matrix as a Float32Array
  4059. * @returns the matrix underlying array.
  4060. */
  4061. asArray(): DeepImmutable<Float32Array>;
  4062. /**
  4063. * Inverts the current matrix in place
  4064. * @returns the current inverted matrix
  4065. */
  4066. invert(): Matrix;
  4067. /**
  4068. * Sets all the matrix elements to zero
  4069. * @returns the current matrix
  4070. */
  4071. reset(): Matrix;
  4072. /**
  4073. * Adds the current matrix with a second one
  4074. * @param other defines the matrix to add
  4075. * @returns a new matrix as the addition of the current matrix and the given one
  4076. */
  4077. add(other: DeepImmutable<Matrix>): Matrix;
  4078. /**
  4079. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4080. * @param other defines the matrix to add
  4081. * @param result defines the target matrix
  4082. * @returns the current matrix
  4083. */
  4084. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4085. /**
  4086. * Adds in place the given matrix to the current matrix
  4087. * @param other defines the second operand
  4088. * @returns the current updated matrix
  4089. */
  4090. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4091. /**
  4092. * Sets the given matrix to the current inverted Matrix
  4093. * @param other defines the target matrix
  4094. * @returns the unmodified current matrix
  4095. */
  4096. invertToRef(other: Matrix): Matrix;
  4097. /**
  4098. * add a value at the specified position in the current Matrix
  4099. * @param index the index of the value within the matrix. between 0 and 15.
  4100. * @param value the value to be added
  4101. * @returns the current updated matrix
  4102. */
  4103. addAtIndex(index: number, value: number): Matrix;
  4104. /**
  4105. * mutiply the specified position in the current Matrix by a value
  4106. * @param index the index of the value within the matrix. between 0 and 15.
  4107. * @param value the value to be added
  4108. * @returns the current updated matrix
  4109. */
  4110. multiplyAtIndex(index: number, value: number): Matrix;
  4111. /**
  4112. * Inserts the translation vector (using 3 floats) in the current matrix
  4113. * @param x defines the 1st component of the translation
  4114. * @param y defines the 2nd component of the translation
  4115. * @param z defines the 3rd component of the translation
  4116. * @returns the current updated matrix
  4117. */
  4118. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4119. /**
  4120. * Adds the translation vector (using 3 floats) in the current matrix
  4121. * @param x defines the 1st component of the translation
  4122. * @param y defines the 2nd component of the translation
  4123. * @param z defines the 3rd component of the translation
  4124. * @returns the current updated matrix
  4125. */
  4126. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4127. /**
  4128. * Inserts the translation vector in the current matrix
  4129. * @param vector3 defines the translation to insert
  4130. * @returns the current updated matrix
  4131. */
  4132. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4133. /**
  4134. * Gets the translation value of the current matrix
  4135. * @returns a new Vector3 as the extracted translation from the matrix
  4136. */
  4137. getTranslation(): Vector3;
  4138. /**
  4139. * Fill a Vector3 with the extracted translation from the matrix
  4140. * @param result defines the Vector3 where to store the translation
  4141. * @returns the current matrix
  4142. */
  4143. getTranslationToRef(result: Vector3): Matrix;
  4144. /**
  4145. * Remove rotation and scaling part from the matrix
  4146. * @returns the updated matrix
  4147. */
  4148. removeRotationAndScaling(): Matrix;
  4149. /**
  4150. * Multiply two matrices
  4151. * @param other defines the second operand
  4152. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4153. */
  4154. multiply(other: DeepImmutable<Matrix>): Matrix;
  4155. /**
  4156. * Copy the current matrix from the given one
  4157. * @param other defines the source matrix
  4158. * @returns the current updated matrix
  4159. */
  4160. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4161. /**
  4162. * Populates the given array from the starting index with the current matrix values
  4163. * @param array defines the target array
  4164. * @param offset defines the offset in the target array where to start storing values
  4165. * @returns the current matrix
  4166. */
  4167. copyToArray(array: Float32Array, offset?: number): Matrix;
  4168. /**
  4169. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4170. * @param other defines the second operand
  4171. * @param result defines the matrix where to store the multiplication
  4172. * @returns the current matrix
  4173. */
  4174. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4175. /**
  4176. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4177. * @param other defines the second operand
  4178. * @param result defines the array where to store the multiplication
  4179. * @param offset defines the offset in the target array where to start storing values
  4180. * @returns the current matrix
  4181. */
  4182. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4183. /**
  4184. * Check equality between this matrix and a second one
  4185. * @param value defines the second matrix to compare
  4186. * @returns true is the current matrix and the given one values are strictly equal
  4187. */
  4188. equals(value: DeepImmutable<Matrix>): boolean;
  4189. /**
  4190. * Clone the current matrix
  4191. * @returns a new matrix from the current matrix
  4192. */
  4193. clone(): Matrix;
  4194. /**
  4195. * Returns the name of the current matrix class
  4196. * @returns the string "Matrix"
  4197. */
  4198. getClassName(): string;
  4199. /**
  4200. * Gets the hash code of the current matrix
  4201. * @returns the hash code
  4202. */
  4203. getHashCode(): number;
  4204. /**
  4205. * Decomposes the current Matrix into a translation, rotation and scaling components
  4206. * @param scale defines the scale vector3 given as a reference to update
  4207. * @param rotation defines the rotation quaternion given as a reference to update
  4208. * @param translation defines the translation vector3 given as a reference to update
  4209. * @returns true if operation was successful
  4210. */
  4211. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4212. /**
  4213. * Gets specific row of the matrix
  4214. * @param index defines the number of the row to get
  4215. * @returns the index-th row of the current matrix as a new Vector4
  4216. */
  4217. getRow(index: number): Nullable<Vector4>;
  4218. /**
  4219. * Sets the index-th row of the current matrix to the vector4 values
  4220. * @param index defines the number of the row to set
  4221. * @param row defines the target vector4
  4222. * @returns the updated current matrix
  4223. */
  4224. setRow(index: number, row: Vector4): Matrix;
  4225. /**
  4226. * Compute the transpose of the matrix
  4227. * @returns the new transposed matrix
  4228. */
  4229. transpose(): Matrix;
  4230. /**
  4231. * Compute the transpose of the matrix and store it in a given matrix
  4232. * @param result defines the target matrix
  4233. * @returns the current matrix
  4234. */
  4235. transposeToRef(result: Matrix): Matrix;
  4236. /**
  4237. * Sets the index-th row of the current matrix with the given 4 x float values
  4238. * @param index defines the row index
  4239. * @param x defines the x component to set
  4240. * @param y defines the y component to set
  4241. * @param z defines the z component to set
  4242. * @param w defines the w component to set
  4243. * @returns the updated current matrix
  4244. */
  4245. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4246. /**
  4247. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4248. * @param scale defines the scale factor
  4249. * @returns a new matrix
  4250. */
  4251. scale(scale: number): Matrix;
  4252. /**
  4253. * Scale the current matrix values by a factor to a given result matrix
  4254. * @param scale defines the scale factor
  4255. * @param result defines the matrix to store the result
  4256. * @returns the current matrix
  4257. */
  4258. scaleToRef(scale: number, result: Matrix): Matrix;
  4259. /**
  4260. * Scale the current matrix values by a factor and add the result to a given matrix
  4261. * @param scale defines the scale factor
  4262. * @param result defines the Matrix to store the result
  4263. * @returns the current matrix
  4264. */
  4265. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4266. /**
  4267. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4268. * @param ref matrix to store the result
  4269. */
  4270. toNormalMatrix(ref: Matrix): void;
  4271. /**
  4272. * Gets only rotation part of the current matrix
  4273. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4274. */
  4275. getRotationMatrix(): Matrix;
  4276. /**
  4277. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4278. * @param result defines the target matrix to store data to
  4279. * @returns the current matrix
  4280. */
  4281. getRotationMatrixToRef(result: Matrix): Matrix;
  4282. /**
  4283. * Toggles model matrix from being right handed to left handed in place and vice versa
  4284. */
  4285. toggleModelMatrixHandInPlace(): void;
  4286. /**
  4287. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4288. */
  4289. toggleProjectionMatrixHandInPlace(): void;
  4290. /**
  4291. * Creates a matrix from an array
  4292. * @param array defines the source array
  4293. * @param offset defines an offset in the source array
  4294. * @returns a new Matrix set from the starting index of the given array
  4295. */
  4296. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4297. /**
  4298. * Copy the content of an array into a given matrix
  4299. * @param array defines the source array
  4300. * @param offset defines an offset in the source array
  4301. * @param result defines the target matrix
  4302. */
  4303. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4304. /**
  4305. * Stores an array into a matrix after having multiplied each component by a given factor
  4306. * @param array defines the source array
  4307. * @param offset defines the offset in the source array
  4308. * @param scale defines the scaling factor
  4309. * @param result defines the target matrix
  4310. */
  4311. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4312. /**
  4313. * Gets an identity matrix that must not be updated
  4314. */
  4315. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4316. /**
  4317. * Stores a list of values (16) inside a given matrix
  4318. * @param initialM11 defines 1st value of 1st row
  4319. * @param initialM12 defines 2nd value of 1st row
  4320. * @param initialM13 defines 3rd value of 1st row
  4321. * @param initialM14 defines 4th value of 1st row
  4322. * @param initialM21 defines 1st value of 2nd row
  4323. * @param initialM22 defines 2nd value of 2nd row
  4324. * @param initialM23 defines 3rd value of 2nd row
  4325. * @param initialM24 defines 4th value of 2nd row
  4326. * @param initialM31 defines 1st value of 3rd row
  4327. * @param initialM32 defines 2nd value of 3rd row
  4328. * @param initialM33 defines 3rd value of 3rd row
  4329. * @param initialM34 defines 4th value of 3rd row
  4330. * @param initialM41 defines 1st value of 4th row
  4331. * @param initialM42 defines 2nd value of 4th row
  4332. * @param initialM43 defines 3rd value of 4th row
  4333. * @param initialM44 defines 4th value of 4th row
  4334. * @param result defines the target matrix
  4335. */
  4336. 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;
  4337. /**
  4338. * Creates new matrix from a list of values (16)
  4339. * @param initialM11 defines 1st value of 1st row
  4340. * @param initialM12 defines 2nd value of 1st row
  4341. * @param initialM13 defines 3rd value of 1st row
  4342. * @param initialM14 defines 4th value of 1st row
  4343. * @param initialM21 defines 1st value of 2nd row
  4344. * @param initialM22 defines 2nd value of 2nd row
  4345. * @param initialM23 defines 3rd value of 2nd row
  4346. * @param initialM24 defines 4th value of 2nd row
  4347. * @param initialM31 defines 1st value of 3rd row
  4348. * @param initialM32 defines 2nd value of 3rd row
  4349. * @param initialM33 defines 3rd value of 3rd row
  4350. * @param initialM34 defines 4th value of 3rd row
  4351. * @param initialM41 defines 1st value of 4th row
  4352. * @param initialM42 defines 2nd value of 4th row
  4353. * @param initialM43 defines 3rd value of 4th row
  4354. * @param initialM44 defines 4th value of 4th row
  4355. * @returns the new matrix
  4356. */
  4357. 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;
  4358. /**
  4359. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4360. * @param scale defines the scale vector3
  4361. * @param rotation defines the rotation quaternion
  4362. * @param translation defines the translation vector3
  4363. * @returns a new matrix
  4364. */
  4365. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4366. /**
  4367. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4368. * @param scale defines the scale vector3
  4369. * @param rotation defines the rotation quaternion
  4370. * @param translation defines the translation vector3
  4371. * @param result defines the target matrix
  4372. */
  4373. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4374. /**
  4375. * Creates a new identity matrix
  4376. * @returns a new identity matrix
  4377. */
  4378. static Identity(): Matrix;
  4379. /**
  4380. * Creates a new identity matrix and stores the result in a given matrix
  4381. * @param result defines the target matrix
  4382. */
  4383. static IdentityToRef(result: Matrix): void;
  4384. /**
  4385. * Creates a new zero matrix
  4386. * @returns a new zero matrix
  4387. */
  4388. static Zero(): Matrix;
  4389. /**
  4390. * Creates a new rotation matrix for "angle" radians around the X axis
  4391. * @param angle defines the angle (in radians) to use
  4392. * @return the new matrix
  4393. */
  4394. static RotationX(angle: number): Matrix;
  4395. /**
  4396. * Creates a new matrix as the invert of a given matrix
  4397. * @param source defines the source matrix
  4398. * @returns the new matrix
  4399. */
  4400. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4403. * @param angle defines the angle (in radians) to use
  4404. * @param result defines the target matrix
  4405. */
  4406. static RotationXToRef(angle: number, result: Matrix): void;
  4407. /**
  4408. * Creates a new rotation matrix for "angle" radians around the Y axis
  4409. * @param angle defines the angle (in radians) to use
  4410. * @return the new matrix
  4411. */
  4412. static RotationY(angle: number): Matrix;
  4413. /**
  4414. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4415. * @param angle defines the angle (in radians) to use
  4416. * @param result defines the target matrix
  4417. */
  4418. static RotationYToRef(angle: number, result: Matrix): void;
  4419. /**
  4420. * Creates a new rotation matrix for "angle" radians around the Z axis
  4421. * @param angle defines the angle (in radians) to use
  4422. * @return the new matrix
  4423. */
  4424. static RotationZ(angle: number): Matrix;
  4425. /**
  4426. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4427. * @param angle defines the angle (in radians) to use
  4428. * @param result defines the target matrix
  4429. */
  4430. static RotationZToRef(angle: number, result: Matrix): void;
  4431. /**
  4432. * Creates a new rotation matrix for "angle" radians around the given axis
  4433. * @param axis defines the axis to use
  4434. * @param angle defines the angle (in radians) to use
  4435. * @return the new matrix
  4436. */
  4437. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4438. /**
  4439. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4440. * @param axis defines the axis to use
  4441. * @param angle defines the angle (in radians) to use
  4442. * @param result defines the target matrix
  4443. */
  4444. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4445. /**
  4446. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4447. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4448. * @param from defines the vector to align
  4449. * @param to defines the vector to align to
  4450. * @param result defines the target matrix
  4451. */
  4452. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4453. /**
  4454. * Creates a rotation matrix
  4455. * @param yaw defines the yaw angle in radians (Y axis)
  4456. * @param pitch defines the pitch angle in radians (X axis)
  4457. * @param roll defines the roll angle in radians (X axis)
  4458. * @returns the new rotation matrix
  4459. */
  4460. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4461. /**
  4462. * Creates a rotation matrix and stores it in a given matrix
  4463. * @param yaw defines the yaw angle in radians (Y axis)
  4464. * @param pitch defines the pitch angle in radians (X axis)
  4465. * @param roll defines the roll angle in radians (X axis)
  4466. * @param result defines the target matrix
  4467. */
  4468. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4469. /**
  4470. * Creates a scaling matrix
  4471. * @param x defines the scale factor on X axis
  4472. * @param y defines the scale factor on Y axis
  4473. * @param z defines the scale factor on Z axis
  4474. * @returns the new matrix
  4475. */
  4476. static Scaling(x: number, y: number, z: number): Matrix;
  4477. /**
  4478. * Creates a scaling matrix and stores it in a given matrix
  4479. * @param x defines the scale factor on X axis
  4480. * @param y defines the scale factor on Y axis
  4481. * @param z defines the scale factor on Z axis
  4482. * @param result defines the target matrix
  4483. */
  4484. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4485. /**
  4486. * Creates a translation matrix
  4487. * @param x defines the translation on X axis
  4488. * @param y defines the translation on Y axis
  4489. * @param z defines the translationon Z axis
  4490. * @returns the new matrix
  4491. */
  4492. static Translation(x: number, y: number, z: number): Matrix;
  4493. /**
  4494. * Creates a translation matrix and stores it in a given matrix
  4495. * @param x defines the translation on X axis
  4496. * @param y defines the translation on Y axis
  4497. * @param z defines the translationon Z axis
  4498. * @param result defines the target matrix
  4499. */
  4500. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4501. /**
  4502. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4503. * @param startValue defines the start value
  4504. * @param endValue defines the end value
  4505. * @param gradient defines the gradient factor
  4506. * @returns the new matrix
  4507. */
  4508. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4509. /**
  4510. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4511. * @param startValue defines the start value
  4512. * @param endValue defines the end value
  4513. * @param gradient defines the gradient factor
  4514. * @param result defines the Matrix object where to store data
  4515. */
  4516. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4517. /**
  4518. * Builds a new matrix whose values are computed by:
  4519. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4520. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4521. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4522. * @param startValue defines the first matrix
  4523. * @param endValue defines the second matrix
  4524. * @param gradient defines the gradient between the two matrices
  4525. * @returns the new matrix
  4526. */
  4527. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4528. /**
  4529. * Update a matrix to values which are computed by:
  4530. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4531. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4532. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4533. * @param startValue defines the first matrix
  4534. * @param endValue defines the second matrix
  4535. * @param gradient defines the gradient between the two matrices
  4536. * @param result defines the target matrix
  4537. */
  4538. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4539. /**
  4540. * 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"
  4541. * This function works in left handed mode
  4542. * @param eye defines the final position of the entity
  4543. * @param target defines where the entity should look at
  4544. * @param up defines the up vector for the entity
  4545. * @returns the new matrix
  4546. */
  4547. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4548. /**
  4549. * 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".
  4550. * This function works in left handed mode
  4551. * @param eye defines the final position of the entity
  4552. * @param target defines where the entity should look at
  4553. * @param up defines the up vector for the entity
  4554. * @param result defines the target matrix
  4555. */
  4556. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4557. /**
  4558. * 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"
  4559. * This function works in right handed mode
  4560. * @param eye defines the final position of the entity
  4561. * @param target defines where the entity should look at
  4562. * @param up defines the up vector for the entity
  4563. * @returns the new matrix
  4564. */
  4565. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4566. /**
  4567. * 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".
  4568. * This function works in right handed mode
  4569. * @param eye defines the final position of the entity
  4570. * @param target defines where the entity should look at
  4571. * @param up defines the up vector for the entity
  4572. * @param result defines the target matrix
  4573. */
  4574. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4575. /**
  4576. * Create a left-handed orthographic projection matrix
  4577. * @param width defines the viewport width
  4578. * @param height defines the viewport height
  4579. * @param znear defines the near clip plane
  4580. * @param zfar defines the far clip plane
  4581. * @returns a new matrix as a left-handed orthographic projection matrix
  4582. */
  4583. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4584. /**
  4585. * Store a left-handed orthographic projection to a given matrix
  4586. * @param width defines the viewport width
  4587. * @param height defines the viewport height
  4588. * @param znear defines the near clip plane
  4589. * @param zfar defines the far clip plane
  4590. * @param result defines the target matrix
  4591. */
  4592. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4593. /**
  4594. * Create a left-handed orthographic projection matrix
  4595. * @param left defines the viewport left coordinate
  4596. * @param right defines the viewport right coordinate
  4597. * @param bottom defines the viewport bottom coordinate
  4598. * @param top defines the viewport top coordinate
  4599. * @param znear defines the near clip plane
  4600. * @param zfar defines the far clip plane
  4601. * @returns a new matrix as a left-handed orthographic projection matrix
  4602. */
  4603. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4604. /**
  4605. * Stores a left-handed orthographic projection into a given matrix
  4606. * @param left defines the viewport left coordinate
  4607. * @param right defines the viewport right coordinate
  4608. * @param bottom defines the viewport bottom coordinate
  4609. * @param top defines the viewport top coordinate
  4610. * @param znear defines the near clip plane
  4611. * @param zfar defines the far clip plane
  4612. * @param result defines the target matrix
  4613. */
  4614. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4615. /**
  4616. * Creates a right-handed orthographic projection matrix
  4617. * @param left defines the viewport left coordinate
  4618. * @param right defines the viewport right coordinate
  4619. * @param bottom defines the viewport bottom coordinate
  4620. * @param top defines the viewport top coordinate
  4621. * @param znear defines the near clip plane
  4622. * @param zfar defines the far clip plane
  4623. * @returns a new matrix as a right-handed orthographic projection matrix
  4624. */
  4625. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4626. /**
  4627. * Stores a right-handed orthographic projection into a given matrix
  4628. * @param left defines the viewport left coordinate
  4629. * @param right defines the viewport right coordinate
  4630. * @param bottom defines the viewport bottom coordinate
  4631. * @param top defines the viewport top coordinate
  4632. * @param znear defines the near clip plane
  4633. * @param zfar defines the far clip plane
  4634. * @param result defines the target matrix
  4635. */
  4636. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4637. /**
  4638. * Creates a left-handed perspective projection matrix
  4639. * @param width defines the viewport width
  4640. * @param height defines the viewport height
  4641. * @param znear defines the near clip plane
  4642. * @param zfar defines the far clip plane
  4643. * @returns a new matrix as a left-handed perspective projection matrix
  4644. */
  4645. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Creates a left-handed perspective projection matrix
  4648. * @param fov defines the horizontal field of view
  4649. * @param aspect defines the aspect ratio
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @returns a new matrix as a left-handed perspective projection matrix
  4653. */
  4654. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4655. /**
  4656. * Stores a left-handed perspective projection into a given matrix
  4657. * @param fov defines the horizontal field of view
  4658. * @param aspect defines the aspect ratio
  4659. * @param znear defines the near clip plane
  4660. * @param zfar defines the far clip plane
  4661. * @param result defines the target matrix
  4662. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4663. */
  4664. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4665. /**
  4666. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4667. * @param fov defines the horizontal field of view
  4668. * @param aspect defines the aspect ratio
  4669. * @param znear defines the near clip plane
  4670. * @param zfar not used as infinity is used as far clip
  4671. * @param result defines the target matrix
  4672. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4673. */
  4674. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4675. /**
  4676. * Creates a right-handed perspective projection matrix
  4677. * @param fov defines the horizontal field of view
  4678. * @param aspect defines the aspect ratio
  4679. * @param znear defines the near clip plane
  4680. * @param zfar defines the far clip plane
  4681. * @returns a new matrix as a right-handed perspective projection matrix
  4682. */
  4683. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4684. /**
  4685. * Stores a right-handed perspective projection into a given matrix
  4686. * @param fov defines the horizontal field of view
  4687. * @param aspect defines the aspect ratio
  4688. * @param znear defines the near clip plane
  4689. * @param zfar defines the far clip plane
  4690. * @param result defines the target matrix
  4691. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4692. */
  4693. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4694. /**
  4695. * Stores a right-handed perspective projection into a given matrix
  4696. * @param fov defines the horizontal field of view
  4697. * @param aspect defines the aspect ratio
  4698. * @param znear defines the near clip plane
  4699. * @param zfar not used as infinity is used as far clip
  4700. * @param result defines the target matrix
  4701. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4702. */
  4703. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4704. /**
  4705. * Stores a perspective projection for WebVR info a given matrix
  4706. * @param fov defines the field of view
  4707. * @param znear defines the near clip plane
  4708. * @param zfar defines the far clip plane
  4709. * @param result defines the target matrix
  4710. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4711. */
  4712. static PerspectiveFovWebVRToRef(fov: {
  4713. upDegrees: number;
  4714. downDegrees: number;
  4715. leftDegrees: number;
  4716. rightDegrees: number;
  4717. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4718. /**
  4719. * Computes a complete transformation matrix
  4720. * @param viewport defines the viewport to use
  4721. * @param world defines the world matrix
  4722. * @param view defines the view matrix
  4723. * @param projection defines the projection matrix
  4724. * @param zmin defines the near clip plane
  4725. * @param zmax defines the far clip plane
  4726. * @returns the transformation matrix
  4727. */
  4728. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4729. /**
  4730. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4731. * @param matrix defines the matrix to use
  4732. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4733. */
  4734. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4735. /**
  4736. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4737. * @param matrix defines the matrix to use
  4738. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4739. */
  4740. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4741. /**
  4742. * Compute the transpose of a given matrix
  4743. * @param matrix defines the matrix to transpose
  4744. * @returns the new matrix
  4745. */
  4746. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4747. /**
  4748. * Compute the transpose of a matrix and store it in a target matrix
  4749. * @param matrix defines the matrix to transpose
  4750. * @param result defines the target matrix
  4751. */
  4752. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4753. /**
  4754. * Computes a reflection matrix from a plane
  4755. * @param plane defines the reflection plane
  4756. * @returns a new matrix
  4757. */
  4758. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4759. /**
  4760. * Computes a reflection matrix from a plane
  4761. * @param plane defines the reflection plane
  4762. * @param result defines the target matrix
  4763. */
  4764. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4765. /**
  4766. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4767. * @param xaxis defines the value of the 1st axis
  4768. * @param yaxis defines the value of the 2nd axis
  4769. * @param zaxis defines the value of the 3rd axis
  4770. * @param result defines the target matrix
  4771. */
  4772. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4773. /**
  4774. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4775. * @param quat defines the quaternion to use
  4776. * @param result defines the target matrix
  4777. */
  4778. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4779. }
  4780. /**
  4781. * @hidden
  4782. */
  4783. export class TmpVectors {
  4784. static Vector2: Vector2[];
  4785. static Vector3: Vector3[];
  4786. static Vector4: Vector4[];
  4787. static Quaternion: Quaternion[];
  4788. static Matrix: Matrix[];
  4789. }
  4790. }
  4791. declare module BABYLON {
  4792. /**
  4793. * Defines potential orientation for back face culling
  4794. */
  4795. export enum Orientation {
  4796. /**
  4797. * Clockwise
  4798. */
  4799. CW = 0,
  4800. /** Counter clockwise */
  4801. CCW = 1
  4802. }
  4803. /** Class used to represent a Bezier curve */
  4804. export class BezierCurve {
  4805. /**
  4806. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4807. * @param t defines the time
  4808. * @param x1 defines the left coordinate on X axis
  4809. * @param y1 defines the left coordinate on Y axis
  4810. * @param x2 defines the right coordinate on X axis
  4811. * @param y2 defines the right coordinate on Y axis
  4812. * @returns the interpolated value
  4813. */
  4814. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4815. }
  4816. /**
  4817. * Defines angle representation
  4818. */
  4819. export class Angle {
  4820. private _radians;
  4821. /**
  4822. * Creates an Angle object of "radians" radians (float).
  4823. * @param radians the angle in radians
  4824. */
  4825. constructor(radians: number);
  4826. /**
  4827. * Get value in degrees
  4828. * @returns the Angle value in degrees (float)
  4829. */
  4830. degrees(): number;
  4831. /**
  4832. * Get value in radians
  4833. * @returns the Angle value in radians (float)
  4834. */
  4835. radians(): number;
  4836. /**
  4837. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4838. * @param a defines first point as the origin
  4839. * @param b defines point
  4840. * @returns a new Angle
  4841. */
  4842. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4843. /**
  4844. * Gets a new Angle object from the given float in radians
  4845. * @param radians defines the angle value in radians
  4846. * @returns a new Angle
  4847. */
  4848. static FromRadians(radians: number): Angle;
  4849. /**
  4850. * Gets a new Angle object from the given float in degrees
  4851. * @param degrees defines the angle value in degrees
  4852. * @returns a new Angle
  4853. */
  4854. static FromDegrees(degrees: number): Angle;
  4855. }
  4856. /**
  4857. * This represents an arc in a 2d space.
  4858. */
  4859. export class Arc2 {
  4860. /** Defines the start point of the arc */
  4861. startPoint: Vector2;
  4862. /** Defines the mid point of the arc */
  4863. midPoint: Vector2;
  4864. /** Defines the end point of the arc */
  4865. endPoint: Vector2;
  4866. /**
  4867. * Defines the center point of the arc.
  4868. */
  4869. centerPoint: Vector2;
  4870. /**
  4871. * Defines the radius of the arc.
  4872. */
  4873. radius: number;
  4874. /**
  4875. * Defines the angle of the arc (from mid point to end point).
  4876. */
  4877. angle: Angle;
  4878. /**
  4879. * Defines the start angle of the arc (from start point to middle point).
  4880. */
  4881. startAngle: Angle;
  4882. /**
  4883. * Defines the orientation of the arc (clock wise/counter clock wise).
  4884. */
  4885. orientation: Orientation;
  4886. /**
  4887. * Creates an Arc object from the three given points : start, middle and end.
  4888. * @param startPoint Defines the start point of the arc
  4889. * @param midPoint Defines the midlle point of the arc
  4890. * @param endPoint Defines the end point of the arc
  4891. */
  4892. constructor(
  4893. /** Defines the start point of the arc */
  4894. startPoint: Vector2,
  4895. /** Defines the mid point of the arc */
  4896. midPoint: Vector2,
  4897. /** Defines the end point of the arc */
  4898. endPoint: Vector2);
  4899. }
  4900. /**
  4901. * Represents a 2D path made up of multiple 2D points
  4902. */
  4903. export class Path2 {
  4904. private _points;
  4905. private _length;
  4906. /**
  4907. * If the path start and end point are the same
  4908. */
  4909. closed: boolean;
  4910. /**
  4911. * Creates a Path2 object from the starting 2D coordinates x and y.
  4912. * @param x the starting points x value
  4913. * @param y the starting points y value
  4914. */
  4915. constructor(x: number, y: number);
  4916. /**
  4917. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4918. * @param x the added points x value
  4919. * @param y the added points y value
  4920. * @returns the updated Path2.
  4921. */
  4922. addLineTo(x: number, y: number): Path2;
  4923. /**
  4924. * 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.
  4925. * @param midX middle point x value
  4926. * @param midY middle point y value
  4927. * @param endX end point x value
  4928. * @param endY end point y value
  4929. * @param numberOfSegments (default: 36)
  4930. * @returns the updated Path2.
  4931. */
  4932. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4933. /**
  4934. * Closes the Path2.
  4935. * @returns the Path2.
  4936. */
  4937. close(): Path2;
  4938. /**
  4939. * Gets the sum of the distance between each sequential point in the path
  4940. * @returns the Path2 total length (float).
  4941. */
  4942. length(): number;
  4943. /**
  4944. * Gets the points which construct the path
  4945. * @returns the Path2 internal array of points.
  4946. */
  4947. getPoints(): Vector2[];
  4948. /**
  4949. * Retreives the point at the distance aways from the starting point
  4950. * @param normalizedLengthPosition the length along the path to retreive the point from
  4951. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4952. */
  4953. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4954. /**
  4955. * Creates a new path starting from an x and y position
  4956. * @param x starting x value
  4957. * @param y starting y value
  4958. * @returns a new Path2 starting at the coordinates (x, y).
  4959. */
  4960. static StartingAt(x: number, y: number): Path2;
  4961. }
  4962. /**
  4963. * Represents a 3D path made up of multiple 3D points
  4964. */
  4965. export class Path3D {
  4966. /**
  4967. * an array of Vector3, the curve axis of the Path3D
  4968. */
  4969. path: Vector3[];
  4970. private _curve;
  4971. private _distances;
  4972. private _tangents;
  4973. private _normals;
  4974. private _binormals;
  4975. private _raw;
  4976. private _alignTangentsWithPath;
  4977. private readonly _pointAtData;
  4978. /**
  4979. * new Path3D(path, normal, raw)
  4980. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4981. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4982. * @param path an array of Vector3, the curve axis of the Path3D
  4983. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4984. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4985. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4986. */
  4987. constructor(
  4988. /**
  4989. * an array of Vector3, the curve axis of the Path3D
  4990. */
  4991. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4992. /**
  4993. * Returns the Path3D array of successive Vector3 designing its curve.
  4994. * @returns the Path3D array of successive Vector3 designing its curve.
  4995. */
  4996. getCurve(): Vector3[];
  4997. /**
  4998. * Returns the Path3D array of successive Vector3 designing its curve.
  4999. * @returns the Path3D array of successive Vector3 designing its curve.
  5000. */
  5001. getPoints(): Vector3[];
  5002. /**
  5003. * @returns the computed length (float) of the path.
  5004. */
  5005. length(): number;
  5006. /**
  5007. * Returns an array populated with tangent vectors on each Path3D curve point.
  5008. * @returns an array populated with tangent vectors on each Path3D curve point.
  5009. */
  5010. getTangents(): Vector3[];
  5011. /**
  5012. * Returns an array populated with normal vectors on each Path3D curve point.
  5013. * @returns an array populated with normal vectors on each Path3D curve point.
  5014. */
  5015. getNormals(): Vector3[];
  5016. /**
  5017. * Returns an array populated with binormal vectors on each Path3D curve point.
  5018. * @returns an array populated with binormal vectors on each Path3D curve point.
  5019. */
  5020. getBinormals(): Vector3[];
  5021. /**
  5022. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5023. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5024. */
  5025. getDistances(): number[];
  5026. /**
  5027. * Returns an interpolated point along this path
  5028. * @param position the position of the point along this path, from 0.0 to 1.0
  5029. * @returns a new Vector3 as the point
  5030. */
  5031. getPointAt(position: number): Vector3;
  5032. /**
  5033. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5034. * @param position the position of the point along this path, from 0.0 to 1.0
  5035. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5036. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5037. */
  5038. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5039. /**
  5040. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5041. * @param position the position of the point along this path, from 0.0 to 1.0
  5042. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5043. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5044. */
  5045. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5046. /**
  5047. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5048. * @param position the position of the point along this path, from 0.0 to 1.0
  5049. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5050. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5051. */
  5052. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5053. /**
  5054. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5055. * @param position the position of the point along this path, from 0.0 to 1.0
  5056. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5057. */
  5058. getDistanceAt(position: number): number;
  5059. /**
  5060. * Returns the array index of the previous point of an interpolated point along this path
  5061. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5062. * @returns the array index
  5063. */
  5064. getPreviousPointIndexAt(position: number): number;
  5065. /**
  5066. * 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)
  5067. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5068. * @returns the sub position
  5069. */
  5070. getSubPositionAt(position: number): number;
  5071. /**
  5072. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5073. * @param target the vector of which to get the closest position to
  5074. * @returns the position of the closest virtual point on this path to the target vector
  5075. */
  5076. getClosestPositionTo(target: Vector3): number;
  5077. /**
  5078. * Returns a sub path (slice) of this path
  5079. * @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
  5080. * @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
  5081. * @returns a sub path (slice) of this path
  5082. */
  5083. slice(start?: number, end?: number): Path3D;
  5084. /**
  5085. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5086. * @param path path which all values are copied into the curves points
  5087. * @param firstNormal which should be projected onto the curve
  5088. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5089. * @returns the same object updated.
  5090. */
  5091. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5092. private _compute;
  5093. private _getFirstNonNullVector;
  5094. private _getLastNonNullVector;
  5095. private _normalVector;
  5096. /**
  5097. * Updates the point at data for an interpolated point along this curve
  5098. * @param position the position of the point along this curve, from 0.0 to 1.0
  5099. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5100. * @returns the (updated) point at data
  5101. */
  5102. private _updatePointAtData;
  5103. /**
  5104. * Updates the point at data from the specified parameters
  5105. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5106. * @param point the interpolated point
  5107. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5108. */
  5109. private _setPointAtData;
  5110. /**
  5111. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5112. */
  5113. private _updateInterpolationMatrix;
  5114. }
  5115. /**
  5116. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5117. * A Curve3 is designed from a series of successive Vector3.
  5118. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5119. */
  5120. export class Curve3 {
  5121. private _points;
  5122. private _length;
  5123. /**
  5124. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5125. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5126. * @param v1 (Vector3) the control point
  5127. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5128. * @param nbPoints (integer) the wanted number of points in the curve
  5129. * @returns the created Curve3
  5130. */
  5131. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5132. /**
  5133. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5134. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5135. * @param v1 (Vector3) the first control point
  5136. * @param v2 (Vector3) the second control point
  5137. * @param v3 (Vector3) the end point of the Cubic Bezier
  5138. * @param nbPoints (integer) the wanted number of points in the curve
  5139. * @returns the created Curve3
  5140. */
  5141. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5142. /**
  5143. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5144. * @param p1 (Vector3) the origin point of the Hermite Spline
  5145. * @param t1 (Vector3) the tangent vector at the origin point
  5146. * @param p2 (Vector3) the end point of the Hermite Spline
  5147. * @param t2 (Vector3) the tangent vector at the end point
  5148. * @param nbPoints (integer) the wanted number of points in the curve
  5149. * @returns the created Curve3
  5150. */
  5151. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5152. /**
  5153. * Returns a Curve3 object along a CatmullRom Spline curve :
  5154. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5155. * @param nbPoints (integer) the wanted number of points between each curve control points
  5156. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5157. * @returns the created Curve3
  5158. */
  5159. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5160. /**
  5161. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5162. * A Curve3 is designed from a series of successive Vector3.
  5163. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5164. * @param points points which make up the curve
  5165. */
  5166. constructor(points: Vector3[]);
  5167. /**
  5168. * @returns the Curve3 stored array of successive Vector3
  5169. */
  5170. getPoints(): Vector3[];
  5171. /**
  5172. * @returns the computed length (float) of the curve.
  5173. */
  5174. length(): number;
  5175. /**
  5176. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5177. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5178. * curveA and curveB keep unchanged.
  5179. * @param curve the curve to continue from this curve
  5180. * @returns the newly constructed curve
  5181. */
  5182. continue(curve: DeepImmutable<Curve3>): Curve3;
  5183. private _computeLength;
  5184. }
  5185. }
  5186. declare module BABYLON {
  5187. /**
  5188. * This represents the main contract an easing function should follow.
  5189. * Easing functions are used throughout the animation system.
  5190. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5191. */
  5192. export interface IEasingFunction {
  5193. /**
  5194. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5195. * of the easing function.
  5196. * The link below provides some of the most common examples of easing functions.
  5197. * @see https://easings.net/
  5198. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5199. * @returns the corresponding value on the curve defined by the easing function
  5200. */
  5201. ease(gradient: number): number;
  5202. }
  5203. /**
  5204. * Base class used for every default easing function.
  5205. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5206. */
  5207. export class EasingFunction implements IEasingFunction {
  5208. /**
  5209. * Interpolation follows the mathematical formula associated with the easing function.
  5210. */
  5211. static readonly EASINGMODE_EASEIN: number;
  5212. /**
  5213. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5214. */
  5215. static readonly EASINGMODE_EASEOUT: number;
  5216. /**
  5217. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5218. */
  5219. static readonly EASINGMODE_EASEINOUT: number;
  5220. private _easingMode;
  5221. /**
  5222. * Sets the easing mode of the current function.
  5223. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5224. */
  5225. setEasingMode(easingMode: number): void;
  5226. /**
  5227. * Gets the current easing mode.
  5228. * @returns the easing mode
  5229. */
  5230. getEasingMode(): number;
  5231. /**
  5232. * @hidden
  5233. */
  5234. easeInCore(gradient: number): number;
  5235. /**
  5236. * Given an input gradient between 0 and 1, this returns the corresponding value
  5237. * of the easing function.
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Easing function with a circle shape (see link below).
  5245. * @see https://easings.net/#easeInCirc
  5246. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5247. */
  5248. export class CircleEase extends EasingFunction implements IEasingFunction {
  5249. /** @hidden */
  5250. easeInCore(gradient: number): number;
  5251. }
  5252. /**
  5253. * Easing function with a ease back shape (see link below).
  5254. * @see https://easings.net/#easeInBack
  5255. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5256. */
  5257. export class BackEase extends EasingFunction implements IEasingFunction {
  5258. /** Defines the amplitude of the function */
  5259. amplitude: number;
  5260. /**
  5261. * Instantiates a back ease easing
  5262. * @see https://easings.net/#easeInBack
  5263. * @param amplitude Defines the amplitude of the function
  5264. */
  5265. constructor(
  5266. /** Defines the amplitude of the function */
  5267. amplitude?: number);
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a bouncing shape (see link below).
  5273. * @see https://easings.net/#easeInBounce
  5274. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class BounceEase extends EasingFunction implements IEasingFunction {
  5277. /** Defines the number of bounces */
  5278. bounces: number;
  5279. /** Defines the amplitude of the bounce */
  5280. bounciness: number;
  5281. /**
  5282. * Instantiates a bounce easing
  5283. * @see https://easings.net/#easeInBounce
  5284. * @param bounces Defines the number of bounces
  5285. * @param bounciness Defines the amplitude of the bounce
  5286. */
  5287. constructor(
  5288. /** Defines the number of bounces */
  5289. bounces?: number,
  5290. /** Defines the amplitude of the bounce */
  5291. bounciness?: number);
  5292. /** @hidden */
  5293. easeInCore(gradient: number): number;
  5294. }
  5295. /**
  5296. * Easing function with a power of 3 shape (see link below).
  5297. * @see https://easings.net/#easeInCubic
  5298. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5299. */
  5300. export class CubicEase extends EasingFunction implements IEasingFunction {
  5301. /** @hidden */
  5302. easeInCore(gradient: number): number;
  5303. }
  5304. /**
  5305. * Easing function with an elastic shape (see link below).
  5306. * @see https://easings.net/#easeInElastic
  5307. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5308. */
  5309. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5310. /** Defines the number of oscillations*/
  5311. oscillations: number;
  5312. /** Defines the amplitude of the oscillations*/
  5313. springiness: number;
  5314. /**
  5315. * Instantiates an elastic easing function
  5316. * @see https://easings.net/#easeInElastic
  5317. * @param oscillations Defines the number of oscillations
  5318. * @param springiness Defines the amplitude of the oscillations
  5319. */
  5320. constructor(
  5321. /** Defines the number of oscillations*/
  5322. oscillations?: number,
  5323. /** Defines the amplitude of the oscillations*/
  5324. springiness?: number);
  5325. /** @hidden */
  5326. easeInCore(gradient: number): number;
  5327. }
  5328. /**
  5329. * Easing function with an exponential shape (see link below).
  5330. * @see https://easings.net/#easeInExpo
  5331. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5332. */
  5333. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5334. /** Defines the exponent of the function */
  5335. exponent: number;
  5336. /**
  5337. * Instantiates an exponential easing function
  5338. * @see https://easings.net/#easeInExpo
  5339. * @param exponent Defines the exponent of the function
  5340. */
  5341. constructor(
  5342. /** Defines the exponent of the function */
  5343. exponent?: number);
  5344. /** @hidden */
  5345. easeInCore(gradient: number): number;
  5346. }
  5347. /**
  5348. * Easing function with a power shape (see link below).
  5349. * @see https://easings.net/#easeInQuad
  5350. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5351. */
  5352. export class PowerEase extends EasingFunction implements IEasingFunction {
  5353. /** Defines the power of the function */
  5354. power: number;
  5355. /**
  5356. * Instantiates an power base easing function
  5357. * @see https://easings.net/#easeInQuad
  5358. * @param power Defines the power of the function
  5359. */
  5360. constructor(
  5361. /** Defines the power of the function */
  5362. power?: number);
  5363. /** @hidden */
  5364. easeInCore(gradient: number): number;
  5365. }
  5366. /**
  5367. * Easing function with a power of 2 shape (see link below).
  5368. * @see https://easings.net/#easeInQuad
  5369. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5370. */
  5371. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5372. /** @hidden */
  5373. easeInCore(gradient: number): number;
  5374. }
  5375. /**
  5376. * Easing function with a power of 4 shape (see link below).
  5377. * @see https://easings.net/#easeInQuart
  5378. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5379. */
  5380. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5381. /** @hidden */
  5382. easeInCore(gradient: number): number;
  5383. }
  5384. /**
  5385. * Easing function with a power of 5 shape (see link below).
  5386. * @see https://easings.net/#easeInQuint
  5387. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5388. */
  5389. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5390. /** @hidden */
  5391. easeInCore(gradient: number): number;
  5392. }
  5393. /**
  5394. * Easing function with a sin shape (see link below).
  5395. * @see https://easings.net/#easeInSine
  5396. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5397. */
  5398. export class SineEase extends EasingFunction implements IEasingFunction {
  5399. /** @hidden */
  5400. easeInCore(gradient: number): number;
  5401. }
  5402. /**
  5403. * Easing function with a bezier shape (see link below).
  5404. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5405. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5406. */
  5407. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5408. /** Defines the x component of the start tangent in the bezier curve */
  5409. x1: number;
  5410. /** Defines the y component of the start tangent in the bezier curve */
  5411. y1: number;
  5412. /** Defines the x component of the end tangent in the bezier curve */
  5413. x2: number;
  5414. /** Defines the y component of the end tangent in the bezier curve */
  5415. y2: number;
  5416. /**
  5417. * Instantiates a bezier function
  5418. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5419. * @param x1 Defines the x component of the start tangent in the bezier curve
  5420. * @param y1 Defines the y component of the start tangent in the bezier curve
  5421. * @param x2 Defines the x component of the end tangent in the bezier curve
  5422. * @param y2 Defines the y component of the end tangent in the bezier curve
  5423. */
  5424. constructor(
  5425. /** Defines the x component of the start tangent in the bezier curve */
  5426. x1?: number,
  5427. /** Defines the y component of the start tangent in the bezier curve */
  5428. y1?: number,
  5429. /** Defines the x component of the end tangent in the bezier curve */
  5430. x2?: number,
  5431. /** Defines the y component of the end tangent in the bezier curve */
  5432. y2?: number);
  5433. /** @hidden */
  5434. easeInCore(gradient: number): number;
  5435. }
  5436. }
  5437. declare module BABYLON {
  5438. /**
  5439. * Class used to hold a RBG color
  5440. */
  5441. export class Color3 {
  5442. /**
  5443. * Defines the red component (between 0 and 1, default is 0)
  5444. */
  5445. r: number;
  5446. /**
  5447. * Defines the green component (between 0 and 1, default is 0)
  5448. */
  5449. g: number;
  5450. /**
  5451. * Defines the blue component (between 0 and 1, default is 0)
  5452. */
  5453. b: number;
  5454. /**
  5455. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5456. * @param r defines the red component (between 0 and 1, default is 0)
  5457. * @param g defines the green component (between 0 and 1, default is 0)
  5458. * @param b defines the blue component (between 0 and 1, default is 0)
  5459. */
  5460. constructor(
  5461. /**
  5462. * Defines the red component (between 0 and 1, default is 0)
  5463. */
  5464. r?: number,
  5465. /**
  5466. * Defines the green component (between 0 and 1, default is 0)
  5467. */
  5468. g?: number,
  5469. /**
  5470. * Defines the blue component (between 0 and 1, default is 0)
  5471. */
  5472. b?: number);
  5473. /**
  5474. * Creates a string with the Color3 current values
  5475. * @returns the string representation of the Color3 object
  5476. */
  5477. toString(): string;
  5478. /**
  5479. * Returns the string "Color3"
  5480. * @returns "Color3"
  5481. */
  5482. getClassName(): string;
  5483. /**
  5484. * Compute the Color3 hash code
  5485. * @returns an unique number that can be used to hash Color3 objects
  5486. */
  5487. getHashCode(): number;
  5488. /**
  5489. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5490. * @param array defines the array where to store the r,g,b components
  5491. * @param index defines an optional index in the target array to define where to start storing values
  5492. * @returns the current Color3 object
  5493. */
  5494. toArray(array: FloatArray, index?: number): Color3;
  5495. /**
  5496. * Returns a new Color4 object from the current Color3 and the given alpha
  5497. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5498. * @returns a new Color4 object
  5499. */
  5500. toColor4(alpha?: number): Color4;
  5501. /**
  5502. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5503. * @returns the new array
  5504. */
  5505. asArray(): number[];
  5506. /**
  5507. * Returns the luminance value
  5508. * @returns a float value
  5509. */
  5510. toLuminance(): number;
  5511. /**
  5512. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5513. * @param otherColor defines the second operand
  5514. * @returns the new Color3 object
  5515. */
  5516. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5517. /**
  5518. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5519. * @param otherColor defines the second operand
  5520. * @param result defines the Color3 object where to store the result
  5521. * @returns the current Color3
  5522. */
  5523. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5524. /**
  5525. * Determines equality between Color3 objects
  5526. * @param otherColor defines the second operand
  5527. * @returns true if the rgb values are equal to the given ones
  5528. */
  5529. equals(otherColor: DeepImmutable<Color3>): boolean;
  5530. /**
  5531. * Determines equality between the current Color3 object and a set of r,b,g values
  5532. * @param r defines the red component to check
  5533. * @param g defines the green component to check
  5534. * @param b defines the blue component to check
  5535. * @returns true if the rgb values are equal to the given ones
  5536. */
  5537. equalsFloats(r: number, g: number, b: number): boolean;
  5538. /**
  5539. * Multiplies in place each rgb value by scale
  5540. * @param scale defines the scaling factor
  5541. * @returns the updated Color3
  5542. */
  5543. scale(scale: number): Color3;
  5544. /**
  5545. * Multiplies the rgb values by scale and stores the result into "result"
  5546. * @param scale defines the scaling factor
  5547. * @param result defines the Color3 object where to store the result
  5548. * @returns the unmodified current Color3
  5549. */
  5550. scaleToRef(scale: number, result: Color3): Color3;
  5551. /**
  5552. * Scale the current Color3 values by a factor and add the result to a given Color3
  5553. * @param scale defines the scale factor
  5554. * @param result defines color to store the result into
  5555. * @returns the unmodified current Color3
  5556. */
  5557. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5558. /**
  5559. * Clamps the rgb values by the min and max values and stores the result into "result"
  5560. * @param min defines minimum clamping value (default is 0)
  5561. * @param max defines maximum clamping value (default is 1)
  5562. * @param result defines color to store the result into
  5563. * @returns the original Color3
  5564. */
  5565. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5566. /**
  5567. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5568. * @param otherColor defines the second operand
  5569. * @returns the new Color3
  5570. */
  5571. add(otherColor: DeepImmutable<Color3>): Color3;
  5572. /**
  5573. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5574. * @param otherColor defines the second operand
  5575. * @param result defines Color3 object to store the result into
  5576. * @returns the unmodified current Color3
  5577. */
  5578. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5579. /**
  5580. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5581. * @param otherColor defines the second operand
  5582. * @returns the new Color3
  5583. */
  5584. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5585. /**
  5586. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5587. * @param otherColor defines the second operand
  5588. * @param result defines Color3 object to store the result into
  5589. * @returns the unmodified current Color3
  5590. */
  5591. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5592. /**
  5593. * Copy the current object
  5594. * @returns a new Color3 copied the current one
  5595. */
  5596. clone(): Color3;
  5597. /**
  5598. * Copies the rgb values from the source in the current Color3
  5599. * @param source defines the source Color3 object
  5600. * @returns the updated Color3 object
  5601. */
  5602. copyFrom(source: DeepImmutable<Color3>): Color3;
  5603. /**
  5604. * Updates the Color3 rgb values from the given floats
  5605. * @param r defines the red component to read from
  5606. * @param g defines the green component to read from
  5607. * @param b defines the blue component to read from
  5608. * @returns the current Color3 object
  5609. */
  5610. copyFromFloats(r: number, g: number, b: number): Color3;
  5611. /**
  5612. * Updates the Color3 rgb values from the given floats
  5613. * @param r defines the red component to read from
  5614. * @param g defines the green component to read from
  5615. * @param b defines the blue component to read from
  5616. * @returns the current Color3 object
  5617. */
  5618. set(r: number, g: number, b: number): Color3;
  5619. /**
  5620. * Compute the Color3 hexadecimal code as a string
  5621. * @returns a string containing the hexadecimal representation of the Color3 object
  5622. */
  5623. toHexString(): string;
  5624. /**
  5625. * Computes a new Color3 converted from the current one to linear space
  5626. * @returns a new Color3 object
  5627. */
  5628. toLinearSpace(): Color3;
  5629. /**
  5630. * Converts current color in rgb space to HSV values
  5631. * @returns a new color3 representing the HSV values
  5632. */
  5633. toHSV(): Color3;
  5634. /**
  5635. * Converts current color in rgb space to HSV values
  5636. * @param result defines the Color3 where to store the HSV values
  5637. */
  5638. toHSVToRef(result: Color3): void;
  5639. /**
  5640. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5641. * @param convertedColor defines the Color3 object where to store the linear space version
  5642. * @returns the unmodified Color3
  5643. */
  5644. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5645. /**
  5646. * Computes a new Color3 converted from the current one to gamma space
  5647. * @returns a new Color3 object
  5648. */
  5649. toGammaSpace(): Color3;
  5650. /**
  5651. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5652. * @param convertedColor defines the Color3 object where to store the gamma space version
  5653. * @returns the unmodified Color3
  5654. */
  5655. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5656. private static _BlackReadOnly;
  5657. /**
  5658. * Convert Hue, saturation and value to a Color3 (RGB)
  5659. * @param hue defines the hue
  5660. * @param saturation defines the saturation
  5661. * @param value defines the value
  5662. * @param result defines the Color3 where to store the RGB values
  5663. */
  5664. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5665. /**
  5666. * Creates a new Color3 from the string containing valid hexadecimal values
  5667. * @param hex defines a string containing valid hexadecimal values
  5668. * @returns a new Color3 object
  5669. */
  5670. static FromHexString(hex: string): Color3;
  5671. /**
  5672. * Creates a new Color3 from the starting index of the given array
  5673. * @param array defines the source array
  5674. * @param offset defines an offset in the source array
  5675. * @returns a new Color3 object
  5676. */
  5677. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5678. /**
  5679. * Creates a new Color3 from integer values (< 256)
  5680. * @param r defines the red component to read from (value between 0 and 255)
  5681. * @param g defines the green component to read from (value between 0 and 255)
  5682. * @param b defines the blue component to read from (value between 0 and 255)
  5683. * @returns a new Color3 object
  5684. */
  5685. static FromInts(r: number, g: number, b: number): Color3;
  5686. /**
  5687. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5688. * @param start defines the start Color3 value
  5689. * @param end defines the end Color3 value
  5690. * @param amount defines the gradient value between start and end
  5691. * @returns a new Color3 object
  5692. */
  5693. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5694. /**
  5695. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5696. * @param left defines the start value
  5697. * @param right defines the end value
  5698. * @param amount defines the gradient factor
  5699. * @param result defines the Color3 object where to store the result
  5700. */
  5701. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5702. /**
  5703. * Returns a Color3 value containing a red color
  5704. * @returns a new Color3 object
  5705. */
  5706. static Red(): Color3;
  5707. /**
  5708. * Returns a Color3 value containing a green color
  5709. * @returns a new Color3 object
  5710. */
  5711. static Green(): Color3;
  5712. /**
  5713. * Returns a Color3 value containing a blue color
  5714. * @returns a new Color3 object
  5715. */
  5716. static Blue(): Color3;
  5717. /**
  5718. * Returns a Color3 value containing a black color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Black(): Color3;
  5722. /**
  5723. * Gets a Color3 value containing a black color that must not be updated
  5724. */
  5725. static get BlackReadOnly(): DeepImmutable<Color3>;
  5726. /**
  5727. * Returns a Color3 value containing a white color
  5728. * @returns a new Color3 object
  5729. */
  5730. static White(): Color3;
  5731. /**
  5732. * Returns a Color3 value containing a purple color
  5733. * @returns a new Color3 object
  5734. */
  5735. static Purple(): Color3;
  5736. /**
  5737. * Returns a Color3 value containing a magenta color
  5738. * @returns a new Color3 object
  5739. */
  5740. static Magenta(): Color3;
  5741. /**
  5742. * Returns a Color3 value containing a yellow color
  5743. * @returns a new Color3 object
  5744. */
  5745. static Yellow(): Color3;
  5746. /**
  5747. * Returns a Color3 value containing a gray color
  5748. * @returns a new Color3 object
  5749. */
  5750. static Gray(): Color3;
  5751. /**
  5752. * Returns a Color3 value containing a teal color
  5753. * @returns a new Color3 object
  5754. */
  5755. static Teal(): Color3;
  5756. /**
  5757. * Returns a Color3 value containing a random color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Random(): Color3;
  5761. }
  5762. /**
  5763. * Class used to hold a RBGA color
  5764. */
  5765. export class Color4 {
  5766. /**
  5767. * Defines the red component (between 0 and 1, default is 0)
  5768. */
  5769. r: number;
  5770. /**
  5771. * Defines the green component (between 0 and 1, default is 0)
  5772. */
  5773. g: number;
  5774. /**
  5775. * Defines the blue component (between 0 and 1, default is 0)
  5776. */
  5777. b: number;
  5778. /**
  5779. * Defines the alpha component (between 0 and 1, default is 1)
  5780. */
  5781. a: number;
  5782. /**
  5783. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5784. * @param r defines the red component (between 0 and 1, default is 0)
  5785. * @param g defines the green component (between 0 and 1, default is 0)
  5786. * @param b defines the blue component (between 0 and 1, default is 0)
  5787. * @param a defines the alpha component (between 0 and 1, default is 1)
  5788. */
  5789. constructor(
  5790. /**
  5791. * Defines the red component (between 0 and 1, default is 0)
  5792. */
  5793. r?: number,
  5794. /**
  5795. * Defines the green component (between 0 and 1, default is 0)
  5796. */
  5797. g?: number,
  5798. /**
  5799. * Defines the blue component (between 0 and 1, default is 0)
  5800. */
  5801. b?: number,
  5802. /**
  5803. * Defines the alpha component (between 0 and 1, default is 1)
  5804. */
  5805. a?: number);
  5806. /**
  5807. * Adds in place the given Color4 values to the current Color4 object
  5808. * @param right defines the second operand
  5809. * @returns the current updated Color4 object
  5810. */
  5811. addInPlace(right: DeepImmutable<Color4>): Color4;
  5812. /**
  5813. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5814. * @returns the new array
  5815. */
  5816. asArray(): number[];
  5817. /**
  5818. * Stores from the starting index in the given array the Color4 successive values
  5819. * @param array defines the array where to store the r,g,b components
  5820. * @param index defines an optional index in the target array to define where to start storing values
  5821. * @returns the current Color4 object
  5822. */
  5823. toArray(array: number[], index?: number): Color4;
  5824. /**
  5825. * Determines equality between Color4 objects
  5826. * @param otherColor defines the second operand
  5827. * @returns true if the rgba values are equal to the given ones
  5828. */
  5829. equals(otherColor: DeepImmutable<Color4>): boolean;
  5830. /**
  5831. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5832. * @param right defines the second operand
  5833. * @returns a new Color4 object
  5834. */
  5835. add(right: DeepImmutable<Color4>): Color4;
  5836. /**
  5837. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5838. * @param right defines the second operand
  5839. * @returns a new Color4 object
  5840. */
  5841. subtract(right: DeepImmutable<Color4>): Color4;
  5842. /**
  5843. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5844. * @param right defines the second operand
  5845. * @param result defines the Color4 object where to store the result
  5846. * @returns the current Color4 object
  5847. */
  5848. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5849. /**
  5850. * Creates a new Color4 with the current Color4 values multiplied by scale
  5851. * @param scale defines the scaling factor to apply
  5852. * @returns a new Color4 object
  5853. */
  5854. scale(scale: number): Color4;
  5855. /**
  5856. * Multiplies the current Color4 values by scale and stores the result in "result"
  5857. * @param scale defines the scaling factor to apply
  5858. * @param result defines the Color4 object where to store the result
  5859. * @returns the current unmodified Color4
  5860. */
  5861. scaleToRef(scale: number, result: Color4): Color4;
  5862. /**
  5863. * Scale the current Color4 values by a factor and add the result to a given Color4
  5864. * @param scale defines the scale factor
  5865. * @param result defines the Color4 object where to store the result
  5866. * @returns the unmodified current Color4
  5867. */
  5868. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5869. /**
  5870. * Clamps the rgb values by the min and max values and stores the result into "result"
  5871. * @param min defines minimum clamping value (default is 0)
  5872. * @param max defines maximum clamping value (default is 1)
  5873. * @param result defines color to store the result into.
  5874. * @returns the cuurent Color4
  5875. */
  5876. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5877. /**
  5878. * Multipy an Color4 value by another and return a new Color4 object
  5879. * @param color defines the Color4 value to multiply by
  5880. * @returns a new Color4 object
  5881. */
  5882. multiply(color: Color4): Color4;
  5883. /**
  5884. * Multipy a Color4 value by another and push the result in a reference value
  5885. * @param color defines the Color4 value to multiply by
  5886. * @param result defines the Color4 to fill the result in
  5887. * @returns the result Color4
  5888. */
  5889. multiplyToRef(color: Color4, result: Color4): Color4;
  5890. /**
  5891. * Creates a string with the Color4 current values
  5892. * @returns the string representation of the Color4 object
  5893. */
  5894. toString(): string;
  5895. /**
  5896. * Returns the string "Color4"
  5897. * @returns "Color4"
  5898. */
  5899. getClassName(): string;
  5900. /**
  5901. * Compute the Color4 hash code
  5902. * @returns an unique number that can be used to hash Color4 objects
  5903. */
  5904. getHashCode(): number;
  5905. /**
  5906. * Creates a new Color4 copied from the current one
  5907. * @returns a new Color4 object
  5908. */
  5909. clone(): Color4;
  5910. /**
  5911. * Copies the given Color4 values into the current one
  5912. * @param source defines the source Color4 object
  5913. * @returns the current updated Color4 object
  5914. */
  5915. copyFrom(source: Color4): Color4;
  5916. /**
  5917. * Copies the given float values into the current one
  5918. * @param r defines the red component to read from
  5919. * @param g defines the green component to read from
  5920. * @param b defines the blue component to read from
  5921. * @param a defines the alpha component to read from
  5922. * @returns the current updated Color4 object
  5923. */
  5924. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5925. /**
  5926. * Copies the given float values into the current one
  5927. * @param r defines the red component to read from
  5928. * @param g defines the green component to read from
  5929. * @param b defines the blue component to read from
  5930. * @param a defines the alpha component to read from
  5931. * @returns the current updated Color4 object
  5932. */
  5933. set(r: number, g: number, b: number, a: number): Color4;
  5934. /**
  5935. * Compute the Color4 hexadecimal code as a string
  5936. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5937. * @returns a string containing the hexadecimal representation of the Color4 object
  5938. */
  5939. toHexString(returnAsColor3?: boolean): string;
  5940. /**
  5941. * Computes a new Color4 converted from the current one to linear space
  5942. * @returns a new Color4 object
  5943. */
  5944. toLinearSpace(): Color4;
  5945. /**
  5946. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5947. * @param convertedColor defines the Color4 object where to store the linear space version
  5948. * @returns the unmodified Color4
  5949. */
  5950. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5951. /**
  5952. * Computes a new Color4 converted from the current one to gamma space
  5953. * @returns a new Color4 object
  5954. */
  5955. toGammaSpace(): Color4;
  5956. /**
  5957. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5958. * @param convertedColor defines the Color4 object where to store the gamma space version
  5959. * @returns the unmodified Color4
  5960. */
  5961. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5962. /**
  5963. * Creates a new Color4 from the string containing valid hexadecimal values
  5964. * @param hex defines a string containing valid hexadecimal values
  5965. * @returns a new Color4 object
  5966. */
  5967. static FromHexString(hex: string): Color4;
  5968. /**
  5969. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5970. * @param left defines the start value
  5971. * @param right defines the end value
  5972. * @param amount defines the gradient factor
  5973. * @returns a new Color4 object
  5974. */
  5975. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5976. /**
  5977. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5978. * @param left defines the start value
  5979. * @param right defines the end value
  5980. * @param amount defines the gradient factor
  5981. * @param result defines the Color4 object where to store data
  5982. */
  5983. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5984. /**
  5985. * Creates a new Color4 from a Color3 and an alpha value
  5986. * @param color3 defines the source Color3 to read from
  5987. * @param alpha defines the alpha component (1.0 by default)
  5988. * @returns a new Color4 object
  5989. */
  5990. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5991. /**
  5992. * Creates a new Color4 from the starting index element of the given array
  5993. * @param array defines the source array to read from
  5994. * @param offset defines the offset in the source array
  5995. * @returns a new Color4 object
  5996. */
  5997. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5998. /**
  5999. * Creates a new Color3 from integer values (< 256)
  6000. * @param r defines the red component to read from (value between 0 and 255)
  6001. * @param g defines the green component to read from (value between 0 and 255)
  6002. * @param b defines the blue component to read from (value between 0 and 255)
  6003. * @param a defines the alpha component to read from (value between 0 and 255)
  6004. * @returns a new Color3 object
  6005. */
  6006. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6007. /**
  6008. * Check the content of a given array and convert it to an array containing RGBA data
  6009. * If the original array was already containing count * 4 values then it is returned directly
  6010. * @param colors defines the array to check
  6011. * @param count defines the number of RGBA data to expect
  6012. * @returns an array containing count * 4 values (RGBA)
  6013. */
  6014. static CheckColors4(colors: number[], count: number): number[];
  6015. }
  6016. /**
  6017. * @hidden
  6018. */
  6019. export class TmpColors {
  6020. static Color3: Color3[];
  6021. static Color4: Color4[];
  6022. }
  6023. }
  6024. declare module BABYLON {
  6025. /**
  6026. * Defines an interface which represents an animation key frame
  6027. */
  6028. export interface IAnimationKey {
  6029. /**
  6030. * Frame of the key frame
  6031. */
  6032. frame: number;
  6033. /**
  6034. * Value at the specifies key frame
  6035. */
  6036. value: any;
  6037. /**
  6038. * The input tangent for the cubic hermite spline
  6039. */
  6040. inTangent?: any;
  6041. /**
  6042. * The output tangent for the cubic hermite spline
  6043. */
  6044. outTangent?: any;
  6045. /**
  6046. * The animation interpolation type
  6047. */
  6048. interpolation?: AnimationKeyInterpolation;
  6049. }
  6050. /**
  6051. * Enum for the animation key frame interpolation type
  6052. */
  6053. export enum AnimationKeyInterpolation {
  6054. /**
  6055. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6056. */
  6057. STEP = 1
  6058. }
  6059. }
  6060. declare module BABYLON {
  6061. /**
  6062. * Represents the range of an animation
  6063. */
  6064. export class AnimationRange {
  6065. /**The name of the animation range**/
  6066. name: string;
  6067. /**The starting frame of the animation */
  6068. from: number;
  6069. /**The ending frame of the animation*/
  6070. to: number;
  6071. /**
  6072. * Initializes the range of an animation
  6073. * @param name The name of the animation range
  6074. * @param from The starting frame of the animation
  6075. * @param to The ending frame of the animation
  6076. */
  6077. constructor(
  6078. /**The name of the animation range**/
  6079. name: string,
  6080. /**The starting frame of the animation */
  6081. from: number,
  6082. /**The ending frame of the animation*/
  6083. to: number);
  6084. /**
  6085. * Makes a copy of the animation range
  6086. * @returns A copy of the animation range
  6087. */
  6088. clone(): AnimationRange;
  6089. }
  6090. }
  6091. declare module BABYLON {
  6092. /**
  6093. * Composed of a frame, and an action function
  6094. */
  6095. export class AnimationEvent {
  6096. /** The frame for which the event is triggered **/
  6097. frame: number;
  6098. /** The event to perform when triggered **/
  6099. action: (currentFrame: number) => void;
  6100. /** Specifies if the event should be triggered only once**/
  6101. onlyOnce?: boolean | undefined;
  6102. /**
  6103. * Specifies if the animation event is done
  6104. */
  6105. isDone: boolean;
  6106. /**
  6107. * Initializes the animation event
  6108. * @param frame The frame for which the event is triggered
  6109. * @param action The event to perform when triggered
  6110. * @param onlyOnce Specifies if the event should be triggered only once
  6111. */
  6112. constructor(
  6113. /** The frame for which the event is triggered **/
  6114. frame: number,
  6115. /** The event to perform when triggered **/
  6116. action: (currentFrame: number) => void,
  6117. /** Specifies if the event should be triggered only once**/
  6118. onlyOnce?: boolean | undefined);
  6119. /** @hidden */
  6120. _clone(): AnimationEvent;
  6121. }
  6122. }
  6123. declare module BABYLON {
  6124. /**
  6125. * Interface used to define a behavior
  6126. */
  6127. export interface Behavior<T> {
  6128. /** gets or sets behavior's name */
  6129. name: string;
  6130. /**
  6131. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6132. */
  6133. init(): void;
  6134. /**
  6135. * Called when the behavior is attached to a target
  6136. * @param target defines the target where the behavior is attached to
  6137. */
  6138. attach(target: T): void;
  6139. /**
  6140. * Called when the behavior is detached from its target
  6141. */
  6142. detach(): void;
  6143. }
  6144. /**
  6145. * Interface implemented by classes supporting behaviors
  6146. */
  6147. export interface IBehaviorAware<T> {
  6148. /**
  6149. * Attach a behavior
  6150. * @param behavior defines the behavior to attach
  6151. * @returns the current host
  6152. */
  6153. addBehavior(behavior: Behavior<T>): T;
  6154. /**
  6155. * Remove a behavior from the current object
  6156. * @param behavior defines the behavior to detach
  6157. * @returns the current host
  6158. */
  6159. removeBehavior(behavior: Behavior<T>): T;
  6160. /**
  6161. * Gets a behavior using its name to search
  6162. * @param name defines the name to search
  6163. * @returns the behavior or null if not found
  6164. */
  6165. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6166. }
  6167. }
  6168. declare module BABYLON {
  6169. /**
  6170. * Defines an array and its length.
  6171. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6172. */
  6173. export interface ISmartArrayLike<T> {
  6174. /**
  6175. * The data of the array.
  6176. */
  6177. data: Array<T>;
  6178. /**
  6179. * The active length of the array.
  6180. */
  6181. length: number;
  6182. }
  6183. /**
  6184. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6185. */
  6186. export class SmartArray<T> implements ISmartArrayLike<T> {
  6187. /**
  6188. * The full set of data from the array.
  6189. */
  6190. data: Array<T>;
  6191. /**
  6192. * The active length of the array.
  6193. */
  6194. length: number;
  6195. protected _id: number;
  6196. /**
  6197. * Instantiates a Smart Array.
  6198. * @param capacity defines the default capacity of the array.
  6199. */
  6200. constructor(capacity: number);
  6201. /**
  6202. * Pushes a value at the end of the active data.
  6203. * @param value defines the object to push in the array.
  6204. */
  6205. push(value: T): void;
  6206. /**
  6207. * Iterates over the active data and apply the lambda to them.
  6208. * @param func defines the action to apply on each value.
  6209. */
  6210. forEach(func: (content: T) => void): void;
  6211. /**
  6212. * Sorts the full sets of data.
  6213. * @param compareFn defines the comparison function to apply.
  6214. */
  6215. sort(compareFn: (a: T, b: T) => number): void;
  6216. /**
  6217. * Resets the active data to an empty array.
  6218. */
  6219. reset(): void;
  6220. /**
  6221. * Releases all the data from the array as well as the array.
  6222. */
  6223. dispose(): void;
  6224. /**
  6225. * Concats the active data with a given array.
  6226. * @param array defines the data to concatenate with.
  6227. */
  6228. concat(array: any): void;
  6229. /**
  6230. * Returns the position of a value in the active data.
  6231. * @param value defines the value to find the index for
  6232. * @returns the index if found in the active data otherwise -1
  6233. */
  6234. indexOf(value: T): number;
  6235. /**
  6236. * Returns whether an element is part of the active data.
  6237. * @param value defines the value to look for
  6238. * @returns true if found in the active data otherwise false
  6239. */
  6240. contains(value: T): boolean;
  6241. private static _GlobalId;
  6242. }
  6243. /**
  6244. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6245. * The data in this array can only be present once
  6246. */
  6247. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6248. private _duplicateId;
  6249. /**
  6250. * Pushes a value at the end of the active data.
  6251. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6252. * @param value defines the object to push in the array.
  6253. */
  6254. push(value: T): void;
  6255. /**
  6256. * Pushes a value at the end of the active data.
  6257. * If the data is already present, it won t be added again
  6258. * @param value defines the object to push in the array.
  6259. * @returns true if added false if it was already present
  6260. */
  6261. pushNoDuplicate(value: T): boolean;
  6262. /**
  6263. * Resets the active data to an empty array.
  6264. */
  6265. reset(): void;
  6266. /**
  6267. * Concats the active data with a given array.
  6268. * This ensures no dupplicate will be present in the result.
  6269. * @param array defines the data to concatenate with.
  6270. */
  6271. concatWithNoDuplicate(array: any): void;
  6272. }
  6273. }
  6274. declare module BABYLON {
  6275. /**
  6276. * @ignore
  6277. * This is a list of all the different input types that are available in the application.
  6278. * Fo instance: ArcRotateCameraGamepadInput...
  6279. */
  6280. export var CameraInputTypes: {};
  6281. /**
  6282. * This is the contract to implement in order to create a new input class.
  6283. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6284. */
  6285. export interface ICameraInput<TCamera extends Camera> {
  6286. /**
  6287. * Defines the camera the input is attached to.
  6288. */
  6289. camera: Nullable<TCamera>;
  6290. /**
  6291. * Gets the class name of the current intput.
  6292. * @returns the class name
  6293. */
  6294. getClassName(): string;
  6295. /**
  6296. * Get the friendly name associated with the input class.
  6297. * @returns the input friendly name
  6298. */
  6299. getSimpleName(): string;
  6300. /**
  6301. * Attach the input controls to a specific dom element to get the input from.
  6302. * @param element Defines the element the controls should be listened from
  6303. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6304. */
  6305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6306. /**
  6307. * Detach the current controls from the specified dom element.
  6308. * @param element Defines the element to stop listening the inputs from
  6309. */
  6310. detachControl(element: Nullable<HTMLElement>): void;
  6311. /**
  6312. * Update the current camera state depending on the inputs that have been used this frame.
  6313. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6314. */
  6315. checkInputs?: () => void;
  6316. }
  6317. /**
  6318. * Represents a map of input types to input instance or input index to input instance.
  6319. */
  6320. export interface CameraInputsMap<TCamera extends Camera> {
  6321. /**
  6322. * Accessor to the input by input type.
  6323. */
  6324. [name: string]: ICameraInput<TCamera>;
  6325. /**
  6326. * Accessor to the input by input index.
  6327. */
  6328. [idx: number]: ICameraInput<TCamera>;
  6329. }
  6330. /**
  6331. * This represents the input manager used within a camera.
  6332. * It helps dealing with all the different kind of input attached to a camera.
  6333. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6334. */
  6335. export class CameraInputsManager<TCamera extends Camera> {
  6336. /**
  6337. * Defines the list of inputs attahed to the camera.
  6338. */
  6339. attached: CameraInputsMap<TCamera>;
  6340. /**
  6341. * Defines the dom element the camera is collecting inputs from.
  6342. * This is null if the controls have not been attached.
  6343. */
  6344. attachedElement: Nullable<HTMLElement>;
  6345. /**
  6346. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6347. */
  6348. noPreventDefault: boolean;
  6349. /**
  6350. * Defined the camera the input manager belongs to.
  6351. */
  6352. camera: TCamera;
  6353. /**
  6354. * Update the current camera state depending on the inputs that have been used this frame.
  6355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6356. */
  6357. checkInputs: () => void;
  6358. /**
  6359. * Instantiate a new Camera Input Manager.
  6360. * @param camera Defines the camera the input manager blongs to
  6361. */
  6362. constructor(camera: TCamera);
  6363. /**
  6364. * Add an input method to a camera
  6365. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6366. * @param input camera input method
  6367. */
  6368. add(input: ICameraInput<TCamera>): void;
  6369. /**
  6370. * Remove a specific input method from a camera
  6371. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6372. * @param inputToRemove camera input method
  6373. */
  6374. remove(inputToRemove: ICameraInput<TCamera>): void;
  6375. /**
  6376. * Remove a specific input type from a camera
  6377. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6378. * @param inputType the type of the input to remove
  6379. */
  6380. removeByType(inputType: string): void;
  6381. private _addCheckInputs;
  6382. /**
  6383. * Attach the input controls to the currently attached dom element to listen the events from.
  6384. * @param input Defines the input to attach
  6385. */
  6386. attachInput(input: ICameraInput<TCamera>): void;
  6387. /**
  6388. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6389. * @param element Defines the dom element to collect the events from
  6390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6391. */
  6392. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6393. /**
  6394. * Detach the current manager inputs controls from a specific dom element.
  6395. * @param element Defines the dom element to collect the events from
  6396. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6397. */
  6398. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6399. /**
  6400. * Rebuild the dynamic inputCheck function from the current list of
  6401. * defined inputs in the manager.
  6402. */
  6403. rebuildInputCheck(): void;
  6404. /**
  6405. * Remove all attached input methods from a camera
  6406. */
  6407. clear(): void;
  6408. /**
  6409. * Serialize the current input manager attached to a camera.
  6410. * This ensures than once parsed,
  6411. * the input associated to the camera will be identical to the current ones
  6412. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6413. */
  6414. serialize(serializedCamera: any): void;
  6415. /**
  6416. * Parses an input manager serialized JSON to restore the previous list of inputs
  6417. * and states associated to a camera.
  6418. * @param parsedCamera Defines the JSON to parse
  6419. */
  6420. parse(parsedCamera: any): void;
  6421. }
  6422. }
  6423. declare module BABYLON {
  6424. /**
  6425. * Class used to store data that will be store in GPU memory
  6426. */
  6427. export class Buffer {
  6428. private _engine;
  6429. private _buffer;
  6430. /** @hidden */
  6431. _data: Nullable<DataArray>;
  6432. private _updatable;
  6433. private _instanced;
  6434. private _divisor;
  6435. /**
  6436. * Gets the byte stride.
  6437. */
  6438. readonly byteStride: number;
  6439. /**
  6440. * Constructor
  6441. * @param engine the engine
  6442. * @param data the data to use for this buffer
  6443. * @param updatable whether the data is updatable
  6444. * @param stride the stride (optional)
  6445. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6446. * @param instanced whether the buffer is instanced (optional)
  6447. * @param useBytes set to true if the stride in in bytes (optional)
  6448. * @param divisor sets an optional divisor for instances (1 by default)
  6449. */
  6450. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6451. /**
  6452. * Create a new VertexBuffer based on the current buffer
  6453. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6454. * @param offset defines offset in the buffer (0 by default)
  6455. * @param size defines the size in floats of attributes (position is 3 for instance)
  6456. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6457. * @param instanced defines if the vertex buffer contains indexed data
  6458. * @param useBytes defines if the offset and stride are in bytes *
  6459. * @param divisor sets an optional divisor for instances (1 by default)
  6460. * @returns the new vertex buffer
  6461. */
  6462. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6463. /**
  6464. * Gets a boolean indicating if the Buffer is updatable?
  6465. * @returns true if the buffer is updatable
  6466. */
  6467. isUpdatable(): boolean;
  6468. /**
  6469. * Gets current buffer's data
  6470. * @returns a DataArray or null
  6471. */
  6472. getData(): Nullable<DataArray>;
  6473. /**
  6474. * Gets underlying native buffer
  6475. * @returns underlying native buffer
  6476. */
  6477. getBuffer(): Nullable<DataBuffer>;
  6478. /**
  6479. * Gets the stride in float32 units (i.e. byte stride / 4).
  6480. * May not be an integer if the byte stride is not divisible by 4.
  6481. * @returns the stride in float32 units
  6482. * @deprecated Please use byteStride instead.
  6483. */
  6484. getStrideSize(): number;
  6485. /**
  6486. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6487. * @param data defines the data to store
  6488. */
  6489. create(data?: Nullable<DataArray>): void;
  6490. /** @hidden */
  6491. _rebuild(): void;
  6492. /**
  6493. * Update current buffer data
  6494. * @param data defines the data to store
  6495. */
  6496. update(data: DataArray): void;
  6497. /**
  6498. * Updates the data directly.
  6499. * @param data the new data
  6500. * @param offset the new offset
  6501. * @param vertexCount the vertex count (optional)
  6502. * @param useBytes set to true if the offset is in bytes
  6503. */
  6504. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6505. /**
  6506. * Release all resources
  6507. */
  6508. dispose(): void;
  6509. }
  6510. /**
  6511. * Specialized buffer used to store vertex data
  6512. */
  6513. export class VertexBuffer {
  6514. /** @hidden */
  6515. _buffer: Buffer;
  6516. private _kind;
  6517. private _size;
  6518. private _ownsBuffer;
  6519. private _instanced;
  6520. private _instanceDivisor;
  6521. /**
  6522. * The byte type.
  6523. */
  6524. static readonly BYTE: number;
  6525. /**
  6526. * The unsigned byte type.
  6527. */
  6528. static readonly UNSIGNED_BYTE: number;
  6529. /**
  6530. * The short type.
  6531. */
  6532. static readonly SHORT: number;
  6533. /**
  6534. * The unsigned short type.
  6535. */
  6536. static readonly UNSIGNED_SHORT: number;
  6537. /**
  6538. * The integer type.
  6539. */
  6540. static readonly INT: number;
  6541. /**
  6542. * The unsigned integer type.
  6543. */
  6544. static readonly UNSIGNED_INT: number;
  6545. /**
  6546. * The float type.
  6547. */
  6548. static readonly FLOAT: number;
  6549. /**
  6550. * Gets or sets the instance divisor when in instanced mode
  6551. */
  6552. get instanceDivisor(): number;
  6553. set instanceDivisor(value: number);
  6554. /**
  6555. * Gets the byte stride.
  6556. */
  6557. readonly byteStride: number;
  6558. /**
  6559. * Gets the byte offset.
  6560. */
  6561. readonly byteOffset: number;
  6562. /**
  6563. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6564. */
  6565. readonly normalized: boolean;
  6566. /**
  6567. * Gets the data type of each component in the array.
  6568. */
  6569. readonly type: number;
  6570. /**
  6571. * Constructor
  6572. * @param engine the engine
  6573. * @param data the data to use for this vertex buffer
  6574. * @param kind the vertex buffer kind
  6575. * @param updatable whether the data is updatable
  6576. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6577. * @param stride the stride (optional)
  6578. * @param instanced whether the buffer is instanced (optional)
  6579. * @param offset the offset of the data (optional)
  6580. * @param size the number of components (optional)
  6581. * @param type the type of the component (optional)
  6582. * @param normalized whether the data contains normalized data (optional)
  6583. * @param useBytes set to true if stride and offset are in bytes (optional)
  6584. * @param divisor defines the instance divisor to use (1 by default)
  6585. */
  6586. 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);
  6587. /** @hidden */
  6588. _rebuild(): void;
  6589. /**
  6590. * Returns the kind of the VertexBuffer (string)
  6591. * @returns a string
  6592. */
  6593. getKind(): string;
  6594. /**
  6595. * Gets a boolean indicating if the VertexBuffer is updatable?
  6596. * @returns true if the buffer is updatable
  6597. */
  6598. isUpdatable(): boolean;
  6599. /**
  6600. * Gets current buffer's data
  6601. * @returns a DataArray or null
  6602. */
  6603. getData(): Nullable<DataArray>;
  6604. /**
  6605. * Gets underlying native buffer
  6606. * @returns underlying native buffer
  6607. */
  6608. getBuffer(): Nullable<DataBuffer>;
  6609. /**
  6610. * Gets the stride in float32 units (i.e. byte stride / 4).
  6611. * May not be an integer if the byte stride is not divisible by 4.
  6612. * @returns the stride in float32 units
  6613. * @deprecated Please use byteStride instead.
  6614. */
  6615. getStrideSize(): number;
  6616. /**
  6617. * Returns the offset as a multiple of the type byte length.
  6618. * @returns the offset in bytes
  6619. * @deprecated Please use byteOffset instead.
  6620. */
  6621. getOffset(): number;
  6622. /**
  6623. * Returns the number of components per vertex attribute (integer)
  6624. * @returns the size in float
  6625. */
  6626. getSize(): number;
  6627. /**
  6628. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6629. * @returns true if this buffer is instanced
  6630. */
  6631. getIsInstanced(): boolean;
  6632. /**
  6633. * Returns the instancing divisor, zero for non-instanced (integer).
  6634. * @returns a number
  6635. */
  6636. getInstanceDivisor(): number;
  6637. /**
  6638. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6639. * @param data defines the data to store
  6640. */
  6641. create(data?: DataArray): void;
  6642. /**
  6643. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6644. * This function will create a new buffer if the current one is not updatable
  6645. * @param data defines the data to store
  6646. */
  6647. update(data: DataArray): void;
  6648. /**
  6649. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6650. * Returns the directly updated WebGLBuffer.
  6651. * @param data the new data
  6652. * @param offset the new offset
  6653. * @param useBytes set to true if the offset is in bytes
  6654. */
  6655. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6656. /**
  6657. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6658. */
  6659. dispose(): void;
  6660. /**
  6661. * Enumerates each value of this vertex buffer as numbers.
  6662. * @param count the number of values to enumerate
  6663. * @param callback the callback function called for each value
  6664. */
  6665. forEach(count: number, callback: (value: number, index: number) => void): void;
  6666. /**
  6667. * Positions
  6668. */
  6669. static readonly PositionKind: string;
  6670. /**
  6671. * Normals
  6672. */
  6673. static readonly NormalKind: string;
  6674. /**
  6675. * Tangents
  6676. */
  6677. static readonly TangentKind: string;
  6678. /**
  6679. * Texture coordinates
  6680. */
  6681. static readonly UVKind: string;
  6682. /**
  6683. * Texture coordinates 2
  6684. */
  6685. static readonly UV2Kind: string;
  6686. /**
  6687. * Texture coordinates 3
  6688. */
  6689. static readonly UV3Kind: string;
  6690. /**
  6691. * Texture coordinates 4
  6692. */
  6693. static readonly UV4Kind: string;
  6694. /**
  6695. * Texture coordinates 5
  6696. */
  6697. static readonly UV5Kind: string;
  6698. /**
  6699. * Texture coordinates 6
  6700. */
  6701. static readonly UV6Kind: string;
  6702. /**
  6703. * Colors
  6704. */
  6705. static readonly ColorKind: string;
  6706. /**
  6707. * Matrix indices (for bones)
  6708. */
  6709. static readonly MatricesIndicesKind: string;
  6710. /**
  6711. * Matrix weights (for bones)
  6712. */
  6713. static readonly MatricesWeightsKind: string;
  6714. /**
  6715. * Additional matrix indices (for bones)
  6716. */
  6717. static readonly MatricesIndicesExtraKind: string;
  6718. /**
  6719. * Additional matrix weights (for bones)
  6720. */
  6721. static readonly MatricesWeightsExtraKind: string;
  6722. /**
  6723. * Deduces the stride given a kind.
  6724. * @param kind The kind string to deduce
  6725. * @returns The deduced stride
  6726. */
  6727. static DeduceStride(kind: string): number;
  6728. /**
  6729. * Gets the byte length of the given type.
  6730. * @param type the type
  6731. * @returns the number of bytes
  6732. */
  6733. static GetTypeByteLength(type: number): number;
  6734. /**
  6735. * Enumerates each value of the given parameters as numbers.
  6736. * @param data the data to enumerate
  6737. * @param byteOffset the byte offset of the data
  6738. * @param byteStride the byte stride of the data
  6739. * @param componentCount the number of components per element
  6740. * @param componentType the type of the component
  6741. * @param count the number of values to enumerate
  6742. * @param normalized whether the data is normalized
  6743. * @param callback the callback function called for each value
  6744. */
  6745. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6746. private static _GetFloatValue;
  6747. }
  6748. }
  6749. declare module BABYLON {
  6750. /**
  6751. * @hidden
  6752. */
  6753. export class IntersectionInfo {
  6754. bu: Nullable<number>;
  6755. bv: Nullable<number>;
  6756. distance: number;
  6757. faceId: number;
  6758. subMeshId: number;
  6759. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6760. }
  6761. }
  6762. declare module BABYLON {
  6763. /**
  6764. * Class used to store bounding sphere information
  6765. */
  6766. export class BoundingSphere {
  6767. /**
  6768. * Gets the center of the bounding sphere in local space
  6769. */
  6770. readonly center: Vector3;
  6771. /**
  6772. * Radius of the bounding sphere in local space
  6773. */
  6774. radius: number;
  6775. /**
  6776. * Gets the center of the bounding sphere in world space
  6777. */
  6778. readonly centerWorld: Vector3;
  6779. /**
  6780. * Radius of the bounding sphere in world space
  6781. */
  6782. radiusWorld: number;
  6783. /**
  6784. * Gets the minimum vector in local space
  6785. */
  6786. readonly minimum: Vector3;
  6787. /**
  6788. * Gets the maximum vector in local space
  6789. */
  6790. readonly maximum: Vector3;
  6791. private _worldMatrix;
  6792. private static readonly TmpVector3;
  6793. /**
  6794. * Creates a new bounding sphere
  6795. * @param min defines the minimum vector (in local space)
  6796. * @param max defines the maximum vector (in local space)
  6797. * @param worldMatrix defines the new world matrix
  6798. */
  6799. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6800. /**
  6801. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6802. * @param min defines the new minimum vector (in local space)
  6803. * @param max defines the new maximum vector (in local space)
  6804. * @param worldMatrix defines the new world matrix
  6805. */
  6806. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6807. /**
  6808. * Scale the current bounding sphere by applying a scale factor
  6809. * @param factor defines the scale factor to apply
  6810. * @returns the current bounding box
  6811. */
  6812. scale(factor: number): BoundingSphere;
  6813. /**
  6814. * Gets the world matrix of the bounding box
  6815. * @returns a matrix
  6816. */
  6817. getWorldMatrix(): DeepImmutable<Matrix>;
  6818. /** @hidden */
  6819. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6820. /**
  6821. * Tests if the bounding sphere is intersecting the frustum planes
  6822. * @param frustumPlanes defines the frustum planes to test
  6823. * @returns true if there is an intersection
  6824. */
  6825. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6826. /**
  6827. * Tests if the bounding sphere center is in between the frustum planes.
  6828. * Used for optimistic fast inclusion.
  6829. * @param frustumPlanes defines the frustum planes to test
  6830. * @returns true if the sphere center is in between the frustum planes
  6831. */
  6832. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6833. /**
  6834. * Tests if a point is inside the bounding sphere
  6835. * @param point defines the point to test
  6836. * @returns true if the point is inside the bounding sphere
  6837. */
  6838. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6839. /**
  6840. * Checks if two sphere intersct
  6841. * @param sphere0 sphere 0
  6842. * @param sphere1 sphere 1
  6843. * @returns true if the speres intersect
  6844. */
  6845. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6846. }
  6847. }
  6848. declare module BABYLON {
  6849. /**
  6850. * Class used to store bounding box information
  6851. */
  6852. export class BoundingBox implements ICullable {
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in local space
  6855. */
  6856. readonly vectors: Vector3[];
  6857. /**
  6858. * Gets the center of the bounding box in local space
  6859. */
  6860. readonly center: Vector3;
  6861. /**
  6862. * Gets the center of the bounding box in world space
  6863. */
  6864. readonly centerWorld: Vector3;
  6865. /**
  6866. * Gets the extend size in local space
  6867. */
  6868. readonly extendSize: Vector3;
  6869. /**
  6870. * Gets the extend size in world space
  6871. */
  6872. readonly extendSizeWorld: Vector3;
  6873. /**
  6874. * Gets the OBB (object bounding box) directions
  6875. */
  6876. readonly directions: Vector3[];
  6877. /**
  6878. * Gets the 8 vectors representing the bounding box in world space
  6879. */
  6880. readonly vectorsWorld: Vector3[];
  6881. /**
  6882. * Gets the minimum vector in world space
  6883. */
  6884. readonly minimumWorld: Vector3;
  6885. /**
  6886. * Gets the maximum vector in world space
  6887. */
  6888. readonly maximumWorld: Vector3;
  6889. /**
  6890. * Gets the minimum vector in local space
  6891. */
  6892. readonly minimum: Vector3;
  6893. /**
  6894. * Gets the maximum vector in local space
  6895. */
  6896. readonly maximum: Vector3;
  6897. private _worldMatrix;
  6898. private static readonly TmpVector3;
  6899. /**
  6900. * @hidden
  6901. */
  6902. _tag: number;
  6903. /**
  6904. * Creates a new bounding box
  6905. * @param min defines the minimum vector (in local space)
  6906. * @param max defines the maximum vector (in local space)
  6907. * @param worldMatrix defines the new world matrix
  6908. */
  6909. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6910. /**
  6911. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6912. * @param min defines the new minimum vector (in local space)
  6913. * @param max defines the new maximum vector (in local space)
  6914. * @param worldMatrix defines the new world matrix
  6915. */
  6916. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6917. /**
  6918. * Scale the current bounding box by applying a scale factor
  6919. * @param factor defines the scale factor to apply
  6920. * @returns the current bounding box
  6921. */
  6922. scale(factor: number): BoundingBox;
  6923. /**
  6924. * Gets the world matrix of the bounding box
  6925. * @returns a matrix
  6926. */
  6927. getWorldMatrix(): DeepImmutable<Matrix>;
  6928. /** @hidden */
  6929. _update(world: DeepImmutable<Matrix>): void;
  6930. /**
  6931. * Tests if the bounding box is intersecting the frustum planes
  6932. * @param frustumPlanes defines the frustum planes to test
  6933. * @returns true if there is an intersection
  6934. */
  6935. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6936. /**
  6937. * Tests if the bounding box is entirely inside the frustum planes
  6938. * @param frustumPlanes defines the frustum planes to test
  6939. * @returns true if there is an inclusion
  6940. */
  6941. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /**
  6943. * Tests if a point is inside the bounding box
  6944. * @param point defines the point to test
  6945. * @returns true if the point is inside the bounding box
  6946. */
  6947. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6948. /**
  6949. * Tests if the bounding box intersects with a bounding sphere
  6950. * @param sphere defines the sphere to test
  6951. * @returns true if there is an intersection
  6952. */
  6953. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6954. /**
  6955. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6956. * @param min defines the min vector to use
  6957. * @param max defines the max vector to use
  6958. * @returns true if there is an intersection
  6959. */
  6960. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6961. /**
  6962. * Tests if two bounding boxes are intersections
  6963. * @param box0 defines the first box to test
  6964. * @param box1 defines the second box to test
  6965. * @returns true if there is an intersection
  6966. */
  6967. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6968. /**
  6969. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6970. * @param minPoint defines the minimum vector of the bounding box
  6971. * @param maxPoint defines the maximum vector of the bounding box
  6972. * @param sphereCenter defines the sphere center
  6973. * @param sphereRadius defines the sphere radius
  6974. * @returns true if there is an intersection
  6975. */
  6976. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6977. /**
  6978. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6979. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6980. * @param frustumPlanes defines the frustum planes to test
  6981. * @return true if there is an inclusion
  6982. */
  6983. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6984. /**
  6985. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6986. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6987. * @param frustumPlanes defines the frustum planes to test
  6988. * @return true if there is an intersection
  6989. */
  6990. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6991. }
  6992. }
  6993. declare module BABYLON {
  6994. /** @hidden */
  6995. export class Collider {
  6996. /** Define if a collision was found */
  6997. collisionFound: boolean;
  6998. /**
  6999. * Define last intersection point in local space
  7000. */
  7001. intersectionPoint: Vector3;
  7002. /**
  7003. * Define last collided mesh
  7004. */
  7005. collidedMesh: Nullable<AbstractMesh>;
  7006. private _collisionPoint;
  7007. private _planeIntersectionPoint;
  7008. private _tempVector;
  7009. private _tempVector2;
  7010. private _tempVector3;
  7011. private _tempVector4;
  7012. private _edge;
  7013. private _baseToVertex;
  7014. private _destinationPoint;
  7015. private _slidePlaneNormal;
  7016. private _displacementVector;
  7017. /** @hidden */
  7018. _radius: Vector3;
  7019. /** @hidden */
  7020. _retry: number;
  7021. private _velocity;
  7022. private _basePoint;
  7023. private _epsilon;
  7024. /** @hidden */
  7025. _velocityWorldLength: number;
  7026. /** @hidden */
  7027. _basePointWorld: Vector3;
  7028. private _velocityWorld;
  7029. private _normalizedVelocity;
  7030. /** @hidden */
  7031. _initialVelocity: Vector3;
  7032. /** @hidden */
  7033. _initialPosition: Vector3;
  7034. private _nearestDistance;
  7035. private _collisionMask;
  7036. get collisionMask(): number;
  7037. set collisionMask(mask: number);
  7038. /**
  7039. * Gets the plane normal used to compute the sliding response (in local space)
  7040. */
  7041. get slidePlaneNormal(): Vector3;
  7042. /** @hidden */
  7043. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7044. /** @hidden */
  7045. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7046. /** @hidden */
  7047. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7048. /** @hidden */
  7049. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7050. /** @hidden */
  7051. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7052. /** @hidden */
  7053. _getResponse(pos: Vector3, vel: Vector3): void;
  7054. }
  7055. }
  7056. declare module BABYLON {
  7057. /**
  7058. * Interface for cullable objects
  7059. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7060. */
  7061. export interface ICullable {
  7062. /**
  7063. * Checks if the object or part of the object is in the frustum
  7064. * @param frustumPlanes Camera near/planes
  7065. * @returns true if the object is in frustum otherwise false
  7066. */
  7067. isInFrustum(frustumPlanes: Plane[]): boolean;
  7068. /**
  7069. * Checks if a cullable object (mesh...) is in the camera frustum
  7070. * Unlike isInFrustum this cheks the full bounding box
  7071. * @param frustumPlanes Camera near/planes
  7072. * @returns true if the object is in frustum otherwise false
  7073. */
  7074. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7075. }
  7076. /**
  7077. * Info for a bounding data of a mesh
  7078. */
  7079. export class BoundingInfo implements ICullable {
  7080. /**
  7081. * Bounding box for the mesh
  7082. */
  7083. readonly boundingBox: BoundingBox;
  7084. /**
  7085. * Bounding sphere for the mesh
  7086. */
  7087. readonly boundingSphere: BoundingSphere;
  7088. private _isLocked;
  7089. private static readonly TmpVector3;
  7090. /**
  7091. * Constructs bounding info
  7092. * @param minimum min vector of the bounding box/sphere
  7093. * @param maximum max vector of the bounding box/sphere
  7094. * @param worldMatrix defines the new world matrix
  7095. */
  7096. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7097. /**
  7098. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7099. * @param min defines the new minimum vector (in local space)
  7100. * @param max defines the new maximum vector (in local space)
  7101. * @param worldMatrix defines the new world matrix
  7102. */
  7103. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7104. /**
  7105. * min vector of the bounding box/sphere
  7106. */
  7107. get minimum(): Vector3;
  7108. /**
  7109. * max vector of the bounding box/sphere
  7110. */
  7111. get maximum(): Vector3;
  7112. /**
  7113. * If the info is locked and won't be updated to avoid perf overhead
  7114. */
  7115. get isLocked(): boolean;
  7116. set isLocked(value: boolean);
  7117. /**
  7118. * Updates the bounding sphere and box
  7119. * @param world world matrix to be used to update
  7120. */
  7121. update(world: DeepImmutable<Matrix>): void;
  7122. /**
  7123. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7124. * @param center New center of the bounding info
  7125. * @param extend New extend of the bounding info
  7126. * @returns the current bounding info
  7127. */
  7128. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7129. /**
  7130. * Scale the current bounding info by applying a scale factor
  7131. * @param factor defines the scale factor to apply
  7132. * @returns the current bounding info
  7133. */
  7134. scale(factor: number): BoundingInfo;
  7135. /**
  7136. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7137. * @param frustumPlanes defines the frustum to test
  7138. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7139. * @returns true if the bounding info is in the frustum planes
  7140. */
  7141. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7142. /**
  7143. * Gets the world distance between the min and max points of the bounding box
  7144. */
  7145. get diagonalLength(): number;
  7146. /**
  7147. * Checks if a cullable object (mesh...) is in the camera frustum
  7148. * Unlike isInFrustum this cheks the full bounding box
  7149. * @param frustumPlanes Camera near/planes
  7150. * @returns true if the object is in frustum otherwise false
  7151. */
  7152. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7153. /** @hidden */
  7154. _checkCollision(collider: Collider): boolean;
  7155. /**
  7156. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7157. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7158. * @param point the point to check intersection with
  7159. * @returns if the point intersects
  7160. */
  7161. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7162. /**
  7163. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7164. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7165. * @param boundingInfo the bounding info to check intersection with
  7166. * @param precise if the intersection should be done using OBB
  7167. * @returns if the bounding info intersects
  7168. */
  7169. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7170. }
  7171. }
  7172. declare module BABYLON {
  7173. /**
  7174. * Extracts minimum and maximum values from a list of indexed positions
  7175. * @param positions defines the positions to use
  7176. * @param indices defines the indices to the positions
  7177. * @param indexStart defines the start index
  7178. * @param indexCount defines the end index
  7179. * @param bias defines bias value to add to the result
  7180. * @return minimum and maximum values
  7181. */
  7182. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7183. minimum: Vector3;
  7184. maximum: Vector3;
  7185. };
  7186. /**
  7187. * Extracts minimum and maximum values from a list of positions
  7188. * @param positions defines the positions to use
  7189. * @param start defines the start index in the positions array
  7190. * @param count defines the number of positions to handle
  7191. * @param bias defines bias value to add to the result
  7192. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7193. * @return minimum and maximum values
  7194. */
  7195. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7196. minimum: Vector3;
  7197. maximum: Vector3;
  7198. };
  7199. }
  7200. declare module BABYLON {
  7201. /** @hidden */
  7202. export class WebGLDataBuffer extends DataBuffer {
  7203. private _buffer;
  7204. constructor(resource: WebGLBuffer);
  7205. get underlyingResource(): any;
  7206. }
  7207. }
  7208. declare module BABYLON {
  7209. /** @hidden */
  7210. export class WebGLPipelineContext implements IPipelineContext {
  7211. engine: ThinEngine;
  7212. program: Nullable<WebGLProgram>;
  7213. context?: WebGLRenderingContext;
  7214. vertexShader?: WebGLShader;
  7215. fragmentShader?: WebGLShader;
  7216. isParallelCompiled: boolean;
  7217. onCompiled?: () => void;
  7218. transformFeedback?: WebGLTransformFeedback | null;
  7219. vertexCompilationError: Nullable<string>;
  7220. fragmentCompilationError: Nullable<string>;
  7221. programLinkError: Nullable<string>;
  7222. programValidationError: Nullable<string>;
  7223. get isAsync(): boolean;
  7224. get isReady(): boolean;
  7225. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7226. _getVertexShaderCode(): string | null;
  7227. _getFragmentShaderCode(): string | null;
  7228. }
  7229. }
  7230. declare module BABYLON {
  7231. interface ThinEngine {
  7232. /**
  7233. * Create an uniform buffer
  7234. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7235. * @param elements defines the content of the uniform buffer
  7236. * @returns the webGL uniform buffer
  7237. */
  7238. createUniformBuffer(elements: FloatArray): DataBuffer;
  7239. /**
  7240. * Create a dynamic uniform buffer
  7241. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7242. * @param elements defines the content of the uniform buffer
  7243. * @returns the webGL uniform buffer
  7244. */
  7245. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7246. /**
  7247. * Update an existing uniform buffer
  7248. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7249. * @param uniformBuffer defines the target uniform buffer
  7250. * @param elements defines the content to update
  7251. * @param offset defines the offset in the uniform buffer where update should start
  7252. * @param count defines the size of the data to update
  7253. */
  7254. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7255. /**
  7256. * Bind an uniform buffer to the current webGL context
  7257. * @param buffer defines the buffer to bind
  7258. */
  7259. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7260. /**
  7261. * Bind a buffer to the current webGL context at a given location
  7262. * @param buffer defines the buffer to bind
  7263. * @param location defines the index where to bind the buffer
  7264. */
  7265. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7266. /**
  7267. * Bind a specific block at a given index in a specific shader program
  7268. * @param pipelineContext defines the pipeline context to use
  7269. * @param blockName defines the block name
  7270. * @param index defines the index where to bind the block
  7271. */
  7272. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7273. }
  7274. }
  7275. declare module BABYLON {
  7276. /**
  7277. * Uniform buffer objects.
  7278. *
  7279. * Handles blocks of uniform on the GPU.
  7280. *
  7281. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7282. *
  7283. * For more information, please refer to :
  7284. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7285. */
  7286. export class UniformBuffer {
  7287. private _engine;
  7288. private _buffer;
  7289. private _data;
  7290. private _bufferData;
  7291. private _dynamic?;
  7292. private _uniformLocations;
  7293. private _uniformSizes;
  7294. private _uniformLocationPointer;
  7295. private _needSync;
  7296. private _noUBO;
  7297. private _currentEffect;
  7298. /** @hidden */
  7299. _alreadyBound: boolean;
  7300. private static _MAX_UNIFORM_SIZE;
  7301. private static _tempBuffer;
  7302. /**
  7303. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7304. * This is dynamic to allow compat with webgl 1 and 2.
  7305. * You will need to pass the name of the uniform as well as the value.
  7306. */
  7307. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7308. /**
  7309. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7310. * This is dynamic to allow compat with webgl 1 and 2.
  7311. * You will need to pass the name of the uniform as well as the value.
  7312. */
  7313. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7314. /**
  7315. * Lambda to Update a single float in a uniform buffer.
  7316. * This is dynamic to allow compat with webgl 1 and 2.
  7317. * You will need to pass the name of the uniform as well as the value.
  7318. */
  7319. updateFloat: (name: string, x: number) => void;
  7320. /**
  7321. * Lambda to Update a vec2 of float in a uniform buffer.
  7322. * This is dynamic to allow compat with webgl 1 and 2.
  7323. * You will need to pass the name of the uniform as well as the value.
  7324. */
  7325. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7326. /**
  7327. * Lambda to Update a vec3 of float in a uniform buffer.
  7328. * This is dynamic to allow compat with webgl 1 and 2.
  7329. * You will need to pass the name of the uniform as well as the value.
  7330. */
  7331. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7332. /**
  7333. * Lambda to Update a vec4 of float in a uniform buffer.
  7334. * This is dynamic to allow compat with webgl 1 and 2.
  7335. * You will need to pass the name of the uniform as well as the value.
  7336. */
  7337. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7338. /**
  7339. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateMatrix: (name: string, mat: Matrix) => void;
  7344. /**
  7345. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7346. * This is dynamic to allow compat with webgl 1 and 2.
  7347. * You will need to pass the name of the uniform as well as the value.
  7348. */
  7349. updateVector3: (name: string, vector: Vector3) => void;
  7350. /**
  7351. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7352. * This is dynamic to allow compat with webgl 1 and 2.
  7353. * You will need to pass the name of the uniform as well as the value.
  7354. */
  7355. updateVector4: (name: string, vector: Vector4) => void;
  7356. /**
  7357. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7358. * This is dynamic to allow compat with webgl 1 and 2.
  7359. * You will need to pass the name of the uniform as well as the value.
  7360. */
  7361. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7362. /**
  7363. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7364. * This is dynamic to allow compat with webgl 1 and 2.
  7365. * You will need to pass the name of the uniform as well as the value.
  7366. */
  7367. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7368. /**
  7369. * Instantiates a new Uniform buffer objects.
  7370. *
  7371. * Handles blocks of uniform on the GPU.
  7372. *
  7373. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7374. *
  7375. * For more information, please refer to :
  7376. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7377. * @param engine Define the engine the buffer is associated with
  7378. * @param data Define the data contained in the buffer
  7379. * @param dynamic Define if the buffer is updatable
  7380. */
  7381. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7382. /**
  7383. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7384. * or just falling back on setUniformXXX calls.
  7385. */
  7386. get useUbo(): boolean;
  7387. /**
  7388. * Indicates if the WebGL underlying uniform buffer is in sync
  7389. * with the javascript cache data.
  7390. */
  7391. get isSync(): boolean;
  7392. /**
  7393. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7394. * Also, a dynamic UniformBuffer will disable cache verification and always
  7395. * update the underlying WebGL uniform buffer to the GPU.
  7396. * @returns if Dynamic, otherwise false
  7397. */
  7398. isDynamic(): boolean;
  7399. /**
  7400. * The data cache on JS side.
  7401. * @returns the underlying data as a float array
  7402. */
  7403. getData(): Float32Array;
  7404. /**
  7405. * The underlying WebGL Uniform buffer.
  7406. * @returns the webgl buffer
  7407. */
  7408. getBuffer(): Nullable<DataBuffer>;
  7409. /**
  7410. * std140 layout specifies how to align data within an UBO structure.
  7411. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7412. * for specs.
  7413. */
  7414. private _fillAlignment;
  7415. /**
  7416. * Adds an uniform in the buffer.
  7417. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7418. * for the layout to be correct !
  7419. * @param name Name of the uniform, as used in the uniform block in the shader.
  7420. * @param size Data size, or data directly.
  7421. */
  7422. addUniform(name: string, size: number | number[]): void;
  7423. /**
  7424. * Adds a Matrix 4x4 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. * @param mat A 4x4 matrix.
  7427. */
  7428. addMatrix(name: string, mat: Matrix): void;
  7429. /**
  7430. * Adds a vec2 to the uniform buffer.
  7431. * @param name Name of the uniform, as used in the uniform block in the shader.
  7432. * @param x Define the x component value of the vec2
  7433. * @param y Define the y component value of the vec2
  7434. */
  7435. addFloat2(name: string, x: number, y: number): void;
  7436. /**
  7437. * Adds a vec3 to the uniform buffer.
  7438. * @param name Name of the uniform, as used in the uniform block in the shader.
  7439. * @param x Define the x component value of the vec3
  7440. * @param y Define the y component value of the vec3
  7441. * @param z Define the z component value of the vec3
  7442. */
  7443. addFloat3(name: string, x: number, y: number, z: number): void;
  7444. /**
  7445. * Adds a vec3 to the uniform buffer.
  7446. * @param name Name of the uniform, as used in the uniform block in the shader.
  7447. * @param color Define the vec3 from a Color
  7448. */
  7449. addColor3(name: string, color: Color3): void;
  7450. /**
  7451. * Adds a vec4 to the uniform buffer.
  7452. * @param name Name of the uniform, as used in the uniform block in the shader.
  7453. * @param color Define the rgb components from a Color
  7454. * @param alpha Define the a component of the vec4
  7455. */
  7456. addColor4(name: string, color: Color3, alpha: number): void;
  7457. /**
  7458. * Adds a vec3 to the uniform buffer.
  7459. * @param name Name of the uniform, as used in the uniform block in the shader.
  7460. * @param vector Define the vec3 components from a Vector
  7461. */
  7462. addVector3(name: string, vector: Vector3): void;
  7463. /**
  7464. * Adds a Matrix 3x3 to the uniform buffer.
  7465. * @param name Name of the uniform, as used in the uniform block in the shader.
  7466. */
  7467. addMatrix3x3(name: string): void;
  7468. /**
  7469. * Adds a Matrix 2x2 to the uniform buffer.
  7470. * @param name Name of the uniform, as used in the uniform block in the shader.
  7471. */
  7472. addMatrix2x2(name: string): void;
  7473. /**
  7474. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7475. */
  7476. create(): void;
  7477. /** @hidden */
  7478. _rebuild(): void;
  7479. /**
  7480. * Updates the WebGL Uniform Buffer on the GPU.
  7481. * If the `dynamic` flag is set to true, no cache comparison is done.
  7482. * Otherwise, the buffer will be updated only if the cache differs.
  7483. */
  7484. update(): void;
  7485. /**
  7486. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7487. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7488. * @param data Define the flattened data
  7489. * @param size Define the size of the data.
  7490. */
  7491. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7492. private _valueCache;
  7493. private _cacheMatrix;
  7494. private _updateMatrix3x3ForUniform;
  7495. private _updateMatrix3x3ForEffect;
  7496. private _updateMatrix2x2ForEffect;
  7497. private _updateMatrix2x2ForUniform;
  7498. private _updateFloatForEffect;
  7499. private _updateFloatForUniform;
  7500. private _updateFloat2ForEffect;
  7501. private _updateFloat2ForUniform;
  7502. private _updateFloat3ForEffect;
  7503. private _updateFloat3ForUniform;
  7504. private _updateFloat4ForEffect;
  7505. private _updateFloat4ForUniform;
  7506. private _updateMatrixForEffect;
  7507. private _updateMatrixForUniform;
  7508. private _updateVector3ForEffect;
  7509. private _updateVector3ForUniform;
  7510. private _updateVector4ForEffect;
  7511. private _updateVector4ForUniform;
  7512. private _updateColor3ForEffect;
  7513. private _updateColor3ForUniform;
  7514. private _updateColor4ForEffect;
  7515. private _updateColor4ForUniform;
  7516. /**
  7517. * Sets a sampler uniform on the effect.
  7518. * @param name Define the name of the sampler.
  7519. * @param texture Define the texture to set in the sampler
  7520. */
  7521. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7522. /**
  7523. * Directly updates the value of the uniform in the cache AND on the GPU.
  7524. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7525. * @param data Define the flattened data
  7526. */
  7527. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7528. /**
  7529. * Binds this uniform buffer to an effect.
  7530. * @param effect Define the effect to bind the buffer to
  7531. * @param name Name of the uniform block in the shader.
  7532. */
  7533. bindToEffect(effect: Effect, name: string): void;
  7534. /**
  7535. * Disposes the uniform buffer.
  7536. */
  7537. dispose(): void;
  7538. }
  7539. }
  7540. declare module BABYLON {
  7541. /**
  7542. * Enum that determines the text-wrapping mode to use.
  7543. */
  7544. export enum InspectableType {
  7545. /**
  7546. * Checkbox for booleans
  7547. */
  7548. Checkbox = 0,
  7549. /**
  7550. * Sliders for numbers
  7551. */
  7552. Slider = 1,
  7553. /**
  7554. * Vector3
  7555. */
  7556. Vector3 = 2,
  7557. /**
  7558. * Quaternions
  7559. */
  7560. Quaternion = 3,
  7561. /**
  7562. * Color3
  7563. */
  7564. Color3 = 4,
  7565. /**
  7566. * String
  7567. */
  7568. String = 5
  7569. }
  7570. /**
  7571. * Interface used to define custom inspectable properties.
  7572. * This interface is used by the inspector to display custom property grids
  7573. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7574. */
  7575. export interface IInspectable {
  7576. /**
  7577. * Gets the label to display
  7578. */
  7579. label: string;
  7580. /**
  7581. * Gets the name of the property to edit
  7582. */
  7583. propertyName: string;
  7584. /**
  7585. * Gets the type of the editor to use
  7586. */
  7587. type: InspectableType;
  7588. /**
  7589. * Gets the minimum value of the property when using in "slider" mode
  7590. */
  7591. min?: number;
  7592. /**
  7593. * Gets the maximum value of the property when using in "slider" mode
  7594. */
  7595. max?: number;
  7596. /**
  7597. * Gets the setp to use when using in "slider" mode
  7598. */
  7599. step?: number;
  7600. }
  7601. }
  7602. declare module BABYLON {
  7603. /**
  7604. * Class used to provide helper for timing
  7605. */
  7606. export class TimingTools {
  7607. /**
  7608. * Polyfill for setImmediate
  7609. * @param action defines the action to execute after the current execution block
  7610. */
  7611. static SetImmediate(action: () => void): void;
  7612. }
  7613. }
  7614. declare module BABYLON {
  7615. /**
  7616. * Class used to enable instatition of objects by class name
  7617. */
  7618. export class InstantiationTools {
  7619. /**
  7620. * Use this object to register external classes like custom textures or material
  7621. * to allow the laoders to instantiate them
  7622. */
  7623. static RegisteredExternalClasses: {
  7624. [key: string]: Object;
  7625. };
  7626. /**
  7627. * Tries to instantiate a new object from a given class name
  7628. * @param className defines the class name to instantiate
  7629. * @returns the new object or null if the system was not able to do the instantiation
  7630. */
  7631. static Instantiate(className: string): any;
  7632. }
  7633. }
  7634. declare module BABYLON {
  7635. /**
  7636. * Define options used to create a depth texture
  7637. */
  7638. export class DepthTextureCreationOptions {
  7639. /** Specifies whether or not a stencil should be allocated in the texture */
  7640. generateStencil?: boolean;
  7641. /** Specifies whether or not bilinear filtering is enable on the texture */
  7642. bilinearFiltering?: boolean;
  7643. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7644. comparisonFunction?: number;
  7645. /** Specifies if the created texture is a cube texture */
  7646. isCube?: boolean;
  7647. }
  7648. }
  7649. declare module BABYLON {
  7650. interface ThinEngine {
  7651. /**
  7652. * Creates a depth stencil cube texture.
  7653. * This is only available in WebGL 2.
  7654. * @param size The size of face edge in the cube texture.
  7655. * @param options The options defining the cube texture.
  7656. * @returns The cube texture
  7657. */
  7658. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7659. /**
  7660. * Creates a cube texture
  7661. * @param rootUrl defines the url where the files to load is located
  7662. * @param scene defines the current scene
  7663. * @param files defines the list of files to load (1 per face)
  7664. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7665. * @param onLoad defines an optional callback raised when the texture is loaded
  7666. * @param onError defines an optional callback raised if there is an issue to load the texture
  7667. * @param format defines the format of the data
  7668. * @param forcedExtension defines the extension to use to pick the right loader
  7669. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7670. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7671. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7672. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7673. * @returns the cube texture as an InternalTexture
  7674. */
  7675. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7676. /**
  7677. * Creates a cube texture
  7678. * @param rootUrl defines the url where the files to load is located
  7679. * @param scene defines the current scene
  7680. * @param files defines the list of files to load (1 per face)
  7681. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7682. * @param onLoad defines an optional callback raised when the texture is loaded
  7683. * @param onError defines an optional callback raised if there is an issue to load the texture
  7684. * @param format defines the format of the data
  7685. * @param forcedExtension defines the extension to use to pick the right loader
  7686. * @returns the cube texture as an InternalTexture
  7687. */
  7688. 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;
  7689. /**
  7690. * Creates a cube texture
  7691. * @param rootUrl defines the url where the files to load is located
  7692. * @param scene defines the current scene
  7693. * @param files defines the list of files to load (1 per face)
  7694. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7695. * @param onLoad defines an optional callback raised when the texture is loaded
  7696. * @param onError defines an optional callback raised if there is an issue to load the texture
  7697. * @param format defines the format of the data
  7698. * @param forcedExtension defines the extension to use to pick the right loader
  7699. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7700. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7701. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7702. * @returns the cube texture as an InternalTexture
  7703. */
  7704. 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;
  7705. /** @hidden */
  7706. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7707. /** @hidden */
  7708. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7709. /** @hidden */
  7710. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7711. /** @hidden */
  7712. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7713. /**
  7714. * @hidden
  7715. */
  7716. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7717. }
  7718. }
  7719. declare module BABYLON {
  7720. /**
  7721. * Class for creating a cube texture
  7722. */
  7723. export class CubeTexture extends BaseTexture {
  7724. private _delayedOnLoad;
  7725. /**
  7726. * Observable triggered once the texture has been loaded.
  7727. */
  7728. onLoadObservable: Observable<CubeTexture>;
  7729. /**
  7730. * The url of the texture
  7731. */
  7732. url: string;
  7733. /**
  7734. * Gets or sets the center of the bounding box associated with the cube texture.
  7735. * It must define where the camera used to render the texture was set
  7736. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7737. */
  7738. boundingBoxPosition: Vector3;
  7739. private _boundingBoxSize;
  7740. /**
  7741. * Gets or sets the size of the bounding box associated with the cube texture
  7742. * When defined, the cubemap will switch to local mode
  7743. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7744. * @example https://www.babylonjs-playground.com/#RNASML
  7745. */
  7746. set boundingBoxSize(value: Vector3);
  7747. /**
  7748. * Returns the bounding box size
  7749. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7750. */
  7751. get boundingBoxSize(): Vector3;
  7752. protected _rotationY: number;
  7753. /**
  7754. * Sets texture matrix rotation angle around Y axis in radians.
  7755. */
  7756. set rotationY(value: number);
  7757. /**
  7758. * Gets texture matrix rotation angle around Y axis radians.
  7759. */
  7760. get rotationY(): number;
  7761. /**
  7762. * Are mip maps generated for this texture or not.
  7763. */
  7764. get noMipmap(): boolean;
  7765. private _noMipmap;
  7766. private _files;
  7767. protected _forcedExtension: Nullable<string>;
  7768. private _extensions;
  7769. private _textureMatrix;
  7770. private _format;
  7771. private _createPolynomials;
  7772. /**
  7773. * Creates a cube texture from an array of image urls
  7774. * @param files defines an array of image urls
  7775. * @param scene defines the hosting scene
  7776. * @param noMipmap specifies if mip maps are not used
  7777. * @returns a cube texture
  7778. */
  7779. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7780. /**
  7781. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7782. * @param url defines the url of the prefiltered texture
  7783. * @param scene defines the scene the texture is attached to
  7784. * @param forcedExtension defines the extension of the file if different from the url
  7785. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7786. * @return the prefiltered texture
  7787. */
  7788. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7789. /**
  7790. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7791. * as prefiltered data.
  7792. * @param rootUrl defines the url of the texture or the root name of the six images
  7793. * @param null defines the scene or engine the texture is attached to
  7794. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7795. * @param noMipmap defines if mipmaps should be created or not
  7796. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7797. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7798. * @param onError defines a callback triggered in case of error during load
  7799. * @param format defines the internal format to use for the texture once loaded
  7800. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7801. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7802. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7803. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7804. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7805. * @return the cube texture
  7806. */
  7807. 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);
  7808. /**
  7809. * Get the current class name of the texture useful for serialization or dynamic coding.
  7810. * @returns "CubeTexture"
  7811. */
  7812. getClassName(): string;
  7813. /**
  7814. * Update the url (and optional buffer) of this texture if url was null during construction.
  7815. * @param url the url of the texture
  7816. * @param forcedExtension defines the extension to use
  7817. * @param onLoad callback called when the texture is loaded (defaults to null)
  7818. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7819. */
  7820. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7821. /**
  7822. * Delays loading of the cube texture
  7823. * @param forcedExtension defines the extension to use
  7824. */
  7825. delayLoad(forcedExtension?: string): void;
  7826. /**
  7827. * Returns the reflection texture matrix
  7828. * @returns the reflection texture matrix
  7829. */
  7830. getReflectionTextureMatrix(): Matrix;
  7831. /**
  7832. * Sets the reflection texture matrix
  7833. * @param value Reflection texture matrix
  7834. */
  7835. setReflectionTextureMatrix(value: Matrix): void;
  7836. /**
  7837. * Parses text to create a cube texture
  7838. * @param parsedTexture define the serialized text to read from
  7839. * @param scene defines the hosting scene
  7840. * @param rootUrl defines the root url of the cube texture
  7841. * @returns a cube texture
  7842. */
  7843. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7844. /**
  7845. * Makes a clone, or deep copy, of the cube texture
  7846. * @returns a new cube texture
  7847. */
  7848. clone(): CubeTexture;
  7849. }
  7850. }
  7851. declare module BABYLON {
  7852. /**
  7853. * Manages the defines for the Material
  7854. */
  7855. export class MaterialDefines {
  7856. /** @hidden */
  7857. protected _keys: string[];
  7858. private _isDirty;
  7859. /** @hidden */
  7860. _renderId: number;
  7861. /** @hidden */
  7862. _areLightsDirty: boolean;
  7863. /** @hidden */
  7864. _areLightsDisposed: boolean;
  7865. /** @hidden */
  7866. _areAttributesDirty: boolean;
  7867. /** @hidden */
  7868. _areTexturesDirty: boolean;
  7869. /** @hidden */
  7870. _areFresnelDirty: boolean;
  7871. /** @hidden */
  7872. _areMiscDirty: boolean;
  7873. /** @hidden */
  7874. _areImageProcessingDirty: boolean;
  7875. /** @hidden */
  7876. _normals: boolean;
  7877. /** @hidden */
  7878. _uvs: boolean;
  7879. /** @hidden */
  7880. _needNormals: boolean;
  7881. /** @hidden */
  7882. _needUVs: boolean;
  7883. [id: string]: any;
  7884. /**
  7885. * Specifies if the material needs to be re-calculated
  7886. */
  7887. get isDirty(): boolean;
  7888. /**
  7889. * Marks the material to indicate that it has been re-calculated
  7890. */
  7891. markAsProcessed(): void;
  7892. /**
  7893. * Marks the material to indicate that it needs to be re-calculated
  7894. */
  7895. markAsUnprocessed(): void;
  7896. /**
  7897. * Marks the material to indicate all of its defines need to be re-calculated
  7898. */
  7899. markAllAsDirty(): void;
  7900. /**
  7901. * Marks the material to indicate that image processing needs to be re-calculated
  7902. */
  7903. markAsImageProcessingDirty(): void;
  7904. /**
  7905. * Marks the material to indicate the lights need to be re-calculated
  7906. * @param disposed Defines whether the light is dirty due to dispose or not
  7907. */
  7908. markAsLightDirty(disposed?: boolean): void;
  7909. /**
  7910. * Marks the attribute state as changed
  7911. */
  7912. markAsAttributesDirty(): void;
  7913. /**
  7914. * Marks the texture state as changed
  7915. */
  7916. markAsTexturesDirty(): void;
  7917. /**
  7918. * Marks the fresnel state as changed
  7919. */
  7920. markAsFresnelDirty(): void;
  7921. /**
  7922. * Marks the misc state as changed
  7923. */
  7924. markAsMiscDirty(): void;
  7925. /**
  7926. * Rebuilds the material defines
  7927. */
  7928. rebuild(): void;
  7929. /**
  7930. * Specifies if two material defines are equal
  7931. * @param other - A material define instance to compare to
  7932. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7933. */
  7934. isEqual(other: MaterialDefines): boolean;
  7935. /**
  7936. * Clones this instance's defines to another instance
  7937. * @param other - material defines to clone values to
  7938. */
  7939. cloneTo(other: MaterialDefines): void;
  7940. /**
  7941. * Resets the material define values
  7942. */
  7943. reset(): void;
  7944. /**
  7945. * Converts the material define values to a string
  7946. * @returns - String of material define information
  7947. */
  7948. toString(): string;
  7949. }
  7950. }
  7951. declare module BABYLON {
  7952. /**
  7953. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7954. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7955. * 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;
  7956. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7957. */
  7958. export class ColorCurves {
  7959. private _dirty;
  7960. private _tempColor;
  7961. private _globalCurve;
  7962. private _highlightsCurve;
  7963. private _midtonesCurve;
  7964. private _shadowsCurve;
  7965. private _positiveCurve;
  7966. private _negativeCurve;
  7967. private _globalHue;
  7968. private _globalDensity;
  7969. private _globalSaturation;
  7970. private _globalExposure;
  7971. /**
  7972. * Gets the global Hue value.
  7973. * 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).
  7974. */
  7975. get globalHue(): number;
  7976. /**
  7977. * Sets the global Hue value.
  7978. * 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).
  7979. */
  7980. set globalHue(value: number);
  7981. /**
  7982. * Gets the global Density value.
  7983. * 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.
  7984. * Values less than zero provide a filter of opposite hue.
  7985. */
  7986. get globalDensity(): number;
  7987. /**
  7988. * Sets the global Density value.
  7989. * 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.
  7990. * Values less than zero provide a filter of opposite hue.
  7991. */
  7992. set globalDensity(value: number);
  7993. /**
  7994. * Gets the global Saturation value.
  7995. * 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.
  7996. */
  7997. get globalSaturation(): number;
  7998. /**
  7999. * Sets the global Saturation value.
  8000. * 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.
  8001. */
  8002. set globalSaturation(value: number);
  8003. /**
  8004. * Gets the global Exposure value.
  8005. * 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.
  8006. */
  8007. get globalExposure(): number;
  8008. /**
  8009. * Sets the global Exposure value.
  8010. * 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.
  8011. */
  8012. set globalExposure(value: number);
  8013. private _highlightsHue;
  8014. private _highlightsDensity;
  8015. private _highlightsSaturation;
  8016. private _highlightsExposure;
  8017. /**
  8018. * Gets the highlights Hue value.
  8019. * 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).
  8020. */
  8021. get highlightsHue(): number;
  8022. /**
  8023. * Sets the highlights Hue value.
  8024. * 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).
  8025. */
  8026. set highlightsHue(value: number);
  8027. /**
  8028. * Gets the highlights Density value.
  8029. * 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.
  8030. * Values less than zero provide a filter of opposite hue.
  8031. */
  8032. get highlightsDensity(): number;
  8033. /**
  8034. * Sets the highlights Density value.
  8035. * 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.
  8036. * Values less than zero provide a filter of opposite hue.
  8037. */
  8038. set highlightsDensity(value: number);
  8039. /**
  8040. * Gets the highlights Saturation value.
  8041. * 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.
  8042. */
  8043. get highlightsSaturation(): number;
  8044. /**
  8045. * Sets the highlights Saturation value.
  8046. * 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.
  8047. */
  8048. set highlightsSaturation(value: number);
  8049. /**
  8050. * Gets the highlights Exposure value.
  8051. * 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.
  8052. */
  8053. get highlightsExposure(): number;
  8054. /**
  8055. * Sets the highlights Exposure value.
  8056. * 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.
  8057. */
  8058. set highlightsExposure(value: number);
  8059. private _midtonesHue;
  8060. private _midtonesDensity;
  8061. private _midtonesSaturation;
  8062. private _midtonesExposure;
  8063. /**
  8064. * Gets the midtones Hue value.
  8065. * 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).
  8066. */
  8067. get midtonesHue(): number;
  8068. /**
  8069. * Sets the midtones Hue value.
  8070. * 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).
  8071. */
  8072. set midtonesHue(value: number);
  8073. /**
  8074. * Gets the midtones Density value.
  8075. * 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.
  8076. * Values less than zero provide a filter of opposite hue.
  8077. */
  8078. get midtonesDensity(): number;
  8079. /**
  8080. * Sets the midtones Density value.
  8081. * 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.
  8082. * Values less than zero provide a filter of opposite hue.
  8083. */
  8084. set midtonesDensity(value: number);
  8085. /**
  8086. * Gets the midtones Saturation value.
  8087. * 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.
  8088. */
  8089. get midtonesSaturation(): number;
  8090. /**
  8091. * Sets the midtones Saturation value.
  8092. * 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.
  8093. */
  8094. set midtonesSaturation(value: number);
  8095. /**
  8096. * Gets the midtones Exposure value.
  8097. * 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.
  8098. */
  8099. get midtonesExposure(): number;
  8100. /**
  8101. * Sets the midtones Exposure value.
  8102. * 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.
  8103. */
  8104. set midtonesExposure(value: number);
  8105. private _shadowsHue;
  8106. private _shadowsDensity;
  8107. private _shadowsSaturation;
  8108. private _shadowsExposure;
  8109. /**
  8110. * Gets the shadows Hue value.
  8111. * 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).
  8112. */
  8113. get shadowsHue(): number;
  8114. /**
  8115. * Sets the shadows Hue value.
  8116. * 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).
  8117. */
  8118. set shadowsHue(value: number);
  8119. /**
  8120. * Gets the shadows Density value.
  8121. * 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.
  8122. * Values less than zero provide a filter of opposite hue.
  8123. */
  8124. get shadowsDensity(): number;
  8125. /**
  8126. * Sets the shadows Density value.
  8127. * 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.
  8128. * Values less than zero provide a filter of opposite hue.
  8129. */
  8130. set shadowsDensity(value: number);
  8131. /**
  8132. * Gets the shadows Saturation value.
  8133. * 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.
  8134. */
  8135. get shadowsSaturation(): number;
  8136. /**
  8137. * Sets the shadows Saturation value.
  8138. * 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.
  8139. */
  8140. set shadowsSaturation(value: number);
  8141. /**
  8142. * Gets the shadows Exposure value.
  8143. * 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.
  8144. */
  8145. get shadowsExposure(): number;
  8146. /**
  8147. * Sets the shadows Exposure value.
  8148. * 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.
  8149. */
  8150. set shadowsExposure(value: number);
  8151. /**
  8152. * Returns the class name
  8153. * @returns The class name
  8154. */
  8155. getClassName(): string;
  8156. /**
  8157. * Binds the color curves to the shader.
  8158. * @param colorCurves The color curve to bind
  8159. * @param effect The effect to bind to
  8160. * @param positiveUniform The positive uniform shader parameter
  8161. * @param neutralUniform The neutral uniform shader parameter
  8162. * @param negativeUniform The negative uniform shader parameter
  8163. */
  8164. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8165. /**
  8166. * Prepare the list of uniforms associated with the ColorCurves effects.
  8167. * @param uniformsList The list of uniforms used in the effect
  8168. */
  8169. static PrepareUniforms(uniformsList: string[]): void;
  8170. /**
  8171. * Returns color grading data based on a hue, density, saturation and exposure value.
  8172. * @param filterHue The hue of the color filter.
  8173. * @param filterDensity The density of the color filter.
  8174. * @param saturation The saturation.
  8175. * @param exposure The exposure.
  8176. * @param result The result data container.
  8177. */
  8178. private getColorGradingDataToRef;
  8179. /**
  8180. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8181. * @param value The input slider value in range [-100,100].
  8182. * @returns Adjusted value.
  8183. */
  8184. private static applyColorGradingSliderNonlinear;
  8185. /**
  8186. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8187. * @param hue The hue (H) input.
  8188. * @param saturation The saturation (S) input.
  8189. * @param brightness The brightness (B) input.
  8190. * @result An RGBA color represented as Vector4.
  8191. */
  8192. private static fromHSBToRef;
  8193. /**
  8194. * Returns a value clamped between min and max
  8195. * @param value The value to clamp
  8196. * @param min The minimum of value
  8197. * @param max The maximum of value
  8198. * @returns The clamped value.
  8199. */
  8200. private static clamp;
  8201. /**
  8202. * Clones the current color curve instance.
  8203. * @return The cloned curves
  8204. */
  8205. clone(): ColorCurves;
  8206. /**
  8207. * Serializes the current color curve instance to a json representation.
  8208. * @return a JSON representation
  8209. */
  8210. serialize(): any;
  8211. /**
  8212. * Parses the color curve from a json representation.
  8213. * @param source the JSON source to parse
  8214. * @return The parsed curves
  8215. */
  8216. static Parse(source: any): ColorCurves;
  8217. }
  8218. }
  8219. declare module BABYLON {
  8220. /**
  8221. * Interface to follow in your material defines to integrate easily the
  8222. * Image proccessing functions.
  8223. * @hidden
  8224. */
  8225. export interface IImageProcessingConfigurationDefines {
  8226. IMAGEPROCESSING: boolean;
  8227. VIGNETTE: boolean;
  8228. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8229. VIGNETTEBLENDMODEOPAQUE: boolean;
  8230. TONEMAPPING: boolean;
  8231. TONEMAPPING_ACES: boolean;
  8232. CONTRAST: boolean;
  8233. EXPOSURE: boolean;
  8234. COLORCURVES: boolean;
  8235. COLORGRADING: boolean;
  8236. COLORGRADING3D: boolean;
  8237. SAMPLER3DGREENDEPTH: boolean;
  8238. SAMPLER3DBGRMAP: boolean;
  8239. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8240. }
  8241. /**
  8242. * @hidden
  8243. */
  8244. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8245. IMAGEPROCESSING: boolean;
  8246. VIGNETTE: boolean;
  8247. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8248. VIGNETTEBLENDMODEOPAQUE: boolean;
  8249. TONEMAPPING: boolean;
  8250. TONEMAPPING_ACES: boolean;
  8251. CONTRAST: boolean;
  8252. COLORCURVES: boolean;
  8253. COLORGRADING: boolean;
  8254. COLORGRADING3D: boolean;
  8255. SAMPLER3DGREENDEPTH: boolean;
  8256. SAMPLER3DBGRMAP: boolean;
  8257. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8258. EXPOSURE: boolean;
  8259. constructor();
  8260. }
  8261. /**
  8262. * This groups together the common properties used for image processing either in direct forward pass
  8263. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8264. * or not.
  8265. */
  8266. export class ImageProcessingConfiguration {
  8267. /**
  8268. * Default tone mapping applied in BabylonJS.
  8269. */
  8270. static readonly TONEMAPPING_STANDARD: number;
  8271. /**
  8272. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8273. * to other engines rendering to increase portability.
  8274. */
  8275. static readonly TONEMAPPING_ACES: number;
  8276. /**
  8277. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8278. */
  8279. colorCurves: Nullable<ColorCurves>;
  8280. private _colorCurvesEnabled;
  8281. /**
  8282. * Gets wether the color curves effect is enabled.
  8283. */
  8284. get colorCurvesEnabled(): boolean;
  8285. /**
  8286. * Sets wether the color curves effect is enabled.
  8287. */
  8288. set colorCurvesEnabled(value: boolean);
  8289. private _colorGradingTexture;
  8290. /**
  8291. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8292. */
  8293. get colorGradingTexture(): Nullable<BaseTexture>;
  8294. /**
  8295. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8296. */
  8297. set colorGradingTexture(value: Nullable<BaseTexture>);
  8298. private _colorGradingEnabled;
  8299. /**
  8300. * Gets wether the color grading effect is enabled.
  8301. */
  8302. get colorGradingEnabled(): boolean;
  8303. /**
  8304. * Sets wether the color grading effect is enabled.
  8305. */
  8306. set colorGradingEnabled(value: boolean);
  8307. private _colorGradingWithGreenDepth;
  8308. /**
  8309. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8310. */
  8311. get colorGradingWithGreenDepth(): boolean;
  8312. /**
  8313. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8314. */
  8315. set colorGradingWithGreenDepth(value: boolean);
  8316. private _colorGradingBGR;
  8317. /**
  8318. * Gets wether the color grading texture contains BGR values.
  8319. */
  8320. get colorGradingBGR(): boolean;
  8321. /**
  8322. * Sets wether the color grading texture contains BGR values.
  8323. */
  8324. set colorGradingBGR(value: boolean);
  8325. /** @hidden */
  8326. _exposure: number;
  8327. /**
  8328. * Gets the Exposure used in the effect.
  8329. */
  8330. get exposure(): number;
  8331. /**
  8332. * Sets the Exposure used in the effect.
  8333. */
  8334. set exposure(value: number);
  8335. private _toneMappingEnabled;
  8336. /**
  8337. * Gets wether the tone mapping effect is enabled.
  8338. */
  8339. get toneMappingEnabled(): boolean;
  8340. /**
  8341. * Sets wether the tone mapping effect is enabled.
  8342. */
  8343. set toneMappingEnabled(value: boolean);
  8344. private _toneMappingType;
  8345. /**
  8346. * Gets the type of tone mapping effect.
  8347. */
  8348. get toneMappingType(): number;
  8349. /**
  8350. * Sets the type of tone mapping effect used in BabylonJS.
  8351. */
  8352. set toneMappingType(value: number);
  8353. protected _contrast: number;
  8354. /**
  8355. * Gets the contrast used in the effect.
  8356. */
  8357. get contrast(): number;
  8358. /**
  8359. * Sets the contrast used in the effect.
  8360. */
  8361. set contrast(value: number);
  8362. /**
  8363. * Vignette stretch size.
  8364. */
  8365. vignetteStretch: number;
  8366. /**
  8367. * Vignette centre X Offset.
  8368. */
  8369. vignetteCentreX: number;
  8370. /**
  8371. * Vignette centre Y Offset.
  8372. */
  8373. vignetteCentreY: number;
  8374. /**
  8375. * Vignette weight or intensity of the vignette effect.
  8376. */
  8377. vignetteWeight: number;
  8378. /**
  8379. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8380. * if vignetteEnabled is set to true.
  8381. */
  8382. vignetteColor: Color4;
  8383. /**
  8384. * Camera field of view used by the Vignette effect.
  8385. */
  8386. vignetteCameraFov: number;
  8387. private _vignetteBlendMode;
  8388. /**
  8389. * Gets the vignette blend mode allowing different kind of effect.
  8390. */
  8391. get vignetteBlendMode(): number;
  8392. /**
  8393. * Sets the vignette blend mode allowing different kind of effect.
  8394. */
  8395. set vignetteBlendMode(value: number);
  8396. private _vignetteEnabled;
  8397. /**
  8398. * Gets wether the vignette effect is enabled.
  8399. */
  8400. get vignetteEnabled(): boolean;
  8401. /**
  8402. * Sets wether the vignette effect is enabled.
  8403. */
  8404. set vignetteEnabled(value: boolean);
  8405. private _applyByPostProcess;
  8406. /**
  8407. * Gets wether the image processing is applied through a post process or not.
  8408. */
  8409. get applyByPostProcess(): boolean;
  8410. /**
  8411. * Sets wether the image processing is applied through a post process or not.
  8412. */
  8413. set applyByPostProcess(value: boolean);
  8414. private _isEnabled;
  8415. /**
  8416. * Gets wether the image processing is enabled or not.
  8417. */
  8418. get isEnabled(): boolean;
  8419. /**
  8420. * Sets wether the image processing is enabled or not.
  8421. */
  8422. set isEnabled(value: boolean);
  8423. /**
  8424. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8425. */
  8426. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8427. /**
  8428. * Method called each time the image processing information changes requires to recompile the effect.
  8429. */
  8430. protected _updateParameters(): void;
  8431. /**
  8432. * Gets the current class name.
  8433. * @return "ImageProcessingConfiguration"
  8434. */
  8435. getClassName(): string;
  8436. /**
  8437. * Prepare the list of uniforms associated with the Image Processing effects.
  8438. * @param uniforms The list of uniforms used in the effect
  8439. * @param defines the list of defines currently in use
  8440. */
  8441. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8442. /**
  8443. * Prepare the list of samplers associated with the Image Processing effects.
  8444. * @param samplersList The list of uniforms used in the effect
  8445. * @param defines the list of defines currently in use
  8446. */
  8447. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8448. /**
  8449. * Prepare the list of defines associated to the shader.
  8450. * @param defines the list of defines to complete
  8451. * @param forPostProcess Define if we are currently in post process mode or not
  8452. */
  8453. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8454. /**
  8455. * Returns true if all the image processing information are ready.
  8456. * @returns True if ready, otherwise, false
  8457. */
  8458. isReady(): boolean;
  8459. /**
  8460. * Binds the image processing to the shader.
  8461. * @param effect The effect to bind to
  8462. * @param overrideAspectRatio Override the aspect ratio of the effect
  8463. */
  8464. bind(effect: Effect, overrideAspectRatio?: number): void;
  8465. /**
  8466. * Clones the current image processing instance.
  8467. * @return The cloned image processing
  8468. */
  8469. clone(): ImageProcessingConfiguration;
  8470. /**
  8471. * Serializes the current image processing instance to a json representation.
  8472. * @return a JSON representation
  8473. */
  8474. serialize(): any;
  8475. /**
  8476. * Parses the image processing from a json representation.
  8477. * @param source the JSON source to parse
  8478. * @return The parsed image processing
  8479. */
  8480. static Parse(source: any): ImageProcessingConfiguration;
  8481. private static _VIGNETTEMODE_MULTIPLY;
  8482. private static _VIGNETTEMODE_OPAQUE;
  8483. /**
  8484. * Used to apply the vignette as a mix with the pixel color.
  8485. */
  8486. static get VIGNETTEMODE_MULTIPLY(): number;
  8487. /**
  8488. * Used to apply the vignette as a replacement of the pixel color.
  8489. */
  8490. static get VIGNETTEMODE_OPAQUE(): number;
  8491. }
  8492. }
  8493. declare module BABYLON {
  8494. /** @hidden */
  8495. export var postprocessVertexShader: {
  8496. name: string;
  8497. shader: string;
  8498. };
  8499. }
  8500. declare module BABYLON {
  8501. interface ThinEngine {
  8502. /**
  8503. * Creates a new render target texture
  8504. * @param size defines the size of the texture
  8505. * @param options defines the options used to create the texture
  8506. * @returns a new render target texture stored in an InternalTexture
  8507. */
  8508. createRenderTargetTexture(size: number | {
  8509. width: number;
  8510. height: number;
  8511. layers?: number;
  8512. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8513. /**
  8514. * Creates a depth stencil texture.
  8515. * This is only available in WebGL 2 or with the depth texture extension available.
  8516. * @param size The size of face edge in the texture.
  8517. * @param options The options defining the texture.
  8518. * @returns The texture
  8519. */
  8520. createDepthStencilTexture(size: number | {
  8521. width: number;
  8522. height: number;
  8523. layers?: number;
  8524. }, options: DepthTextureCreationOptions): InternalTexture;
  8525. /** @hidden */
  8526. _createDepthStencilTexture(size: number | {
  8527. width: number;
  8528. height: number;
  8529. layers?: number;
  8530. }, options: DepthTextureCreationOptions): InternalTexture;
  8531. }
  8532. }
  8533. declare module BABYLON {
  8534. /**
  8535. * Defines the kind of connection point for node based material
  8536. */
  8537. export enum NodeMaterialBlockConnectionPointTypes {
  8538. /** Float */
  8539. Float = 1,
  8540. /** Int */
  8541. Int = 2,
  8542. /** Vector2 */
  8543. Vector2 = 4,
  8544. /** Vector3 */
  8545. Vector3 = 8,
  8546. /** Vector4 */
  8547. Vector4 = 16,
  8548. /** Color3 */
  8549. Color3 = 32,
  8550. /** Color4 */
  8551. Color4 = 64,
  8552. /** Matrix */
  8553. Matrix = 128,
  8554. /** Custom object */
  8555. Object = 256,
  8556. /** Detect type based on connection */
  8557. AutoDetect = 1024,
  8558. /** Output type that will be defined by input type */
  8559. BasedOnInput = 2048
  8560. }
  8561. }
  8562. declare module BABYLON {
  8563. /**
  8564. * Enum used to define the target of a block
  8565. */
  8566. export enum NodeMaterialBlockTargets {
  8567. /** Vertex shader */
  8568. Vertex = 1,
  8569. /** Fragment shader */
  8570. Fragment = 2,
  8571. /** Neutral */
  8572. Neutral = 4,
  8573. /** Vertex and Fragment */
  8574. VertexAndFragment = 3
  8575. }
  8576. }
  8577. declare module BABYLON {
  8578. /**
  8579. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8580. */
  8581. export enum NodeMaterialBlockConnectionPointMode {
  8582. /** Value is an uniform */
  8583. Uniform = 0,
  8584. /** Value is a mesh attribute */
  8585. Attribute = 1,
  8586. /** Value is a varying between vertex and fragment shaders */
  8587. Varying = 2,
  8588. /** Mode is undefined */
  8589. Undefined = 3
  8590. }
  8591. }
  8592. declare module BABYLON {
  8593. /**
  8594. * Enum used to define system values e.g. values automatically provided by the system
  8595. */
  8596. export enum NodeMaterialSystemValues {
  8597. /** World */
  8598. World = 1,
  8599. /** View */
  8600. View = 2,
  8601. /** Projection */
  8602. Projection = 3,
  8603. /** ViewProjection */
  8604. ViewProjection = 4,
  8605. /** WorldView */
  8606. WorldView = 5,
  8607. /** WorldViewProjection */
  8608. WorldViewProjection = 6,
  8609. /** CameraPosition */
  8610. CameraPosition = 7,
  8611. /** Fog Color */
  8612. FogColor = 8,
  8613. /** Delta time */
  8614. DeltaTime = 9
  8615. }
  8616. }
  8617. declare module BABYLON {
  8618. /** Defines supported spaces */
  8619. export enum Space {
  8620. /** Local (object) space */
  8621. LOCAL = 0,
  8622. /** World space */
  8623. WORLD = 1,
  8624. /** Bone space */
  8625. BONE = 2
  8626. }
  8627. /** Defines the 3 main axes */
  8628. export class Axis {
  8629. /** X axis */
  8630. static X: Vector3;
  8631. /** Y axis */
  8632. static Y: Vector3;
  8633. /** Z axis */
  8634. static Z: Vector3;
  8635. }
  8636. }
  8637. declare module BABYLON {
  8638. /**
  8639. * Represents a camera frustum
  8640. */
  8641. export class Frustum {
  8642. /**
  8643. * Gets the planes representing the frustum
  8644. * @param transform matrix to be applied to the returned planes
  8645. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8646. */
  8647. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8648. /**
  8649. * Gets the near frustum plane transformed by the transform matrix
  8650. * @param transform transformation matrix to be applied to the resulting frustum plane
  8651. * @param frustumPlane the resuling frustum plane
  8652. */
  8653. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8654. /**
  8655. * Gets the far frustum plane transformed by the transform matrix
  8656. * @param transform transformation matrix to be applied to the resulting frustum plane
  8657. * @param frustumPlane the resuling frustum plane
  8658. */
  8659. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8660. /**
  8661. * Gets the left frustum plane transformed by the transform matrix
  8662. * @param transform transformation matrix to be applied to the resulting frustum plane
  8663. * @param frustumPlane the resuling frustum plane
  8664. */
  8665. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8666. /**
  8667. * Gets the right frustum plane transformed by the transform matrix
  8668. * @param transform transformation matrix to be applied to the resulting frustum plane
  8669. * @param frustumPlane the resuling frustum plane
  8670. */
  8671. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8672. /**
  8673. * Gets the top frustum plane transformed by the transform matrix
  8674. * @param transform transformation matrix to be applied to the resulting frustum plane
  8675. * @param frustumPlane the resuling frustum plane
  8676. */
  8677. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8678. /**
  8679. * Gets the bottom frustum plane transformed by the transform matrix
  8680. * @param transform transformation matrix to be applied to the resulting frustum plane
  8681. * @param frustumPlane the resuling frustum plane
  8682. */
  8683. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8684. /**
  8685. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8686. * @param transform transformation matrix to be applied to the resulting frustum planes
  8687. * @param frustumPlanes the resuling frustum planes
  8688. */
  8689. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8690. }
  8691. }
  8692. declare module BABYLON {
  8693. /**
  8694. * Interface for the size containing width and height
  8695. */
  8696. export interface ISize {
  8697. /**
  8698. * Width
  8699. */
  8700. width: number;
  8701. /**
  8702. * Heighht
  8703. */
  8704. height: number;
  8705. }
  8706. /**
  8707. * Size containing widht and height
  8708. */
  8709. export class Size implements ISize {
  8710. /**
  8711. * Width
  8712. */
  8713. width: number;
  8714. /**
  8715. * Height
  8716. */
  8717. height: number;
  8718. /**
  8719. * Creates a Size object from the given width and height (floats).
  8720. * @param width width of the new size
  8721. * @param height height of the new size
  8722. */
  8723. constructor(width: number, height: number);
  8724. /**
  8725. * Returns a string with the Size width and height
  8726. * @returns a string with the Size width and height
  8727. */
  8728. toString(): string;
  8729. /**
  8730. * "Size"
  8731. * @returns the string "Size"
  8732. */
  8733. getClassName(): string;
  8734. /**
  8735. * Returns the Size hash code.
  8736. * @returns a hash code for a unique width and height
  8737. */
  8738. getHashCode(): number;
  8739. /**
  8740. * Updates the current size from the given one.
  8741. * @param src the given size
  8742. */
  8743. copyFrom(src: Size): void;
  8744. /**
  8745. * Updates in place the current Size from the given floats.
  8746. * @param width width of the new size
  8747. * @param height height of the new size
  8748. * @returns the updated Size.
  8749. */
  8750. copyFromFloats(width: number, height: number): Size;
  8751. /**
  8752. * Updates in place the current Size from the given floats.
  8753. * @param width width to set
  8754. * @param height height to set
  8755. * @returns the updated Size.
  8756. */
  8757. set(width: number, height: number): Size;
  8758. /**
  8759. * Multiplies the width and height by numbers
  8760. * @param w factor to multiple the width by
  8761. * @param h factor to multiple the height by
  8762. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8763. */
  8764. multiplyByFloats(w: number, h: number): Size;
  8765. /**
  8766. * Clones the size
  8767. * @returns a new Size copied from the given one.
  8768. */
  8769. clone(): Size;
  8770. /**
  8771. * True if the current Size and the given one width and height are strictly equal.
  8772. * @param other the other size to compare against
  8773. * @returns True if the current Size and the given one width and height are strictly equal.
  8774. */
  8775. equals(other: Size): boolean;
  8776. /**
  8777. * The surface of the Size : width * height (float).
  8778. */
  8779. get surface(): number;
  8780. /**
  8781. * Create a new size of zero
  8782. * @returns a new Size set to (0.0, 0.0)
  8783. */
  8784. static Zero(): Size;
  8785. /**
  8786. * Sums the width and height of two sizes
  8787. * @param otherSize size to add to this size
  8788. * @returns a new Size set as the addition result of the current Size and the given one.
  8789. */
  8790. add(otherSize: Size): Size;
  8791. /**
  8792. * Subtracts the width and height of two
  8793. * @param otherSize size to subtract to this size
  8794. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8795. */
  8796. subtract(otherSize: Size): Size;
  8797. /**
  8798. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8799. * @param start starting size to lerp between
  8800. * @param end end size to lerp between
  8801. * @param amount amount to lerp between the start and end values
  8802. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8803. */
  8804. static Lerp(start: Size, end: Size, amount: number): Size;
  8805. }
  8806. }
  8807. declare module BABYLON {
  8808. /**
  8809. * Contains position and normal vectors for a vertex
  8810. */
  8811. export class PositionNormalVertex {
  8812. /** the position of the vertex (defaut: 0,0,0) */
  8813. position: Vector3;
  8814. /** the normal of the vertex (defaut: 0,1,0) */
  8815. normal: Vector3;
  8816. /**
  8817. * Creates a PositionNormalVertex
  8818. * @param position the position of the vertex (defaut: 0,0,0)
  8819. * @param normal the normal of the vertex (defaut: 0,1,0)
  8820. */
  8821. constructor(
  8822. /** the position of the vertex (defaut: 0,0,0) */
  8823. position?: Vector3,
  8824. /** the normal of the vertex (defaut: 0,1,0) */
  8825. normal?: Vector3);
  8826. /**
  8827. * Clones the PositionNormalVertex
  8828. * @returns the cloned PositionNormalVertex
  8829. */
  8830. clone(): PositionNormalVertex;
  8831. }
  8832. /**
  8833. * Contains position, normal and uv vectors for a vertex
  8834. */
  8835. export class PositionNormalTextureVertex {
  8836. /** the position of the vertex (defaut: 0,0,0) */
  8837. position: Vector3;
  8838. /** the normal of the vertex (defaut: 0,1,0) */
  8839. normal: Vector3;
  8840. /** the uv of the vertex (default: 0,0) */
  8841. uv: Vector2;
  8842. /**
  8843. * Creates a PositionNormalTextureVertex
  8844. * @param position the position of the vertex (defaut: 0,0,0)
  8845. * @param normal the normal of the vertex (defaut: 0,1,0)
  8846. * @param uv the uv of the vertex (default: 0,0)
  8847. */
  8848. constructor(
  8849. /** the position of the vertex (defaut: 0,0,0) */
  8850. position?: Vector3,
  8851. /** the normal of the vertex (defaut: 0,1,0) */
  8852. normal?: Vector3,
  8853. /** the uv of the vertex (default: 0,0) */
  8854. uv?: Vector2);
  8855. /**
  8856. * Clones the PositionNormalTextureVertex
  8857. * @returns the cloned PositionNormalTextureVertex
  8858. */
  8859. clone(): PositionNormalTextureVertex;
  8860. }
  8861. }
  8862. declare module BABYLON {
  8863. /**
  8864. * Enum defining the type of animations supported by InputBlock
  8865. */
  8866. export enum AnimatedInputBlockTypes {
  8867. /** No animation */
  8868. None = 0,
  8869. /** Time based animation. Will only work for floats */
  8870. Time = 1
  8871. }
  8872. }
  8873. declare module BABYLON {
  8874. /**
  8875. * Interface describing all the common properties and methods a shadow light needs to implement.
  8876. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8877. * as well as binding the different shadow properties to the effects.
  8878. */
  8879. export interface IShadowLight extends Light {
  8880. /**
  8881. * The light id in the scene (used in scene.findLighById for instance)
  8882. */
  8883. id: string;
  8884. /**
  8885. * The position the shdow will be casted from.
  8886. */
  8887. position: Vector3;
  8888. /**
  8889. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8890. */
  8891. direction: Vector3;
  8892. /**
  8893. * The transformed position. Position of the light in world space taking parenting in account.
  8894. */
  8895. transformedPosition: Vector3;
  8896. /**
  8897. * The transformed direction. Direction of the light in world space taking parenting in account.
  8898. */
  8899. transformedDirection: Vector3;
  8900. /**
  8901. * The friendly name of the light in the scene.
  8902. */
  8903. name: string;
  8904. /**
  8905. * Defines the shadow projection clipping minimum z value.
  8906. */
  8907. shadowMinZ: number;
  8908. /**
  8909. * Defines the shadow projection clipping maximum z value.
  8910. */
  8911. shadowMaxZ: number;
  8912. /**
  8913. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8914. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8915. */
  8916. computeTransformedInformation(): boolean;
  8917. /**
  8918. * Gets the scene the light belongs to.
  8919. * @returns The scene
  8920. */
  8921. getScene(): Scene;
  8922. /**
  8923. * Callback defining a custom Projection Matrix Builder.
  8924. * This can be used to override the default projection matrix computation.
  8925. */
  8926. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8927. /**
  8928. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8929. * @param matrix The materix to updated with the projection information
  8930. * @param viewMatrix The transform matrix of the light
  8931. * @param renderList The list of mesh to render in the map
  8932. * @returns The current light
  8933. */
  8934. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8935. /**
  8936. * Gets the current depth scale used in ESM.
  8937. * @returns The scale
  8938. */
  8939. getDepthScale(): number;
  8940. /**
  8941. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8942. * @returns true if a cube texture needs to be use
  8943. */
  8944. needCube(): boolean;
  8945. /**
  8946. * Detects if the projection matrix requires to be recomputed this frame.
  8947. * @returns true if it requires to be recomputed otherwise, false.
  8948. */
  8949. needProjectionMatrixCompute(): boolean;
  8950. /**
  8951. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8952. */
  8953. forceProjectionMatrixCompute(): void;
  8954. /**
  8955. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8956. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8957. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8958. */
  8959. getShadowDirection(faceIndex?: number): Vector3;
  8960. /**
  8961. * Gets the minZ used for shadow according to both the scene and the light.
  8962. * @param activeCamera The camera we are returning the min for
  8963. * @returns the depth min z
  8964. */
  8965. getDepthMinZ(activeCamera: Camera): number;
  8966. /**
  8967. * Gets the maxZ used for shadow according to both the scene and the light.
  8968. * @param activeCamera The camera we are returning the max for
  8969. * @returns the depth max z
  8970. */
  8971. getDepthMaxZ(activeCamera: Camera): number;
  8972. }
  8973. /**
  8974. * Base implementation IShadowLight
  8975. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8976. */
  8977. export abstract class ShadowLight extends Light implements IShadowLight {
  8978. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8979. protected _position: Vector3;
  8980. protected _setPosition(value: Vector3): void;
  8981. /**
  8982. * Sets the position the shadow will be casted from. Also use as the light position for both
  8983. * point and spot lights.
  8984. */
  8985. get position(): Vector3;
  8986. /**
  8987. * Sets the position the shadow will be casted from. Also use as the light position for both
  8988. * point and spot lights.
  8989. */
  8990. set position(value: Vector3);
  8991. protected _direction: Vector3;
  8992. protected _setDirection(value: Vector3): void;
  8993. /**
  8994. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8995. * Also use as the light direction on spot and directional lights.
  8996. */
  8997. get direction(): Vector3;
  8998. /**
  8999. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9000. * Also use as the light direction on spot and directional lights.
  9001. */
  9002. set direction(value: Vector3);
  9003. protected _shadowMinZ: number;
  9004. /**
  9005. * Gets the shadow projection clipping minimum z value.
  9006. */
  9007. get shadowMinZ(): number;
  9008. /**
  9009. * Sets the shadow projection clipping minimum z value.
  9010. */
  9011. set shadowMinZ(value: number);
  9012. protected _shadowMaxZ: number;
  9013. /**
  9014. * Sets the shadow projection clipping maximum z value.
  9015. */
  9016. get shadowMaxZ(): number;
  9017. /**
  9018. * Gets the shadow projection clipping maximum z value.
  9019. */
  9020. set shadowMaxZ(value: number);
  9021. /**
  9022. * Callback defining a custom Projection Matrix Builder.
  9023. * This can be used to override the default projection matrix computation.
  9024. */
  9025. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9026. /**
  9027. * The transformed position. Position of the light in world space taking parenting in account.
  9028. */
  9029. transformedPosition: Vector3;
  9030. /**
  9031. * The transformed direction. Direction of the light in world space taking parenting in account.
  9032. */
  9033. transformedDirection: Vector3;
  9034. private _needProjectionMatrixCompute;
  9035. /**
  9036. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9037. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9038. */
  9039. computeTransformedInformation(): boolean;
  9040. /**
  9041. * Return the depth scale used for the shadow map.
  9042. * @returns the depth scale.
  9043. */
  9044. getDepthScale(): number;
  9045. /**
  9046. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9047. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9048. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9049. */
  9050. getShadowDirection(faceIndex?: number): Vector3;
  9051. /**
  9052. * Returns the ShadowLight absolute position in the World.
  9053. * @returns the position vector in world space
  9054. */
  9055. getAbsolutePosition(): Vector3;
  9056. /**
  9057. * Sets the ShadowLight direction toward the passed target.
  9058. * @param target The point to target in local space
  9059. * @returns the updated ShadowLight direction
  9060. */
  9061. setDirectionToTarget(target: Vector3): Vector3;
  9062. /**
  9063. * Returns the light rotation in euler definition.
  9064. * @returns the x y z rotation in local space.
  9065. */
  9066. getRotation(): Vector3;
  9067. /**
  9068. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9069. * @returns true if a cube texture needs to be use
  9070. */
  9071. needCube(): boolean;
  9072. /**
  9073. * Detects if the projection matrix requires to be recomputed this frame.
  9074. * @returns true if it requires to be recomputed otherwise, false.
  9075. */
  9076. needProjectionMatrixCompute(): boolean;
  9077. /**
  9078. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9079. */
  9080. forceProjectionMatrixCompute(): void;
  9081. /** @hidden */
  9082. _initCache(): void;
  9083. /** @hidden */
  9084. _isSynchronized(): boolean;
  9085. /**
  9086. * Computes the world matrix of the node
  9087. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9088. * @returns the world matrix
  9089. */
  9090. computeWorldMatrix(force?: boolean): Matrix;
  9091. /**
  9092. * Gets the minZ used for shadow according to both the scene and the light.
  9093. * @param activeCamera The camera we are returning the min for
  9094. * @returns the depth min z
  9095. */
  9096. getDepthMinZ(activeCamera: Camera): number;
  9097. /**
  9098. * Gets the maxZ used for shadow according to both the scene and the light.
  9099. * @param activeCamera The camera we are returning the max for
  9100. * @returns the depth max z
  9101. */
  9102. getDepthMaxZ(activeCamera: Camera): number;
  9103. /**
  9104. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9105. * @param matrix The materix to updated with the projection information
  9106. * @param viewMatrix The transform matrix of the light
  9107. * @param renderList The list of mesh to render in the map
  9108. * @returns The current light
  9109. */
  9110. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9111. }
  9112. }
  9113. declare module BABYLON {
  9114. /** @hidden */
  9115. export var packingFunctions: {
  9116. name: string;
  9117. shader: string;
  9118. };
  9119. }
  9120. declare module BABYLON {
  9121. /** @hidden */
  9122. export var bayerDitherFunctions: {
  9123. name: string;
  9124. shader: string;
  9125. };
  9126. }
  9127. declare module BABYLON {
  9128. /** @hidden */
  9129. export var shadowMapFragmentDeclaration: {
  9130. name: string;
  9131. shader: string;
  9132. };
  9133. }
  9134. declare module BABYLON {
  9135. /** @hidden */
  9136. export var clipPlaneFragmentDeclaration: {
  9137. name: string;
  9138. shader: string;
  9139. };
  9140. }
  9141. declare module BABYLON {
  9142. /** @hidden */
  9143. export var clipPlaneFragment: {
  9144. name: string;
  9145. shader: string;
  9146. };
  9147. }
  9148. declare module BABYLON {
  9149. /** @hidden */
  9150. export var shadowMapFragment: {
  9151. name: string;
  9152. shader: string;
  9153. };
  9154. }
  9155. declare module BABYLON {
  9156. /** @hidden */
  9157. export var shadowMapPixelShader: {
  9158. name: string;
  9159. shader: string;
  9160. };
  9161. }
  9162. declare module BABYLON {
  9163. /** @hidden */
  9164. export var bonesDeclaration: {
  9165. name: string;
  9166. shader: string;
  9167. };
  9168. }
  9169. declare module BABYLON {
  9170. /** @hidden */
  9171. export var morphTargetsVertexGlobalDeclaration: {
  9172. name: string;
  9173. shader: string;
  9174. };
  9175. }
  9176. declare module BABYLON {
  9177. /** @hidden */
  9178. export var morphTargetsVertexDeclaration: {
  9179. name: string;
  9180. shader: string;
  9181. };
  9182. }
  9183. declare module BABYLON {
  9184. /** @hidden */
  9185. export var instancesDeclaration: {
  9186. name: string;
  9187. shader: string;
  9188. };
  9189. }
  9190. declare module BABYLON {
  9191. /** @hidden */
  9192. export var helperFunctions: {
  9193. name: string;
  9194. shader: string;
  9195. };
  9196. }
  9197. declare module BABYLON {
  9198. /** @hidden */
  9199. export var shadowMapVertexDeclaration: {
  9200. name: string;
  9201. shader: string;
  9202. };
  9203. }
  9204. declare module BABYLON {
  9205. /** @hidden */
  9206. export var clipPlaneVertexDeclaration: {
  9207. name: string;
  9208. shader: string;
  9209. };
  9210. }
  9211. declare module BABYLON {
  9212. /** @hidden */
  9213. export var morphTargetsVertex: {
  9214. name: string;
  9215. shader: string;
  9216. };
  9217. }
  9218. declare module BABYLON {
  9219. /** @hidden */
  9220. export var instancesVertex: {
  9221. name: string;
  9222. shader: string;
  9223. };
  9224. }
  9225. declare module BABYLON {
  9226. /** @hidden */
  9227. export var bonesVertex: {
  9228. name: string;
  9229. shader: string;
  9230. };
  9231. }
  9232. declare module BABYLON {
  9233. /** @hidden */
  9234. export var shadowMapVertexNormalBias: {
  9235. name: string;
  9236. shader: string;
  9237. };
  9238. }
  9239. declare module BABYLON {
  9240. /** @hidden */
  9241. export var shadowMapVertexMetric: {
  9242. name: string;
  9243. shader: string;
  9244. };
  9245. }
  9246. declare module BABYLON {
  9247. /** @hidden */
  9248. export var clipPlaneVertex: {
  9249. name: string;
  9250. shader: string;
  9251. };
  9252. }
  9253. declare module BABYLON {
  9254. /** @hidden */
  9255. export var shadowMapVertexShader: {
  9256. name: string;
  9257. shader: string;
  9258. };
  9259. }
  9260. declare module BABYLON {
  9261. /** @hidden */
  9262. export var depthBoxBlurPixelShader: {
  9263. name: string;
  9264. shader: string;
  9265. };
  9266. }
  9267. declare module BABYLON {
  9268. /** @hidden */
  9269. export var shadowMapFragmentSoftTransparentShadow: {
  9270. name: string;
  9271. shader: string;
  9272. };
  9273. }
  9274. declare module BABYLON {
  9275. /**
  9276. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9277. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9278. */
  9279. export class EffectFallbacks implements IEffectFallbacks {
  9280. private _defines;
  9281. private _currentRank;
  9282. private _maxRank;
  9283. private _mesh;
  9284. /**
  9285. * Removes the fallback from the bound mesh.
  9286. */
  9287. unBindMesh(): void;
  9288. /**
  9289. * Adds a fallback on the specified property.
  9290. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9291. * @param define The name of the define in the shader
  9292. */
  9293. addFallback(rank: number, define: string): void;
  9294. /**
  9295. * Sets the mesh to use CPU skinning when needing to fallback.
  9296. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9297. * @param mesh The mesh to use the fallbacks.
  9298. */
  9299. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9300. /**
  9301. * Checks to see if more fallbacks are still availible.
  9302. */
  9303. get hasMoreFallbacks(): boolean;
  9304. /**
  9305. * Removes the defines that should be removed when falling back.
  9306. * @param currentDefines defines the current define statements for the shader.
  9307. * @param effect defines the current effect we try to compile
  9308. * @returns The resulting defines with defines of the current rank removed.
  9309. */
  9310. reduce(currentDefines: string, effect: Effect): string;
  9311. }
  9312. }
  9313. declare module BABYLON {
  9314. /**
  9315. * Interface used to define Action
  9316. */
  9317. export interface IAction {
  9318. /**
  9319. * Trigger for the action
  9320. */
  9321. trigger: number;
  9322. /** Options of the trigger */
  9323. triggerOptions: any;
  9324. /**
  9325. * Gets the trigger parameters
  9326. * @returns the trigger parameters
  9327. */
  9328. getTriggerParameter(): any;
  9329. /**
  9330. * Internal only - executes current action event
  9331. * @hidden
  9332. */
  9333. _executeCurrent(evt?: ActionEvent): void;
  9334. /**
  9335. * Serialize placeholder for child classes
  9336. * @param parent of child
  9337. * @returns the serialized object
  9338. */
  9339. serialize(parent: any): any;
  9340. /**
  9341. * Internal only
  9342. * @hidden
  9343. */
  9344. _prepare(): void;
  9345. /**
  9346. * Internal only - manager for action
  9347. * @hidden
  9348. */
  9349. _actionManager: AbstractActionManager;
  9350. /**
  9351. * Adds action to chain of actions, may be a DoNothingAction
  9352. * @param action defines the next action to execute
  9353. * @returns The action passed in
  9354. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9355. */
  9356. then(action: IAction): IAction;
  9357. }
  9358. /**
  9359. * The action to be carried out following a trigger
  9360. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9361. */
  9362. export class Action implements IAction {
  9363. /** the trigger, with or without parameters, for the action */
  9364. triggerOptions: any;
  9365. /**
  9366. * Trigger for the action
  9367. */
  9368. trigger: number;
  9369. /**
  9370. * Internal only - manager for action
  9371. * @hidden
  9372. */
  9373. _actionManager: ActionManager;
  9374. private _nextActiveAction;
  9375. private _child;
  9376. private _condition?;
  9377. private _triggerParameter;
  9378. /**
  9379. * An event triggered prior to action being executed.
  9380. */
  9381. onBeforeExecuteObservable: Observable<Action>;
  9382. /**
  9383. * Creates a new Action
  9384. * @param triggerOptions the trigger, with or without parameters, for the action
  9385. * @param condition an optional determinant of action
  9386. */
  9387. constructor(
  9388. /** the trigger, with or without parameters, for the action */
  9389. triggerOptions: any, condition?: Condition);
  9390. /**
  9391. * Internal only
  9392. * @hidden
  9393. */
  9394. _prepare(): void;
  9395. /**
  9396. * Gets the trigger parameters
  9397. * @returns the trigger parameters
  9398. */
  9399. getTriggerParameter(): any;
  9400. /**
  9401. * Internal only - executes current action event
  9402. * @hidden
  9403. */
  9404. _executeCurrent(evt?: ActionEvent): void;
  9405. /**
  9406. * Execute placeholder for child classes
  9407. * @param evt optional action event
  9408. */
  9409. execute(evt?: ActionEvent): void;
  9410. /**
  9411. * Skips to next active action
  9412. */
  9413. skipToNextActiveAction(): void;
  9414. /**
  9415. * Adds action to chain of actions, may be a DoNothingAction
  9416. * @param action defines the next action to execute
  9417. * @returns The action passed in
  9418. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9419. */
  9420. then(action: Action): Action;
  9421. /**
  9422. * Internal only
  9423. * @hidden
  9424. */
  9425. _getProperty(propertyPath: string): string;
  9426. /**
  9427. * Internal only
  9428. * @hidden
  9429. */
  9430. _getEffectiveTarget(target: any, propertyPath: string): any;
  9431. /**
  9432. * Serialize placeholder for child classes
  9433. * @param parent of child
  9434. * @returns the serialized object
  9435. */
  9436. serialize(parent: any): any;
  9437. /**
  9438. * Internal only called by serialize
  9439. * @hidden
  9440. */
  9441. protected _serialize(serializedAction: any, parent?: any): any;
  9442. /**
  9443. * Internal only
  9444. * @hidden
  9445. */
  9446. static _SerializeValueAsString: (value: any) => string;
  9447. /**
  9448. * Internal only
  9449. * @hidden
  9450. */
  9451. static _GetTargetProperty: (target: Scene | Node) => {
  9452. name: string;
  9453. targetType: string;
  9454. value: string;
  9455. };
  9456. }
  9457. }
  9458. declare module BABYLON {
  9459. /**
  9460. * A Condition applied to an Action
  9461. */
  9462. export class Condition {
  9463. /**
  9464. * Internal only - manager for action
  9465. * @hidden
  9466. */
  9467. _actionManager: ActionManager;
  9468. /**
  9469. * Internal only
  9470. * @hidden
  9471. */
  9472. _evaluationId: number;
  9473. /**
  9474. * Internal only
  9475. * @hidden
  9476. */
  9477. _currentResult: boolean;
  9478. /**
  9479. * Creates a new Condition
  9480. * @param actionManager the manager of the action the condition is applied to
  9481. */
  9482. constructor(actionManager: ActionManager);
  9483. /**
  9484. * Check if the current condition is valid
  9485. * @returns a boolean
  9486. */
  9487. isValid(): boolean;
  9488. /**
  9489. * Internal only
  9490. * @hidden
  9491. */
  9492. _getProperty(propertyPath: string): string;
  9493. /**
  9494. * Internal only
  9495. * @hidden
  9496. */
  9497. _getEffectiveTarget(target: any, propertyPath: string): any;
  9498. /**
  9499. * Serialize placeholder for child classes
  9500. * @returns the serialized object
  9501. */
  9502. serialize(): any;
  9503. /**
  9504. * Internal only
  9505. * @hidden
  9506. */
  9507. protected _serialize(serializedCondition: any): any;
  9508. }
  9509. /**
  9510. * Defines specific conditional operators as extensions of Condition
  9511. */
  9512. export class ValueCondition extends Condition {
  9513. /** path to specify the property of the target the conditional operator uses */
  9514. propertyPath: string;
  9515. /** the value compared by the conditional operator against the current value of the property */
  9516. value: any;
  9517. /** the conditional operator, default ValueCondition.IsEqual */
  9518. operator: number;
  9519. /**
  9520. * Internal only
  9521. * @hidden
  9522. */
  9523. private static _IsEqual;
  9524. /**
  9525. * Internal only
  9526. * @hidden
  9527. */
  9528. private static _IsDifferent;
  9529. /**
  9530. * Internal only
  9531. * @hidden
  9532. */
  9533. private static _IsGreater;
  9534. /**
  9535. * Internal only
  9536. * @hidden
  9537. */
  9538. private static _IsLesser;
  9539. /**
  9540. * returns the number for IsEqual
  9541. */
  9542. static get IsEqual(): number;
  9543. /**
  9544. * Returns the number for IsDifferent
  9545. */
  9546. static get IsDifferent(): number;
  9547. /**
  9548. * Returns the number for IsGreater
  9549. */
  9550. static get IsGreater(): number;
  9551. /**
  9552. * Returns the number for IsLesser
  9553. */
  9554. static get IsLesser(): number;
  9555. /**
  9556. * Internal only The action manager for the condition
  9557. * @hidden
  9558. */
  9559. _actionManager: ActionManager;
  9560. /**
  9561. * Internal only
  9562. * @hidden
  9563. */
  9564. private _target;
  9565. /**
  9566. * Internal only
  9567. * @hidden
  9568. */
  9569. private _effectiveTarget;
  9570. /**
  9571. * Internal only
  9572. * @hidden
  9573. */
  9574. private _property;
  9575. /**
  9576. * Creates a new ValueCondition
  9577. * @param actionManager manager for the action the condition applies to
  9578. * @param target for the action
  9579. * @param propertyPath path to specify the property of the target the conditional operator uses
  9580. * @param value the value compared by the conditional operator against the current value of the property
  9581. * @param operator the conditional operator, default ValueCondition.IsEqual
  9582. */
  9583. constructor(actionManager: ActionManager, target: any,
  9584. /** path to specify the property of the target the conditional operator uses */
  9585. propertyPath: string,
  9586. /** the value compared by the conditional operator against the current value of the property */
  9587. value: any,
  9588. /** the conditional operator, default ValueCondition.IsEqual */
  9589. operator?: number);
  9590. /**
  9591. * Compares the given value with the property value for the specified conditional operator
  9592. * @returns the result of the comparison
  9593. */
  9594. isValid(): boolean;
  9595. /**
  9596. * Serialize the ValueCondition into a JSON compatible object
  9597. * @returns serialization object
  9598. */
  9599. serialize(): any;
  9600. /**
  9601. * Gets the name of the conditional operator for the ValueCondition
  9602. * @param operator the conditional operator
  9603. * @returns the name
  9604. */
  9605. static GetOperatorName(operator: number): string;
  9606. }
  9607. /**
  9608. * Defines a predicate condition as an extension of Condition
  9609. */
  9610. export class PredicateCondition extends Condition {
  9611. /** defines the predicate function used to validate the condition */
  9612. predicate: () => boolean;
  9613. /**
  9614. * Internal only - manager for action
  9615. * @hidden
  9616. */
  9617. _actionManager: ActionManager;
  9618. /**
  9619. * Creates a new PredicateCondition
  9620. * @param actionManager manager for the action the condition applies to
  9621. * @param predicate defines the predicate function used to validate the condition
  9622. */
  9623. constructor(actionManager: ActionManager,
  9624. /** defines the predicate function used to validate the condition */
  9625. predicate: () => boolean);
  9626. /**
  9627. * @returns the validity of the predicate condition
  9628. */
  9629. isValid(): boolean;
  9630. }
  9631. /**
  9632. * Defines a state condition as an extension of Condition
  9633. */
  9634. export class StateCondition extends Condition {
  9635. /** Value to compare with target state */
  9636. value: string;
  9637. /**
  9638. * Internal only - manager for action
  9639. * @hidden
  9640. */
  9641. _actionManager: ActionManager;
  9642. /**
  9643. * Internal only
  9644. * @hidden
  9645. */
  9646. private _target;
  9647. /**
  9648. * Creates a new StateCondition
  9649. * @param actionManager manager for the action the condition applies to
  9650. * @param target of the condition
  9651. * @param value to compare with target state
  9652. */
  9653. constructor(actionManager: ActionManager, target: any,
  9654. /** Value to compare with target state */
  9655. value: string);
  9656. /**
  9657. * Gets a boolean indicating if the current condition is met
  9658. * @returns the validity of the state
  9659. */
  9660. isValid(): boolean;
  9661. /**
  9662. * Serialize the StateCondition into a JSON compatible object
  9663. * @returns serialization object
  9664. */
  9665. serialize(): any;
  9666. }
  9667. }
  9668. declare module BABYLON {
  9669. /**
  9670. * This defines an action responsible to toggle a boolean once triggered.
  9671. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9672. */
  9673. export class SwitchBooleanAction extends Action {
  9674. /**
  9675. * The path to the boolean property in the target object
  9676. */
  9677. propertyPath: string;
  9678. private _target;
  9679. private _effectiveTarget;
  9680. private _property;
  9681. /**
  9682. * Instantiate the action
  9683. * @param triggerOptions defines the trigger options
  9684. * @param target defines the object containing the boolean
  9685. * @param propertyPath defines the path to the boolean property in the target object
  9686. * @param condition defines the trigger related conditions
  9687. */
  9688. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9689. /** @hidden */
  9690. _prepare(): void;
  9691. /**
  9692. * Execute the action toggle the boolean value.
  9693. */
  9694. execute(): void;
  9695. /**
  9696. * Serializes the actions and its related information.
  9697. * @param parent defines the object to serialize in
  9698. * @returns the serialized object
  9699. */
  9700. serialize(parent: any): any;
  9701. }
  9702. /**
  9703. * This defines an action responsible to set a the state field of the target
  9704. * to a desired value once triggered.
  9705. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9706. */
  9707. export class SetStateAction extends Action {
  9708. /**
  9709. * The value to store in the state field.
  9710. */
  9711. value: string;
  9712. private _target;
  9713. /**
  9714. * Instantiate the action
  9715. * @param triggerOptions defines the trigger options
  9716. * @param target defines the object containing the state property
  9717. * @param value defines the value to store in the state field
  9718. * @param condition defines the trigger related conditions
  9719. */
  9720. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9721. /**
  9722. * Execute the action and store the value on the target state property.
  9723. */
  9724. execute(): void;
  9725. /**
  9726. * Serializes the actions and its related information.
  9727. * @param parent defines the object to serialize in
  9728. * @returns the serialized object
  9729. */
  9730. serialize(parent: any): any;
  9731. }
  9732. /**
  9733. * This defines an action responsible to set a property of the target
  9734. * to a desired value once triggered.
  9735. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9736. */
  9737. export class SetValueAction extends Action {
  9738. /**
  9739. * The path of the property to set in the target.
  9740. */
  9741. propertyPath: string;
  9742. /**
  9743. * The value to set in the property
  9744. */
  9745. value: any;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the property
  9753. * @param propertyPath defines the path of the property to set in the target
  9754. * @param value defines the value to set in the property
  9755. * @param condition defines the trigger related conditions
  9756. */
  9757. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9758. /** @hidden */
  9759. _prepare(): void;
  9760. /**
  9761. * Execute the action and set the targetted property to the desired value.
  9762. */
  9763. execute(): void;
  9764. /**
  9765. * Serializes the actions and its related information.
  9766. * @param parent defines the object to serialize in
  9767. * @returns the serialized object
  9768. */
  9769. serialize(parent: any): any;
  9770. }
  9771. /**
  9772. * This defines an action responsible to increment the target value
  9773. * to a desired value once triggered.
  9774. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9775. */
  9776. export class IncrementValueAction extends Action {
  9777. /**
  9778. * The path of the property to increment in the target.
  9779. */
  9780. propertyPath: string;
  9781. /**
  9782. * The value we should increment the property by.
  9783. */
  9784. value: any;
  9785. private _target;
  9786. private _effectiveTarget;
  9787. private _property;
  9788. /**
  9789. * Instantiate the action
  9790. * @param triggerOptions defines the trigger options
  9791. * @param target defines the object containing the property
  9792. * @param propertyPath defines the path of the property to increment in the target
  9793. * @param value defines the value value we should increment the property by
  9794. * @param condition defines the trigger related conditions
  9795. */
  9796. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9797. /** @hidden */
  9798. _prepare(): void;
  9799. /**
  9800. * Execute the action and increment the target of the value amount.
  9801. */
  9802. execute(): void;
  9803. /**
  9804. * Serializes the actions and its related information.
  9805. * @param parent defines the object to serialize in
  9806. * @returns the serialized object
  9807. */
  9808. serialize(parent: any): any;
  9809. }
  9810. /**
  9811. * This defines an action responsible to start an animation once triggered.
  9812. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9813. */
  9814. export class PlayAnimationAction extends Action {
  9815. /**
  9816. * Where the animation should start (animation frame)
  9817. */
  9818. from: number;
  9819. /**
  9820. * Where the animation should stop (animation frame)
  9821. */
  9822. to: number;
  9823. /**
  9824. * Define if the animation should loop or stop after the first play.
  9825. */
  9826. loop?: boolean;
  9827. private _target;
  9828. /**
  9829. * Instantiate the action
  9830. * @param triggerOptions defines the trigger options
  9831. * @param target defines the target animation or animation name
  9832. * @param from defines from where the animation should start (animation frame)
  9833. * @param end defines where the animation should stop (animation frame)
  9834. * @param loop defines if the animation should loop or stop after the first play
  9835. * @param condition defines the trigger related conditions
  9836. */
  9837. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9838. /** @hidden */
  9839. _prepare(): void;
  9840. /**
  9841. * Execute the action and play the animation.
  9842. */
  9843. execute(): void;
  9844. /**
  9845. * Serializes the actions and its related information.
  9846. * @param parent defines the object to serialize in
  9847. * @returns the serialized object
  9848. */
  9849. serialize(parent: any): any;
  9850. }
  9851. /**
  9852. * This defines an action responsible to stop an animation once triggered.
  9853. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9854. */
  9855. export class StopAnimationAction extends Action {
  9856. private _target;
  9857. /**
  9858. * Instantiate the action
  9859. * @param triggerOptions defines the trigger options
  9860. * @param target defines the target animation or animation name
  9861. * @param condition defines the trigger related conditions
  9862. */
  9863. constructor(triggerOptions: any, target: any, condition?: Condition);
  9864. /** @hidden */
  9865. _prepare(): void;
  9866. /**
  9867. * Execute the action and stop the animation.
  9868. */
  9869. execute(): void;
  9870. /**
  9871. * Serializes the actions and its related information.
  9872. * @param parent defines the object to serialize in
  9873. * @returns the serialized object
  9874. */
  9875. serialize(parent: any): any;
  9876. }
  9877. /**
  9878. * This defines an action responsible that does nothing once triggered.
  9879. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9880. */
  9881. export class DoNothingAction extends Action {
  9882. /**
  9883. * Instantiate the action
  9884. * @param triggerOptions defines the trigger options
  9885. * @param condition defines the trigger related conditions
  9886. */
  9887. constructor(triggerOptions?: any, condition?: Condition);
  9888. /**
  9889. * Execute the action and do nothing.
  9890. */
  9891. execute(): void;
  9892. /**
  9893. * Serializes the actions and its related information.
  9894. * @param parent defines the object to serialize in
  9895. * @returns the serialized object
  9896. */
  9897. serialize(parent: any): any;
  9898. }
  9899. /**
  9900. * This defines an action responsible to trigger several actions once triggered.
  9901. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9902. */
  9903. export class CombineAction extends Action {
  9904. /**
  9905. * The list of aggregated animations to run.
  9906. */
  9907. children: Action[];
  9908. /**
  9909. * Instantiate the action
  9910. * @param triggerOptions defines the trigger options
  9911. * @param children defines the list of aggregated animations to run
  9912. * @param condition defines the trigger related conditions
  9913. */
  9914. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9915. /** @hidden */
  9916. _prepare(): void;
  9917. /**
  9918. * Execute the action and executes all the aggregated actions.
  9919. */
  9920. execute(evt: ActionEvent): void;
  9921. /**
  9922. * Serializes the actions and its related information.
  9923. * @param parent defines the object to serialize in
  9924. * @returns the serialized object
  9925. */
  9926. serialize(parent: any): any;
  9927. }
  9928. /**
  9929. * This defines an action responsible to run code (external event) once triggered.
  9930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9931. */
  9932. export class ExecuteCodeAction extends Action {
  9933. /**
  9934. * The callback function to run.
  9935. */
  9936. func: (evt: ActionEvent) => void;
  9937. /**
  9938. * Instantiate the action
  9939. * @param triggerOptions defines the trigger options
  9940. * @param func defines the callback function to run
  9941. * @param condition defines the trigger related conditions
  9942. */
  9943. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  9944. /**
  9945. * Execute the action and run the attached code.
  9946. */
  9947. execute(evt: ActionEvent): void;
  9948. }
  9949. /**
  9950. * This defines an action responsible to set the parent property of the target once triggered.
  9951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9952. */
  9953. export class SetParentAction extends Action {
  9954. private _parent;
  9955. private _target;
  9956. /**
  9957. * Instantiate the action
  9958. * @param triggerOptions defines the trigger options
  9959. * @param target defines the target containing the parent property
  9960. * @param parent defines from where the animation should start (animation frame)
  9961. * @param condition defines the trigger related conditions
  9962. */
  9963. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  9964. /** @hidden */
  9965. _prepare(): void;
  9966. /**
  9967. * Execute the action and set the parent property.
  9968. */
  9969. execute(): void;
  9970. /**
  9971. * Serializes the actions and its related information.
  9972. * @param parent defines the object to serialize in
  9973. * @returns the serialized object
  9974. */
  9975. serialize(parent: any): any;
  9976. }
  9977. }
  9978. declare module BABYLON {
  9979. /**
  9980. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  9981. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  9982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9983. */
  9984. export class ActionManager extends AbstractActionManager {
  9985. /**
  9986. * Nothing
  9987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9988. */
  9989. static readonly NothingTrigger: number;
  9990. /**
  9991. * On pick
  9992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9993. */
  9994. static readonly OnPickTrigger: number;
  9995. /**
  9996. * On left pick
  9997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  9998. */
  9999. static readonly OnLeftPickTrigger: number;
  10000. /**
  10001. * On right pick
  10002. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10003. */
  10004. static readonly OnRightPickTrigger: number;
  10005. /**
  10006. * On center pick
  10007. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10008. */
  10009. static readonly OnCenterPickTrigger: number;
  10010. /**
  10011. * On pick down
  10012. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10013. */
  10014. static readonly OnPickDownTrigger: number;
  10015. /**
  10016. * On double pick
  10017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10018. */
  10019. static readonly OnDoublePickTrigger: number;
  10020. /**
  10021. * On pick up
  10022. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10023. */
  10024. static readonly OnPickUpTrigger: number;
  10025. /**
  10026. * On pick out.
  10027. * This trigger will only be raised if you also declared a OnPickDown
  10028. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10029. */
  10030. static readonly OnPickOutTrigger: number;
  10031. /**
  10032. * On long press
  10033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10034. */
  10035. static readonly OnLongPressTrigger: number;
  10036. /**
  10037. * On pointer over
  10038. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10039. */
  10040. static readonly OnPointerOverTrigger: number;
  10041. /**
  10042. * On pointer out
  10043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10044. */
  10045. static readonly OnPointerOutTrigger: number;
  10046. /**
  10047. * On every frame
  10048. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10049. */
  10050. static readonly OnEveryFrameTrigger: number;
  10051. /**
  10052. * On intersection enter
  10053. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10054. */
  10055. static readonly OnIntersectionEnterTrigger: number;
  10056. /**
  10057. * On intersection exit
  10058. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10059. */
  10060. static readonly OnIntersectionExitTrigger: number;
  10061. /**
  10062. * On key down
  10063. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10064. */
  10065. static readonly OnKeyDownTrigger: number;
  10066. /**
  10067. * On key up
  10068. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10069. */
  10070. static readonly OnKeyUpTrigger: number;
  10071. private _scene;
  10072. /**
  10073. * Creates a new action manager
  10074. * @param scene defines the hosting scene
  10075. */
  10076. constructor(scene: Scene);
  10077. /**
  10078. * Releases all associated resources
  10079. */
  10080. dispose(): void;
  10081. /**
  10082. * Gets hosting scene
  10083. * @returns the hosting scene
  10084. */
  10085. getScene(): Scene;
  10086. /**
  10087. * Does this action manager handles actions of any of the given triggers
  10088. * @param triggers defines the triggers to be tested
  10089. * @return a boolean indicating whether one (or more) of the triggers is handled
  10090. */
  10091. hasSpecificTriggers(triggers: number[]): boolean;
  10092. /**
  10093. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10094. * speed.
  10095. * @param triggerA defines the trigger to be tested
  10096. * @param triggerB defines the trigger to be tested
  10097. * @return a boolean indicating whether one (or more) of the triggers is handled
  10098. */
  10099. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10100. /**
  10101. * Does this action manager handles actions of a given trigger
  10102. * @param trigger defines the trigger to be tested
  10103. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10104. * @return whether the trigger is handled
  10105. */
  10106. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10107. /**
  10108. * Does this action manager has pointer triggers
  10109. */
  10110. get hasPointerTriggers(): boolean;
  10111. /**
  10112. * Does this action manager has pick triggers
  10113. */
  10114. get hasPickTriggers(): boolean;
  10115. /**
  10116. * Registers an action to this action manager
  10117. * @param action defines the action to be registered
  10118. * @return the action amended (prepared) after registration
  10119. */
  10120. registerAction(action: IAction): Nullable<IAction>;
  10121. /**
  10122. * Unregisters an action to this action manager
  10123. * @param action defines the action to be unregistered
  10124. * @return a boolean indicating whether the action has been unregistered
  10125. */
  10126. unregisterAction(action: IAction): Boolean;
  10127. /**
  10128. * Process a specific trigger
  10129. * @param trigger defines the trigger to process
  10130. * @param evt defines the event details to be processed
  10131. */
  10132. processTrigger(trigger: number, evt?: IActionEvent): void;
  10133. /** @hidden */
  10134. _getEffectiveTarget(target: any, propertyPath: string): any;
  10135. /** @hidden */
  10136. _getProperty(propertyPath: string): string;
  10137. /**
  10138. * Serialize this manager to a JSON object
  10139. * @param name defines the property name to store this manager
  10140. * @returns a JSON representation of this manager
  10141. */
  10142. serialize(name: string): any;
  10143. /**
  10144. * Creates a new ActionManager from a JSON data
  10145. * @param parsedActions defines the JSON data to read from
  10146. * @param object defines the hosting mesh
  10147. * @param scene defines the hosting scene
  10148. */
  10149. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10150. /**
  10151. * Get a trigger name by index
  10152. * @param trigger defines the trigger index
  10153. * @returns a trigger name
  10154. */
  10155. static GetTriggerName(trigger: number): string;
  10156. }
  10157. }
  10158. declare module BABYLON {
  10159. /**
  10160. * Class used to represent a sprite
  10161. * @see https://doc.babylonjs.com/babylon101/sprites
  10162. */
  10163. export class Sprite implements IAnimatable {
  10164. /** defines the name */
  10165. name: string;
  10166. /** Gets or sets the current world position */
  10167. position: Vector3;
  10168. /** Gets or sets the main color */
  10169. color: Color4;
  10170. /** Gets or sets the width */
  10171. width: number;
  10172. /** Gets or sets the height */
  10173. height: number;
  10174. /** Gets or sets rotation angle */
  10175. angle: number;
  10176. /** Gets or sets the cell index in the sprite sheet */
  10177. cellIndex: number;
  10178. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10179. cellRef: string;
  10180. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10181. invertU: boolean;
  10182. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10183. invertV: boolean;
  10184. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10185. disposeWhenFinishedAnimating: boolean;
  10186. /** Gets the list of attached animations */
  10187. animations: Nullable<Array<Animation>>;
  10188. /** Gets or sets a boolean indicating if the sprite can be picked */
  10189. isPickable: boolean;
  10190. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10191. useAlphaForPicking: boolean;
  10192. /** @hidden */
  10193. _xOffset: number;
  10194. /** @hidden */
  10195. _yOffset: number;
  10196. /** @hidden */
  10197. _xSize: number;
  10198. /** @hidden */
  10199. _ySize: number;
  10200. /**
  10201. * Gets or sets the associated action manager
  10202. */
  10203. actionManager: Nullable<ActionManager>;
  10204. /**
  10205. * An event triggered when the control has been disposed
  10206. */
  10207. onDisposeObservable: Observable<Sprite>;
  10208. private _animationStarted;
  10209. private _loopAnimation;
  10210. private _fromIndex;
  10211. private _toIndex;
  10212. private _delay;
  10213. private _direction;
  10214. private _manager;
  10215. private _time;
  10216. private _onAnimationEnd;
  10217. /**
  10218. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10219. */
  10220. isVisible: boolean;
  10221. /**
  10222. * Gets or sets the sprite size
  10223. */
  10224. get size(): number;
  10225. set size(value: number);
  10226. /**
  10227. * Returns a boolean indicating if the animation is started
  10228. */
  10229. get animationStarted(): boolean;
  10230. /**
  10231. * Gets or sets the unique id of the sprite
  10232. */
  10233. uniqueId: number;
  10234. /**
  10235. * Gets the manager of this sprite
  10236. */
  10237. get manager(): ISpriteManager;
  10238. /**
  10239. * Creates a new Sprite
  10240. * @param name defines the name
  10241. * @param manager defines the manager
  10242. */
  10243. constructor(
  10244. /** defines the name */
  10245. name: string, manager: ISpriteManager);
  10246. /**
  10247. * Returns the string "Sprite"
  10248. * @returns "Sprite"
  10249. */
  10250. getClassName(): string;
  10251. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10252. get fromIndex(): number;
  10253. set fromIndex(value: number);
  10254. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10255. get toIndex(): number;
  10256. set toIndex(value: number);
  10257. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10258. get loopAnimation(): boolean;
  10259. set loopAnimation(value: boolean);
  10260. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10261. get delay(): number;
  10262. set delay(value: number);
  10263. /**
  10264. * Starts an animation
  10265. * @param from defines the initial key
  10266. * @param to defines the end key
  10267. * @param loop defines if the animation must loop
  10268. * @param delay defines the start delay (in ms)
  10269. * @param onAnimationEnd defines a callback to call when animation ends
  10270. */
  10271. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10272. /** Stops current animation (if any) */
  10273. stopAnimation(): void;
  10274. /** @hidden */
  10275. _animate(deltaTime: number): void;
  10276. /** Release associated resources */
  10277. dispose(): void;
  10278. /**
  10279. * Serializes the sprite to a JSON object
  10280. * @returns the JSON object
  10281. */
  10282. serialize(): any;
  10283. /**
  10284. * Parses a JSON object to create a new sprite
  10285. * @param parsedSprite The JSON object to parse
  10286. * @param manager defines the hosting manager
  10287. * @returns the new sprite
  10288. */
  10289. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10290. }
  10291. }
  10292. declare module BABYLON {
  10293. /**
  10294. * Information about the result of picking within a scene
  10295. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10296. */
  10297. export class PickingInfo {
  10298. /** @hidden */
  10299. _pickingUnavailable: boolean;
  10300. /**
  10301. * If the pick collided with an object
  10302. */
  10303. hit: boolean;
  10304. /**
  10305. * Distance away where the pick collided
  10306. */
  10307. distance: number;
  10308. /**
  10309. * The location of pick collision
  10310. */
  10311. pickedPoint: Nullable<Vector3>;
  10312. /**
  10313. * The mesh corresponding the the pick collision
  10314. */
  10315. pickedMesh: Nullable<AbstractMesh>;
  10316. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10317. bu: number;
  10318. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10319. bv: number;
  10320. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10321. faceId: number;
  10322. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10323. subMeshFaceId: number;
  10324. /** Id of the the submesh that was picked */
  10325. subMeshId: number;
  10326. /** If a sprite was picked, this will be the sprite the pick collided with */
  10327. pickedSprite: Nullable<Sprite>;
  10328. /**
  10329. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10330. */
  10331. originMesh: Nullable<AbstractMesh>;
  10332. /**
  10333. * The ray that was used to perform the picking.
  10334. */
  10335. ray: Nullable<Ray>;
  10336. /**
  10337. * Gets the normal correspodning to the face the pick collided with
  10338. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10339. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10340. * @returns The normal correspodning to the face the pick collided with
  10341. */
  10342. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10343. /**
  10344. * Gets the texture coordinates of where the pick occured
  10345. * @returns the vector containing the coordnates of the texture
  10346. */
  10347. getTextureCoordinates(): Nullable<Vector2>;
  10348. }
  10349. }
  10350. declare module BABYLON {
  10351. /**
  10352. * Class representing a ray with position and direction
  10353. */
  10354. export class Ray {
  10355. /** origin point */
  10356. origin: Vector3;
  10357. /** direction */
  10358. direction: Vector3;
  10359. /** length of the ray */
  10360. length: number;
  10361. private static readonly TmpVector3;
  10362. private _tmpRay;
  10363. /**
  10364. * Creates a new ray
  10365. * @param origin origin point
  10366. * @param direction direction
  10367. * @param length length of the ray
  10368. */
  10369. constructor(
  10370. /** origin point */
  10371. origin: Vector3,
  10372. /** direction */
  10373. direction: Vector3,
  10374. /** length of the ray */
  10375. length?: number);
  10376. /**
  10377. * Checks if the ray intersects a box
  10378. * This does not account for the ray lenght by design to improve perfs.
  10379. * @param minimum bound of the box
  10380. * @param maximum bound of the box
  10381. * @param intersectionTreshold extra extend to be added to the box in all direction
  10382. * @returns if the box was hit
  10383. */
  10384. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10385. /**
  10386. * Checks if the ray intersects a box
  10387. * This does not account for the ray lenght by design to improve perfs.
  10388. * @param box the bounding box to check
  10389. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10390. * @returns if the box was hit
  10391. */
  10392. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10393. /**
  10394. * If the ray hits a sphere
  10395. * @param sphere the bounding sphere to check
  10396. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10397. * @returns true if it hits the sphere
  10398. */
  10399. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10400. /**
  10401. * If the ray hits a triange
  10402. * @param vertex0 triangle vertex
  10403. * @param vertex1 triangle vertex
  10404. * @param vertex2 triangle vertex
  10405. * @returns intersection information if hit
  10406. */
  10407. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10408. /**
  10409. * Checks if ray intersects a plane
  10410. * @param plane the plane to check
  10411. * @returns the distance away it was hit
  10412. */
  10413. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10414. /**
  10415. * Calculate the intercept of a ray on a given axis
  10416. * @param axis to check 'x' | 'y' | 'z'
  10417. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10418. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10419. */
  10420. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10421. /**
  10422. * Checks if ray intersects a mesh
  10423. * @param mesh the mesh to check
  10424. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10425. * @returns picking info of the intersecton
  10426. */
  10427. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10428. /**
  10429. * Checks if ray intersects a mesh
  10430. * @param meshes the meshes to check
  10431. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10432. * @param results array to store result in
  10433. * @returns Array of picking infos
  10434. */
  10435. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10436. private _comparePickingInfo;
  10437. private static smallnum;
  10438. private static rayl;
  10439. /**
  10440. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10441. * @param sega the first point of the segment to test the intersection against
  10442. * @param segb the second point of the segment to test the intersection against
  10443. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10444. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10445. */
  10446. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10447. /**
  10448. * Update the ray from viewport position
  10449. * @param x position
  10450. * @param y y position
  10451. * @param viewportWidth viewport width
  10452. * @param viewportHeight viewport height
  10453. * @param world world matrix
  10454. * @param view view matrix
  10455. * @param projection projection matrix
  10456. * @returns this ray updated
  10457. */
  10458. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10459. /**
  10460. * Creates a ray with origin and direction of 0,0,0
  10461. * @returns the new ray
  10462. */
  10463. static Zero(): Ray;
  10464. /**
  10465. * Creates a new ray from screen space and viewport
  10466. * @param x position
  10467. * @param y y position
  10468. * @param viewportWidth viewport width
  10469. * @param viewportHeight viewport height
  10470. * @param world world matrix
  10471. * @param view view matrix
  10472. * @param projection projection matrix
  10473. * @returns new ray
  10474. */
  10475. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10476. /**
  10477. * 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
  10478. * transformed to the given world matrix.
  10479. * @param origin The origin point
  10480. * @param end The end point
  10481. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10482. * @returns the new ray
  10483. */
  10484. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10485. /**
  10486. * Transforms a ray by a matrix
  10487. * @param ray ray to transform
  10488. * @param matrix matrix to apply
  10489. * @returns the resulting new ray
  10490. */
  10491. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10492. /**
  10493. * Transforms a ray by a matrix
  10494. * @param ray ray to transform
  10495. * @param matrix matrix to apply
  10496. * @param result ray to store result in
  10497. */
  10498. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10499. /**
  10500. * Unproject a ray from screen space to object space
  10501. * @param sourceX defines the screen space x coordinate to use
  10502. * @param sourceY defines the screen space y coordinate to use
  10503. * @param viewportWidth defines the current width of the viewport
  10504. * @param viewportHeight defines the current height of the viewport
  10505. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10506. * @param view defines the view matrix to use
  10507. * @param projection defines the projection matrix to use
  10508. */
  10509. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10510. }
  10511. /**
  10512. * Type used to define predicate used to select faces when a mesh intersection is detected
  10513. */
  10514. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10515. interface Scene {
  10516. /** @hidden */
  10517. _tempPickingRay: Nullable<Ray>;
  10518. /** @hidden */
  10519. _cachedRayForTransform: Ray;
  10520. /** @hidden */
  10521. _pickWithRayInverseMatrix: Matrix;
  10522. /** @hidden */
  10523. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10524. /** @hidden */
  10525. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10526. }
  10527. }
  10528. declare module BABYLON {
  10529. /**
  10530. * Groups all the scene component constants in one place to ease maintenance.
  10531. * @hidden
  10532. */
  10533. export class SceneComponentConstants {
  10534. static readonly NAME_EFFECTLAYER: string;
  10535. static readonly NAME_LAYER: string;
  10536. static readonly NAME_LENSFLARESYSTEM: string;
  10537. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10538. static readonly NAME_PARTICLESYSTEM: string;
  10539. static readonly NAME_GAMEPAD: string;
  10540. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10541. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10542. static readonly NAME_PREPASSRENDERER: string;
  10543. static readonly NAME_DEPTHRENDERER: string;
  10544. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10545. static readonly NAME_SPRITE: string;
  10546. static readonly NAME_OUTLINERENDERER: string;
  10547. static readonly NAME_PROCEDURALTEXTURE: string;
  10548. static readonly NAME_SHADOWGENERATOR: string;
  10549. static readonly NAME_OCTREE: string;
  10550. static readonly NAME_PHYSICSENGINE: string;
  10551. static readonly NAME_AUDIO: string;
  10552. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10553. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10554. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10555. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10556. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10557. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10558. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10559. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10560. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10561. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10562. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10563. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10564. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10565. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10566. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10567. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10568. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10569. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10570. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10571. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10572. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10573. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10574. static readonly STEP_AFTERRENDER_AUDIO: number;
  10575. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10576. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10577. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10578. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10579. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10580. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10581. static readonly STEP_POINTERMOVE_SPRITE: number;
  10582. static readonly STEP_POINTERDOWN_SPRITE: number;
  10583. static readonly STEP_POINTERUP_SPRITE: number;
  10584. }
  10585. /**
  10586. * This represents a scene component.
  10587. *
  10588. * This is used to decouple the dependency the scene is having on the different workloads like
  10589. * layers, post processes...
  10590. */
  10591. export interface ISceneComponent {
  10592. /**
  10593. * The name of the component. Each component must have a unique name.
  10594. */
  10595. name: string;
  10596. /**
  10597. * The scene the component belongs to.
  10598. */
  10599. scene: Scene;
  10600. /**
  10601. * Register the component to one instance of a scene.
  10602. */
  10603. register(): void;
  10604. /**
  10605. * Rebuilds the elements related to this component in case of
  10606. * context lost for instance.
  10607. */
  10608. rebuild(): void;
  10609. /**
  10610. * Disposes the component and the associated ressources.
  10611. */
  10612. dispose(): void;
  10613. }
  10614. /**
  10615. * This represents a SERIALIZABLE scene component.
  10616. *
  10617. * This extends Scene Component to add Serialization methods on top.
  10618. */
  10619. export interface ISceneSerializableComponent extends ISceneComponent {
  10620. /**
  10621. * Adds all the elements from the container to the scene
  10622. * @param container the container holding the elements
  10623. */
  10624. addFromContainer(container: AbstractScene): void;
  10625. /**
  10626. * Removes all the elements in the container from the scene
  10627. * @param container contains the elements to remove
  10628. * @param dispose if the removed element should be disposed (default: false)
  10629. */
  10630. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10631. /**
  10632. * Serializes the component data to the specified json object
  10633. * @param serializationObject The object to serialize to
  10634. */
  10635. serialize(serializationObject: any): void;
  10636. }
  10637. /**
  10638. * Strong typing of a Mesh related stage step action
  10639. */
  10640. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10641. /**
  10642. * Strong typing of a Evaluate Sub Mesh related stage step action
  10643. */
  10644. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10645. /**
  10646. * Strong typing of a Active Mesh related stage step action
  10647. */
  10648. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10649. /**
  10650. * Strong typing of a Camera related stage step action
  10651. */
  10652. export type CameraStageAction = (camera: Camera) => void;
  10653. /**
  10654. * Strong typing of a Camera Frame buffer related stage step action
  10655. */
  10656. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10657. /**
  10658. * Strong typing of a Render Target related stage step action
  10659. */
  10660. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10661. /**
  10662. * Strong typing of a RenderingGroup related stage step action
  10663. */
  10664. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10665. /**
  10666. * Strong typing of a Mesh Render related stage step action
  10667. */
  10668. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10669. /**
  10670. * Strong typing of a simple stage step action
  10671. */
  10672. export type SimpleStageAction = () => void;
  10673. /**
  10674. * Strong typing of a render target action.
  10675. */
  10676. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10677. /**
  10678. * Strong typing of a pointer move action.
  10679. */
  10680. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10681. /**
  10682. * Strong typing of a pointer up/down action.
  10683. */
  10684. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10685. /**
  10686. * Representation of a stage in the scene (Basically a list of ordered steps)
  10687. * @hidden
  10688. */
  10689. export class Stage<T extends Function> extends Array<{
  10690. index: number;
  10691. component: ISceneComponent;
  10692. action: T;
  10693. }> {
  10694. /**
  10695. * Hide ctor from the rest of the world.
  10696. * @param items The items to add.
  10697. */
  10698. private constructor();
  10699. /**
  10700. * Creates a new Stage.
  10701. * @returns A new instance of a Stage
  10702. */
  10703. static Create<T extends Function>(): Stage<T>;
  10704. /**
  10705. * Registers a step in an ordered way in the targeted stage.
  10706. * @param index Defines the position to register the step in
  10707. * @param component Defines the component attached to the step
  10708. * @param action Defines the action to launch during the step
  10709. */
  10710. registerStep(index: number, component: ISceneComponent, action: T): void;
  10711. /**
  10712. * Clears all the steps from the stage.
  10713. */
  10714. clear(): void;
  10715. }
  10716. }
  10717. declare module BABYLON {
  10718. interface Scene {
  10719. /** @hidden */
  10720. _pointerOverSprite: Nullable<Sprite>;
  10721. /** @hidden */
  10722. _pickedDownSprite: Nullable<Sprite>;
  10723. /** @hidden */
  10724. _tempSpritePickingRay: Nullable<Ray>;
  10725. /**
  10726. * All of the sprite managers added to this scene
  10727. * @see https://doc.babylonjs.com/babylon101/sprites
  10728. */
  10729. spriteManagers: Array<ISpriteManager>;
  10730. /**
  10731. * An event triggered when sprites rendering is about to start
  10732. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10733. */
  10734. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10735. /**
  10736. * An event triggered when sprites rendering is done
  10737. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10738. */
  10739. onAfterSpritesRenderingObservable: Observable<Scene>;
  10740. /** @hidden */
  10741. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10742. /** Launch a ray to try to pick a sprite in the scene
  10743. * @param x position on screen
  10744. * @param y position on screen
  10745. * @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
  10746. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10747. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10748. * @returns a PickingInfo
  10749. */
  10750. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10751. /** Use the given ray to pick a sprite in the scene
  10752. * @param ray The ray (in world space) to use to pick meshes
  10753. * @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
  10754. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10755. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10756. * @returns a PickingInfo
  10757. */
  10758. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10759. /** @hidden */
  10760. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10761. /** Launch a ray to try to pick sprites in the scene
  10762. * @param x position on screen
  10763. * @param y position on screen
  10764. * @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
  10765. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10766. * @returns a PickingInfo array
  10767. */
  10768. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10769. /** Use the given ray to pick sprites in the scene
  10770. * @param ray The ray (in world space) to use to pick meshes
  10771. * @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
  10772. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10773. * @returns a PickingInfo array
  10774. */
  10775. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10776. /**
  10777. * Force the sprite under the pointer
  10778. * @param sprite defines the sprite to use
  10779. */
  10780. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10781. /**
  10782. * Gets the sprite under the pointer
  10783. * @returns a Sprite or null if no sprite is under the pointer
  10784. */
  10785. getPointerOverSprite(): Nullable<Sprite>;
  10786. }
  10787. /**
  10788. * Defines the sprite scene component responsible to manage sprites
  10789. * in a given scene.
  10790. */
  10791. export class SpriteSceneComponent implements ISceneComponent {
  10792. /**
  10793. * The component name helpfull to identify the component in the list of scene components.
  10794. */
  10795. readonly name: string;
  10796. /**
  10797. * The scene the component belongs to.
  10798. */
  10799. scene: Scene;
  10800. /** @hidden */
  10801. private _spritePredicate;
  10802. /**
  10803. * Creates a new instance of the component for the given scene
  10804. * @param scene Defines the scene to register the component in
  10805. */
  10806. constructor(scene: Scene);
  10807. /**
  10808. * Registers the component in a given scene
  10809. */
  10810. register(): void;
  10811. /**
  10812. * Rebuilds the elements related to this component in case of
  10813. * context lost for instance.
  10814. */
  10815. rebuild(): void;
  10816. /**
  10817. * Disposes the component and the associated ressources.
  10818. */
  10819. dispose(): void;
  10820. private _pickSpriteButKeepRay;
  10821. private _pointerMove;
  10822. private _pointerDown;
  10823. private _pointerUp;
  10824. }
  10825. }
  10826. declare module BABYLON {
  10827. /** @hidden */
  10828. export var fogFragmentDeclaration: {
  10829. name: string;
  10830. shader: string;
  10831. };
  10832. }
  10833. declare module BABYLON {
  10834. /** @hidden */
  10835. export var fogFragment: {
  10836. name: string;
  10837. shader: string;
  10838. };
  10839. }
  10840. declare module BABYLON {
  10841. /** @hidden */
  10842. export var spritesPixelShader: {
  10843. name: string;
  10844. shader: string;
  10845. };
  10846. }
  10847. declare module BABYLON {
  10848. /** @hidden */
  10849. export var fogVertexDeclaration: {
  10850. name: string;
  10851. shader: string;
  10852. };
  10853. }
  10854. declare module BABYLON {
  10855. /** @hidden */
  10856. export var spritesVertexShader: {
  10857. name: string;
  10858. shader: string;
  10859. };
  10860. }
  10861. declare module BABYLON {
  10862. /**
  10863. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10864. */
  10865. export interface ISpriteManager extends IDisposable {
  10866. /**
  10867. * Gets manager's name
  10868. */
  10869. name: string;
  10870. /**
  10871. * Restricts the camera to viewing objects with the same layerMask.
  10872. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10873. */
  10874. layerMask: number;
  10875. /**
  10876. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10877. */
  10878. isPickable: boolean;
  10879. /**
  10880. * Gets the hosting scene
  10881. */
  10882. scene: Scene;
  10883. /**
  10884. * Specifies the rendering group id for this mesh (0 by default)
  10885. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10886. */
  10887. renderingGroupId: number;
  10888. /**
  10889. * Defines the list of sprites managed by the manager.
  10890. */
  10891. sprites: Array<Sprite>;
  10892. /**
  10893. * Gets or sets the spritesheet texture
  10894. */
  10895. texture: Texture;
  10896. /** Defines the default width of a cell in the spritesheet */
  10897. cellWidth: number;
  10898. /** Defines the default height of a cell in the spritesheet */
  10899. cellHeight: number;
  10900. /**
  10901. * Tests the intersection of a sprite with a specific ray.
  10902. * @param ray The ray we are sending to test the collision
  10903. * @param camera The camera space we are sending rays in
  10904. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10905. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10906. * @returns picking info or null.
  10907. */
  10908. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10909. /**
  10910. * Intersects the sprites with a ray
  10911. * @param ray defines the ray to intersect with
  10912. * @param camera defines the current active camera
  10913. * @param predicate defines a predicate used to select candidate sprites
  10914. * @returns null if no hit or a PickingInfo array
  10915. */
  10916. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10917. /**
  10918. * Renders the list of sprites on screen.
  10919. */
  10920. render(): void;
  10921. }
  10922. /**
  10923. * Class used to manage multiple sprites on the same spritesheet
  10924. * @see https://doc.babylonjs.com/babylon101/sprites
  10925. */
  10926. export class SpriteManager implements ISpriteManager {
  10927. /** defines the manager's name */
  10928. name: string;
  10929. /** Define the Url to load snippets */
  10930. static SnippetUrl: string;
  10931. /** Snippet ID if the manager was created from the snippet server */
  10932. snippetId: string;
  10933. /** Gets the list of sprites */
  10934. sprites: Sprite[];
  10935. /** Gets or sets the rendering group id (0 by default) */
  10936. renderingGroupId: number;
  10937. /** Gets or sets camera layer mask */
  10938. layerMask: number;
  10939. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10940. fogEnabled: boolean;
  10941. /** Gets or sets a boolean indicating if the sprites are pickable */
  10942. isPickable: boolean;
  10943. /** Defines the default width of a cell in the spritesheet */
  10944. cellWidth: number;
  10945. /** Defines the default height of a cell in the spritesheet */
  10946. cellHeight: number;
  10947. /** Associative array from JSON sprite data file */
  10948. private _cellData;
  10949. /** Array of sprite names from JSON sprite data file */
  10950. private _spriteMap;
  10951. /** True when packed cell data from JSON file is ready*/
  10952. private _packedAndReady;
  10953. private _textureContent;
  10954. /**
  10955. * An event triggered when the manager is disposed.
  10956. */
  10957. onDisposeObservable: Observable<SpriteManager>;
  10958. private _onDisposeObserver;
  10959. /**
  10960. * Callback called when the manager is disposed
  10961. */
  10962. set onDispose(callback: () => void);
  10963. private _capacity;
  10964. private _fromPacked;
  10965. private _spriteTexture;
  10966. private _epsilon;
  10967. private _scene;
  10968. private _vertexData;
  10969. private _buffer;
  10970. private _vertexBuffers;
  10971. private _indexBuffer;
  10972. private _effectBase;
  10973. private _effectFog;
  10974. /**
  10975. * Gets or sets the unique id of the sprite
  10976. */
  10977. uniqueId: number;
  10978. /**
  10979. * Gets the array of sprites
  10980. */
  10981. get children(): Sprite[];
  10982. /**
  10983. * Gets the hosting scene
  10984. */
  10985. get scene(): Scene;
  10986. /**
  10987. * Gets the capacity of the manager
  10988. */
  10989. get capacity(): number;
  10990. /**
  10991. * Gets or sets the spritesheet texture
  10992. */
  10993. get texture(): Texture;
  10994. set texture(value: Texture);
  10995. private _blendMode;
  10996. /**
  10997. * Blend mode use to render the particle, it can be any of
  10998. * the static Constants.ALPHA_x properties provided in this class.
  10999. * Default value is Constants.ALPHA_COMBINE
  11000. */
  11001. get blendMode(): number;
  11002. set blendMode(blendMode: number);
  11003. /** Disables writing to the depth buffer when rendering the sprites.
  11004. * It can be handy to disable depth writing when using textures without alpha channel
  11005. * and setting some specific blend modes.
  11006. */
  11007. disableDepthWrite: boolean;
  11008. /**
  11009. * Creates a new sprite manager
  11010. * @param name defines the manager's name
  11011. * @param imgUrl defines the sprite sheet url
  11012. * @param capacity defines the maximum allowed number of sprites
  11013. * @param cellSize defines the size of a sprite cell
  11014. * @param scene defines the hosting scene
  11015. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11016. * @param samplingMode defines the smapling mode to use with spritesheet
  11017. * @param fromPacked set to false; do not alter
  11018. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11019. */
  11020. constructor(
  11021. /** defines the manager's name */
  11022. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11023. /**
  11024. * Returns the string "SpriteManager"
  11025. * @returns "SpriteManager"
  11026. */
  11027. getClassName(): string;
  11028. private _makePacked;
  11029. private _appendSpriteVertex;
  11030. private _checkTextureAlpha;
  11031. /**
  11032. * Intersects the sprites with a ray
  11033. * @param ray defines the ray to intersect with
  11034. * @param camera defines the current active camera
  11035. * @param predicate defines a predicate used to select candidate sprites
  11036. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11037. * @returns null if no hit or a PickingInfo
  11038. */
  11039. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11040. /**
  11041. * Intersects the sprites with a ray
  11042. * @param ray defines the ray to intersect with
  11043. * @param camera defines the current active camera
  11044. * @param predicate defines a predicate used to select candidate sprites
  11045. * @returns null if no hit or a PickingInfo array
  11046. */
  11047. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11048. /**
  11049. * Render all child sprites
  11050. */
  11051. render(): void;
  11052. /**
  11053. * Release associated resources
  11054. */
  11055. dispose(): void;
  11056. /**
  11057. * Serializes the sprite manager to a JSON object
  11058. * @param serializeTexture defines if the texture must be serialized as well
  11059. * @returns the JSON object
  11060. */
  11061. serialize(serializeTexture?: boolean): any;
  11062. /**
  11063. * Parses a JSON object to create a new sprite manager.
  11064. * @param parsedManager The JSON object to parse
  11065. * @param scene The scene to create the sprite managerin
  11066. * @param rootUrl The root url to use to load external dependencies like texture
  11067. * @returns the new sprite manager
  11068. */
  11069. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11070. /**
  11071. * Creates a sprite manager from a snippet saved in a remote file
  11072. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11073. * @param url defines the url to load from
  11074. * @param scene defines the hosting scene
  11075. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11076. * @returns a promise that will resolve to the new sprite manager
  11077. */
  11078. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11079. /**
  11080. * Creates a sprite manager from a snippet saved by the sprite editor
  11081. * @param snippetId defines the snippet to load
  11082. * @param scene defines the hosting scene
  11083. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11084. * @returns a promise that will resolve to the new sprite manager
  11085. */
  11086. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11087. }
  11088. }
  11089. declare module BABYLON {
  11090. /** Interface used by value gradients (color, factor, ...) */
  11091. export interface IValueGradient {
  11092. /**
  11093. * Gets or sets the gradient value (between 0 and 1)
  11094. */
  11095. gradient: number;
  11096. }
  11097. /** Class used to store color4 gradient */
  11098. export class ColorGradient implements IValueGradient {
  11099. /**
  11100. * Gets or sets the gradient value (between 0 and 1)
  11101. */
  11102. gradient: number;
  11103. /**
  11104. * Gets or sets first associated color
  11105. */
  11106. color1: Color4;
  11107. /**
  11108. * Gets or sets second associated color
  11109. */
  11110. color2?: Color4 | undefined;
  11111. /**
  11112. * Creates a new color4 gradient
  11113. * @param gradient gets or sets the gradient value (between 0 and 1)
  11114. * @param color1 gets or sets first associated color
  11115. * @param color2 gets or sets first second color
  11116. */
  11117. constructor(
  11118. /**
  11119. * Gets or sets the gradient value (between 0 and 1)
  11120. */
  11121. gradient: number,
  11122. /**
  11123. * Gets or sets first associated color
  11124. */
  11125. color1: Color4,
  11126. /**
  11127. * Gets or sets second associated color
  11128. */
  11129. color2?: Color4 | undefined);
  11130. /**
  11131. * Will get a color picked randomly between color1 and color2.
  11132. * If color2 is undefined then color1 will be used
  11133. * @param result defines the target Color4 to store the result in
  11134. */
  11135. getColorToRef(result: Color4): void;
  11136. }
  11137. /** Class used to store color 3 gradient */
  11138. export class Color3Gradient implements IValueGradient {
  11139. /**
  11140. * Gets or sets the gradient value (between 0 and 1)
  11141. */
  11142. gradient: number;
  11143. /**
  11144. * Gets or sets the associated color
  11145. */
  11146. color: Color3;
  11147. /**
  11148. * Creates a new color3 gradient
  11149. * @param gradient gets or sets the gradient value (between 0 and 1)
  11150. * @param color gets or sets associated color
  11151. */
  11152. constructor(
  11153. /**
  11154. * Gets or sets the gradient value (between 0 and 1)
  11155. */
  11156. gradient: number,
  11157. /**
  11158. * Gets or sets the associated color
  11159. */
  11160. color: Color3);
  11161. }
  11162. /** Class used to store factor gradient */
  11163. export class FactorGradient implements IValueGradient {
  11164. /**
  11165. * Gets or sets the gradient value (between 0 and 1)
  11166. */
  11167. gradient: number;
  11168. /**
  11169. * Gets or sets first associated factor
  11170. */
  11171. factor1: number;
  11172. /**
  11173. * Gets or sets second associated factor
  11174. */
  11175. factor2?: number | undefined;
  11176. /**
  11177. * Creates a new factor gradient
  11178. * @param gradient gets or sets the gradient value (between 0 and 1)
  11179. * @param factor1 gets or sets first associated factor
  11180. * @param factor2 gets or sets second associated factor
  11181. */
  11182. constructor(
  11183. /**
  11184. * Gets or sets the gradient value (between 0 and 1)
  11185. */
  11186. gradient: number,
  11187. /**
  11188. * Gets or sets first associated factor
  11189. */
  11190. factor1: number,
  11191. /**
  11192. * Gets or sets second associated factor
  11193. */
  11194. factor2?: number | undefined);
  11195. /**
  11196. * Will get a number picked randomly between factor1 and factor2.
  11197. * If factor2 is undefined then factor1 will be used
  11198. * @returns the picked number
  11199. */
  11200. getFactor(): number;
  11201. }
  11202. /**
  11203. * Helper used to simplify some generic gradient tasks
  11204. */
  11205. export class GradientHelper {
  11206. /**
  11207. * Gets the current gradient from an array of IValueGradient
  11208. * @param ratio defines the current ratio to get
  11209. * @param gradients defines the array of IValueGradient
  11210. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11211. */
  11212. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11213. }
  11214. }
  11215. declare module BABYLON {
  11216. interface ThinEngine {
  11217. /**
  11218. * Creates a raw texture
  11219. * @param data defines the data to store in the texture
  11220. * @param width defines the width of the texture
  11221. * @param height defines the height of the texture
  11222. * @param format defines the format of the data
  11223. * @param generateMipMaps defines if the engine should generate the mip levels
  11224. * @param invertY defines if data must be stored with Y axis inverted
  11225. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11226. * @param compression defines the compression used (null by default)
  11227. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11228. * @returns the raw texture inside an InternalTexture
  11229. */
  11230. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11231. /**
  11232. * Update a raw texture
  11233. * @param texture defines the texture to update
  11234. * @param data defines the data to store in the texture
  11235. * @param format defines the format of the data
  11236. * @param invertY defines if data must be stored with Y axis inverted
  11237. */
  11238. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11239. /**
  11240. * Update a raw texture
  11241. * @param texture defines the texture to update
  11242. * @param data defines the data to store in the texture
  11243. * @param format defines the format of the data
  11244. * @param invertY defines if data must be stored with Y axis inverted
  11245. * @param compression defines the compression used (null by default)
  11246. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11247. */
  11248. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11249. /**
  11250. * Creates a new raw cube texture
  11251. * @param data defines the array of data to use to create each face
  11252. * @param size defines the size of the textures
  11253. * @param format defines the format of the data
  11254. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11255. * @param generateMipMaps defines if the engine should generate the mip levels
  11256. * @param invertY defines if data must be stored with Y axis inverted
  11257. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11258. * @param compression defines the compression used (null by default)
  11259. * @returns the cube texture as an InternalTexture
  11260. */
  11261. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11262. /**
  11263. * Update a raw cube texture
  11264. * @param texture defines the texture to udpdate
  11265. * @param data defines the data to store
  11266. * @param format defines the data format
  11267. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11268. * @param invertY defines if data must be stored with Y axis inverted
  11269. */
  11270. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11271. /**
  11272. * Update a raw cube texture
  11273. * @param texture defines the texture to udpdate
  11274. * @param data defines the data to store
  11275. * @param format defines the data format
  11276. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11277. * @param invertY defines if data must be stored with Y axis inverted
  11278. * @param compression defines the compression used (null by default)
  11279. */
  11280. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11281. /**
  11282. * Update a raw cube texture
  11283. * @param texture defines the texture to udpdate
  11284. * @param data defines the data to store
  11285. * @param format defines the data format
  11286. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11287. * @param invertY defines if data must be stored with Y axis inverted
  11288. * @param compression defines the compression used (null by default)
  11289. * @param level defines which level of the texture to update
  11290. */
  11291. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11292. /**
  11293. * Creates a new raw cube texture from a specified url
  11294. * @param url defines the url where the data is located
  11295. * @param scene defines the current scene
  11296. * @param size defines the size of the textures
  11297. * @param format defines the format of the data
  11298. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11299. * @param noMipmap defines if the engine should avoid generating the mip levels
  11300. * @param callback defines a callback used to extract texture data from loaded data
  11301. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11302. * @param onLoad defines a callback called when texture is loaded
  11303. * @param onError defines a callback called if there is an error
  11304. * @returns the cube texture as an InternalTexture
  11305. */
  11306. 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;
  11307. /**
  11308. * Creates a new raw cube texture from a specified url
  11309. * @param url defines the url where the data is located
  11310. * @param scene defines the current scene
  11311. * @param size defines the size of the textures
  11312. * @param format defines the format of the data
  11313. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11314. * @param noMipmap defines if the engine should avoid generating the mip levels
  11315. * @param callback defines a callback used to extract texture data from loaded data
  11316. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11317. * @param onLoad defines a callback called when texture is loaded
  11318. * @param onError defines a callback called if there is an error
  11319. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11320. * @param invertY defines if data must be stored with Y axis inverted
  11321. * @returns the cube texture as an InternalTexture
  11322. */
  11323. 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;
  11324. /**
  11325. * Creates a new raw 3D texture
  11326. * @param data defines the data used to create the texture
  11327. * @param width defines the width of the texture
  11328. * @param height defines the height of the texture
  11329. * @param depth defines the depth of the texture
  11330. * @param format defines the format of the texture
  11331. * @param generateMipMaps defines if the engine must generate mip levels
  11332. * @param invertY defines if data must be stored with Y axis inverted
  11333. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11334. * @param compression defines the compressed used (can be null)
  11335. * @param textureType defines the compressed used (can be null)
  11336. * @returns a new raw 3D texture (stored in an InternalTexture)
  11337. */
  11338. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11339. /**
  11340. * Update a raw 3D texture
  11341. * @param texture defines the texture to update
  11342. * @param data defines the data to store
  11343. * @param format defines the data format
  11344. * @param invertY defines if data must be stored with Y axis inverted
  11345. */
  11346. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11347. /**
  11348. * Update a raw 3D texture
  11349. * @param texture defines the texture to update
  11350. * @param data defines the data to store
  11351. * @param format defines the data format
  11352. * @param invertY defines if data must be stored with Y axis inverted
  11353. * @param compression defines the used compression (can be null)
  11354. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11355. */
  11356. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11357. /**
  11358. * Creates a new raw 2D array texture
  11359. * @param data defines the data used to create the texture
  11360. * @param width defines the width of the texture
  11361. * @param height defines the height of the texture
  11362. * @param depth defines the number of layers of the texture
  11363. * @param format defines the format of the texture
  11364. * @param generateMipMaps defines if the engine must generate mip levels
  11365. * @param invertY defines if data must be stored with Y axis inverted
  11366. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11367. * @param compression defines the compressed used (can be null)
  11368. * @param textureType defines the compressed used (can be null)
  11369. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11370. */
  11371. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11372. /**
  11373. * Update a raw 2D array texture
  11374. * @param texture defines the texture to update
  11375. * @param data defines the data to store
  11376. * @param format defines the data format
  11377. * @param invertY defines if data must be stored with Y axis inverted
  11378. */
  11379. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11380. /**
  11381. * Update a raw 2D array texture
  11382. * @param texture defines the texture to update
  11383. * @param data defines the data to store
  11384. * @param format defines the data format
  11385. * @param invertY defines if data must be stored with Y axis inverted
  11386. * @param compression defines the used compression (can be null)
  11387. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11388. */
  11389. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11390. }
  11391. }
  11392. declare module BABYLON {
  11393. /**
  11394. * Raw texture can help creating a texture directly from an array of data.
  11395. * This can be super useful if you either get the data from an uncompressed source or
  11396. * if you wish to create your texture pixel by pixel.
  11397. */
  11398. export class RawTexture extends Texture {
  11399. /**
  11400. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11401. */
  11402. format: number;
  11403. /**
  11404. * Instantiates a new RawTexture.
  11405. * Raw texture can help creating a texture directly from an array of data.
  11406. * This can be super useful if you either get the data from an uncompressed source or
  11407. * if you wish to create your texture pixel by pixel.
  11408. * @param data define the array of data to use to create the texture
  11409. * @param width define the width of the texture
  11410. * @param height define the height of the texture
  11411. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11412. * @param scene define the scene the texture belongs to
  11413. * @param generateMipMaps define whether mip maps should be generated or not
  11414. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11415. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11416. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11417. */
  11418. constructor(data: ArrayBufferView, width: number, height: number,
  11419. /**
  11420. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11421. */
  11422. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11423. /**
  11424. * Updates the texture underlying data.
  11425. * @param data Define the new data of the texture
  11426. */
  11427. update(data: ArrayBufferView): void;
  11428. /**
  11429. * Creates a luminance texture from some data.
  11430. * @param data Define the texture data
  11431. * @param width Define the width of the texture
  11432. * @param height Define the height of the texture
  11433. * @param scene Define the scene the texture belongs to
  11434. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11435. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11436. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11437. * @returns the luminance texture
  11438. */
  11439. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11440. /**
  11441. * Creates a luminance alpha texture from some data.
  11442. * @param data Define the texture data
  11443. * @param width Define the width of the texture
  11444. * @param height Define the height of the texture
  11445. * @param scene Define the scene the texture belongs to
  11446. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11447. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11448. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11449. * @returns the luminance alpha texture
  11450. */
  11451. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11452. /**
  11453. * Creates an alpha texture from some data.
  11454. * @param data Define the texture data
  11455. * @param width Define the width of the texture
  11456. * @param height Define the height of the texture
  11457. * @param scene Define the scene the texture belongs to
  11458. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11459. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11460. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11461. * @returns the alpha texture
  11462. */
  11463. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11464. /**
  11465. * Creates a RGB texture from some data.
  11466. * @param data Define the texture data
  11467. * @param width Define the width of the texture
  11468. * @param height Define the height of the texture
  11469. * @param scene Define the scene the texture belongs to
  11470. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11471. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11472. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11473. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11474. * @returns the RGB alpha texture
  11475. */
  11476. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11477. /**
  11478. * Creates a RGBA texture from some data.
  11479. * @param data Define the texture data
  11480. * @param width Define the width of the texture
  11481. * @param height Define the height of the texture
  11482. * @param scene Define the scene the texture belongs to
  11483. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11484. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11485. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11486. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11487. * @returns the RGBA texture
  11488. */
  11489. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11490. /**
  11491. * Creates a R texture from some data.
  11492. * @param data Define the texture data
  11493. * @param width Define the width of the texture
  11494. * @param height Define the height of the texture
  11495. * @param scene Define the scene the texture belongs to
  11496. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11497. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11498. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11499. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11500. * @returns the R texture
  11501. */
  11502. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11503. }
  11504. }
  11505. declare module BABYLON {
  11506. interface AbstractScene {
  11507. /**
  11508. * The list of procedural textures added to the scene
  11509. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11510. */
  11511. proceduralTextures: Array<ProceduralTexture>;
  11512. }
  11513. /**
  11514. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11515. * in a given scene.
  11516. */
  11517. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11518. /**
  11519. * The component name helpfull to identify the component in the list of scene components.
  11520. */
  11521. readonly name: string;
  11522. /**
  11523. * The scene the component belongs to.
  11524. */
  11525. scene: Scene;
  11526. /**
  11527. * Creates a new instance of the component for the given scene
  11528. * @param scene Defines the scene to register the component in
  11529. */
  11530. constructor(scene: Scene);
  11531. /**
  11532. * Registers the component in a given scene
  11533. */
  11534. register(): void;
  11535. /**
  11536. * Rebuilds the elements related to this component in case of
  11537. * context lost for instance.
  11538. */
  11539. rebuild(): void;
  11540. /**
  11541. * Disposes the component and the associated ressources.
  11542. */
  11543. dispose(): void;
  11544. private _beforeClear;
  11545. }
  11546. }
  11547. declare module BABYLON {
  11548. interface ThinEngine {
  11549. /**
  11550. * Creates a new render target cube texture
  11551. * @param size defines the size of the texture
  11552. * @param options defines the options used to create the texture
  11553. * @returns a new render target cube texture stored in an InternalTexture
  11554. */
  11555. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11556. }
  11557. }
  11558. declare module BABYLON {
  11559. /** @hidden */
  11560. export var proceduralVertexShader: {
  11561. name: string;
  11562. shader: string;
  11563. };
  11564. }
  11565. declare module BABYLON {
  11566. /**
  11567. * 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.
  11568. * This is the base class of any Procedural texture and contains most of the shareable code.
  11569. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11570. */
  11571. export class ProceduralTexture extends Texture {
  11572. isCube: boolean;
  11573. /**
  11574. * Define if the texture is enabled or not (disabled texture will not render)
  11575. */
  11576. isEnabled: boolean;
  11577. /**
  11578. * Define if the texture must be cleared before rendering (default is true)
  11579. */
  11580. autoClear: boolean;
  11581. /**
  11582. * Callback called when the texture is generated
  11583. */
  11584. onGenerated: () => void;
  11585. /**
  11586. * Event raised when the texture is generated
  11587. */
  11588. onGeneratedObservable: Observable<ProceduralTexture>;
  11589. /** @hidden */
  11590. _generateMipMaps: boolean;
  11591. /** @hidden **/
  11592. _effect: Effect;
  11593. /** @hidden */
  11594. _textures: {
  11595. [key: string]: Texture;
  11596. };
  11597. /** @hidden */
  11598. protected _fallbackTexture: Nullable<Texture>;
  11599. private _size;
  11600. private _currentRefreshId;
  11601. private _frameId;
  11602. private _refreshRate;
  11603. private _vertexBuffers;
  11604. private _indexBuffer;
  11605. private _uniforms;
  11606. private _samplers;
  11607. private _fragment;
  11608. private _floats;
  11609. private _ints;
  11610. private _floatsArrays;
  11611. private _colors3;
  11612. private _colors4;
  11613. private _vectors2;
  11614. private _vectors3;
  11615. private _matrices;
  11616. private _fallbackTextureUsed;
  11617. private _fullEngine;
  11618. private _cachedDefines;
  11619. private _contentUpdateId;
  11620. private _contentData;
  11621. /**
  11622. * Instantiates a new procedural texture.
  11623. * 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.
  11624. * This is the base class of any Procedural texture and contains most of the shareable code.
  11625. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11626. * @param name Define the name of the texture
  11627. * @param size Define the size of the texture to create
  11628. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11629. * @param scene Define the scene the texture belongs to
  11630. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11631. * @param generateMipMaps Define if the texture should creates mip maps or not
  11632. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11633. */
  11634. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11635. /**
  11636. * The effect that is created when initializing the post process.
  11637. * @returns The created effect corresponding the the postprocess.
  11638. */
  11639. getEffect(): Effect;
  11640. /**
  11641. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11642. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11643. */
  11644. getContent(): Nullable<ArrayBufferView>;
  11645. private _createIndexBuffer;
  11646. /** @hidden */
  11647. _rebuild(): void;
  11648. /**
  11649. * Resets the texture in order to recreate its associated resources.
  11650. * This can be called in case of context loss
  11651. */
  11652. reset(): void;
  11653. protected _getDefines(): string;
  11654. /**
  11655. * Is the texture ready to be used ? (rendered at least once)
  11656. * @returns true if ready, otherwise, false.
  11657. */
  11658. isReady(): boolean;
  11659. /**
  11660. * Resets the refresh counter of the texture and start bak from scratch.
  11661. * Could be useful to regenerate the texture if it is setup to render only once.
  11662. */
  11663. resetRefreshCounter(): void;
  11664. /**
  11665. * Set the fragment shader to use in order to render the texture.
  11666. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11667. */
  11668. setFragment(fragment: any): void;
  11669. /**
  11670. * Define the refresh rate of the texture or the rendering frequency.
  11671. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11672. */
  11673. get refreshRate(): number;
  11674. set refreshRate(value: number);
  11675. /** @hidden */
  11676. _shouldRender(): boolean;
  11677. /**
  11678. * Get the size the texture is rendering at.
  11679. * @returns the size (texture is always squared)
  11680. */
  11681. getRenderSize(): number;
  11682. /**
  11683. * Resize the texture to new value.
  11684. * @param size Define the new size the texture should have
  11685. * @param generateMipMaps Define whether the new texture should create mip maps
  11686. */
  11687. resize(size: number, generateMipMaps: boolean): void;
  11688. private _checkUniform;
  11689. /**
  11690. * Set a texture in the shader program used to render.
  11691. * @param name Define the name of the uniform samplers as defined in the shader
  11692. * @param texture Define the texture to bind to this sampler
  11693. * @return the texture itself allowing "fluent" like uniform updates
  11694. */
  11695. setTexture(name: string, texture: Texture): ProceduralTexture;
  11696. /**
  11697. * Set a float in the shader.
  11698. * @param name Define the name of the uniform as defined in the shader
  11699. * @param value Define the value to give to the uniform
  11700. * @return the texture itself allowing "fluent" like uniform updates
  11701. */
  11702. setFloat(name: string, value: number): ProceduralTexture;
  11703. /**
  11704. * Set a int in the shader.
  11705. * @param name Define the name of the uniform as defined in the shader
  11706. * @param value Define the value to give to the uniform
  11707. * @return the texture itself allowing "fluent" like uniform updates
  11708. */
  11709. setInt(name: string, value: number): ProceduralTexture;
  11710. /**
  11711. * Set an array of floats in the shader.
  11712. * @param name Define the name of the uniform as defined in the shader
  11713. * @param value Define the value to give to the uniform
  11714. * @return the texture itself allowing "fluent" like uniform updates
  11715. */
  11716. setFloats(name: string, value: number[]): ProceduralTexture;
  11717. /**
  11718. * Set a vec3 in the shader from a Color3.
  11719. * @param name Define the name of the uniform as defined in the shader
  11720. * @param value Define the value to give to the uniform
  11721. * @return the texture itself allowing "fluent" like uniform updates
  11722. */
  11723. setColor3(name: string, value: Color3): ProceduralTexture;
  11724. /**
  11725. * Set a vec4 in the shader from a Color4.
  11726. * @param name Define the name of the uniform as defined in the shader
  11727. * @param value Define the value to give to the uniform
  11728. * @return the texture itself allowing "fluent" like uniform updates
  11729. */
  11730. setColor4(name: string, value: Color4): ProceduralTexture;
  11731. /**
  11732. * Set a vec2 in the shader from a Vector2.
  11733. * @param name Define the name of the uniform as defined in the shader
  11734. * @param value Define the value to give to the uniform
  11735. * @return the texture itself allowing "fluent" like uniform updates
  11736. */
  11737. setVector2(name: string, value: Vector2): ProceduralTexture;
  11738. /**
  11739. * Set a vec3 in the shader from a Vector3.
  11740. * @param name Define the name of the uniform as defined in the shader
  11741. * @param value Define the value to give to the uniform
  11742. * @return the texture itself allowing "fluent" like uniform updates
  11743. */
  11744. setVector3(name: string, value: Vector3): ProceduralTexture;
  11745. /**
  11746. * Set a mat4 in the shader from a MAtrix.
  11747. * @param name Define the name of the uniform as defined in the shader
  11748. * @param value Define the value to give to the uniform
  11749. * @return the texture itself allowing "fluent" like uniform updates
  11750. */
  11751. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11752. /**
  11753. * Render the texture to its associated render target.
  11754. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11755. */
  11756. render(useCameraPostProcess?: boolean): void;
  11757. /**
  11758. * Clone the texture.
  11759. * @returns the cloned texture
  11760. */
  11761. clone(): ProceduralTexture;
  11762. /**
  11763. * Dispose the texture and release its asoociated resources.
  11764. */
  11765. dispose(): void;
  11766. }
  11767. }
  11768. declare module BABYLON {
  11769. /**
  11770. * This represents the base class for particle system in Babylon.
  11771. * 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.
  11772. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11773. * @example https://doc.babylonjs.com/babylon101/particles
  11774. */
  11775. export class BaseParticleSystem {
  11776. /**
  11777. * Source color is added to the destination color without alpha affecting the result
  11778. */
  11779. static BLENDMODE_ONEONE: number;
  11780. /**
  11781. * Blend current color and particle color using particle’s alpha
  11782. */
  11783. static BLENDMODE_STANDARD: number;
  11784. /**
  11785. * Add current color and particle color multiplied by particle’s alpha
  11786. */
  11787. static BLENDMODE_ADD: number;
  11788. /**
  11789. * Multiply current color with particle color
  11790. */
  11791. static BLENDMODE_MULTIPLY: number;
  11792. /**
  11793. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11794. */
  11795. static BLENDMODE_MULTIPLYADD: number;
  11796. /**
  11797. * List of animations used by the particle system.
  11798. */
  11799. animations: Animation[];
  11800. /**
  11801. * Gets or sets the unique id of the particle system
  11802. */
  11803. uniqueId: number;
  11804. /**
  11805. * The id of the Particle system.
  11806. */
  11807. id: string;
  11808. /**
  11809. * The friendly name of the Particle system.
  11810. */
  11811. name: string;
  11812. /**
  11813. * Snippet ID if the particle system was created from the snippet server
  11814. */
  11815. snippetId: string;
  11816. /**
  11817. * The rendering group used by the Particle system to chose when to render.
  11818. */
  11819. renderingGroupId: number;
  11820. /**
  11821. * The emitter represents the Mesh or position we are attaching the particle system to.
  11822. */
  11823. emitter: Nullable<AbstractMesh | Vector3>;
  11824. /**
  11825. * The maximum number of particles to emit per frame
  11826. */
  11827. emitRate: number;
  11828. /**
  11829. * If you want to launch only a few particles at once, that can be done, as well.
  11830. */
  11831. manualEmitCount: number;
  11832. /**
  11833. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11834. */
  11835. updateSpeed: number;
  11836. /**
  11837. * The amount of time the particle system is running (depends of the overall update speed).
  11838. */
  11839. targetStopDuration: number;
  11840. /**
  11841. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11842. */
  11843. disposeOnStop: boolean;
  11844. /**
  11845. * Minimum power of emitting particles.
  11846. */
  11847. minEmitPower: number;
  11848. /**
  11849. * Maximum power of emitting particles.
  11850. */
  11851. maxEmitPower: number;
  11852. /**
  11853. * Minimum life time of emitting particles.
  11854. */
  11855. minLifeTime: number;
  11856. /**
  11857. * Maximum life time of emitting particles.
  11858. */
  11859. maxLifeTime: number;
  11860. /**
  11861. * Minimum Size of emitting particles.
  11862. */
  11863. minSize: number;
  11864. /**
  11865. * Maximum Size of emitting particles.
  11866. */
  11867. maxSize: number;
  11868. /**
  11869. * Minimum scale of emitting particles on X axis.
  11870. */
  11871. minScaleX: number;
  11872. /**
  11873. * Maximum scale of emitting particles on X axis.
  11874. */
  11875. maxScaleX: number;
  11876. /**
  11877. * Minimum scale of emitting particles on Y axis.
  11878. */
  11879. minScaleY: number;
  11880. /**
  11881. * Maximum scale of emitting particles on Y axis.
  11882. */
  11883. maxScaleY: number;
  11884. /**
  11885. * Gets or sets the minimal initial rotation in radians.
  11886. */
  11887. minInitialRotation: number;
  11888. /**
  11889. * Gets or sets the maximal initial rotation in radians.
  11890. */
  11891. maxInitialRotation: number;
  11892. /**
  11893. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11894. */
  11895. minAngularSpeed: number;
  11896. /**
  11897. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11898. */
  11899. maxAngularSpeed: number;
  11900. /**
  11901. * The texture used to render each particle. (this can be a spritesheet)
  11902. */
  11903. particleTexture: Nullable<Texture>;
  11904. /**
  11905. * The layer mask we are rendering the particles through.
  11906. */
  11907. layerMask: number;
  11908. /**
  11909. * This can help using your own shader to render the particle system.
  11910. * The according effect will be created
  11911. */
  11912. customShader: any;
  11913. /**
  11914. * By default particle system starts as soon as they are created. This prevents the
  11915. * automatic start to happen and let you decide when to start emitting particles.
  11916. */
  11917. preventAutoStart: boolean;
  11918. private _noiseTexture;
  11919. /**
  11920. * Gets or sets a texture used to add random noise to particle positions
  11921. */
  11922. get noiseTexture(): Nullable<ProceduralTexture>;
  11923. set noiseTexture(value: Nullable<ProceduralTexture>);
  11924. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11925. noiseStrength: Vector3;
  11926. /**
  11927. * Callback triggered when the particle animation is ending.
  11928. */
  11929. onAnimationEnd: Nullable<() => void>;
  11930. /**
  11931. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11932. */
  11933. blendMode: number;
  11934. /**
  11935. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11936. * to override the particles.
  11937. */
  11938. forceDepthWrite: boolean;
  11939. /** 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 */
  11940. preWarmCycles: number;
  11941. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11942. preWarmStepOffset: number;
  11943. /**
  11944. * 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)
  11945. */
  11946. spriteCellChangeSpeed: number;
  11947. /**
  11948. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11949. */
  11950. startSpriteCellID: number;
  11951. /**
  11952. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11953. */
  11954. endSpriteCellID: number;
  11955. /**
  11956. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11957. */
  11958. spriteCellWidth: number;
  11959. /**
  11960. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11961. */
  11962. spriteCellHeight: number;
  11963. /**
  11964. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11965. */
  11966. spriteRandomStartCell: boolean;
  11967. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11968. translationPivot: Vector2;
  11969. /** @hidden */
  11970. protected _isAnimationSheetEnabled: boolean;
  11971. /**
  11972. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11973. */
  11974. beginAnimationOnStart: boolean;
  11975. /**
  11976. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11977. */
  11978. beginAnimationFrom: number;
  11979. /**
  11980. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11981. */
  11982. beginAnimationTo: number;
  11983. /**
  11984. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11985. */
  11986. beginAnimationLoop: boolean;
  11987. /**
  11988. * Gets or sets a world offset applied to all particles
  11989. */
  11990. worldOffset: Vector3;
  11991. /**
  11992. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11993. */
  11994. get isAnimationSheetEnabled(): boolean;
  11995. set isAnimationSheetEnabled(value: boolean);
  11996. /**
  11997. * Get hosting scene
  11998. * @returns the scene
  11999. */
  12000. getScene(): Scene;
  12001. /**
  12002. * You can use gravity if you want to give an orientation to your particles.
  12003. */
  12004. gravity: Vector3;
  12005. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12006. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12007. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12008. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12009. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12010. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12011. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12012. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12013. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12014. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12015. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12016. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12017. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12018. /**
  12019. * Defines the delay in milliseconds before starting the system (0 by default)
  12020. */
  12021. startDelay: number;
  12022. /**
  12023. * Gets the current list of drag gradients.
  12024. * You must use addDragGradient and removeDragGradient to udpate this list
  12025. * @returns the list of drag gradients
  12026. */
  12027. getDragGradients(): Nullable<Array<FactorGradient>>;
  12028. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12029. limitVelocityDamping: number;
  12030. /**
  12031. * Gets the current list of limit velocity gradients.
  12032. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12033. * @returns the list of limit velocity gradients
  12034. */
  12035. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12036. /**
  12037. * Gets the current list of color gradients.
  12038. * You must use addColorGradient and removeColorGradient to udpate this list
  12039. * @returns the list of color gradients
  12040. */
  12041. getColorGradients(): Nullable<Array<ColorGradient>>;
  12042. /**
  12043. * Gets the current list of size gradients.
  12044. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12045. * @returns the list of size gradients
  12046. */
  12047. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12048. /**
  12049. * Gets the current list of color remap gradients.
  12050. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12051. * @returns the list of color remap gradients
  12052. */
  12053. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12054. /**
  12055. * Gets the current list of alpha remap gradients.
  12056. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12057. * @returns the list of alpha remap gradients
  12058. */
  12059. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12060. /**
  12061. * Gets the current list of life time gradients.
  12062. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12063. * @returns the list of life time gradients
  12064. */
  12065. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12066. /**
  12067. * Gets the current list of angular speed gradients.
  12068. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12069. * @returns the list of angular speed gradients
  12070. */
  12071. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12072. /**
  12073. * Gets the current list of velocity gradients.
  12074. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12075. * @returns the list of velocity gradients
  12076. */
  12077. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12078. /**
  12079. * Gets the current list of start size gradients.
  12080. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12081. * @returns the list of start size gradients
  12082. */
  12083. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12084. /**
  12085. * Gets the current list of emit rate gradients.
  12086. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12087. * @returns the list of emit rate gradients
  12088. */
  12089. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12090. /**
  12091. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12092. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12093. */
  12094. get direction1(): Vector3;
  12095. set direction1(value: Vector3);
  12096. /**
  12097. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12098. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12099. */
  12100. get direction2(): Vector3;
  12101. set direction2(value: Vector3);
  12102. /**
  12103. * 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.
  12104. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12105. */
  12106. get minEmitBox(): Vector3;
  12107. set minEmitBox(value: Vector3);
  12108. /**
  12109. * 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.
  12110. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12111. */
  12112. get maxEmitBox(): Vector3;
  12113. set maxEmitBox(value: Vector3);
  12114. /**
  12115. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12116. */
  12117. color1: Color4;
  12118. /**
  12119. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12120. */
  12121. color2: Color4;
  12122. /**
  12123. * Color the particle will have at the end of its lifetime
  12124. */
  12125. colorDead: Color4;
  12126. /**
  12127. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12128. */
  12129. textureMask: Color4;
  12130. /**
  12131. * The particle emitter type defines the emitter used by the particle system.
  12132. * It can be for example box, sphere, or cone...
  12133. */
  12134. particleEmitterType: IParticleEmitterType;
  12135. /** @hidden */
  12136. _isSubEmitter: boolean;
  12137. /**
  12138. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12139. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12140. */
  12141. billboardMode: number;
  12142. protected _isBillboardBased: boolean;
  12143. /**
  12144. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12145. */
  12146. get isBillboardBased(): boolean;
  12147. set isBillboardBased(value: boolean);
  12148. /**
  12149. * The scene the particle system belongs to.
  12150. */
  12151. protected _scene: Scene;
  12152. /**
  12153. * Local cache of defines for image processing.
  12154. */
  12155. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12156. /**
  12157. * Default configuration related to image processing available in the standard Material.
  12158. */
  12159. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12160. /**
  12161. * Gets the image processing configuration used either in this material.
  12162. */
  12163. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12164. /**
  12165. * Sets the Default image processing configuration used either in the this material.
  12166. *
  12167. * If sets to null, the scene one is in use.
  12168. */
  12169. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12170. /**
  12171. * Attaches a new image processing configuration to the Standard Material.
  12172. * @param configuration
  12173. */
  12174. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12175. /** @hidden */
  12176. protected _reset(): void;
  12177. /** @hidden */
  12178. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12179. /**
  12180. * Instantiates a particle system.
  12181. * 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.
  12182. * @param name The name of the particle system
  12183. */
  12184. constructor(name: string);
  12185. /**
  12186. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12187. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12188. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12189. * @returns the emitter
  12190. */
  12191. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12192. /**
  12193. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12194. * @param radius The radius of the hemisphere to emit from
  12195. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12196. * @returns the emitter
  12197. */
  12198. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12199. /**
  12200. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12201. * @param radius The radius of the sphere to emit from
  12202. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12203. * @returns the emitter
  12204. */
  12205. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12206. /**
  12207. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12208. * @param radius The radius of the sphere to emit from
  12209. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12210. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12211. * @returns the emitter
  12212. */
  12213. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12214. /**
  12215. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12216. * @param radius The radius of the emission cylinder
  12217. * @param height The height of the emission cylinder
  12218. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12219. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12220. * @returns the emitter
  12221. */
  12222. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12223. /**
  12224. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12225. * @param radius The radius of the cylinder to emit from
  12226. * @param height The height of the emission cylinder
  12227. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12228. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12229. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12230. * @returns the emitter
  12231. */
  12232. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12233. /**
  12234. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12235. * @param radius The radius of the cone to emit from
  12236. * @param angle The base angle of the cone
  12237. * @returns the emitter
  12238. */
  12239. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12240. /**
  12241. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12242. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12243. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12244. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12245. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12246. * @returns the emitter
  12247. */
  12248. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12249. }
  12250. }
  12251. declare module BABYLON {
  12252. /**
  12253. * Type of sub emitter
  12254. */
  12255. export enum SubEmitterType {
  12256. /**
  12257. * Attached to the particle over it's lifetime
  12258. */
  12259. ATTACHED = 0,
  12260. /**
  12261. * Created when the particle dies
  12262. */
  12263. END = 1
  12264. }
  12265. /**
  12266. * Sub emitter class used to emit particles from an existing particle
  12267. */
  12268. export class SubEmitter {
  12269. /**
  12270. * the particle system to be used by the sub emitter
  12271. */
  12272. particleSystem: ParticleSystem;
  12273. /**
  12274. * Type of the submitter (Default: END)
  12275. */
  12276. type: SubEmitterType;
  12277. /**
  12278. * 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)
  12279. * Note: This only is supported when using an emitter of type Mesh
  12280. */
  12281. inheritDirection: boolean;
  12282. /**
  12283. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12284. */
  12285. inheritedVelocityAmount: number;
  12286. /**
  12287. * Creates a sub emitter
  12288. * @param particleSystem the particle system to be used by the sub emitter
  12289. */
  12290. constructor(
  12291. /**
  12292. * the particle system to be used by the sub emitter
  12293. */
  12294. particleSystem: ParticleSystem);
  12295. /**
  12296. * Clones the sub emitter
  12297. * @returns the cloned sub emitter
  12298. */
  12299. clone(): SubEmitter;
  12300. /**
  12301. * Serialize current object to a JSON object
  12302. * @returns the serialized object
  12303. */
  12304. serialize(): any;
  12305. /** @hidden */
  12306. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12307. /**
  12308. * Creates a new SubEmitter from a serialized JSON version
  12309. * @param serializationObject defines the JSON object to read from
  12310. * @param scene defines the hosting scene
  12311. * @param rootUrl defines the rootUrl for data loading
  12312. * @returns a new SubEmitter
  12313. */
  12314. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12315. /** Release associated resources */
  12316. dispose(): void;
  12317. }
  12318. }
  12319. declare module BABYLON {
  12320. /** @hidden */
  12321. export var imageProcessingDeclaration: {
  12322. name: string;
  12323. shader: string;
  12324. };
  12325. }
  12326. declare module BABYLON {
  12327. /** @hidden */
  12328. export var imageProcessingFunctions: {
  12329. name: string;
  12330. shader: string;
  12331. };
  12332. }
  12333. declare module BABYLON {
  12334. /** @hidden */
  12335. export var particlesPixelShader: {
  12336. name: string;
  12337. shader: string;
  12338. };
  12339. }
  12340. declare module BABYLON {
  12341. /** @hidden */
  12342. export var particlesVertexShader: {
  12343. name: string;
  12344. shader: string;
  12345. };
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * This represents a particle system in Babylon.
  12350. * 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.
  12351. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12352. * @example https://doc.babylonjs.com/babylon101/particles
  12353. */
  12354. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12355. /**
  12356. * Billboard mode will only apply to Y axis
  12357. */
  12358. static readonly BILLBOARDMODE_Y: number;
  12359. /**
  12360. * Billboard mode will apply to all axes
  12361. */
  12362. static readonly BILLBOARDMODE_ALL: number;
  12363. /**
  12364. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12365. */
  12366. static readonly BILLBOARDMODE_STRETCHED: number;
  12367. /**
  12368. * This function can be defined to provide custom update for active particles.
  12369. * This function will be called instead of regular update (age, position, color, etc.).
  12370. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12371. */
  12372. updateFunction: (particles: Particle[]) => void;
  12373. private _emitterWorldMatrix;
  12374. /**
  12375. * This function can be defined to specify initial direction for every new particle.
  12376. * It by default use the emitterType defined function
  12377. */
  12378. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12379. /**
  12380. * This function can be defined to specify initial position for every new particle.
  12381. * It by default use the emitterType defined function
  12382. */
  12383. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12384. /**
  12385. * @hidden
  12386. */
  12387. _inheritedVelocityOffset: Vector3;
  12388. /**
  12389. * An event triggered when the system is disposed
  12390. */
  12391. onDisposeObservable: Observable<IParticleSystem>;
  12392. private _onDisposeObserver;
  12393. /**
  12394. * Sets a callback that will be triggered when the system is disposed
  12395. */
  12396. set onDispose(callback: () => void);
  12397. private _particles;
  12398. private _epsilon;
  12399. private _capacity;
  12400. private _stockParticles;
  12401. private _newPartsExcess;
  12402. private _vertexData;
  12403. private _vertexBuffer;
  12404. private _vertexBuffers;
  12405. private _spriteBuffer;
  12406. private _indexBuffer;
  12407. private _effect;
  12408. private _customEffect;
  12409. private _cachedDefines;
  12410. private _scaledColorStep;
  12411. private _colorDiff;
  12412. private _scaledDirection;
  12413. private _scaledGravity;
  12414. private _currentRenderId;
  12415. private _alive;
  12416. private _useInstancing;
  12417. private _started;
  12418. private _stopped;
  12419. private _actualFrame;
  12420. private _scaledUpdateSpeed;
  12421. private _vertexBufferSize;
  12422. /** @hidden */
  12423. _currentEmitRateGradient: Nullable<FactorGradient>;
  12424. /** @hidden */
  12425. _currentEmitRate1: number;
  12426. /** @hidden */
  12427. _currentEmitRate2: number;
  12428. /** @hidden */
  12429. _currentStartSizeGradient: Nullable<FactorGradient>;
  12430. /** @hidden */
  12431. _currentStartSize1: number;
  12432. /** @hidden */
  12433. _currentStartSize2: number;
  12434. private readonly _rawTextureWidth;
  12435. private _rampGradientsTexture;
  12436. private _useRampGradients;
  12437. /** Gets or sets a boolean indicating that ramp gradients must be used
  12438. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12439. */
  12440. get useRampGradients(): boolean;
  12441. set useRampGradients(value: boolean);
  12442. /**
  12443. * 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.
  12444. * 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: [])
  12445. */
  12446. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12447. private _subEmitters;
  12448. /**
  12449. * @hidden
  12450. * If the particle systems emitter should be disposed when the particle system is disposed
  12451. */
  12452. _disposeEmitterOnDispose: boolean;
  12453. /**
  12454. * The current active Sub-systems, this property is used by the root particle system only.
  12455. */
  12456. activeSubSystems: Array<ParticleSystem>;
  12457. /**
  12458. * Specifies if the particles are updated in emitter local space or world space
  12459. */
  12460. isLocal: boolean;
  12461. private _rootParticleSystem;
  12462. /**
  12463. * Gets the current list of active particles
  12464. */
  12465. get particles(): Particle[];
  12466. /**
  12467. * Gets the number of particles active at the same time.
  12468. * @returns The number of active particles.
  12469. */
  12470. getActiveCount(): number;
  12471. /**
  12472. * Returns the string "ParticleSystem"
  12473. * @returns a string containing the class name
  12474. */
  12475. getClassName(): string;
  12476. /**
  12477. * Gets a boolean indicating that the system is stopping
  12478. * @returns true if the system is currently stopping
  12479. */
  12480. isStopping(): boolean;
  12481. /**
  12482. * Gets the custom effect used to render the particles
  12483. * @param blendMode Blend mode for which the effect should be retrieved
  12484. * @returns The effect
  12485. */
  12486. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12487. /**
  12488. * Sets the custom effect used to render the particles
  12489. * @param effect The effect to set
  12490. * @param blendMode Blend mode for which the effect should be set
  12491. */
  12492. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12493. /** @hidden */
  12494. private _onBeforeDrawParticlesObservable;
  12495. /**
  12496. * Observable that will be called just before the particles are drawn
  12497. */
  12498. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12499. /**
  12500. * Gets the name of the particle vertex shader
  12501. */
  12502. get vertexShaderName(): string;
  12503. /**
  12504. * Instantiates a particle system.
  12505. * 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.
  12506. * @param name The name of the particle system
  12507. * @param capacity The max number of particles alive at the same time
  12508. * @param scene The scene the particle system belongs to
  12509. * @param customEffect a custom effect used to change the way particles are rendered by default
  12510. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12511. * @param epsilon Offset used to render the particles
  12512. */
  12513. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12514. private _addFactorGradient;
  12515. private _removeFactorGradient;
  12516. /**
  12517. * Adds a new life time gradient
  12518. * @param gradient defines the gradient to use (between 0 and 1)
  12519. * @param factor defines the life time factor to affect to the specified gradient
  12520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12521. * @returns the current particle system
  12522. */
  12523. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12524. /**
  12525. * Remove a specific life time gradient
  12526. * @param gradient defines the gradient to remove
  12527. * @returns the current particle system
  12528. */
  12529. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12530. /**
  12531. * Adds a new size gradient
  12532. * @param gradient defines the gradient to use (between 0 and 1)
  12533. * @param factor defines the size factor to affect to the specified gradient
  12534. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12535. * @returns the current particle system
  12536. */
  12537. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12538. /**
  12539. * Remove a specific size gradient
  12540. * @param gradient defines the gradient to remove
  12541. * @returns the current particle system
  12542. */
  12543. removeSizeGradient(gradient: number): IParticleSystem;
  12544. /**
  12545. * Adds a new color remap gradient
  12546. * @param gradient defines the gradient to use (between 0 and 1)
  12547. * @param min defines the color remap minimal range
  12548. * @param max defines the color remap maximal range
  12549. * @returns the current particle system
  12550. */
  12551. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12552. /**
  12553. * Remove a specific color remap gradient
  12554. * @param gradient defines the gradient to remove
  12555. * @returns the current particle system
  12556. */
  12557. removeColorRemapGradient(gradient: number): IParticleSystem;
  12558. /**
  12559. * Adds a new alpha remap gradient
  12560. * @param gradient defines the gradient to use (between 0 and 1)
  12561. * @param min defines the alpha remap minimal range
  12562. * @param max defines the alpha remap maximal range
  12563. * @returns the current particle system
  12564. */
  12565. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12566. /**
  12567. * Remove a specific alpha remap gradient
  12568. * @param gradient defines the gradient to remove
  12569. * @returns the current particle system
  12570. */
  12571. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12572. /**
  12573. * Adds a new angular speed gradient
  12574. * @param gradient defines the gradient to use (between 0 and 1)
  12575. * @param factor defines the angular speed to affect to the specified gradient
  12576. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12577. * @returns the current particle system
  12578. */
  12579. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12580. /**
  12581. * Remove a specific angular speed gradient
  12582. * @param gradient defines the gradient to remove
  12583. * @returns the current particle system
  12584. */
  12585. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12586. /**
  12587. * Adds a new velocity gradient
  12588. * @param gradient defines the gradient to use (between 0 and 1)
  12589. * @param factor defines the velocity to affect to the specified gradient
  12590. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12591. * @returns the current particle system
  12592. */
  12593. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12594. /**
  12595. * Remove a specific velocity gradient
  12596. * @param gradient defines the gradient to remove
  12597. * @returns the current particle system
  12598. */
  12599. removeVelocityGradient(gradient: number): IParticleSystem;
  12600. /**
  12601. * Adds a new limit velocity gradient
  12602. * @param gradient defines the gradient to use (between 0 and 1)
  12603. * @param factor defines the limit velocity value to affect to the specified gradient
  12604. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12605. * @returns the current particle system
  12606. */
  12607. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12608. /**
  12609. * Remove a specific limit velocity gradient
  12610. * @param gradient defines the gradient to remove
  12611. * @returns the current particle system
  12612. */
  12613. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12614. /**
  12615. * Adds a new drag gradient
  12616. * @param gradient defines the gradient to use (between 0 and 1)
  12617. * @param factor defines the drag value to affect to the specified gradient
  12618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12619. * @returns the current particle system
  12620. */
  12621. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12622. /**
  12623. * Remove a specific drag gradient
  12624. * @param gradient defines the gradient to remove
  12625. * @returns the current particle system
  12626. */
  12627. removeDragGradient(gradient: number): IParticleSystem;
  12628. /**
  12629. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12630. * @param gradient defines the gradient to use (between 0 and 1)
  12631. * @param factor defines the emit rate value to affect to the specified gradient
  12632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12633. * @returns the current particle system
  12634. */
  12635. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12636. /**
  12637. * Remove a specific emit rate gradient
  12638. * @param gradient defines the gradient to remove
  12639. * @returns the current particle system
  12640. */
  12641. removeEmitRateGradient(gradient: number): IParticleSystem;
  12642. /**
  12643. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12644. * @param gradient defines the gradient to use (between 0 and 1)
  12645. * @param factor defines the start size value to affect to the specified gradient
  12646. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12647. * @returns the current particle system
  12648. */
  12649. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12650. /**
  12651. * Remove a specific start size gradient
  12652. * @param gradient defines the gradient to remove
  12653. * @returns the current particle system
  12654. */
  12655. removeStartSizeGradient(gradient: number): IParticleSystem;
  12656. private _createRampGradientTexture;
  12657. /**
  12658. * Gets the current list of ramp gradients.
  12659. * You must use addRampGradient and removeRampGradient to udpate this list
  12660. * @returns the list of ramp gradients
  12661. */
  12662. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12663. /** Force the system to rebuild all gradients that need to be resync */
  12664. forceRefreshGradients(): void;
  12665. private _syncRampGradientTexture;
  12666. /**
  12667. * Adds a new ramp gradient used to remap particle colors
  12668. * @param gradient defines the gradient to use (between 0 and 1)
  12669. * @param color defines the color to affect to the specified gradient
  12670. * @returns the current particle system
  12671. */
  12672. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12673. /**
  12674. * Remove a specific ramp gradient
  12675. * @param gradient defines the gradient to remove
  12676. * @returns the current particle system
  12677. */
  12678. removeRampGradient(gradient: number): ParticleSystem;
  12679. /**
  12680. * Adds a new color gradient
  12681. * @param gradient defines the gradient to use (between 0 and 1)
  12682. * @param color1 defines the color to affect to the specified gradient
  12683. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12684. * @returns this particle system
  12685. */
  12686. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12687. /**
  12688. * Remove a specific color gradient
  12689. * @param gradient defines the gradient to remove
  12690. * @returns this particle system
  12691. */
  12692. removeColorGradient(gradient: number): IParticleSystem;
  12693. private _fetchR;
  12694. protected _reset(): void;
  12695. private _resetEffect;
  12696. private _createVertexBuffers;
  12697. private _createIndexBuffer;
  12698. /**
  12699. * Gets the maximum number of particles active at the same time.
  12700. * @returns The max number of active particles.
  12701. */
  12702. getCapacity(): number;
  12703. /**
  12704. * Gets whether there are still active particles in the system.
  12705. * @returns True if it is alive, otherwise false.
  12706. */
  12707. isAlive(): boolean;
  12708. /**
  12709. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12710. * @returns True if it has been started, otherwise false.
  12711. */
  12712. isStarted(): boolean;
  12713. private _prepareSubEmitterInternalArray;
  12714. /**
  12715. * Starts the particle system and begins to emit
  12716. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12717. */
  12718. start(delay?: number): void;
  12719. /**
  12720. * Stops the particle system.
  12721. * @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.
  12722. */
  12723. stop(stopSubEmitters?: boolean): void;
  12724. /**
  12725. * Remove all active particles
  12726. */
  12727. reset(): void;
  12728. /**
  12729. * @hidden (for internal use only)
  12730. */
  12731. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12732. /**
  12733. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12734. * Its lifetime will start back at 0.
  12735. */
  12736. recycleParticle: (particle: Particle) => void;
  12737. private _stopSubEmitters;
  12738. private _createParticle;
  12739. private _removeFromRoot;
  12740. private _emitFromParticle;
  12741. private _update;
  12742. /** @hidden */
  12743. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12744. /** @hidden */
  12745. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12746. /**
  12747. * Fill the defines array according to the current settings of the particle system
  12748. * @param defines Array to be updated
  12749. * @param blendMode blend mode to take into account when updating the array
  12750. */
  12751. fillDefines(defines: Array<string>, blendMode: number): void;
  12752. /**
  12753. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12754. * @param uniforms Uniforms array to fill
  12755. * @param attributes Attributes array to fill
  12756. * @param samplers Samplers array to fill
  12757. */
  12758. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12759. /** @hidden */
  12760. private _getEffect;
  12761. /**
  12762. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12763. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12764. */
  12765. animate(preWarmOnly?: boolean): void;
  12766. private _appendParticleVertices;
  12767. /**
  12768. * Rebuilds the particle system.
  12769. */
  12770. rebuild(): void;
  12771. /**
  12772. * Is this system ready to be used/rendered
  12773. * @return true if the system is ready
  12774. */
  12775. isReady(): boolean;
  12776. private _render;
  12777. /**
  12778. * Renders the particle system in its current state.
  12779. * @returns the current number of particles
  12780. */
  12781. render(): number;
  12782. /**
  12783. * Disposes the particle system and free the associated resources
  12784. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12785. */
  12786. dispose(disposeTexture?: boolean): void;
  12787. /**
  12788. * Clones the particle system.
  12789. * @param name The name of the cloned object
  12790. * @param newEmitter The new emitter to use
  12791. * @returns the cloned particle system
  12792. */
  12793. clone(name: string, newEmitter: any): ParticleSystem;
  12794. /**
  12795. * Serializes the particle system to a JSON object
  12796. * @param serializeTexture defines if the texture must be serialized as well
  12797. * @returns the JSON object
  12798. */
  12799. serialize(serializeTexture?: boolean): any;
  12800. /** @hidden */
  12801. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12802. /** @hidden */
  12803. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12804. /**
  12805. * Parses a JSON object to create a particle system.
  12806. * @param parsedParticleSystem The JSON object to parse
  12807. * @param scene The scene to create the particle system in
  12808. * @param rootUrl The root url to use to load external dependencies like texture
  12809. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12810. * @returns the Parsed particle system
  12811. */
  12812. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12813. }
  12814. }
  12815. declare module BABYLON {
  12816. /**
  12817. * A particle represents one of the element emitted by a particle system.
  12818. * This is mainly define by its coordinates, direction, velocity and age.
  12819. */
  12820. export class Particle {
  12821. /**
  12822. * The particle system the particle belongs to.
  12823. */
  12824. particleSystem: ParticleSystem;
  12825. private static _Count;
  12826. /**
  12827. * Unique ID of the particle
  12828. */
  12829. id: number;
  12830. /**
  12831. * The world position of the particle in the scene.
  12832. */
  12833. position: Vector3;
  12834. /**
  12835. * The world direction of the particle in the scene.
  12836. */
  12837. direction: Vector3;
  12838. /**
  12839. * The color of the particle.
  12840. */
  12841. color: Color4;
  12842. /**
  12843. * The color change of the particle per step.
  12844. */
  12845. colorStep: Color4;
  12846. /**
  12847. * Defines how long will the life of the particle be.
  12848. */
  12849. lifeTime: number;
  12850. /**
  12851. * The current age of the particle.
  12852. */
  12853. age: number;
  12854. /**
  12855. * The current size of the particle.
  12856. */
  12857. size: number;
  12858. /**
  12859. * The current scale of the particle.
  12860. */
  12861. scale: Vector2;
  12862. /**
  12863. * The current angle of the particle.
  12864. */
  12865. angle: number;
  12866. /**
  12867. * Defines how fast is the angle changing.
  12868. */
  12869. angularSpeed: number;
  12870. /**
  12871. * Defines the cell index used by the particle to be rendered from a sprite.
  12872. */
  12873. cellIndex: number;
  12874. /**
  12875. * The information required to support color remapping
  12876. */
  12877. remapData: Vector4;
  12878. /** @hidden */
  12879. _randomCellOffset?: number;
  12880. /** @hidden */
  12881. _initialDirection: Nullable<Vector3>;
  12882. /** @hidden */
  12883. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12884. /** @hidden */
  12885. _initialStartSpriteCellID: number;
  12886. /** @hidden */
  12887. _initialEndSpriteCellID: number;
  12888. /** @hidden */
  12889. _currentColorGradient: Nullable<ColorGradient>;
  12890. /** @hidden */
  12891. _currentColor1: Color4;
  12892. /** @hidden */
  12893. _currentColor2: Color4;
  12894. /** @hidden */
  12895. _currentSizeGradient: Nullable<FactorGradient>;
  12896. /** @hidden */
  12897. _currentSize1: number;
  12898. /** @hidden */
  12899. _currentSize2: number;
  12900. /** @hidden */
  12901. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12902. /** @hidden */
  12903. _currentAngularSpeed1: number;
  12904. /** @hidden */
  12905. _currentAngularSpeed2: number;
  12906. /** @hidden */
  12907. _currentVelocityGradient: Nullable<FactorGradient>;
  12908. /** @hidden */
  12909. _currentVelocity1: number;
  12910. /** @hidden */
  12911. _currentVelocity2: number;
  12912. /** @hidden */
  12913. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12914. /** @hidden */
  12915. _currentLimitVelocity1: number;
  12916. /** @hidden */
  12917. _currentLimitVelocity2: number;
  12918. /** @hidden */
  12919. _currentDragGradient: Nullable<FactorGradient>;
  12920. /** @hidden */
  12921. _currentDrag1: number;
  12922. /** @hidden */
  12923. _currentDrag2: number;
  12924. /** @hidden */
  12925. _randomNoiseCoordinates1: Vector3;
  12926. /** @hidden */
  12927. _randomNoiseCoordinates2: Vector3;
  12928. /** @hidden */
  12929. _localPosition?: Vector3;
  12930. /**
  12931. * Creates a new instance Particle
  12932. * @param particleSystem the particle system the particle belongs to
  12933. */
  12934. constructor(
  12935. /**
  12936. * The particle system the particle belongs to.
  12937. */
  12938. particleSystem: ParticleSystem);
  12939. private updateCellInfoFromSystem;
  12940. /**
  12941. * Defines how the sprite cell index is updated for the particle
  12942. */
  12943. updateCellIndex(): void;
  12944. /** @hidden */
  12945. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12946. /** @hidden */
  12947. _inheritParticleInfoToSubEmitters(): void;
  12948. /** @hidden */
  12949. _reset(): void;
  12950. /**
  12951. * Copy the properties of particle to another one.
  12952. * @param other the particle to copy the information to.
  12953. */
  12954. copyTo(other: Particle): void;
  12955. }
  12956. }
  12957. declare module BABYLON {
  12958. /**
  12959. * Particle emitter represents a volume emitting particles.
  12960. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12961. */
  12962. export interface IParticleEmitterType {
  12963. /**
  12964. * Called by the particle System when the direction is computed for the created particle.
  12965. * @param worldMatrix is the world matrix of the particle system
  12966. * @param directionToUpdate is the direction vector to update with the result
  12967. * @param particle is the particle we are computed the direction for
  12968. * @param isLocal defines if the direction should be set in local space
  12969. */
  12970. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12971. /**
  12972. * Called by the particle System when the position is computed for the created particle.
  12973. * @param worldMatrix is the world matrix of the particle system
  12974. * @param positionToUpdate is the position vector to update with the result
  12975. * @param particle is the particle we are computed the position for
  12976. * @param isLocal defines if the position should be set in local space
  12977. */
  12978. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12979. /**
  12980. * Clones the current emitter and returns a copy of it
  12981. * @returns the new emitter
  12982. */
  12983. clone(): IParticleEmitterType;
  12984. /**
  12985. * Called by the GPUParticleSystem to setup the update shader
  12986. * @param effect defines the update shader
  12987. */
  12988. applyToShader(effect: Effect): void;
  12989. /**
  12990. * Returns a string to use to update the GPU particles update shader
  12991. * @returns the effect defines string
  12992. */
  12993. getEffectDefines(): string;
  12994. /**
  12995. * Returns a string representing the class name
  12996. * @returns a string containing the class name
  12997. */
  12998. getClassName(): string;
  12999. /**
  13000. * Serializes the particle system to a JSON object.
  13001. * @returns the JSON object
  13002. */
  13003. serialize(): any;
  13004. /**
  13005. * Parse properties from a JSON object
  13006. * @param serializationObject defines the JSON object
  13007. * @param scene defines the hosting scene
  13008. */
  13009. parse(serializationObject: any, scene: Scene): void;
  13010. }
  13011. }
  13012. declare module BABYLON {
  13013. /**
  13014. * Particle emitter emitting particles from the inside of a box.
  13015. * It emits the particles randomly between 2 given directions.
  13016. */
  13017. export class BoxParticleEmitter implements IParticleEmitterType {
  13018. /**
  13019. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13020. */
  13021. direction1: Vector3;
  13022. /**
  13023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13024. */
  13025. direction2: Vector3;
  13026. /**
  13027. * 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.
  13028. */
  13029. minEmitBox: Vector3;
  13030. /**
  13031. * 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.
  13032. */
  13033. maxEmitBox: Vector3;
  13034. /**
  13035. * Creates a new instance BoxParticleEmitter
  13036. */
  13037. constructor();
  13038. /**
  13039. * Called by the particle System when the direction is computed for the created particle.
  13040. * @param worldMatrix is the world matrix of the particle system
  13041. * @param directionToUpdate is the direction vector to update with the result
  13042. * @param particle is the particle we are computed the direction for
  13043. * @param isLocal defines if the direction should be set in local space
  13044. */
  13045. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13046. /**
  13047. * Called by the particle System when the position is computed for the created particle.
  13048. * @param worldMatrix is the world matrix of the particle system
  13049. * @param positionToUpdate is the position vector to update with the result
  13050. * @param particle is the particle we are computed the position for
  13051. * @param isLocal defines if the position should be set in local space
  13052. */
  13053. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13054. /**
  13055. * Clones the current emitter and returns a copy of it
  13056. * @returns the new emitter
  13057. */
  13058. clone(): BoxParticleEmitter;
  13059. /**
  13060. * Called by the GPUParticleSystem to setup the update shader
  13061. * @param effect defines the update shader
  13062. */
  13063. applyToShader(effect: Effect): void;
  13064. /**
  13065. * Returns a string to use to update the GPU particles update shader
  13066. * @returns a string containng the defines string
  13067. */
  13068. getEffectDefines(): string;
  13069. /**
  13070. * Returns the string "BoxParticleEmitter"
  13071. * @returns a string containing the class name
  13072. */
  13073. getClassName(): string;
  13074. /**
  13075. * Serializes the particle system to a JSON object.
  13076. * @returns the JSON object
  13077. */
  13078. serialize(): any;
  13079. /**
  13080. * Parse properties from a JSON object
  13081. * @param serializationObject defines the JSON object
  13082. */
  13083. parse(serializationObject: any): void;
  13084. }
  13085. }
  13086. declare module BABYLON {
  13087. /**
  13088. * Particle emitter emitting particles from the inside of a cone.
  13089. * It emits the particles alongside the cone volume from the base to the particle.
  13090. * The emission direction might be randomized.
  13091. */
  13092. export class ConeParticleEmitter implements IParticleEmitterType {
  13093. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13094. directionRandomizer: number;
  13095. private _radius;
  13096. private _angle;
  13097. private _height;
  13098. /**
  13099. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13100. */
  13101. radiusRange: number;
  13102. /**
  13103. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13104. */
  13105. heightRange: number;
  13106. /**
  13107. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13108. */
  13109. emitFromSpawnPointOnly: boolean;
  13110. /**
  13111. * Gets or sets the radius of the emission cone
  13112. */
  13113. get radius(): number;
  13114. set radius(value: number);
  13115. /**
  13116. * Gets or sets the angle of the emission cone
  13117. */
  13118. get angle(): number;
  13119. set angle(value: number);
  13120. private _buildHeight;
  13121. /**
  13122. * Creates a new instance ConeParticleEmitter
  13123. * @param radius the radius of the emission cone (1 by default)
  13124. * @param angle the cone base angle (PI by default)
  13125. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13126. */
  13127. constructor(radius?: number, angle?: number,
  13128. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13129. directionRandomizer?: number);
  13130. /**
  13131. * Called by the particle System when the direction is computed for the created particle.
  13132. * @param worldMatrix is the world matrix of the particle system
  13133. * @param directionToUpdate is the direction vector to update with the result
  13134. * @param particle is the particle we are computed the direction for
  13135. * @param isLocal defines if the direction should be set in local space
  13136. */
  13137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13138. /**
  13139. * Called by the particle System when the position is computed for the created particle.
  13140. * @param worldMatrix is the world matrix of the particle system
  13141. * @param positionToUpdate is the position vector to update with the result
  13142. * @param particle is the particle we are computed the position for
  13143. * @param isLocal defines if the position should be set in local space
  13144. */
  13145. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13146. /**
  13147. * Clones the current emitter and returns a copy of it
  13148. * @returns the new emitter
  13149. */
  13150. clone(): ConeParticleEmitter;
  13151. /**
  13152. * Called by the GPUParticleSystem to setup the update shader
  13153. * @param effect defines the update shader
  13154. */
  13155. applyToShader(effect: Effect): void;
  13156. /**
  13157. * Returns a string to use to update the GPU particles update shader
  13158. * @returns a string containng the defines string
  13159. */
  13160. getEffectDefines(): string;
  13161. /**
  13162. * Returns the string "ConeParticleEmitter"
  13163. * @returns a string containing the class name
  13164. */
  13165. getClassName(): string;
  13166. /**
  13167. * Serializes the particle system to a JSON object.
  13168. * @returns the JSON object
  13169. */
  13170. serialize(): any;
  13171. /**
  13172. * Parse properties from a JSON object
  13173. * @param serializationObject defines the JSON object
  13174. */
  13175. parse(serializationObject: any): void;
  13176. }
  13177. }
  13178. declare module BABYLON {
  13179. /**
  13180. * Particle emitter emitting particles from the inside of a cylinder.
  13181. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13182. */
  13183. export class CylinderParticleEmitter implements IParticleEmitterType {
  13184. /**
  13185. * The radius of the emission cylinder.
  13186. */
  13187. radius: number;
  13188. /**
  13189. * The height of the emission cylinder.
  13190. */
  13191. height: number;
  13192. /**
  13193. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13194. */
  13195. radiusRange: number;
  13196. /**
  13197. * How much to randomize the particle direction [0-1].
  13198. */
  13199. directionRandomizer: number;
  13200. /**
  13201. * Creates a new instance CylinderParticleEmitter
  13202. * @param radius the radius of the emission cylinder (1 by default)
  13203. * @param height the height of the emission cylinder (1 by default)
  13204. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13205. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13206. */
  13207. constructor(
  13208. /**
  13209. * The radius of the emission cylinder.
  13210. */
  13211. radius?: number,
  13212. /**
  13213. * The height of the emission cylinder.
  13214. */
  13215. height?: number,
  13216. /**
  13217. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13218. */
  13219. radiusRange?: number,
  13220. /**
  13221. * How much to randomize the particle direction [0-1].
  13222. */
  13223. directionRandomizer?: number);
  13224. /**
  13225. * Called by the particle System when the direction is computed for the created particle.
  13226. * @param worldMatrix is the world matrix of the particle system
  13227. * @param directionToUpdate is the direction vector to update with the result
  13228. * @param particle is the particle we are computed the direction for
  13229. * @param isLocal defines if the direction should be set in local space
  13230. */
  13231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13232. /**
  13233. * Called by the particle System when the position is computed for the created particle.
  13234. * @param worldMatrix is the world matrix of the particle system
  13235. * @param positionToUpdate is the position vector to update with the result
  13236. * @param particle is the particle we are computed the position for
  13237. * @param isLocal defines if the position should be set in local space
  13238. */
  13239. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13240. /**
  13241. * Clones the current emitter and returns a copy of it
  13242. * @returns the new emitter
  13243. */
  13244. clone(): CylinderParticleEmitter;
  13245. /**
  13246. * Called by the GPUParticleSystem to setup the update shader
  13247. * @param effect defines the update shader
  13248. */
  13249. applyToShader(effect: Effect): void;
  13250. /**
  13251. * Returns a string to use to update the GPU particles update shader
  13252. * @returns a string containng the defines string
  13253. */
  13254. getEffectDefines(): string;
  13255. /**
  13256. * Returns the string "CylinderParticleEmitter"
  13257. * @returns a string containing the class name
  13258. */
  13259. getClassName(): string;
  13260. /**
  13261. * Serializes the particle system to a JSON object.
  13262. * @returns the JSON object
  13263. */
  13264. serialize(): any;
  13265. /**
  13266. * Parse properties from a JSON object
  13267. * @param serializationObject defines the JSON object
  13268. */
  13269. parse(serializationObject: any): void;
  13270. }
  13271. /**
  13272. * Particle emitter emitting particles from the inside of a cylinder.
  13273. * It emits the particles randomly between two vectors.
  13274. */
  13275. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13276. /**
  13277. * The min limit of the emission direction.
  13278. */
  13279. direction1: Vector3;
  13280. /**
  13281. * The max limit of the emission direction.
  13282. */
  13283. direction2: Vector3;
  13284. /**
  13285. * Creates a new instance CylinderDirectedParticleEmitter
  13286. * @param radius the radius of the emission cylinder (1 by default)
  13287. * @param height the height of the emission cylinder (1 by default)
  13288. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13289. * @param direction1 the min limit of the emission direction (up vector by default)
  13290. * @param direction2 the max limit of the emission direction (up vector by default)
  13291. */
  13292. constructor(radius?: number, height?: number, radiusRange?: number,
  13293. /**
  13294. * The min limit of the emission direction.
  13295. */
  13296. direction1?: Vector3,
  13297. /**
  13298. * The max limit of the emission direction.
  13299. */
  13300. direction2?: Vector3);
  13301. /**
  13302. * Called by the particle System when the direction is computed for the created particle.
  13303. * @param worldMatrix is the world matrix of the particle system
  13304. * @param directionToUpdate is the direction vector to update with the result
  13305. * @param particle is the particle we are computed the direction for
  13306. */
  13307. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13308. /**
  13309. * Clones the current emitter and returns a copy of it
  13310. * @returns the new emitter
  13311. */
  13312. clone(): CylinderDirectedParticleEmitter;
  13313. /**
  13314. * Called by the GPUParticleSystem to setup the update shader
  13315. * @param effect defines the update shader
  13316. */
  13317. applyToShader(effect: Effect): void;
  13318. /**
  13319. * Returns a string to use to update the GPU particles update shader
  13320. * @returns a string containng the defines string
  13321. */
  13322. getEffectDefines(): string;
  13323. /**
  13324. * Returns the string "CylinderDirectedParticleEmitter"
  13325. * @returns a string containing the class name
  13326. */
  13327. getClassName(): string;
  13328. /**
  13329. * Serializes the particle system to a JSON object.
  13330. * @returns the JSON object
  13331. */
  13332. serialize(): any;
  13333. /**
  13334. * Parse properties from a JSON object
  13335. * @param serializationObject defines the JSON object
  13336. */
  13337. parse(serializationObject: any): void;
  13338. }
  13339. }
  13340. declare module BABYLON {
  13341. /**
  13342. * Particle emitter emitting particles from the inside of a hemisphere.
  13343. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13344. */
  13345. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13346. /**
  13347. * The radius of the emission hemisphere.
  13348. */
  13349. radius: number;
  13350. /**
  13351. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13352. */
  13353. radiusRange: number;
  13354. /**
  13355. * How much to randomize the particle direction [0-1].
  13356. */
  13357. directionRandomizer: number;
  13358. /**
  13359. * Creates a new instance HemisphericParticleEmitter
  13360. * @param radius the radius of the emission hemisphere (1 by default)
  13361. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13362. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13363. */
  13364. constructor(
  13365. /**
  13366. * The radius of the emission hemisphere.
  13367. */
  13368. radius?: number,
  13369. /**
  13370. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13371. */
  13372. radiusRange?: number,
  13373. /**
  13374. * How much to randomize the particle direction [0-1].
  13375. */
  13376. directionRandomizer?: number);
  13377. /**
  13378. * Called by the particle System when the direction is computed for the created particle.
  13379. * @param worldMatrix is the world matrix of the particle system
  13380. * @param directionToUpdate is the direction vector to update with the result
  13381. * @param particle is the particle we are computed the direction for
  13382. * @param isLocal defines if the direction should be set in local space
  13383. */
  13384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13385. /**
  13386. * Called by the particle System when the position is computed for the created particle.
  13387. * @param worldMatrix is the world matrix of the particle system
  13388. * @param positionToUpdate is the position vector to update with the result
  13389. * @param particle is the particle we are computed the position for
  13390. * @param isLocal defines if the position should be set in local space
  13391. */
  13392. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13393. /**
  13394. * Clones the current emitter and returns a copy of it
  13395. * @returns the new emitter
  13396. */
  13397. clone(): HemisphericParticleEmitter;
  13398. /**
  13399. * Called by the GPUParticleSystem to setup the update shader
  13400. * @param effect defines the update shader
  13401. */
  13402. applyToShader(effect: Effect): void;
  13403. /**
  13404. * Returns a string to use to update the GPU particles update shader
  13405. * @returns a string containng the defines string
  13406. */
  13407. getEffectDefines(): string;
  13408. /**
  13409. * Returns the string "HemisphericParticleEmitter"
  13410. * @returns a string containing the class name
  13411. */
  13412. getClassName(): string;
  13413. /**
  13414. * Serializes the particle system to a JSON object.
  13415. * @returns the JSON object
  13416. */
  13417. serialize(): any;
  13418. /**
  13419. * Parse properties from a JSON object
  13420. * @param serializationObject defines the JSON object
  13421. */
  13422. parse(serializationObject: any): void;
  13423. }
  13424. }
  13425. declare module BABYLON {
  13426. /**
  13427. * Particle emitter emitting particles from a point.
  13428. * It emits the particles randomly between 2 given directions.
  13429. */
  13430. export class PointParticleEmitter implements IParticleEmitterType {
  13431. /**
  13432. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13433. */
  13434. direction1: Vector3;
  13435. /**
  13436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13437. */
  13438. direction2: Vector3;
  13439. /**
  13440. * Creates a new instance PointParticleEmitter
  13441. */
  13442. constructor();
  13443. /**
  13444. * Called by the particle System when the direction is computed for the created particle.
  13445. * @param worldMatrix is the world matrix of the particle system
  13446. * @param directionToUpdate is the direction vector to update with the result
  13447. * @param particle is the particle we are computed the direction for
  13448. * @param isLocal defines if the direction should be set in local space
  13449. */
  13450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13451. /**
  13452. * Called by the particle System when the position is computed for the created particle.
  13453. * @param worldMatrix is the world matrix of the particle system
  13454. * @param positionToUpdate is the position vector to update with the result
  13455. * @param particle is the particle we are computed the position for
  13456. * @param isLocal defines if the position should be set in local space
  13457. */
  13458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13459. /**
  13460. * Clones the current emitter and returns a copy of it
  13461. * @returns the new emitter
  13462. */
  13463. clone(): PointParticleEmitter;
  13464. /**
  13465. * Called by the GPUParticleSystem to setup the update shader
  13466. * @param effect defines the update shader
  13467. */
  13468. applyToShader(effect: Effect): void;
  13469. /**
  13470. * Returns a string to use to update the GPU particles update shader
  13471. * @returns a string containng the defines string
  13472. */
  13473. getEffectDefines(): string;
  13474. /**
  13475. * Returns the string "PointParticleEmitter"
  13476. * @returns a string containing the class name
  13477. */
  13478. getClassName(): string;
  13479. /**
  13480. * Serializes the particle system to a JSON object.
  13481. * @returns the JSON object
  13482. */
  13483. serialize(): any;
  13484. /**
  13485. * Parse properties from a JSON object
  13486. * @param serializationObject defines the JSON object
  13487. */
  13488. parse(serializationObject: any): void;
  13489. }
  13490. }
  13491. declare module BABYLON {
  13492. /**
  13493. * Particle emitter emitting particles from the inside of a sphere.
  13494. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13495. */
  13496. export class SphereParticleEmitter implements IParticleEmitterType {
  13497. /**
  13498. * The radius of the emission sphere.
  13499. */
  13500. radius: number;
  13501. /**
  13502. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13503. */
  13504. radiusRange: number;
  13505. /**
  13506. * How much to randomize the particle direction [0-1].
  13507. */
  13508. directionRandomizer: number;
  13509. /**
  13510. * Creates a new instance SphereParticleEmitter
  13511. * @param radius the radius of the emission sphere (1 by default)
  13512. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13513. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13514. */
  13515. constructor(
  13516. /**
  13517. * The radius of the emission sphere.
  13518. */
  13519. radius?: number,
  13520. /**
  13521. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13522. */
  13523. radiusRange?: number,
  13524. /**
  13525. * How much to randomize the particle direction [0-1].
  13526. */
  13527. directionRandomizer?: number);
  13528. /**
  13529. * Called by the particle System when the direction is computed for the created particle.
  13530. * @param worldMatrix is the world matrix of the particle system
  13531. * @param directionToUpdate is the direction vector to update with the result
  13532. * @param particle is the particle we are computed the direction for
  13533. * @param isLocal defines if the direction should be set in local space
  13534. */
  13535. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13536. /**
  13537. * Called by the particle System when the position is computed for the created particle.
  13538. * @param worldMatrix is the world matrix of the particle system
  13539. * @param positionToUpdate is the position vector to update with the result
  13540. * @param particle is the particle we are computed the position for
  13541. * @param isLocal defines if the position should be set in local space
  13542. */
  13543. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13544. /**
  13545. * Clones the current emitter and returns a copy of it
  13546. * @returns the new emitter
  13547. */
  13548. clone(): SphereParticleEmitter;
  13549. /**
  13550. * Called by the GPUParticleSystem to setup the update shader
  13551. * @param effect defines the update shader
  13552. */
  13553. applyToShader(effect: Effect): void;
  13554. /**
  13555. * Returns a string to use to update the GPU particles update shader
  13556. * @returns a string containng the defines string
  13557. */
  13558. getEffectDefines(): string;
  13559. /**
  13560. * Returns the string "SphereParticleEmitter"
  13561. * @returns a string containing the class name
  13562. */
  13563. getClassName(): string;
  13564. /**
  13565. * Serializes the particle system to a JSON object.
  13566. * @returns the JSON object
  13567. */
  13568. serialize(): any;
  13569. /**
  13570. * Parse properties from a JSON object
  13571. * @param serializationObject defines the JSON object
  13572. */
  13573. parse(serializationObject: any): void;
  13574. }
  13575. /**
  13576. * Particle emitter emitting particles from the inside of a sphere.
  13577. * It emits the particles randomly between two vectors.
  13578. */
  13579. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13580. /**
  13581. * The min limit of the emission direction.
  13582. */
  13583. direction1: Vector3;
  13584. /**
  13585. * The max limit of the emission direction.
  13586. */
  13587. direction2: Vector3;
  13588. /**
  13589. * Creates a new instance SphereDirectedParticleEmitter
  13590. * @param radius the radius of the emission sphere (1 by default)
  13591. * @param direction1 the min limit of the emission direction (up vector by default)
  13592. * @param direction2 the max limit of the emission direction (up vector by default)
  13593. */
  13594. constructor(radius?: number,
  13595. /**
  13596. * The min limit of the emission direction.
  13597. */
  13598. direction1?: Vector3,
  13599. /**
  13600. * The max limit of the emission direction.
  13601. */
  13602. direction2?: Vector3);
  13603. /**
  13604. * Called by the particle System when the direction is computed for the created particle.
  13605. * @param worldMatrix is the world matrix of the particle system
  13606. * @param directionToUpdate is the direction vector to update with the result
  13607. * @param particle is the particle we are computed the direction for
  13608. */
  13609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13610. /**
  13611. * Clones the current emitter and returns a copy of it
  13612. * @returns the new emitter
  13613. */
  13614. clone(): SphereDirectedParticleEmitter;
  13615. /**
  13616. * Called by the GPUParticleSystem to setup the update shader
  13617. * @param effect defines the update shader
  13618. */
  13619. applyToShader(effect: Effect): void;
  13620. /**
  13621. * Returns a string to use to update the GPU particles update shader
  13622. * @returns a string containng the defines string
  13623. */
  13624. getEffectDefines(): string;
  13625. /**
  13626. * Returns the string "SphereDirectedParticleEmitter"
  13627. * @returns a string containing the class name
  13628. */
  13629. getClassName(): string;
  13630. /**
  13631. * Serializes the particle system to a JSON object.
  13632. * @returns the JSON object
  13633. */
  13634. serialize(): any;
  13635. /**
  13636. * Parse properties from a JSON object
  13637. * @param serializationObject defines the JSON object
  13638. */
  13639. parse(serializationObject: any): void;
  13640. }
  13641. }
  13642. declare module BABYLON {
  13643. /**
  13644. * Particle emitter emitting particles from a custom list of positions.
  13645. */
  13646. export class CustomParticleEmitter implements IParticleEmitterType {
  13647. /**
  13648. * Gets or sets the position generator that will create the inital position of each particle.
  13649. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13650. */
  13651. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13652. /**
  13653. * Gets or sets the destination generator that will create the final destination of each particle.
  13654. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13655. */
  13656. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13657. /**
  13658. * Creates a new instance CustomParticleEmitter
  13659. */
  13660. constructor();
  13661. /**
  13662. * Called by the particle System when the direction is computed for the created particle.
  13663. * @param worldMatrix is the world matrix of the particle system
  13664. * @param directionToUpdate is the direction vector to update with the result
  13665. * @param particle is the particle we are computed the direction for
  13666. * @param isLocal defines if the direction should be set in local space
  13667. */
  13668. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13669. /**
  13670. * Called by the particle System when the position is computed for the created particle.
  13671. * @param worldMatrix is the world matrix of the particle system
  13672. * @param positionToUpdate is the position vector to update with the result
  13673. * @param particle is the particle we are computed the position for
  13674. * @param isLocal defines if the position should be set in local space
  13675. */
  13676. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13677. /**
  13678. * Clones the current emitter and returns a copy of it
  13679. * @returns the new emitter
  13680. */
  13681. clone(): CustomParticleEmitter;
  13682. /**
  13683. * Called by the GPUParticleSystem to setup the update shader
  13684. * @param effect defines the update shader
  13685. */
  13686. applyToShader(effect: Effect): void;
  13687. /**
  13688. * Returns a string to use to update the GPU particles update shader
  13689. * @returns a string containng the defines string
  13690. */
  13691. getEffectDefines(): string;
  13692. /**
  13693. * Returns the string "PointParticleEmitter"
  13694. * @returns a string containing the class name
  13695. */
  13696. getClassName(): string;
  13697. /**
  13698. * Serializes the particle system to a JSON object.
  13699. * @returns the JSON object
  13700. */
  13701. serialize(): any;
  13702. /**
  13703. * Parse properties from a JSON object
  13704. * @param serializationObject defines the JSON object
  13705. */
  13706. parse(serializationObject: any): void;
  13707. }
  13708. }
  13709. declare module BABYLON {
  13710. /**
  13711. * Particle emitter emitting particles from the inside of a box.
  13712. * It emits the particles randomly between 2 given directions.
  13713. */
  13714. export class MeshParticleEmitter implements IParticleEmitterType {
  13715. private _indices;
  13716. private _positions;
  13717. private _normals;
  13718. private _storedNormal;
  13719. private _mesh;
  13720. /**
  13721. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13722. */
  13723. direction1: Vector3;
  13724. /**
  13725. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13726. */
  13727. direction2: Vector3;
  13728. /**
  13729. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13730. */
  13731. useMeshNormalsForDirection: boolean;
  13732. /** Defines the mesh to use as source */
  13733. get mesh(): Nullable<AbstractMesh>;
  13734. set mesh(value: Nullable<AbstractMesh>);
  13735. /**
  13736. * Creates a new instance MeshParticleEmitter
  13737. * @param mesh defines the mesh to use as source
  13738. */
  13739. constructor(mesh?: Nullable<AbstractMesh>);
  13740. /**
  13741. * Called by the particle System when the direction is computed for the created particle.
  13742. * @param worldMatrix is the world matrix of the particle system
  13743. * @param directionToUpdate is the direction vector to update with the result
  13744. * @param particle is the particle we are computed the direction for
  13745. * @param isLocal defines if the direction should be set in local space
  13746. */
  13747. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13748. /**
  13749. * Called by the particle System when the position is computed for the created particle.
  13750. * @param worldMatrix is the world matrix of the particle system
  13751. * @param positionToUpdate is the position vector to update with the result
  13752. * @param particle is the particle we are computed the position for
  13753. * @param isLocal defines if the position should be set in local space
  13754. */
  13755. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13756. /**
  13757. * Clones the current emitter and returns a copy of it
  13758. * @returns the new emitter
  13759. */
  13760. clone(): MeshParticleEmitter;
  13761. /**
  13762. * Called by the GPUParticleSystem to setup the update shader
  13763. * @param effect defines the update shader
  13764. */
  13765. applyToShader(effect: Effect): void;
  13766. /**
  13767. * Returns a string to use to update the GPU particles update shader
  13768. * @returns a string containng the defines string
  13769. */
  13770. getEffectDefines(): string;
  13771. /**
  13772. * Returns the string "BoxParticleEmitter"
  13773. * @returns a string containing the class name
  13774. */
  13775. getClassName(): string;
  13776. /**
  13777. * Serializes the particle system to a JSON object.
  13778. * @returns the JSON object
  13779. */
  13780. serialize(): any;
  13781. /**
  13782. * Parse properties from a JSON object
  13783. * @param serializationObject defines the JSON object
  13784. * @param scene defines the hosting scene
  13785. */
  13786. parse(serializationObject: any, scene: Scene): void;
  13787. }
  13788. }
  13789. declare module BABYLON {
  13790. /**
  13791. * Interface representing a particle system in Babylon.js.
  13792. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13793. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13794. */
  13795. export interface IParticleSystem {
  13796. /**
  13797. * List of animations used by the particle system.
  13798. */
  13799. animations: Animation[];
  13800. /**
  13801. * The id of the Particle system.
  13802. */
  13803. id: string;
  13804. /**
  13805. * The name of the Particle system.
  13806. */
  13807. name: string;
  13808. /**
  13809. * The emitter represents the Mesh or position we are attaching the particle system to.
  13810. */
  13811. emitter: Nullable<AbstractMesh | Vector3>;
  13812. /**
  13813. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13814. */
  13815. isBillboardBased: boolean;
  13816. /**
  13817. * The rendering group used by the Particle system to chose when to render.
  13818. */
  13819. renderingGroupId: number;
  13820. /**
  13821. * The layer mask we are rendering the particles through.
  13822. */
  13823. layerMask: number;
  13824. /**
  13825. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13826. */
  13827. updateSpeed: number;
  13828. /**
  13829. * The amount of time the particle system is running (depends of the overall update speed).
  13830. */
  13831. targetStopDuration: number;
  13832. /**
  13833. * The texture used to render each particle. (this can be a spritesheet)
  13834. */
  13835. particleTexture: Nullable<Texture>;
  13836. /**
  13837. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13838. */
  13839. blendMode: number;
  13840. /**
  13841. * Minimum life time of emitting particles.
  13842. */
  13843. minLifeTime: number;
  13844. /**
  13845. * Maximum life time of emitting particles.
  13846. */
  13847. maxLifeTime: number;
  13848. /**
  13849. * Minimum Size of emitting particles.
  13850. */
  13851. minSize: number;
  13852. /**
  13853. * Maximum Size of emitting particles.
  13854. */
  13855. maxSize: number;
  13856. /**
  13857. * Minimum scale of emitting particles on X axis.
  13858. */
  13859. minScaleX: number;
  13860. /**
  13861. * Maximum scale of emitting particles on X axis.
  13862. */
  13863. maxScaleX: number;
  13864. /**
  13865. * Minimum scale of emitting particles on Y axis.
  13866. */
  13867. minScaleY: number;
  13868. /**
  13869. * Maximum scale of emitting particles on Y axis.
  13870. */
  13871. maxScaleY: number;
  13872. /**
  13873. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13874. */
  13875. color1: Color4;
  13876. /**
  13877. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13878. */
  13879. color2: Color4;
  13880. /**
  13881. * Color the particle will have at the end of its lifetime.
  13882. */
  13883. colorDead: Color4;
  13884. /**
  13885. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13886. */
  13887. emitRate: number;
  13888. /**
  13889. * You can use gravity if you want to give an orientation to your particles.
  13890. */
  13891. gravity: Vector3;
  13892. /**
  13893. * Minimum power of emitting particles.
  13894. */
  13895. minEmitPower: number;
  13896. /**
  13897. * Maximum power of emitting particles.
  13898. */
  13899. maxEmitPower: number;
  13900. /**
  13901. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13902. */
  13903. minAngularSpeed: number;
  13904. /**
  13905. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13906. */
  13907. maxAngularSpeed: number;
  13908. /**
  13909. * Gets or sets the minimal initial rotation in radians.
  13910. */
  13911. minInitialRotation: number;
  13912. /**
  13913. * Gets or sets the maximal initial rotation in radians.
  13914. */
  13915. maxInitialRotation: number;
  13916. /**
  13917. * The particle emitter type defines the emitter used by the particle system.
  13918. * It can be for example box, sphere, or cone...
  13919. */
  13920. particleEmitterType: Nullable<IParticleEmitterType>;
  13921. /**
  13922. * Defines the delay in milliseconds before starting the system (0 by default)
  13923. */
  13924. startDelay: number;
  13925. /**
  13926. * 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
  13927. */
  13928. preWarmCycles: number;
  13929. /**
  13930. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13931. */
  13932. preWarmStepOffset: number;
  13933. /**
  13934. * 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)
  13935. */
  13936. spriteCellChangeSpeed: number;
  13937. /**
  13938. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13939. */
  13940. startSpriteCellID: number;
  13941. /**
  13942. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13943. */
  13944. endSpriteCellID: number;
  13945. /**
  13946. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13947. */
  13948. spriteCellWidth: number;
  13949. /**
  13950. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13951. */
  13952. spriteCellHeight: number;
  13953. /**
  13954. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13955. */
  13956. spriteRandomStartCell: boolean;
  13957. /**
  13958. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13959. */
  13960. isAnimationSheetEnabled: boolean;
  13961. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13962. translationPivot: Vector2;
  13963. /**
  13964. * Gets or sets a texture used to add random noise to particle positions
  13965. */
  13966. noiseTexture: Nullable<BaseTexture>;
  13967. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13968. noiseStrength: Vector3;
  13969. /**
  13970. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13971. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13972. */
  13973. billboardMode: number;
  13974. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13975. limitVelocityDamping: number;
  13976. /**
  13977. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13978. */
  13979. beginAnimationOnStart: boolean;
  13980. /**
  13981. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13982. */
  13983. beginAnimationFrom: number;
  13984. /**
  13985. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13986. */
  13987. beginAnimationTo: number;
  13988. /**
  13989. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13990. */
  13991. beginAnimationLoop: boolean;
  13992. /**
  13993. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13994. */
  13995. disposeOnStop: boolean;
  13996. /**
  13997. * Specifies if the particles are updated in emitter local space or world space
  13998. */
  13999. isLocal: boolean;
  14000. /** Snippet ID if the particle system was created from the snippet server */
  14001. snippetId: string;
  14002. /**
  14003. * Gets the maximum number of particles active at the same time.
  14004. * @returns The max number of active particles.
  14005. */
  14006. getCapacity(): number;
  14007. /**
  14008. * Gets the number of particles active at the same time.
  14009. * @returns The number of active particles.
  14010. */
  14011. getActiveCount(): number;
  14012. /**
  14013. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14014. * @returns True if it has been started, otherwise false.
  14015. */
  14016. isStarted(): boolean;
  14017. /**
  14018. * Animates the particle system for this frame.
  14019. */
  14020. animate(): void;
  14021. /**
  14022. * Renders the particle system in its current state.
  14023. * @returns the current number of particles
  14024. */
  14025. render(): number;
  14026. /**
  14027. * Dispose the particle system and frees its associated resources.
  14028. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14029. */
  14030. dispose(disposeTexture?: boolean): void;
  14031. /**
  14032. * An event triggered when the system is disposed
  14033. */
  14034. onDisposeObservable: Observable<IParticleSystem>;
  14035. /**
  14036. * Clones the particle system.
  14037. * @param name The name of the cloned object
  14038. * @param newEmitter The new emitter to use
  14039. * @returns the cloned particle system
  14040. */
  14041. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14042. /**
  14043. * Serializes the particle system to a JSON object
  14044. * @param serializeTexture defines if the texture must be serialized as well
  14045. * @returns the JSON object
  14046. */
  14047. serialize(serializeTexture: boolean): any;
  14048. /**
  14049. * Rebuild the particle system
  14050. */
  14051. rebuild(): void;
  14052. /** Force the system to rebuild all gradients that need to be resync */
  14053. forceRefreshGradients(): void;
  14054. /**
  14055. * Starts the particle system and begins to emit
  14056. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14057. */
  14058. start(delay?: number): void;
  14059. /**
  14060. * Stops the particle system.
  14061. */
  14062. stop(): void;
  14063. /**
  14064. * Remove all active particles
  14065. */
  14066. reset(): void;
  14067. /**
  14068. * Gets a boolean indicating that the system is stopping
  14069. * @returns true if the system is currently stopping
  14070. */
  14071. isStopping(): boolean;
  14072. /**
  14073. * Is this system ready to be used/rendered
  14074. * @return true if the system is ready
  14075. */
  14076. isReady(): boolean;
  14077. /**
  14078. * Returns the string "ParticleSystem"
  14079. * @returns a string containing the class name
  14080. */
  14081. getClassName(): string;
  14082. /**
  14083. * Gets the custom effect used to render the particles
  14084. * @param blendMode Blend mode for which the effect should be retrieved
  14085. * @returns The effect
  14086. */
  14087. getCustomEffect(blendMode: number): Nullable<Effect>;
  14088. /**
  14089. * Sets the custom effect used to render the particles
  14090. * @param effect The effect to set
  14091. * @param blendMode Blend mode for which the effect should be set
  14092. */
  14093. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14094. /**
  14095. * Fill the defines array according to the current settings of the particle system
  14096. * @param defines Array to be updated
  14097. * @param blendMode blend mode to take into account when updating the array
  14098. */
  14099. fillDefines(defines: Array<string>, blendMode: number): void;
  14100. /**
  14101. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14102. * @param uniforms Uniforms array to fill
  14103. * @param attributes Attributes array to fill
  14104. * @param samplers Samplers array to fill
  14105. */
  14106. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14107. /**
  14108. * Observable that will be called just before the particles are drawn
  14109. */
  14110. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14111. /**
  14112. * Gets the name of the particle vertex shader
  14113. */
  14114. vertexShaderName: string;
  14115. /**
  14116. * Adds a new color gradient
  14117. * @param gradient defines the gradient to use (between 0 and 1)
  14118. * @param color1 defines the color to affect to the specified gradient
  14119. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14120. * @returns the current particle system
  14121. */
  14122. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14123. /**
  14124. * Remove a specific color gradient
  14125. * @param gradient defines the gradient to remove
  14126. * @returns the current particle system
  14127. */
  14128. removeColorGradient(gradient: number): IParticleSystem;
  14129. /**
  14130. * Adds a new size gradient
  14131. * @param gradient defines the gradient to use (between 0 and 1)
  14132. * @param factor defines the size factor to affect to the specified gradient
  14133. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14134. * @returns the current particle system
  14135. */
  14136. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14137. /**
  14138. * Remove a specific size gradient
  14139. * @param gradient defines the gradient to remove
  14140. * @returns the current particle system
  14141. */
  14142. removeSizeGradient(gradient: number): IParticleSystem;
  14143. /**
  14144. * Gets the current list of color gradients.
  14145. * You must use addColorGradient and removeColorGradient to udpate this list
  14146. * @returns the list of color gradients
  14147. */
  14148. getColorGradients(): Nullable<Array<ColorGradient>>;
  14149. /**
  14150. * Gets the current list of size gradients.
  14151. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14152. * @returns the list of size gradients
  14153. */
  14154. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14155. /**
  14156. * Gets the current list of angular speed gradients.
  14157. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14158. * @returns the list of angular speed gradients
  14159. */
  14160. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14161. /**
  14162. * Adds a new angular speed gradient
  14163. * @param gradient defines the gradient to use (between 0 and 1)
  14164. * @param factor defines the angular speed to affect to the specified gradient
  14165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14166. * @returns the current particle system
  14167. */
  14168. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14169. /**
  14170. * Remove a specific angular speed gradient
  14171. * @param gradient defines the gradient to remove
  14172. * @returns the current particle system
  14173. */
  14174. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14175. /**
  14176. * Gets the current list of velocity gradients.
  14177. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14178. * @returns the list of velocity gradients
  14179. */
  14180. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14181. /**
  14182. * Adds a new velocity gradient
  14183. * @param gradient defines the gradient to use (between 0 and 1)
  14184. * @param factor defines the velocity to affect to the specified gradient
  14185. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14186. * @returns the current particle system
  14187. */
  14188. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14189. /**
  14190. * Remove a specific velocity gradient
  14191. * @param gradient defines the gradient to remove
  14192. * @returns the current particle system
  14193. */
  14194. removeVelocityGradient(gradient: number): IParticleSystem;
  14195. /**
  14196. * Gets the current list of limit velocity gradients.
  14197. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14198. * @returns the list of limit velocity gradients
  14199. */
  14200. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14201. /**
  14202. * Adds a new limit velocity gradient
  14203. * @param gradient defines the gradient to use (between 0 and 1)
  14204. * @param factor defines the limit velocity to affect to the specified gradient
  14205. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14206. * @returns the current particle system
  14207. */
  14208. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14209. /**
  14210. * Remove a specific limit velocity gradient
  14211. * @param gradient defines the gradient to remove
  14212. * @returns the current particle system
  14213. */
  14214. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14215. /**
  14216. * Adds a new drag gradient
  14217. * @param gradient defines the gradient to use (between 0 and 1)
  14218. * @param factor defines the drag to affect to the specified gradient
  14219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14220. * @returns the current particle system
  14221. */
  14222. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14223. /**
  14224. * Remove a specific drag gradient
  14225. * @param gradient defines the gradient to remove
  14226. * @returns the current particle system
  14227. */
  14228. removeDragGradient(gradient: number): IParticleSystem;
  14229. /**
  14230. * Gets the current list of drag gradients.
  14231. * You must use addDragGradient and removeDragGradient to udpate this list
  14232. * @returns the list of drag gradients
  14233. */
  14234. getDragGradients(): Nullable<Array<FactorGradient>>;
  14235. /**
  14236. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14237. * @param gradient defines the gradient to use (between 0 and 1)
  14238. * @param factor defines the emit rate to affect to the specified gradient
  14239. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14240. * @returns the current particle system
  14241. */
  14242. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14243. /**
  14244. * Remove a specific emit rate gradient
  14245. * @param gradient defines the gradient to remove
  14246. * @returns the current particle system
  14247. */
  14248. removeEmitRateGradient(gradient: number): IParticleSystem;
  14249. /**
  14250. * Gets the current list of emit rate gradients.
  14251. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14252. * @returns the list of emit rate gradients
  14253. */
  14254. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14255. /**
  14256. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14257. * @param gradient defines the gradient to use (between 0 and 1)
  14258. * @param factor defines the start size to affect to the specified gradient
  14259. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14260. * @returns the current particle system
  14261. */
  14262. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14263. /**
  14264. * Remove a specific start size gradient
  14265. * @param gradient defines the gradient to remove
  14266. * @returns the current particle system
  14267. */
  14268. removeStartSizeGradient(gradient: number): IParticleSystem;
  14269. /**
  14270. * Gets the current list of start size gradients.
  14271. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14272. * @returns the list of start size gradients
  14273. */
  14274. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14275. /**
  14276. * Adds a new life time gradient
  14277. * @param gradient defines the gradient to use (between 0 and 1)
  14278. * @param factor defines the life time factor to affect to the specified gradient
  14279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14280. * @returns the current particle system
  14281. */
  14282. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14283. /**
  14284. * Remove a specific life time gradient
  14285. * @param gradient defines the gradient to remove
  14286. * @returns the current particle system
  14287. */
  14288. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14289. /**
  14290. * Gets the current list of life time gradients.
  14291. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14292. * @returns the list of life time gradients
  14293. */
  14294. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14295. /**
  14296. * Gets the current list of color gradients.
  14297. * You must use addColorGradient and removeColorGradient to udpate this list
  14298. * @returns the list of color gradients
  14299. */
  14300. getColorGradients(): Nullable<Array<ColorGradient>>;
  14301. /**
  14302. * Adds a new ramp gradient used to remap particle colors
  14303. * @param gradient defines the gradient to use (between 0 and 1)
  14304. * @param color defines the color to affect to the specified gradient
  14305. * @returns the current particle system
  14306. */
  14307. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14308. /**
  14309. * Gets the current list of ramp gradients.
  14310. * You must use addRampGradient and removeRampGradient to udpate this list
  14311. * @returns the list of ramp gradients
  14312. */
  14313. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14314. /** Gets or sets a boolean indicating that ramp gradients must be used
  14315. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14316. */
  14317. useRampGradients: boolean;
  14318. /**
  14319. * Adds a new color remap gradient
  14320. * @param gradient defines the gradient to use (between 0 and 1)
  14321. * @param min defines the color remap minimal range
  14322. * @param max defines the color remap maximal range
  14323. * @returns the current particle system
  14324. */
  14325. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14326. /**
  14327. * Gets the current list of color remap gradients.
  14328. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14329. * @returns the list of color remap gradients
  14330. */
  14331. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14332. /**
  14333. * Adds a new alpha remap gradient
  14334. * @param gradient defines the gradient to use (between 0 and 1)
  14335. * @param min defines the alpha remap minimal range
  14336. * @param max defines the alpha remap maximal range
  14337. * @returns the current particle system
  14338. */
  14339. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14340. /**
  14341. * Gets the current list of alpha remap gradients.
  14342. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14343. * @returns the list of alpha remap gradients
  14344. */
  14345. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14346. /**
  14347. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14348. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14349. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14350. * @returns the emitter
  14351. */
  14352. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14353. /**
  14354. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14355. * @param radius The radius of the hemisphere to emit from
  14356. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14357. * @returns the emitter
  14358. */
  14359. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14360. /**
  14361. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14362. * @param radius The radius of the sphere to emit from
  14363. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14364. * @returns the emitter
  14365. */
  14366. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14367. /**
  14368. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14369. * @param radius The radius of the sphere to emit from
  14370. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14371. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14372. * @returns the emitter
  14373. */
  14374. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14375. /**
  14376. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14377. * @param radius The radius of the emission cylinder
  14378. * @param height The height of the emission cylinder
  14379. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14380. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14381. * @returns the emitter
  14382. */
  14383. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14384. /**
  14385. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14386. * @param radius The radius of the cylinder to emit from
  14387. * @param height The height of the emission cylinder
  14388. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14391. * @returns the emitter
  14392. */
  14393. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14394. /**
  14395. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14396. * @param radius The radius of the cone to emit from
  14397. * @param angle The base angle of the cone
  14398. * @returns the emitter
  14399. */
  14400. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14401. /**
  14402. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14405. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14406. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14407. * @returns the emitter
  14408. */
  14409. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14410. /**
  14411. * Get hosting scene
  14412. * @returns the scene
  14413. */
  14414. getScene(): Scene;
  14415. }
  14416. }
  14417. declare module BABYLON {
  14418. /**
  14419. * 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.
  14420. * @see https://doc.babylonjs.com/how_to/transformnode
  14421. */
  14422. export class TransformNode extends Node {
  14423. /**
  14424. * Object will not rotate to face the camera
  14425. */
  14426. static BILLBOARDMODE_NONE: number;
  14427. /**
  14428. * Object will rotate to face the camera but only on the x axis
  14429. */
  14430. static BILLBOARDMODE_X: number;
  14431. /**
  14432. * Object will rotate to face the camera but only on the y axis
  14433. */
  14434. static BILLBOARDMODE_Y: number;
  14435. /**
  14436. * Object will rotate to face the camera but only on the z axis
  14437. */
  14438. static BILLBOARDMODE_Z: number;
  14439. /**
  14440. * Object will rotate to face the camera
  14441. */
  14442. static BILLBOARDMODE_ALL: number;
  14443. /**
  14444. * Object will rotate to face the camera's position instead of orientation
  14445. */
  14446. static BILLBOARDMODE_USE_POSITION: number;
  14447. private static _TmpRotation;
  14448. private static _TmpScaling;
  14449. private static _TmpTranslation;
  14450. private _forward;
  14451. private _forwardInverted;
  14452. private _up;
  14453. private _right;
  14454. private _rightInverted;
  14455. private _position;
  14456. private _rotation;
  14457. private _rotationQuaternion;
  14458. protected _scaling: Vector3;
  14459. protected _isDirty: boolean;
  14460. private _transformToBoneReferal;
  14461. private _isAbsoluteSynced;
  14462. private _billboardMode;
  14463. /**
  14464. * Gets or sets the billboard mode. Default is 0.
  14465. *
  14466. * | Value | Type | Description |
  14467. * | --- | --- | --- |
  14468. * | 0 | BILLBOARDMODE_NONE | |
  14469. * | 1 | BILLBOARDMODE_X | |
  14470. * | 2 | BILLBOARDMODE_Y | |
  14471. * | 4 | BILLBOARDMODE_Z | |
  14472. * | 7 | BILLBOARDMODE_ALL | |
  14473. *
  14474. */
  14475. get billboardMode(): number;
  14476. set billboardMode(value: number);
  14477. private _preserveParentRotationForBillboard;
  14478. /**
  14479. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14480. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14481. */
  14482. get preserveParentRotationForBillboard(): boolean;
  14483. set preserveParentRotationForBillboard(value: boolean);
  14484. /**
  14485. * 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
  14486. */
  14487. scalingDeterminant: number;
  14488. private _infiniteDistance;
  14489. /**
  14490. * Gets or sets the distance of the object to max, often used by skybox
  14491. */
  14492. get infiniteDistance(): boolean;
  14493. set infiniteDistance(value: boolean);
  14494. /**
  14495. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14496. * By default the system will update normals to compensate
  14497. */
  14498. ignoreNonUniformScaling: boolean;
  14499. /**
  14500. * 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
  14501. */
  14502. reIntegrateRotationIntoRotationQuaternion: boolean;
  14503. /** @hidden */
  14504. _poseMatrix: Nullable<Matrix>;
  14505. /** @hidden */
  14506. _localMatrix: Matrix;
  14507. private _usePivotMatrix;
  14508. private _absolutePosition;
  14509. private _absoluteScaling;
  14510. private _absoluteRotationQuaternion;
  14511. private _pivotMatrix;
  14512. private _pivotMatrixInverse;
  14513. protected _postMultiplyPivotMatrix: boolean;
  14514. protected _isWorldMatrixFrozen: boolean;
  14515. /** @hidden */
  14516. _indexInSceneTransformNodesArray: number;
  14517. /**
  14518. * An event triggered after the world matrix is updated
  14519. */
  14520. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14521. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14522. /**
  14523. * Gets a string identifying the name of the class
  14524. * @returns "TransformNode" string
  14525. */
  14526. getClassName(): string;
  14527. /**
  14528. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14529. */
  14530. get position(): Vector3;
  14531. set position(newPosition: Vector3);
  14532. /**
  14533. * 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)).
  14534. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14535. */
  14536. get rotation(): Vector3;
  14537. set rotation(newRotation: Vector3);
  14538. /**
  14539. * 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)).
  14540. */
  14541. get scaling(): Vector3;
  14542. set scaling(newScaling: Vector3);
  14543. /**
  14544. * 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).
  14545. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14546. */
  14547. get rotationQuaternion(): Nullable<Quaternion>;
  14548. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14549. /**
  14550. * The forward direction of that transform in world space.
  14551. */
  14552. get forward(): Vector3;
  14553. /**
  14554. * The up direction of that transform in world space.
  14555. */
  14556. get up(): Vector3;
  14557. /**
  14558. * The right direction of that transform in world space.
  14559. */
  14560. get right(): Vector3;
  14561. /**
  14562. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14563. * @param matrix the matrix to copy the pose from
  14564. * @returns this TransformNode.
  14565. */
  14566. updatePoseMatrix(matrix: Matrix): TransformNode;
  14567. /**
  14568. * Returns the mesh Pose matrix.
  14569. * @returns the pose matrix
  14570. */
  14571. getPoseMatrix(): Matrix;
  14572. /** @hidden */
  14573. _isSynchronized(): boolean;
  14574. /** @hidden */
  14575. _initCache(): void;
  14576. /**
  14577. * Flag the transform node as dirty (Forcing it to update everything)
  14578. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14579. * @returns this transform node
  14580. */
  14581. markAsDirty(property: string): TransformNode;
  14582. /**
  14583. * Returns the current mesh absolute position.
  14584. * Returns a Vector3.
  14585. */
  14586. get absolutePosition(): Vector3;
  14587. /**
  14588. * Returns the current mesh absolute scaling.
  14589. * Returns a Vector3.
  14590. */
  14591. get absoluteScaling(): Vector3;
  14592. /**
  14593. * Returns the current mesh absolute rotation.
  14594. * Returns a Quaternion.
  14595. */
  14596. get absoluteRotationQuaternion(): Quaternion;
  14597. /**
  14598. * Sets a new matrix to apply before all other transformation
  14599. * @param matrix defines the transform matrix
  14600. * @returns the current TransformNode
  14601. */
  14602. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14603. /**
  14604. * Sets a new pivot matrix to the current node
  14605. * @param matrix defines the new pivot matrix to use
  14606. * @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
  14607. * @returns the current TransformNode
  14608. */
  14609. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14610. /**
  14611. * Returns the mesh pivot matrix.
  14612. * Default : Identity.
  14613. * @returns the matrix
  14614. */
  14615. getPivotMatrix(): Matrix;
  14616. /**
  14617. * Instantiate (when possible) or clone that node with its hierarchy
  14618. * @param newParent defines the new parent to use for the instance (or clone)
  14619. * @param options defines options to configure how copy is done
  14620. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14621. * @returns an instance (or a clone) of the current node with its hiearchy
  14622. */
  14623. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14624. doNotInstantiate: boolean;
  14625. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14626. /**
  14627. * Prevents the World matrix to be computed any longer
  14628. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14629. * @returns the TransformNode.
  14630. */
  14631. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14632. /**
  14633. * Allows back the World matrix computation.
  14634. * @returns the TransformNode.
  14635. */
  14636. unfreezeWorldMatrix(): this;
  14637. /**
  14638. * True if the World matrix has been frozen.
  14639. */
  14640. get isWorldMatrixFrozen(): boolean;
  14641. /**
  14642. * Retuns the mesh absolute position in the World.
  14643. * @returns a Vector3.
  14644. */
  14645. getAbsolutePosition(): Vector3;
  14646. /**
  14647. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14648. * @param absolutePosition the absolute position to set
  14649. * @returns the TransformNode.
  14650. */
  14651. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14652. /**
  14653. * Sets the mesh position in its local space.
  14654. * @param vector3 the position to set in localspace
  14655. * @returns the TransformNode.
  14656. */
  14657. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14658. /**
  14659. * Returns the mesh position in the local space from the current World matrix values.
  14660. * @returns a new Vector3.
  14661. */
  14662. getPositionExpressedInLocalSpace(): Vector3;
  14663. /**
  14664. * Translates the mesh along the passed Vector3 in its local space.
  14665. * @param vector3 the distance to translate in localspace
  14666. * @returns the TransformNode.
  14667. */
  14668. locallyTranslate(vector3: Vector3): TransformNode;
  14669. private static _lookAtVectorCache;
  14670. /**
  14671. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14672. * @param targetPoint the position (must be in same space as current mesh) to look at
  14673. * @param yawCor optional yaw (y-axis) correction in radians
  14674. * @param pitchCor optional pitch (x-axis) correction in radians
  14675. * @param rollCor optional roll (z-axis) correction in radians
  14676. * @param space the choosen space of the target
  14677. * @returns the TransformNode.
  14678. */
  14679. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14680. /**
  14681. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14682. * This Vector3 is expressed in the World space.
  14683. * @param localAxis axis to rotate
  14684. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14685. */
  14686. getDirection(localAxis: Vector3): Vector3;
  14687. /**
  14688. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14689. * localAxis is expressed in the mesh local space.
  14690. * result is computed in the Wordl space from the mesh World matrix.
  14691. * @param localAxis axis to rotate
  14692. * @param result the resulting transformnode
  14693. * @returns this TransformNode.
  14694. */
  14695. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14696. /**
  14697. * Sets this transform node rotation to the given local axis.
  14698. * @param localAxis the axis in local space
  14699. * @param yawCor optional yaw (y-axis) correction in radians
  14700. * @param pitchCor optional pitch (x-axis) correction in radians
  14701. * @param rollCor optional roll (z-axis) correction in radians
  14702. * @returns this TransformNode
  14703. */
  14704. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14705. /**
  14706. * Sets a new pivot point to the current node
  14707. * @param point defines the new pivot point to use
  14708. * @param space defines if the point is in world or local space (local by default)
  14709. * @returns the current TransformNode
  14710. */
  14711. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14712. /**
  14713. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14714. * @returns the pivot point
  14715. */
  14716. getPivotPoint(): Vector3;
  14717. /**
  14718. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14719. * @param result the vector3 to store the result
  14720. * @returns this TransformNode.
  14721. */
  14722. getPivotPointToRef(result: Vector3): TransformNode;
  14723. /**
  14724. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14725. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14726. */
  14727. getAbsolutePivotPoint(): Vector3;
  14728. /**
  14729. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14730. * @param result vector3 to store the result
  14731. * @returns this TransformNode.
  14732. */
  14733. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14734. /**
  14735. * Defines the passed node as the parent of the current node.
  14736. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14737. * @see https://doc.babylonjs.com/how_to/parenting
  14738. * @param node the node ot set as the parent
  14739. * @returns this TransformNode.
  14740. */
  14741. setParent(node: Nullable<Node>): TransformNode;
  14742. private _nonUniformScaling;
  14743. /**
  14744. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14745. */
  14746. get nonUniformScaling(): boolean;
  14747. /** @hidden */
  14748. _updateNonUniformScalingState(value: boolean): boolean;
  14749. /**
  14750. * Attach the current TransformNode to another TransformNode associated with a bone
  14751. * @param bone Bone affecting the TransformNode
  14752. * @param affectedTransformNode TransformNode associated with the bone
  14753. * @returns this object
  14754. */
  14755. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14756. /**
  14757. * Detach the transform node if its associated with a bone
  14758. * @returns this object
  14759. */
  14760. detachFromBone(): TransformNode;
  14761. private static _rotationAxisCache;
  14762. /**
  14763. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14764. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14765. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14766. * The passed axis is also normalized.
  14767. * @param axis the axis to rotate around
  14768. * @param amount the amount to rotate in radians
  14769. * @param space Space to rotate in (Default: local)
  14770. * @returns the TransformNode.
  14771. */
  14772. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14773. /**
  14774. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14775. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14776. * The passed axis is also normalized. .
  14777. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14778. * @param point the point to rotate around
  14779. * @param axis the axis to rotate around
  14780. * @param amount the amount to rotate in radians
  14781. * @returns the TransformNode
  14782. */
  14783. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14784. /**
  14785. * Translates the mesh along the axis vector for the passed distance in the given space.
  14786. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14787. * @param axis the axis to translate in
  14788. * @param distance the distance to translate
  14789. * @param space Space to rotate in (Default: local)
  14790. * @returns the TransformNode.
  14791. */
  14792. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14793. /**
  14794. * Adds a rotation step to the mesh current rotation.
  14795. * x, y, z are Euler angles expressed in radians.
  14796. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14797. * This means this rotation is made in the mesh local space only.
  14798. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14799. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14800. * ```javascript
  14801. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14802. * ```
  14803. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14804. * 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.
  14805. * @param x Rotation to add
  14806. * @param y Rotation to add
  14807. * @param z Rotation to add
  14808. * @returns the TransformNode.
  14809. */
  14810. addRotation(x: number, y: number, z: number): TransformNode;
  14811. /**
  14812. * @hidden
  14813. */
  14814. protected _getEffectiveParent(): Nullable<Node>;
  14815. /**
  14816. * Computes the world matrix of the node
  14817. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14818. * @returns the world matrix
  14819. */
  14820. computeWorldMatrix(force?: boolean): Matrix;
  14821. /**
  14822. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14823. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14824. */
  14825. resetLocalMatrix(independentOfChildren?: boolean): void;
  14826. protected _afterComputeWorldMatrix(): void;
  14827. /**
  14828. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14829. * @param func callback function to add
  14830. *
  14831. * @returns the TransformNode.
  14832. */
  14833. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14834. /**
  14835. * Removes a registered callback function.
  14836. * @param func callback function to remove
  14837. * @returns the TransformNode.
  14838. */
  14839. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14840. /**
  14841. * Gets the position of the current mesh in camera space
  14842. * @param camera defines the camera to use
  14843. * @returns a position
  14844. */
  14845. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14846. /**
  14847. * Returns the distance from the mesh to the active camera
  14848. * @param camera defines the camera to use
  14849. * @returns the distance
  14850. */
  14851. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14852. /**
  14853. * Clone the current transform node
  14854. * @param name Name of the new clone
  14855. * @param newParent New parent for the clone
  14856. * @param doNotCloneChildren Do not clone children hierarchy
  14857. * @returns the new transform node
  14858. */
  14859. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14860. /**
  14861. * Serializes the objects information.
  14862. * @param currentSerializationObject defines the object to serialize in
  14863. * @returns the serialized object
  14864. */
  14865. serialize(currentSerializationObject?: any): any;
  14866. /**
  14867. * Returns a new TransformNode object parsed from the source provided.
  14868. * @param parsedTransformNode is the source.
  14869. * @param scene the scne the object belongs to
  14870. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14871. * @returns a new TransformNode object parsed from the source provided.
  14872. */
  14873. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14874. /**
  14875. * Get all child-transformNodes of this node
  14876. * @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
  14877. * @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
  14878. * @returns an array of TransformNode
  14879. */
  14880. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14881. /**
  14882. * Releases resources associated with this transform node.
  14883. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14884. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14885. */
  14886. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14887. /**
  14888. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14889. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14890. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14891. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14892. * @returns the current mesh
  14893. */
  14894. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14895. private _syncAbsoluteScalingAndRotation;
  14896. }
  14897. }
  14898. declare module BABYLON {
  14899. /**
  14900. * Class used to override all child animations of a given target
  14901. */
  14902. export class AnimationPropertiesOverride {
  14903. /**
  14904. * Gets or sets a value indicating if animation blending must be used
  14905. */
  14906. enableBlending: boolean;
  14907. /**
  14908. * Gets or sets the blending speed to use when enableBlending is true
  14909. */
  14910. blendingSpeed: number;
  14911. /**
  14912. * Gets or sets the default loop mode to use
  14913. */
  14914. loopMode: number;
  14915. }
  14916. }
  14917. declare module BABYLON {
  14918. /**
  14919. * Class used to store bone information
  14920. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14921. */
  14922. export class Bone extends Node {
  14923. /**
  14924. * defines the bone name
  14925. */
  14926. name: string;
  14927. private static _tmpVecs;
  14928. private static _tmpQuat;
  14929. private static _tmpMats;
  14930. /**
  14931. * Gets the list of child bones
  14932. */
  14933. children: Bone[];
  14934. /** Gets the animations associated with this bone */
  14935. animations: Animation[];
  14936. /**
  14937. * Gets or sets bone length
  14938. */
  14939. length: number;
  14940. /**
  14941. * @hidden Internal only
  14942. * Set this value to map this bone to a different index in the transform matrices
  14943. * Set this value to -1 to exclude the bone from the transform matrices
  14944. */
  14945. _index: Nullable<number>;
  14946. private _skeleton;
  14947. private _localMatrix;
  14948. private _restPose;
  14949. private _baseMatrix;
  14950. private _absoluteTransform;
  14951. private _invertedAbsoluteTransform;
  14952. private _parent;
  14953. private _scalingDeterminant;
  14954. private _worldTransform;
  14955. private _localScaling;
  14956. private _localRotation;
  14957. private _localPosition;
  14958. private _needToDecompose;
  14959. private _needToCompose;
  14960. /** @hidden */
  14961. _linkedTransformNode: Nullable<TransformNode>;
  14962. /** @hidden */
  14963. _waitingTransformNodeId: Nullable<string>;
  14964. /** @hidden */
  14965. get _matrix(): Matrix;
  14966. /** @hidden */
  14967. set _matrix(value: Matrix);
  14968. /**
  14969. * Create a new bone
  14970. * @param name defines the bone name
  14971. * @param skeleton defines the parent skeleton
  14972. * @param parentBone defines the parent (can be null if the bone is the root)
  14973. * @param localMatrix defines the local matrix
  14974. * @param restPose defines the rest pose matrix
  14975. * @param baseMatrix defines the base matrix
  14976. * @param index defines index of the bone in the hiearchy
  14977. */
  14978. constructor(
  14979. /**
  14980. * defines the bone name
  14981. */
  14982. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14983. /**
  14984. * Gets the current object class name.
  14985. * @return the class name
  14986. */
  14987. getClassName(): string;
  14988. /**
  14989. * Gets the parent skeleton
  14990. * @returns a skeleton
  14991. */
  14992. getSkeleton(): Skeleton;
  14993. /**
  14994. * Gets parent bone
  14995. * @returns a bone or null if the bone is the root of the bone hierarchy
  14996. */
  14997. getParent(): Nullable<Bone>;
  14998. /**
  14999. * Returns an array containing the root bones
  15000. * @returns an array containing the root bones
  15001. */
  15002. getChildren(): Array<Bone>;
  15003. /**
  15004. * Gets the node index in matrix array generated for rendering
  15005. * @returns the node index
  15006. */
  15007. getIndex(): number;
  15008. /**
  15009. * Sets the parent bone
  15010. * @param parent defines the parent (can be null if the bone is the root)
  15011. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15012. */
  15013. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15014. /**
  15015. * Gets the local matrix
  15016. * @returns a matrix
  15017. */
  15018. getLocalMatrix(): Matrix;
  15019. /**
  15020. * Gets the base matrix (initial matrix which remains unchanged)
  15021. * @returns a matrix
  15022. */
  15023. getBaseMatrix(): Matrix;
  15024. /**
  15025. * Gets the rest pose matrix
  15026. * @returns a matrix
  15027. */
  15028. getRestPose(): Matrix;
  15029. /**
  15030. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15031. */
  15032. getWorldMatrix(): Matrix;
  15033. /**
  15034. * Sets the local matrix to rest pose matrix
  15035. */
  15036. returnToRest(): void;
  15037. /**
  15038. * Gets the inverse of the absolute transform matrix.
  15039. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15040. * @returns a matrix
  15041. */
  15042. getInvertedAbsoluteTransform(): Matrix;
  15043. /**
  15044. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15045. * @returns a matrix
  15046. */
  15047. getAbsoluteTransform(): Matrix;
  15048. /**
  15049. * Links with the given transform node.
  15050. * The local matrix of this bone is copied from the transform node every frame.
  15051. * @param transformNode defines the transform node to link to
  15052. */
  15053. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15054. /**
  15055. * Gets the node used to drive the bone's transformation
  15056. * @returns a transform node or null
  15057. */
  15058. getTransformNode(): Nullable<TransformNode>;
  15059. /** Gets or sets current position (in local space) */
  15060. get position(): Vector3;
  15061. set position(newPosition: Vector3);
  15062. /** Gets or sets current rotation (in local space) */
  15063. get rotation(): Vector3;
  15064. set rotation(newRotation: Vector3);
  15065. /** Gets or sets current rotation quaternion (in local space) */
  15066. get rotationQuaternion(): Quaternion;
  15067. set rotationQuaternion(newRotation: Quaternion);
  15068. /** Gets or sets current scaling (in local space) */
  15069. get scaling(): Vector3;
  15070. set scaling(newScaling: Vector3);
  15071. /**
  15072. * Gets the animation properties override
  15073. */
  15074. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15075. private _decompose;
  15076. private _compose;
  15077. /**
  15078. * Update the base and local matrices
  15079. * @param matrix defines the new base or local matrix
  15080. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15081. * @param updateLocalMatrix defines if the local matrix should be updated
  15082. */
  15083. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15084. /** @hidden */
  15085. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15086. /**
  15087. * Flag the bone as dirty (Forcing it to update everything)
  15088. */
  15089. markAsDirty(): void;
  15090. /** @hidden */
  15091. _markAsDirtyAndCompose(): void;
  15092. private _markAsDirtyAndDecompose;
  15093. /**
  15094. * Translate the bone in local or world space
  15095. * @param vec The amount to translate the bone
  15096. * @param space The space that the translation is in
  15097. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15098. */
  15099. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15100. /**
  15101. * Set the postion of the bone in local or world space
  15102. * @param position The position to set the bone
  15103. * @param space The space that the position is in
  15104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15105. */
  15106. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15107. /**
  15108. * Set the absolute position of the bone (world space)
  15109. * @param position The position to set the bone
  15110. * @param mesh The mesh that this bone is attached to
  15111. */
  15112. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15113. /**
  15114. * Scale the bone on the x, y and z axes (in local space)
  15115. * @param x The amount to scale the bone on the x axis
  15116. * @param y The amount to scale the bone on the y axis
  15117. * @param z The amount to scale the bone on the z axis
  15118. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15119. */
  15120. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15121. /**
  15122. * Set the bone scaling in local space
  15123. * @param scale defines the scaling vector
  15124. */
  15125. setScale(scale: Vector3): void;
  15126. /**
  15127. * Gets the current scaling in local space
  15128. * @returns the current scaling vector
  15129. */
  15130. getScale(): Vector3;
  15131. /**
  15132. * Gets the current scaling in local space and stores it in a target vector
  15133. * @param result defines the target vector
  15134. */
  15135. getScaleToRef(result: Vector3): void;
  15136. /**
  15137. * Set the yaw, pitch, and roll of the bone in local or world space
  15138. * @param yaw The rotation of the bone on the y axis
  15139. * @param pitch The rotation of the bone on the x axis
  15140. * @param roll The rotation of the bone on the z axis
  15141. * @param space The space that the axes of rotation are in
  15142. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15143. */
  15144. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15145. /**
  15146. * Add a rotation to the bone on an axis in local or world space
  15147. * @param axis The axis to rotate the bone on
  15148. * @param amount The amount to rotate the bone
  15149. * @param space The space that the axis is in
  15150. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15151. */
  15152. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15153. /**
  15154. * Set the rotation of the bone to a particular axis angle in local or world space
  15155. * @param axis The axis to rotate the bone on
  15156. * @param angle The angle that the bone should be rotated to
  15157. * @param space The space that the axis is in
  15158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15159. */
  15160. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15161. /**
  15162. * Set the euler rotation of the bone in local of world space
  15163. * @param rotation The euler rotation that the bone should be set to
  15164. * @param space The space that the rotation is in
  15165. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15166. */
  15167. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15168. /**
  15169. * Set the quaternion rotation of the bone in local of world space
  15170. * @param quat The quaternion rotation that the bone should be set to
  15171. * @param space The space that the rotation is in
  15172. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15173. */
  15174. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15175. /**
  15176. * Set the rotation matrix of the bone in local of world space
  15177. * @param rotMat The rotation matrix that the bone should be set to
  15178. * @param space The space that the rotation is in
  15179. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15180. */
  15181. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15182. private _rotateWithMatrix;
  15183. private _getNegativeRotationToRef;
  15184. /**
  15185. * Get the position of the bone in local or world space
  15186. * @param space The space that the returned position is in
  15187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15188. * @returns The position of the bone
  15189. */
  15190. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15191. /**
  15192. * Copy the position of the bone to a vector3 in local or world space
  15193. * @param space The space that the returned position is in
  15194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15195. * @param result The vector3 to copy the position to
  15196. */
  15197. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15198. /**
  15199. * Get the absolute position of the bone (world space)
  15200. * @param mesh The mesh that this bone is attached to
  15201. * @returns The absolute position of the bone
  15202. */
  15203. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15204. /**
  15205. * Copy the absolute position of the bone (world space) to the result param
  15206. * @param mesh The mesh that this bone is attached to
  15207. * @param result The vector3 to copy the absolute position to
  15208. */
  15209. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15210. /**
  15211. * Compute the absolute transforms of this bone and its children
  15212. */
  15213. computeAbsoluteTransforms(): void;
  15214. /**
  15215. * Get the world direction from an axis that is in the local space of the bone
  15216. * @param localAxis The local direction that is used to compute the world direction
  15217. * @param mesh The mesh that this bone is attached to
  15218. * @returns The world direction
  15219. */
  15220. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15221. /**
  15222. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15223. * @param localAxis The local direction that is used to compute the world direction
  15224. * @param mesh The mesh that this bone is attached to
  15225. * @param result The vector3 that the world direction will be copied to
  15226. */
  15227. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15228. /**
  15229. * Get the euler rotation of the bone in local or world space
  15230. * @param space The space that the rotation should be in
  15231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15232. * @returns The euler rotation
  15233. */
  15234. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15235. /**
  15236. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15237. * @param space The space that the rotation should be in
  15238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15239. * @param result The vector3 that the rotation should be copied to
  15240. */
  15241. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15242. /**
  15243. * Get the quaternion rotation of the bone in either local or world space
  15244. * @param space The space that the rotation should be in
  15245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15246. * @returns The quaternion rotation
  15247. */
  15248. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15249. /**
  15250. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15251. * @param space The space that the rotation should be in
  15252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15253. * @param result The quaternion that the rotation should be copied to
  15254. */
  15255. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15256. /**
  15257. * Get the rotation matrix of the bone in local or world space
  15258. * @param space The space that the rotation should be in
  15259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15260. * @returns The rotation matrix
  15261. */
  15262. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15263. /**
  15264. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15265. * @param space The space that the rotation should be in
  15266. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15267. * @param result The quaternion that the rotation should be copied to
  15268. */
  15269. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15270. /**
  15271. * Get the world position of a point that is in the local space of the bone
  15272. * @param position The local position
  15273. * @param mesh The mesh that this bone is attached to
  15274. * @returns The world position
  15275. */
  15276. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15277. /**
  15278. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15279. * @param position The local position
  15280. * @param mesh The mesh that this bone is attached to
  15281. * @param result The vector3 that the world position should be copied to
  15282. */
  15283. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15284. /**
  15285. * Get the local position of a point that is in world space
  15286. * @param position The world position
  15287. * @param mesh The mesh that this bone is attached to
  15288. * @returns The local position
  15289. */
  15290. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15291. /**
  15292. * Get the local position of a point that is in world space and copy it to the result param
  15293. * @param position The world position
  15294. * @param mesh The mesh that this bone is attached to
  15295. * @param result The vector3 that the local position should be copied to
  15296. */
  15297. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15298. }
  15299. }
  15300. declare module BABYLON {
  15301. /**
  15302. * Defines a runtime animation
  15303. */
  15304. export class RuntimeAnimation {
  15305. private _events;
  15306. /**
  15307. * The current frame of the runtime animation
  15308. */
  15309. private _currentFrame;
  15310. /**
  15311. * The animation used by the runtime animation
  15312. */
  15313. private _animation;
  15314. /**
  15315. * The target of the runtime animation
  15316. */
  15317. private _target;
  15318. /**
  15319. * The initiating animatable
  15320. */
  15321. private _host;
  15322. /**
  15323. * The original value of the runtime animation
  15324. */
  15325. private _originalValue;
  15326. /**
  15327. * The original blend value of the runtime animation
  15328. */
  15329. private _originalBlendValue;
  15330. /**
  15331. * The offsets cache of the runtime animation
  15332. */
  15333. private _offsetsCache;
  15334. /**
  15335. * The high limits cache of the runtime animation
  15336. */
  15337. private _highLimitsCache;
  15338. /**
  15339. * Specifies if the runtime animation has been stopped
  15340. */
  15341. private _stopped;
  15342. /**
  15343. * The blending factor of the runtime animation
  15344. */
  15345. private _blendingFactor;
  15346. /**
  15347. * The BabylonJS scene
  15348. */
  15349. private _scene;
  15350. /**
  15351. * The current value of the runtime animation
  15352. */
  15353. private _currentValue;
  15354. /** @hidden */
  15355. _animationState: _IAnimationState;
  15356. /**
  15357. * The active target of the runtime animation
  15358. */
  15359. private _activeTargets;
  15360. private _currentActiveTarget;
  15361. private _directTarget;
  15362. /**
  15363. * The target path of the runtime animation
  15364. */
  15365. private _targetPath;
  15366. /**
  15367. * The weight of the runtime animation
  15368. */
  15369. private _weight;
  15370. /**
  15371. * The ratio offset of the runtime animation
  15372. */
  15373. private _ratioOffset;
  15374. /**
  15375. * The previous delay of the runtime animation
  15376. */
  15377. private _previousDelay;
  15378. /**
  15379. * The previous ratio of the runtime animation
  15380. */
  15381. private _previousRatio;
  15382. private _enableBlending;
  15383. private _keys;
  15384. private _minFrame;
  15385. private _maxFrame;
  15386. private _minValue;
  15387. private _maxValue;
  15388. private _targetIsArray;
  15389. /**
  15390. * Gets the current frame of the runtime animation
  15391. */
  15392. get currentFrame(): number;
  15393. /**
  15394. * Gets the weight of the runtime animation
  15395. */
  15396. get weight(): number;
  15397. /**
  15398. * Gets the current value of the runtime animation
  15399. */
  15400. get currentValue(): any;
  15401. /**
  15402. * Gets the target path of the runtime animation
  15403. */
  15404. get targetPath(): string;
  15405. /**
  15406. * Gets the actual target of the runtime animation
  15407. */
  15408. get target(): any;
  15409. /**
  15410. * Gets the additive state of the runtime animation
  15411. */
  15412. get isAdditive(): boolean;
  15413. /** @hidden */
  15414. _onLoop: () => void;
  15415. /**
  15416. * Create a new RuntimeAnimation object
  15417. * @param target defines the target of the animation
  15418. * @param animation defines the source animation object
  15419. * @param scene defines the hosting scene
  15420. * @param host defines the initiating Animatable
  15421. */
  15422. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15423. private _preparePath;
  15424. /**
  15425. * Gets the animation from the runtime animation
  15426. */
  15427. get animation(): Animation;
  15428. /**
  15429. * Resets the runtime animation to the beginning
  15430. * @param restoreOriginal defines whether to restore the target property to the original value
  15431. */
  15432. reset(restoreOriginal?: boolean): void;
  15433. /**
  15434. * Specifies if the runtime animation is stopped
  15435. * @returns Boolean specifying if the runtime animation is stopped
  15436. */
  15437. isStopped(): boolean;
  15438. /**
  15439. * Disposes of the runtime animation
  15440. */
  15441. dispose(): void;
  15442. /**
  15443. * Apply the interpolated value to the target
  15444. * @param currentValue defines the value computed by the animation
  15445. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15446. */
  15447. setValue(currentValue: any, weight: number): void;
  15448. private _getOriginalValues;
  15449. private _setValue;
  15450. /**
  15451. * Gets the loop pmode of the runtime animation
  15452. * @returns Loop Mode
  15453. */
  15454. private _getCorrectLoopMode;
  15455. /**
  15456. * Move the current animation to a given frame
  15457. * @param frame defines the frame to move to
  15458. */
  15459. goToFrame(frame: number): void;
  15460. /**
  15461. * @hidden Internal use only
  15462. */
  15463. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15464. /**
  15465. * Execute the current animation
  15466. * @param delay defines the delay to add to the current frame
  15467. * @param from defines the lower bound of the animation range
  15468. * @param to defines the upper bound of the animation range
  15469. * @param loop defines if the current animation must loop
  15470. * @param speedRatio defines the current speed ratio
  15471. * @param weight defines the weight of the animation (default is -1 so no weight)
  15472. * @param onLoop optional callback called when animation loops
  15473. * @returns a boolean indicating if the animation is running
  15474. */
  15475. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15476. }
  15477. }
  15478. declare module BABYLON {
  15479. /**
  15480. * Class used to store an actual running animation
  15481. */
  15482. export class Animatable {
  15483. /** defines the target object */
  15484. target: any;
  15485. /** defines the starting frame number (default is 0) */
  15486. fromFrame: number;
  15487. /** defines the ending frame number (default is 100) */
  15488. toFrame: number;
  15489. /** defines if the animation must loop (default is false) */
  15490. loopAnimation: boolean;
  15491. /** defines a callback to call when animation ends if it is not looping */
  15492. onAnimationEnd?: (() => void) | null | undefined;
  15493. /** defines a callback to call when animation loops */
  15494. onAnimationLoop?: (() => void) | null | undefined;
  15495. /** defines whether the animation should be evaluated additively */
  15496. isAdditive: boolean;
  15497. private _localDelayOffset;
  15498. private _pausedDelay;
  15499. private _runtimeAnimations;
  15500. private _paused;
  15501. private _scene;
  15502. private _speedRatio;
  15503. private _weight;
  15504. private _syncRoot;
  15505. /**
  15506. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15507. * This will only apply for non looping animation (default is true)
  15508. */
  15509. disposeOnEnd: boolean;
  15510. /**
  15511. * Gets a boolean indicating if the animation has started
  15512. */
  15513. animationStarted: boolean;
  15514. /**
  15515. * Observer raised when the animation ends
  15516. */
  15517. onAnimationEndObservable: Observable<Animatable>;
  15518. /**
  15519. * Observer raised when the animation loops
  15520. */
  15521. onAnimationLoopObservable: Observable<Animatable>;
  15522. /**
  15523. * Gets the root Animatable used to synchronize and normalize animations
  15524. */
  15525. get syncRoot(): Nullable<Animatable>;
  15526. /**
  15527. * Gets the current frame of the first RuntimeAnimation
  15528. * Used to synchronize Animatables
  15529. */
  15530. get masterFrame(): number;
  15531. /**
  15532. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15533. */
  15534. get weight(): number;
  15535. set weight(value: number);
  15536. /**
  15537. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15538. */
  15539. get speedRatio(): number;
  15540. set speedRatio(value: number);
  15541. /**
  15542. * Creates a new Animatable
  15543. * @param scene defines the hosting scene
  15544. * @param target defines the target object
  15545. * @param fromFrame defines the starting frame number (default is 0)
  15546. * @param toFrame defines the ending frame number (default is 100)
  15547. * @param loopAnimation defines if the animation must loop (default is false)
  15548. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15549. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15550. * @param animations defines a group of animation to add to the new Animatable
  15551. * @param onAnimationLoop defines a callback to call when animation loops
  15552. * @param isAdditive defines whether the animation should be evaluated additively
  15553. */
  15554. constructor(scene: Scene,
  15555. /** defines the target object */
  15556. target: any,
  15557. /** defines the starting frame number (default is 0) */
  15558. fromFrame?: number,
  15559. /** defines the ending frame number (default is 100) */
  15560. toFrame?: number,
  15561. /** defines if the animation must loop (default is false) */
  15562. loopAnimation?: boolean, speedRatio?: number,
  15563. /** defines a callback to call when animation ends if it is not looping */
  15564. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15565. /** defines a callback to call when animation loops */
  15566. onAnimationLoop?: (() => void) | null | undefined,
  15567. /** defines whether the animation should be evaluated additively */
  15568. isAdditive?: boolean);
  15569. /**
  15570. * Synchronize and normalize current Animatable with a source Animatable
  15571. * This is useful when using animation weights and when animations are not of the same length
  15572. * @param root defines the root Animatable to synchronize with
  15573. * @returns the current Animatable
  15574. */
  15575. syncWith(root: Animatable): Animatable;
  15576. /**
  15577. * Gets the list of runtime animations
  15578. * @returns an array of RuntimeAnimation
  15579. */
  15580. getAnimations(): RuntimeAnimation[];
  15581. /**
  15582. * Adds more animations to the current animatable
  15583. * @param target defines the target of the animations
  15584. * @param animations defines the new animations to add
  15585. */
  15586. appendAnimations(target: any, animations: Animation[]): void;
  15587. /**
  15588. * Gets the source animation for a specific property
  15589. * @param property defines the propertyu to look for
  15590. * @returns null or the source animation for the given property
  15591. */
  15592. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15593. /**
  15594. * Gets the runtime animation for a specific property
  15595. * @param property defines the propertyu to look for
  15596. * @returns null or the runtime animation for the given property
  15597. */
  15598. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15599. /**
  15600. * Resets the animatable to its original state
  15601. */
  15602. reset(): void;
  15603. /**
  15604. * Allows the animatable to blend with current running animations
  15605. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15606. * @param blendingSpeed defines the blending speed to use
  15607. */
  15608. enableBlending(blendingSpeed: number): void;
  15609. /**
  15610. * Disable animation blending
  15611. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15612. */
  15613. disableBlending(): void;
  15614. /**
  15615. * Jump directly to a given frame
  15616. * @param frame defines the frame to jump to
  15617. */
  15618. goToFrame(frame: number): void;
  15619. /**
  15620. * Pause the animation
  15621. */
  15622. pause(): void;
  15623. /**
  15624. * Restart the animation
  15625. */
  15626. restart(): void;
  15627. private _raiseOnAnimationEnd;
  15628. /**
  15629. * Stop and delete the current animation
  15630. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15631. * @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)
  15632. */
  15633. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15634. /**
  15635. * Wait asynchronously for the animation to end
  15636. * @returns a promise which will be fullfilled when the animation ends
  15637. */
  15638. waitAsync(): Promise<Animatable>;
  15639. /** @hidden */
  15640. _animate(delay: number): boolean;
  15641. }
  15642. interface Scene {
  15643. /** @hidden */
  15644. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15645. /** @hidden */
  15646. _processLateAnimationBindingsForMatrices(holder: {
  15647. totalWeight: number;
  15648. totalAdditiveWeight: number;
  15649. animations: RuntimeAnimation[];
  15650. additiveAnimations: RuntimeAnimation[];
  15651. originalValue: Matrix;
  15652. }): any;
  15653. /** @hidden */
  15654. _processLateAnimationBindingsForQuaternions(holder: {
  15655. totalWeight: number;
  15656. totalAdditiveWeight: number;
  15657. animations: RuntimeAnimation[];
  15658. additiveAnimations: RuntimeAnimation[];
  15659. originalValue: Quaternion;
  15660. }, refQuaternion: Quaternion): Quaternion;
  15661. /** @hidden */
  15662. _processLateAnimationBindings(): void;
  15663. /**
  15664. * Will start the animation sequence of a given target
  15665. * @param target defines the target
  15666. * @param from defines from which frame should animation start
  15667. * @param to defines until which frame should animation run.
  15668. * @param weight defines the weight to apply to the animation (1.0 by default)
  15669. * @param loop defines if the animation loops
  15670. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15671. * @param onAnimationEnd defines the function to be executed when the animation ends
  15672. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15673. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15674. * @param onAnimationLoop defines the callback to call when an animation loops
  15675. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15676. * @returns the animatable object created for this animation
  15677. */
  15678. 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;
  15679. /**
  15680. * Will start the animation sequence of a given target
  15681. * @param target defines the target
  15682. * @param from defines from which frame should animation start
  15683. * @param to defines until which frame should animation run.
  15684. * @param loop defines if the animation loops
  15685. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15686. * @param onAnimationEnd defines the function to be executed when the animation ends
  15687. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15688. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15689. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15690. * @param onAnimationLoop defines the callback to call when an animation loops
  15691. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15692. * @returns the animatable object created for this animation
  15693. */
  15694. 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;
  15695. /**
  15696. * Will start the animation sequence of a given target and its hierarchy
  15697. * @param target defines the target
  15698. * @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.
  15699. * @param from defines from which frame should animation start
  15700. * @param to defines until which frame should animation run.
  15701. * @param loop defines if the animation loops
  15702. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15703. * @param onAnimationEnd defines the function to be executed when the animation ends
  15704. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15705. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15706. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15707. * @param onAnimationLoop defines the callback to call when an animation loops
  15708. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15709. * @returns the list of created animatables
  15710. */
  15711. 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[];
  15712. /**
  15713. * Begin a new animation on a given node
  15714. * @param target defines the target where the animation will take place
  15715. * @param animations defines the list of animations to start
  15716. * @param from defines the initial value
  15717. * @param to defines the final value
  15718. * @param loop defines if you want animation to loop (off by default)
  15719. * @param speedRatio defines the speed ratio to apply to all animations
  15720. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15721. * @param onAnimationLoop defines the callback to call when an animation loops
  15722. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15723. * @returns the list of created animatables
  15724. */
  15725. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15726. /**
  15727. * Begin a new animation on a given node and its hierarchy
  15728. * @param target defines the root node where the animation will take place
  15729. * @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.
  15730. * @param animations defines the list of animations to start
  15731. * @param from defines the initial value
  15732. * @param to defines the final value
  15733. * @param loop defines if you want animation to loop (off by default)
  15734. * @param speedRatio defines the speed ratio to apply to all animations
  15735. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15736. * @param onAnimationLoop defines the callback to call when an animation loops
  15737. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15738. * @returns the list of animatables created for all nodes
  15739. */
  15740. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15741. /**
  15742. * Gets the animatable associated with a specific target
  15743. * @param target defines the target of the animatable
  15744. * @returns the required animatable if found
  15745. */
  15746. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15747. /**
  15748. * Gets all animatables associated with a given target
  15749. * @param target defines the target to look animatables for
  15750. * @returns an array of Animatables
  15751. */
  15752. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15753. /**
  15754. * Stops and removes all animations that have been applied to the scene
  15755. */
  15756. stopAllAnimations(): void;
  15757. /**
  15758. * Gets the current delta time used by animation engine
  15759. */
  15760. deltaTime: number;
  15761. }
  15762. interface Bone {
  15763. /**
  15764. * Copy an animation range from another bone
  15765. * @param source defines the source bone
  15766. * @param rangeName defines the range name to copy
  15767. * @param frameOffset defines the frame offset
  15768. * @param rescaleAsRequired defines if rescaling must be applied if required
  15769. * @param skelDimensionsRatio defines the scaling ratio
  15770. * @returns true if operation was successful
  15771. */
  15772. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15773. }
  15774. }
  15775. declare module BABYLON {
  15776. /**
  15777. * Class used to handle skinning animations
  15778. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15779. */
  15780. export class Skeleton implements IAnimatable {
  15781. /** defines the skeleton name */
  15782. name: string;
  15783. /** defines the skeleton Id */
  15784. id: string;
  15785. /**
  15786. * Defines the list of child bones
  15787. */
  15788. bones: Bone[];
  15789. /**
  15790. * Defines an estimate of the dimension of the skeleton at rest
  15791. */
  15792. dimensionsAtRest: Vector3;
  15793. /**
  15794. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15795. */
  15796. needInitialSkinMatrix: boolean;
  15797. /**
  15798. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15799. */
  15800. overrideMesh: Nullable<AbstractMesh>;
  15801. /**
  15802. * Gets the list of animations attached to this skeleton
  15803. */
  15804. animations: Array<Animation>;
  15805. private _scene;
  15806. private _isDirty;
  15807. private _transformMatrices;
  15808. private _transformMatrixTexture;
  15809. private _meshesWithPoseMatrix;
  15810. private _animatables;
  15811. private _identity;
  15812. private _synchronizedWithMesh;
  15813. private _ranges;
  15814. private _lastAbsoluteTransformsUpdateId;
  15815. private _canUseTextureForBones;
  15816. private _uniqueId;
  15817. /** @hidden */
  15818. _numBonesWithLinkedTransformNode: number;
  15819. /** @hidden */
  15820. _hasWaitingData: Nullable<boolean>;
  15821. /**
  15822. * Specifies if the skeleton should be serialized
  15823. */
  15824. doNotSerialize: boolean;
  15825. private _useTextureToStoreBoneMatrices;
  15826. /**
  15827. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15828. * Please note that this option is not available if the hardware does not support it
  15829. */
  15830. get useTextureToStoreBoneMatrices(): boolean;
  15831. set useTextureToStoreBoneMatrices(value: boolean);
  15832. private _animationPropertiesOverride;
  15833. /**
  15834. * Gets or sets the animation properties override
  15835. */
  15836. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15837. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15838. /**
  15839. * List of inspectable custom properties (used by the Inspector)
  15840. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15841. */
  15842. inspectableCustomProperties: IInspectable[];
  15843. /**
  15844. * An observable triggered before computing the skeleton's matrices
  15845. */
  15846. onBeforeComputeObservable: Observable<Skeleton>;
  15847. /**
  15848. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15849. */
  15850. get isUsingTextureForMatrices(): boolean;
  15851. /**
  15852. * Gets the unique ID of this skeleton
  15853. */
  15854. get uniqueId(): number;
  15855. /**
  15856. * Creates a new skeleton
  15857. * @param name defines the skeleton name
  15858. * @param id defines the skeleton Id
  15859. * @param scene defines the hosting scene
  15860. */
  15861. constructor(
  15862. /** defines the skeleton name */
  15863. name: string,
  15864. /** defines the skeleton Id */
  15865. id: string, scene: Scene);
  15866. /**
  15867. * Gets the current object class name.
  15868. * @return the class name
  15869. */
  15870. getClassName(): string;
  15871. /**
  15872. * Returns an array containing the root bones
  15873. * @returns an array containing the root bones
  15874. */
  15875. getChildren(): Array<Bone>;
  15876. /**
  15877. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15878. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15879. * @returns a Float32Array containing matrices data
  15880. */
  15881. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15882. /**
  15883. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15884. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15885. * @returns a raw texture containing the data
  15886. */
  15887. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15888. /**
  15889. * Gets the current hosting scene
  15890. * @returns a scene object
  15891. */
  15892. getScene(): Scene;
  15893. /**
  15894. * Gets a string representing the current skeleton data
  15895. * @param fullDetails defines a boolean indicating if we want a verbose version
  15896. * @returns a string representing the current skeleton data
  15897. */
  15898. toString(fullDetails?: boolean): string;
  15899. /**
  15900. * Get bone's index searching by name
  15901. * @param name defines bone's name to search for
  15902. * @return the indice of the bone. Returns -1 if not found
  15903. */
  15904. getBoneIndexByName(name: string): number;
  15905. /**
  15906. * Creater a new animation range
  15907. * @param name defines the name of the range
  15908. * @param from defines the start key
  15909. * @param to defines the end key
  15910. */
  15911. createAnimationRange(name: string, from: number, to: number): void;
  15912. /**
  15913. * Delete a specific animation range
  15914. * @param name defines the name of the range
  15915. * @param deleteFrames defines if frames must be removed as well
  15916. */
  15917. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15918. /**
  15919. * Gets a specific animation range
  15920. * @param name defines the name of the range to look for
  15921. * @returns the requested animation range or null if not found
  15922. */
  15923. getAnimationRange(name: string): Nullable<AnimationRange>;
  15924. /**
  15925. * Gets the list of all animation ranges defined on this skeleton
  15926. * @returns an array
  15927. */
  15928. getAnimationRanges(): Nullable<AnimationRange>[];
  15929. /**
  15930. * Copy animation range from a source skeleton.
  15931. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15932. * @param source defines the source skeleton
  15933. * @param name defines the name of the range to copy
  15934. * @param rescaleAsRequired defines if rescaling must be applied if required
  15935. * @returns true if operation was successful
  15936. */
  15937. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15938. /**
  15939. * Forces the skeleton to go to rest pose
  15940. */
  15941. returnToRest(): void;
  15942. private _getHighestAnimationFrame;
  15943. /**
  15944. * Begin a specific animation range
  15945. * @param name defines the name of the range to start
  15946. * @param loop defines if looping must be turned on (false by default)
  15947. * @param speedRatio defines the speed ratio to apply (1 by default)
  15948. * @param onAnimationEnd defines a callback which will be called when animation will end
  15949. * @returns a new animatable
  15950. */
  15951. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15952. /**
  15953. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15954. * @param skeleton defines the Skeleton containing the animation range to convert
  15955. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15956. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15957. * @returns the original skeleton
  15958. */
  15959. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15960. /** @hidden */
  15961. _markAsDirty(): void;
  15962. /** @hidden */
  15963. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15964. /** @hidden */
  15965. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15966. private _computeTransformMatrices;
  15967. /**
  15968. * Build all resources required to render a skeleton
  15969. */
  15970. prepare(): void;
  15971. /**
  15972. * Gets the list of animatables currently running for this skeleton
  15973. * @returns an array of animatables
  15974. */
  15975. getAnimatables(): IAnimatable[];
  15976. /**
  15977. * Clone the current skeleton
  15978. * @param name defines the name of the new skeleton
  15979. * @param id defines the id of the new skeleton
  15980. * @returns the new skeleton
  15981. */
  15982. clone(name: string, id?: string): Skeleton;
  15983. /**
  15984. * Enable animation blending for this skeleton
  15985. * @param blendingSpeed defines the blending speed to apply
  15986. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15987. */
  15988. enableBlending(blendingSpeed?: number): void;
  15989. /**
  15990. * Releases all resources associated with the current skeleton
  15991. */
  15992. dispose(): void;
  15993. /**
  15994. * Serialize the skeleton in a JSON object
  15995. * @returns a JSON object
  15996. */
  15997. serialize(): any;
  15998. /**
  15999. * Creates a new skeleton from serialized data
  16000. * @param parsedSkeleton defines the serialized data
  16001. * @param scene defines the hosting scene
  16002. * @returns a new skeleton
  16003. */
  16004. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16005. /**
  16006. * Compute all node absolute transforms
  16007. * @param forceUpdate defines if computation must be done even if cache is up to date
  16008. */
  16009. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16010. /**
  16011. * Gets the root pose matrix
  16012. * @returns a matrix
  16013. */
  16014. getPoseMatrix(): Nullable<Matrix>;
  16015. /**
  16016. * Sorts bones per internal index
  16017. */
  16018. sortBones(): void;
  16019. private _sortBones;
  16020. }
  16021. }
  16022. declare module BABYLON {
  16023. /**
  16024. * Creates an instance based on a source mesh.
  16025. */
  16026. export class InstancedMesh extends AbstractMesh {
  16027. private _sourceMesh;
  16028. private _currentLOD;
  16029. /** @hidden */
  16030. _indexInSourceMeshInstanceArray: number;
  16031. constructor(name: string, source: Mesh);
  16032. /**
  16033. * Returns the string "InstancedMesh".
  16034. */
  16035. getClassName(): string;
  16036. /** Gets the list of lights affecting that mesh */
  16037. get lightSources(): Light[];
  16038. _resyncLightSources(): void;
  16039. _resyncLightSource(light: Light): void;
  16040. _removeLightSource(light: Light, dispose: boolean): void;
  16041. /**
  16042. * If the source mesh receives shadows
  16043. */
  16044. get receiveShadows(): boolean;
  16045. /**
  16046. * The material of the source mesh
  16047. */
  16048. get material(): Nullable<Material>;
  16049. /**
  16050. * Visibility of the source mesh
  16051. */
  16052. get visibility(): number;
  16053. /**
  16054. * Skeleton of the source mesh
  16055. */
  16056. get skeleton(): Nullable<Skeleton>;
  16057. /**
  16058. * Rendering ground id of the source mesh
  16059. */
  16060. get renderingGroupId(): number;
  16061. set renderingGroupId(value: number);
  16062. /**
  16063. * Returns the total number of vertices (integer).
  16064. */
  16065. getTotalVertices(): number;
  16066. /**
  16067. * Returns a positive integer : the total number of indices in this mesh geometry.
  16068. * @returns the numner of indices or zero if the mesh has no geometry.
  16069. */
  16070. getTotalIndices(): number;
  16071. /**
  16072. * The source mesh of the instance
  16073. */
  16074. get sourceMesh(): Mesh;
  16075. /**
  16076. * Creates a new InstancedMesh object from the mesh model.
  16077. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16078. * @param name defines the name of the new instance
  16079. * @returns a new InstancedMesh
  16080. */
  16081. createInstance(name: string): InstancedMesh;
  16082. /**
  16083. * Is this node ready to be used/rendered
  16084. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16085. * @return {boolean} is it ready
  16086. */
  16087. isReady(completeCheck?: boolean): boolean;
  16088. /**
  16089. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16090. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16091. * @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.
  16092. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16093. */
  16094. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16095. /**
  16096. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16097. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16098. * The `data` are either a numeric array either a Float32Array.
  16099. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16100. * 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).
  16101. * Note that a new underlying VertexBuffer object is created each call.
  16102. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16103. *
  16104. * Possible `kind` values :
  16105. * - VertexBuffer.PositionKind
  16106. * - VertexBuffer.UVKind
  16107. * - VertexBuffer.UV2Kind
  16108. * - VertexBuffer.UV3Kind
  16109. * - VertexBuffer.UV4Kind
  16110. * - VertexBuffer.UV5Kind
  16111. * - VertexBuffer.UV6Kind
  16112. * - VertexBuffer.ColorKind
  16113. * - VertexBuffer.MatricesIndicesKind
  16114. * - VertexBuffer.MatricesIndicesExtraKind
  16115. * - VertexBuffer.MatricesWeightsKind
  16116. * - VertexBuffer.MatricesWeightsExtraKind
  16117. *
  16118. * Returns the Mesh.
  16119. */
  16120. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16121. /**
  16122. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16123. * If the mesh has no geometry, it is simply returned as it is.
  16124. * The `data` are either a numeric array either a Float32Array.
  16125. * No new underlying VertexBuffer object is created.
  16126. * 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.
  16127. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16128. *
  16129. * Possible `kind` values :
  16130. * - VertexBuffer.PositionKind
  16131. * - VertexBuffer.UVKind
  16132. * - VertexBuffer.UV2Kind
  16133. * - VertexBuffer.UV3Kind
  16134. * - VertexBuffer.UV4Kind
  16135. * - VertexBuffer.UV5Kind
  16136. * - VertexBuffer.UV6Kind
  16137. * - VertexBuffer.ColorKind
  16138. * - VertexBuffer.MatricesIndicesKind
  16139. * - VertexBuffer.MatricesIndicesExtraKind
  16140. * - VertexBuffer.MatricesWeightsKind
  16141. * - VertexBuffer.MatricesWeightsExtraKind
  16142. *
  16143. * Returns the Mesh.
  16144. */
  16145. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16146. /**
  16147. * Sets the mesh indices.
  16148. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16149. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16150. * This method creates a new index buffer each call.
  16151. * Returns the Mesh.
  16152. */
  16153. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16154. /**
  16155. * Boolean : True if the mesh owns the requested kind of data.
  16156. */
  16157. isVerticesDataPresent(kind: string): boolean;
  16158. /**
  16159. * Returns an array of indices (IndicesArray).
  16160. */
  16161. getIndices(): Nullable<IndicesArray>;
  16162. get _positions(): Nullable<Vector3[]>;
  16163. /**
  16164. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16165. * This means the mesh underlying bounding box and sphere are recomputed.
  16166. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16167. * @returns the current mesh
  16168. */
  16169. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16170. /** @hidden */
  16171. _preActivate(): InstancedMesh;
  16172. /** @hidden */
  16173. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16174. /** @hidden */
  16175. _postActivate(): void;
  16176. getWorldMatrix(): Matrix;
  16177. get isAnInstance(): boolean;
  16178. /**
  16179. * Returns the current associated LOD AbstractMesh.
  16180. */
  16181. getLOD(camera: Camera): AbstractMesh;
  16182. /** @hidden */
  16183. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16184. /** @hidden */
  16185. _syncSubMeshes(): InstancedMesh;
  16186. /** @hidden */
  16187. _generatePointsArray(): boolean;
  16188. /**
  16189. * Creates a new InstancedMesh from the current mesh.
  16190. * - name (string) : the cloned mesh name
  16191. * - newParent (optional Node) : the optional Node to parent the clone to.
  16192. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16193. *
  16194. * Returns the clone.
  16195. */
  16196. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16197. /**
  16198. * Disposes the InstancedMesh.
  16199. * Returns nothing.
  16200. */
  16201. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16202. }
  16203. interface Mesh {
  16204. /**
  16205. * Register a custom buffer that will be instanced
  16206. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16207. * @param kind defines the buffer kind
  16208. * @param stride defines the stride in floats
  16209. */
  16210. registerInstancedBuffer(kind: string, stride: number): void;
  16211. /**
  16212. * true to use the edge renderer for all instances of this mesh
  16213. */
  16214. edgesShareWithInstances: boolean;
  16215. /** @hidden */
  16216. _userInstancedBuffersStorage: {
  16217. data: {
  16218. [key: string]: Float32Array;
  16219. };
  16220. sizes: {
  16221. [key: string]: number;
  16222. };
  16223. vertexBuffers: {
  16224. [key: string]: Nullable<VertexBuffer>;
  16225. };
  16226. strides: {
  16227. [key: string]: number;
  16228. };
  16229. };
  16230. }
  16231. interface AbstractMesh {
  16232. /**
  16233. * Object used to store instanced buffers defined by user
  16234. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16235. */
  16236. instancedBuffers: {
  16237. [key: string]: any;
  16238. };
  16239. }
  16240. }
  16241. declare module BABYLON {
  16242. /**
  16243. * Defines the options associated with the creation of a shader material.
  16244. */
  16245. export interface IShaderMaterialOptions {
  16246. /**
  16247. * Does the material work in alpha blend mode
  16248. */
  16249. needAlphaBlending: boolean;
  16250. /**
  16251. * Does the material work in alpha test mode
  16252. */
  16253. needAlphaTesting: boolean;
  16254. /**
  16255. * The list of attribute names used in the shader
  16256. */
  16257. attributes: string[];
  16258. /**
  16259. * The list of unifrom names used in the shader
  16260. */
  16261. uniforms: string[];
  16262. /**
  16263. * The list of UBO names used in the shader
  16264. */
  16265. uniformBuffers: string[];
  16266. /**
  16267. * The list of sampler names used in the shader
  16268. */
  16269. samplers: string[];
  16270. /**
  16271. * The list of defines used in the shader
  16272. */
  16273. defines: string[];
  16274. }
  16275. /**
  16276. * 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.
  16277. *
  16278. * This returned material effects how the mesh will look based on the code in the shaders.
  16279. *
  16280. * @see https://doc.babylonjs.com/how_to/shader_material
  16281. */
  16282. export class ShaderMaterial extends Material {
  16283. private _shaderPath;
  16284. private _options;
  16285. private _textures;
  16286. private _textureArrays;
  16287. private _floats;
  16288. private _ints;
  16289. private _floatsArrays;
  16290. private _colors3;
  16291. private _colors3Arrays;
  16292. private _colors4;
  16293. private _colors4Arrays;
  16294. private _vectors2;
  16295. private _vectors3;
  16296. private _vectors4;
  16297. private _matrices;
  16298. private _matrixArrays;
  16299. private _matrices3x3;
  16300. private _matrices2x2;
  16301. private _vectors2Arrays;
  16302. private _vectors3Arrays;
  16303. private _vectors4Arrays;
  16304. private _cachedWorldViewMatrix;
  16305. private _cachedWorldViewProjectionMatrix;
  16306. private _renderId;
  16307. private _multiview;
  16308. private _cachedDefines;
  16309. /** Define the Url to load snippets */
  16310. static SnippetUrl: string;
  16311. /** Snippet ID if the material was created from the snippet server */
  16312. snippetId: string;
  16313. /**
  16314. * Instantiate a new shader material.
  16315. * 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.
  16316. * This returned material effects how the mesh will look based on the code in the shaders.
  16317. * @see https://doc.babylonjs.com/how_to/shader_material
  16318. * @param name Define the name of the material in the scene
  16319. * @param scene Define the scene the material belongs to
  16320. * @param shaderPath Defines the route to the shader code in one of three ways:
  16321. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16322. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16323. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16324. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16325. * @param options Define the options used to create the shader
  16326. */
  16327. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16328. /**
  16329. * Gets the shader path used to define the shader code
  16330. * It can be modified to trigger a new compilation
  16331. */
  16332. get shaderPath(): any;
  16333. /**
  16334. * Sets the shader path used to define the shader code
  16335. * It can be modified to trigger a new compilation
  16336. */
  16337. set shaderPath(shaderPath: any);
  16338. /**
  16339. * Gets the options used to compile the shader.
  16340. * They can be modified to trigger a new compilation
  16341. */
  16342. get options(): IShaderMaterialOptions;
  16343. /**
  16344. * Gets the current class name of the material e.g. "ShaderMaterial"
  16345. * Mainly use in serialization.
  16346. * @returns the class name
  16347. */
  16348. getClassName(): string;
  16349. /**
  16350. * Specifies if the material will require alpha blending
  16351. * @returns a boolean specifying if alpha blending is needed
  16352. */
  16353. needAlphaBlending(): boolean;
  16354. /**
  16355. * Specifies if this material should be rendered in alpha test mode
  16356. * @returns a boolean specifying if an alpha test is needed.
  16357. */
  16358. needAlphaTesting(): boolean;
  16359. private _checkUniform;
  16360. /**
  16361. * Set a texture in the shader.
  16362. * @param name Define the name of the uniform samplers as defined in the shader
  16363. * @param texture Define the texture to bind to this sampler
  16364. * @return the material itself allowing "fluent" like uniform updates
  16365. */
  16366. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16367. /**
  16368. * Set a texture array in the shader.
  16369. * @param name Define the name of the uniform sampler array as defined in the shader
  16370. * @param textures Define the list of textures to bind to this sampler
  16371. * @return the material itself allowing "fluent" like uniform updates
  16372. */
  16373. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16374. /**
  16375. * Set a float in the shader.
  16376. * @param name Define the name of the uniform as defined in the shader
  16377. * @param value Define the value to give to the uniform
  16378. * @return the material itself allowing "fluent" like uniform updates
  16379. */
  16380. setFloat(name: string, value: number): ShaderMaterial;
  16381. /**
  16382. * Set a int in the shader.
  16383. * @param name Define the name of the uniform as defined in the shader
  16384. * @param value Define the value to give to the uniform
  16385. * @return the material itself allowing "fluent" like uniform updates
  16386. */
  16387. setInt(name: string, value: number): ShaderMaterial;
  16388. /**
  16389. * Set an array of floats in the shader.
  16390. * @param name Define the name of the uniform as defined in the shader
  16391. * @param value Define the value to give to the uniform
  16392. * @return the material itself allowing "fluent" like uniform updates
  16393. */
  16394. setFloats(name: string, value: number[]): ShaderMaterial;
  16395. /**
  16396. * Set a vec3 in the shader from a Color3.
  16397. * @param name Define the name of the uniform as defined in the shader
  16398. * @param value Define the value to give to the uniform
  16399. * @return the material itself allowing "fluent" like uniform updates
  16400. */
  16401. setColor3(name: string, value: Color3): ShaderMaterial;
  16402. /**
  16403. * Set a vec3 array in the shader from a Color3 array.
  16404. * @param name Define the name of the uniform as defined in the shader
  16405. * @param value Define the value to give to the uniform
  16406. * @return the material itself allowing "fluent" like uniform updates
  16407. */
  16408. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16409. /**
  16410. * Set a vec4 in the shader from a Color4.
  16411. * @param name Define the name of the uniform as defined in the shader
  16412. * @param value Define the value to give to the uniform
  16413. * @return the material itself allowing "fluent" like uniform updates
  16414. */
  16415. setColor4(name: string, value: Color4): ShaderMaterial;
  16416. /**
  16417. * Set a vec4 array in the shader from a Color4 array.
  16418. * @param name Define the name of the uniform as defined in the shader
  16419. * @param value Define the value to give to the uniform
  16420. * @return the material itself allowing "fluent" like uniform updates
  16421. */
  16422. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16423. /**
  16424. * Set a vec2 in the shader from a Vector2.
  16425. * @param name Define the name of the uniform as defined in the shader
  16426. * @param value Define the value to give to the uniform
  16427. * @return the material itself allowing "fluent" like uniform updates
  16428. */
  16429. setVector2(name: string, value: Vector2): ShaderMaterial;
  16430. /**
  16431. * Set a vec3 in the shader from a Vector3.
  16432. * @param name Define the name of the uniform as defined in the shader
  16433. * @param value Define the value to give to the uniform
  16434. * @return the material itself allowing "fluent" like uniform updates
  16435. */
  16436. setVector3(name: string, value: Vector3): ShaderMaterial;
  16437. /**
  16438. * Set a vec4 in the shader from a Vector4.
  16439. * @param name Define the name of the uniform as defined in the shader
  16440. * @param value Define the value to give to the uniform
  16441. * @return the material itself allowing "fluent" like uniform updates
  16442. */
  16443. setVector4(name: string, value: Vector4): ShaderMaterial;
  16444. /**
  16445. * Set a mat4 in the shader from a Matrix.
  16446. * @param name Define the name of the uniform as defined in the shader
  16447. * @param value Define the value to give to the uniform
  16448. * @return the material itself allowing "fluent" like uniform updates
  16449. */
  16450. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16451. /**
  16452. * Set a float32Array in the shader from a matrix array.
  16453. * @param name Define the name of the uniform as defined in the shader
  16454. * @param value Define the value to give to the uniform
  16455. * @return the material itself allowing "fluent" like uniform updates
  16456. */
  16457. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16458. /**
  16459. * Set a mat3 in the shader from a Float32Array.
  16460. * @param name Define the name of the uniform as defined in the shader
  16461. * @param value Define the value to give to the uniform
  16462. * @return the material itself allowing "fluent" like uniform updates
  16463. */
  16464. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16465. /**
  16466. * Set a mat2 in the shader from a Float32Array.
  16467. * @param name Define the name of the uniform as defined in the shader
  16468. * @param value Define the value to give to the uniform
  16469. * @return the material itself allowing "fluent" like uniform updates
  16470. */
  16471. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16472. /**
  16473. * Set a vec2 array in the shader from a number array.
  16474. * @param name Define the name of the uniform as defined in the shader
  16475. * @param value Define the value to give to the uniform
  16476. * @return the material itself allowing "fluent" like uniform updates
  16477. */
  16478. setArray2(name: string, value: number[]): ShaderMaterial;
  16479. /**
  16480. * Set a vec3 array in the shader from a number array.
  16481. * @param name Define the name of the uniform as defined in the shader
  16482. * @param value Define the value to give to the uniform
  16483. * @return the material itself allowing "fluent" like uniform updates
  16484. */
  16485. setArray3(name: string, value: number[]): ShaderMaterial;
  16486. /**
  16487. * Set a vec4 array in the shader from a number array.
  16488. * @param name Define the name of the uniform as defined in the shader
  16489. * @param value Define the value to give to the uniform
  16490. * @return the material itself allowing "fluent" like uniform updates
  16491. */
  16492. setArray4(name: string, value: number[]): ShaderMaterial;
  16493. private _checkCache;
  16494. /**
  16495. * Specifies that the submesh is ready to be used
  16496. * @param mesh defines the mesh to check
  16497. * @param subMesh defines which submesh to check
  16498. * @param useInstances specifies that instances should be used
  16499. * @returns a boolean indicating that the submesh is ready or not
  16500. */
  16501. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16502. /**
  16503. * Checks if the material is ready to render the requested mesh
  16504. * @param mesh Define the mesh to render
  16505. * @param useInstances Define whether or not the material is used with instances
  16506. * @returns true if ready, otherwise false
  16507. */
  16508. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16509. /**
  16510. * Binds the world matrix to the material
  16511. * @param world defines the world transformation matrix
  16512. * @param effectOverride - If provided, use this effect instead of internal effect
  16513. */
  16514. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16515. /**
  16516. * Binds the submesh to this material by preparing the effect and shader to draw
  16517. * @param world defines the world transformation matrix
  16518. * @param mesh defines the mesh containing the submesh
  16519. * @param subMesh defines the submesh to bind the material to
  16520. */
  16521. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16522. /**
  16523. * Binds the material to the mesh
  16524. * @param world defines the world transformation matrix
  16525. * @param mesh defines the mesh to bind the material to
  16526. * @param effectOverride - If provided, use this effect instead of internal effect
  16527. */
  16528. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16529. protected _afterBind(mesh?: Mesh): void;
  16530. /**
  16531. * Gets the active textures from the material
  16532. * @returns an array of textures
  16533. */
  16534. getActiveTextures(): BaseTexture[];
  16535. /**
  16536. * Specifies if the material uses a texture
  16537. * @param texture defines the texture to check against the material
  16538. * @returns a boolean specifying if the material uses the texture
  16539. */
  16540. hasTexture(texture: BaseTexture): boolean;
  16541. /**
  16542. * Makes a duplicate of the material, and gives it a new name
  16543. * @param name defines the new name for the duplicated material
  16544. * @returns the cloned material
  16545. */
  16546. clone(name: string): ShaderMaterial;
  16547. /**
  16548. * Disposes the material
  16549. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16550. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16551. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16552. */
  16553. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16554. /**
  16555. * Serializes this material in a JSON representation
  16556. * @returns the serialized material object
  16557. */
  16558. serialize(): any;
  16559. /**
  16560. * Creates a shader material from parsed shader material data
  16561. * @param source defines the JSON represnetation of the material
  16562. * @param scene defines the hosting scene
  16563. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16564. * @returns a new material
  16565. */
  16566. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16567. /**
  16568. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16569. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16570. * @param url defines the url to load from
  16571. * @param scene defines the hosting scene
  16572. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16573. * @returns a promise that will resolve to the new ShaderMaterial
  16574. */
  16575. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16576. /**
  16577. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16578. * @param snippetId defines the snippet to load
  16579. * @param scene defines the hosting scene
  16580. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16581. * @returns a promise that will resolve to the new ShaderMaterial
  16582. */
  16583. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16584. }
  16585. }
  16586. declare module BABYLON {
  16587. /** @hidden */
  16588. export var colorPixelShader: {
  16589. name: string;
  16590. shader: string;
  16591. };
  16592. }
  16593. declare module BABYLON {
  16594. /** @hidden */
  16595. export var colorVertexShader: {
  16596. name: string;
  16597. shader: string;
  16598. };
  16599. }
  16600. declare module BABYLON {
  16601. /**
  16602. * Line mesh
  16603. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16604. */
  16605. export class LinesMesh extends Mesh {
  16606. /**
  16607. * If vertex color should be applied to the mesh
  16608. */
  16609. readonly useVertexColor?: boolean | undefined;
  16610. /**
  16611. * If vertex alpha should be applied to the mesh
  16612. */
  16613. readonly useVertexAlpha?: boolean | undefined;
  16614. /**
  16615. * Color of the line (Default: White)
  16616. */
  16617. color: Color3;
  16618. /**
  16619. * Alpha of the line (Default: 1)
  16620. */
  16621. alpha: number;
  16622. /**
  16623. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16624. * This margin is expressed in world space coordinates, so its value may vary.
  16625. * Default value is 0.1
  16626. */
  16627. intersectionThreshold: number;
  16628. private _colorShader;
  16629. private color4;
  16630. /**
  16631. * Creates a new LinesMesh
  16632. * @param name defines the name
  16633. * @param scene defines the hosting scene
  16634. * @param parent defines the parent mesh if any
  16635. * @param source defines the optional source LinesMesh used to clone data from
  16636. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16637. * When false, achieved by calling a clone(), also passing False.
  16638. * This will make creation of children, recursive.
  16639. * @param useVertexColor defines if this LinesMesh supports vertex color
  16640. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16641. */
  16642. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16643. /**
  16644. * If vertex color should be applied to the mesh
  16645. */
  16646. useVertexColor?: boolean | undefined,
  16647. /**
  16648. * If vertex alpha should be applied to the mesh
  16649. */
  16650. useVertexAlpha?: boolean | undefined);
  16651. private _addClipPlaneDefine;
  16652. private _removeClipPlaneDefine;
  16653. isReady(): boolean;
  16654. /**
  16655. * Returns the string "LineMesh"
  16656. */
  16657. getClassName(): string;
  16658. /**
  16659. * @hidden
  16660. */
  16661. get material(): Material;
  16662. /**
  16663. * @hidden
  16664. */
  16665. set material(value: Material);
  16666. /**
  16667. * @hidden
  16668. */
  16669. get checkCollisions(): boolean;
  16670. /** @hidden */
  16671. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16672. /** @hidden */
  16673. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16674. /**
  16675. * Disposes of the line mesh
  16676. * @param doNotRecurse If children should be disposed
  16677. */
  16678. dispose(doNotRecurse?: boolean): void;
  16679. /**
  16680. * Returns a new LineMesh object cloned from the current one.
  16681. */
  16682. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16683. /**
  16684. * Creates a new InstancedLinesMesh object from the mesh model.
  16685. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16686. * @param name defines the name of the new instance
  16687. * @returns a new InstancedLinesMesh
  16688. */
  16689. createInstance(name: string): InstancedLinesMesh;
  16690. }
  16691. /**
  16692. * Creates an instance based on a source LinesMesh
  16693. */
  16694. export class InstancedLinesMesh extends InstancedMesh {
  16695. /**
  16696. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16697. * This margin is expressed in world space coordinates, so its value may vary.
  16698. * Initilized with the intersectionThreshold value of the source LinesMesh
  16699. */
  16700. intersectionThreshold: number;
  16701. constructor(name: string, source: LinesMesh);
  16702. /**
  16703. * Returns the string "InstancedLinesMesh".
  16704. */
  16705. getClassName(): string;
  16706. }
  16707. }
  16708. declare module BABYLON {
  16709. /** @hidden */
  16710. export var linePixelShader: {
  16711. name: string;
  16712. shader: string;
  16713. };
  16714. }
  16715. declare module BABYLON {
  16716. /** @hidden */
  16717. export var lineVertexShader: {
  16718. name: string;
  16719. shader: string;
  16720. };
  16721. }
  16722. declare module BABYLON {
  16723. interface Scene {
  16724. /** @hidden */
  16725. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16726. }
  16727. interface AbstractMesh {
  16728. /**
  16729. * Gets the edgesRenderer associated with the mesh
  16730. */
  16731. edgesRenderer: Nullable<EdgesRenderer>;
  16732. }
  16733. interface LinesMesh {
  16734. /**
  16735. * Enables the edge rendering mode on the mesh.
  16736. * This mode makes the mesh edges visible
  16737. * @param epsilon defines the maximal distance between two angles to detect a face
  16738. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16739. * @returns the currentAbstractMesh
  16740. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16741. */
  16742. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16743. }
  16744. interface InstancedLinesMesh {
  16745. /**
  16746. * Enables the edge rendering mode on the mesh.
  16747. * This mode makes the mesh edges visible
  16748. * @param epsilon defines the maximal distance between two angles to detect a face
  16749. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16750. * @returns the current InstancedLinesMesh
  16751. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16752. */
  16753. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16754. }
  16755. /**
  16756. * Defines the minimum contract an Edges renderer should follow.
  16757. */
  16758. export interface IEdgesRenderer extends IDisposable {
  16759. /**
  16760. * Gets or sets a boolean indicating if the edgesRenderer is active
  16761. */
  16762. isEnabled: boolean;
  16763. /**
  16764. * Renders the edges of the attached mesh,
  16765. */
  16766. render(): void;
  16767. /**
  16768. * Checks wether or not the edges renderer is ready to render.
  16769. * @return true if ready, otherwise false.
  16770. */
  16771. isReady(): boolean;
  16772. /**
  16773. * List of instances to render in case the source mesh has instances
  16774. */
  16775. customInstances: SmartArray<Matrix>;
  16776. }
  16777. /**
  16778. * Defines the additional options of the edges renderer
  16779. */
  16780. export interface IEdgesRendererOptions {
  16781. /**
  16782. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16783. * If not defined, the default value is true
  16784. */
  16785. useAlternateEdgeFinder?: boolean;
  16786. /**
  16787. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16788. * If not defined, the default value is true.
  16789. * 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)
  16790. * This option is used only if useAlternateEdgeFinder = true
  16791. */
  16792. useFastVertexMerger?: boolean;
  16793. /**
  16794. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  16795. * The default value is 1e-6
  16796. * This option is used only if useAlternateEdgeFinder = true
  16797. */
  16798. epsilonVertexMerge?: number;
  16799. /**
  16800. * 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
  16801. * 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.
  16802. * This option is used only if useAlternateEdgeFinder = true
  16803. */
  16804. applyTessellation?: boolean;
  16805. /**
  16806. * 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
  16807. * The default value is 1e-6
  16808. * This option is used only if useAlternateEdgeFinder = true
  16809. */
  16810. epsilonVertexAligned?: number;
  16811. }
  16812. /**
  16813. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16814. */
  16815. export class EdgesRenderer implements IEdgesRenderer {
  16816. /**
  16817. * Define the size of the edges with an orthographic camera
  16818. */
  16819. edgesWidthScalerForOrthographic: number;
  16820. /**
  16821. * Define the size of the edges with a perspective camera
  16822. */
  16823. edgesWidthScalerForPerspective: number;
  16824. protected _source: AbstractMesh;
  16825. protected _linesPositions: number[];
  16826. protected _linesNormals: number[];
  16827. protected _linesIndices: number[];
  16828. protected _epsilon: number;
  16829. protected _indicesCount: number;
  16830. protected _lineShader: ShaderMaterial;
  16831. protected _ib: DataBuffer;
  16832. protected _buffers: {
  16833. [key: string]: Nullable<VertexBuffer>;
  16834. };
  16835. protected _buffersForInstances: {
  16836. [key: string]: Nullable<VertexBuffer>;
  16837. };
  16838. protected _checkVerticesInsteadOfIndices: boolean;
  16839. protected _options: Nullable<IEdgesRendererOptions>;
  16840. private _meshRebuildObserver;
  16841. private _meshDisposeObserver;
  16842. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16843. isEnabled: boolean;
  16844. /**
  16845. * List of instances to render in case the source mesh has instances
  16846. */
  16847. customInstances: SmartArray<Matrix>;
  16848. private static GetShader;
  16849. /**
  16850. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16851. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16852. * @param source Mesh used to create edges
  16853. * @param epsilon sum of angles in adjacency to check for edge
  16854. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  16855. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16856. * @param options The options to apply when generating the edges
  16857. */
  16858. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  16859. protected _prepareRessources(): void;
  16860. /** @hidden */
  16861. _rebuild(): void;
  16862. /**
  16863. * Releases the required resources for the edges renderer
  16864. */
  16865. dispose(): void;
  16866. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16867. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16868. /**
  16869. * Checks if the pair of p0 and p1 is en edge
  16870. * @param faceIndex
  16871. * @param edge
  16872. * @param faceNormals
  16873. * @param p0
  16874. * @param p1
  16875. * @private
  16876. */
  16877. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16878. /**
  16879. * push line into the position, normal and index buffer
  16880. * @protected
  16881. */
  16882. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16883. /**
  16884. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  16885. */
  16886. private _tessellateTriangle;
  16887. private _generateEdgesLinesAlternate;
  16888. /**
  16889. * Generates lines edges from adjacencjes
  16890. * @private
  16891. */
  16892. _generateEdgesLines(): void;
  16893. /**
  16894. * Checks wether or not the edges renderer is ready to render.
  16895. * @return true if ready, otherwise false.
  16896. */
  16897. isReady(): boolean;
  16898. /**
  16899. * Renders the edges of the attached mesh,
  16900. */
  16901. render(): void;
  16902. }
  16903. /**
  16904. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16905. */
  16906. export class LineEdgesRenderer extends EdgesRenderer {
  16907. /**
  16908. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16909. * @param source LineMesh used to generate edges
  16910. * @param epsilon not important (specified angle for edge detection)
  16911. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16912. */
  16913. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16914. /**
  16915. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16916. */
  16917. _generateEdgesLines(): void;
  16918. }
  16919. }
  16920. declare module BABYLON {
  16921. /**
  16922. * This represents the object necessary to create a rendering group.
  16923. * This is exclusively used and created by the rendering manager.
  16924. * To modify the behavior, you use the available helpers in your scene or meshes.
  16925. * @hidden
  16926. */
  16927. export class RenderingGroup {
  16928. index: number;
  16929. private static _zeroVector;
  16930. private _scene;
  16931. private _opaqueSubMeshes;
  16932. private _transparentSubMeshes;
  16933. private _alphaTestSubMeshes;
  16934. private _depthOnlySubMeshes;
  16935. private _particleSystems;
  16936. private _spriteManagers;
  16937. private _opaqueSortCompareFn;
  16938. private _alphaTestSortCompareFn;
  16939. private _transparentSortCompareFn;
  16940. private _renderOpaque;
  16941. private _renderAlphaTest;
  16942. private _renderTransparent;
  16943. /** @hidden */
  16944. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  16945. onBeforeTransparentRendering: () => void;
  16946. /**
  16947. * Set the opaque sort comparison function.
  16948. * If null the sub meshes will be render in the order they were created
  16949. */
  16950. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16951. /**
  16952. * Set the alpha test sort comparison function.
  16953. * If null the sub meshes will be render in the order they were created
  16954. */
  16955. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16956. /**
  16957. * Set the transparent sort comparison function.
  16958. * If null the sub meshes will be render in the order they were created
  16959. */
  16960. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16961. /**
  16962. * Creates a new rendering group.
  16963. * @param index The rendering group index
  16964. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16965. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16966. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16967. */
  16968. 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>);
  16969. /**
  16970. * Render all the sub meshes contained in the group.
  16971. * @param customRenderFunction Used to override the default render behaviour of the group.
  16972. * @returns true if rendered some submeshes.
  16973. */
  16974. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16975. /**
  16976. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16977. * @param subMeshes The submeshes to render
  16978. */
  16979. private renderOpaqueSorted;
  16980. /**
  16981. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16982. * @param subMeshes The submeshes to render
  16983. */
  16984. private renderAlphaTestSorted;
  16985. /**
  16986. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16987. * @param subMeshes The submeshes to render
  16988. */
  16989. private renderTransparentSorted;
  16990. /**
  16991. * Renders the submeshes in a specified order.
  16992. * @param subMeshes The submeshes to sort before render
  16993. * @param sortCompareFn The comparison function use to sort
  16994. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16995. * @param transparent Specifies to activate blending if true
  16996. */
  16997. private static renderSorted;
  16998. /**
  16999. * Renders the submeshes in the order they were dispatched (no sort applied).
  17000. * @param subMeshes The submeshes to render
  17001. */
  17002. private static renderUnsorted;
  17003. /**
  17004. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17005. * are rendered back to front if in the same alpha index.
  17006. *
  17007. * @param a The first submesh
  17008. * @param b The second submesh
  17009. * @returns The result of the comparison
  17010. */
  17011. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17012. /**
  17013. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17014. * are rendered back to front.
  17015. *
  17016. * @param a The first submesh
  17017. * @param b The second submesh
  17018. * @returns The result of the comparison
  17019. */
  17020. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17021. /**
  17022. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17023. * are rendered front to back (prevent overdraw).
  17024. *
  17025. * @param a The first submesh
  17026. * @param b The second submesh
  17027. * @returns The result of the comparison
  17028. */
  17029. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17030. /**
  17031. * Resets the different lists of submeshes to prepare a new frame.
  17032. */
  17033. prepare(): void;
  17034. dispose(): void;
  17035. /**
  17036. * Inserts the submesh in its correct queue depending on its material.
  17037. * @param subMesh The submesh to dispatch
  17038. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17039. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17040. */
  17041. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17042. dispatchSprites(spriteManager: ISpriteManager): void;
  17043. dispatchParticles(particleSystem: IParticleSystem): void;
  17044. private _renderParticles;
  17045. private _renderSprites;
  17046. }
  17047. }
  17048. declare module BABYLON {
  17049. /**
  17050. * Interface describing the different options available in the rendering manager
  17051. * regarding Auto Clear between groups.
  17052. */
  17053. export interface IRenderingManagerAutoClearSetup {
  17054. /**
  17055. * Defines whether or not autoclear is enable.
  17056. */
  17057. autoClear: boolean;
  17058. /**
  17059. * Defines whether or not to autoclear the depth buffer.
  17060. */
  17061. depth: boolean;
  17062. /**
  17063. * Defines whether or not to autoclear the stencil buffer.
  17064. */
  17065. stencil: boolean;
  17066. }
  17067. /**
  17068. * This class is used by the onRenderingGroupObservable
  17069. */
  17070. export class RenderingGroupInfo {
  17071. /**
  17072. * The Scene that being rendered
  17073. */
  17074. scene: Scene;
  17075. /**
  17076. * The camera currently used for the rendering pass
  17077. */
  17078. camera: Nullable<Camera>;
  17079. /**
  17080. * The ID of the renderingGroup being processed
  17081. */
  17082. renderingGroupId: number;
  17083. }
  17084. /**
  17085. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17086. * It is enable to manage the different groups as well as the different necessary sort functions.
  17087. * This should not be used directly aside of the few static configurations
  17088. */
  17089. export class RenderingManager {
  17090. /**
  17091. * The max id used for rendering groups (not included)
  17092. */
  17093. static MAX_RENDERINGGROUPS: number;
  17094. /**
  17095. * The min id used for rendering groups (included)
  17096. */
  17097. static MIN_RENDERINGGROUPS: number;
  17098. /**
  17099. * Used to globally prevent autoclearing scenes.
  17100. */
  17101. static AUTOCLEAR: boolean;
  17102. /**
  17103. * @hidden
  17104. */
  17105. _useSceneAutoClearSetup: boolean;
  17106. private _scene;
  17107. private _renderingGroups;
  17108. private _depthStencilBufferAlreadyCleaned;
  17109. private _autoClearDepthStencil;
  17110. private _customOpaqueSortCompareFn;
  17111. private _customAlphaTestSortCompareFn;
  17112. private _customTransparentSortCompareFn;
  17113. private _renderingGroupInfo;
  17114. /**
  17115. * Instantiates a new rendering group for a particular scene
  17116. * @param scene Defines the scene the groups belongs to
  17117. */
  17118. constructor(scene: Scene);
  17119. private _clearDepthStencilBuffer;
  17120. /**
  17121. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17122. * @hidden
  17123. */
  17124. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17125. /**
  17126. * Resets the different information of the group to prepare a new frame
  17127. * @hidden
  17128. */
  17129. reset(): void;
  17130. /**
  17131. * Dispose and release the group and its associated resources.
  17132. * @hidden
  17133. */
  17134. dispose(): void;
  17135. /**
  17136. * Clear the info related to rendering groups preventing retention points during dispose.
  17137. */
  17138. freeRenderingGroups(): void;
  17139. private _prepareRenderingGroup;
  17140. /**
  17141. * Add a sprite manager to the rendering manager in order to render it this frame.
  17142. * @param spriteManager Define the sprite manager to render
  17143. */
  17144. dispatchSprites(spriteManager: ISpriteManager): void;
  17145. /**
  17146. * Add a particle system to the rendering manager in order to render it this frame.
  17147. * @param particleSystem Define the particle system to render
  17148. */
  17149. dispatchParticles(particleSystem: IParticleSystem): void;
  17150. /**
  17151. * Add a submesh to the manager in order to render it this frame
  17152. * @param subMesh The submesh to dispatch
  17153. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17154. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17155. */
  17156. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17157. /**
  17158. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17159. * This allowed control for front to back rendering or reversly depending of the special needs.
  17160. *
  17161. * @param renderingGroupId The rendering group id corresponding to its index
  17162. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17163. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17164. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17165. */
  17166. 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;
  17167. /**
  17168. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17169. *
  17170. * @param renderingGroupId The rendering group id corresponding to its index
  17171. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17172. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17173. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17174. */
  17175. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17176. /**
  17177. * Gets the current auto clear configuration for one rendering group of the rendering
  17178. * manager.
  17179. * @param index the rendering group index to get the information for
  17180. * @returns The auto clear setup for the requested rendering group
  17181. */
  17182. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17183. }
  17184. }
  17185. declare module BABYLON {
  17186. /**
  17187. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17188. */
  17189. export interface ICustomShaderOptions {
  17190. /**
  17191. * Gets or sets the custom shader name to use
  17192. */
  17193. shaderName: string;
  17194. /**
  17195. * The list of attribute names used in the shader
  17196. */
  17197. attributes?: string[];
  17198. /**
  17199. * The list of unifrom names used in the shader
  17200. */
  17201. uniforms?: string[];
  17202. /**
  17203. * The list of sampler names used in the shader
  17204. */
  17205. samplers?: string[];
  17206. /**
  17207. * The list of defines used in the shader
  17208. */
  17209. defines?: string[];
  17210. }
  17211. /**
  17212. * Interface to implement to create a shadow generator compatible with BJS.
  17213. */
  17214. export interface IShadowGenerator {
  17215. /**
  17216. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17217. * @returns The render target texture if present otherwise, null
  17218. */
  17219. getShadowMap(): Nullable<RenderTargetTexture>;
  17220. /**
  17221. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17222. * @param subMesh The submesh we want to render in the shadow map
  17223. * @param useInstances Defines wether will draw in the map using instances
  17224. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17225. * @returns true if ready otherwise, false
  17226. */
  17227. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17228. /**
  17229. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17230. * @param defines Defines of the material we want to update
  17231. * @param lightIndex Index of the light in the enabled light list of the material
  17232. */
  17233. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17234. /**
  17235. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17236. * defined in the generator but impacting the effect).
  17237. * It implies the unifroms available on the materials are the standard BJS ones.
  17238. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17239. * @param effect The effect we are binfing the information for
  17240. */
  17241. bindShadowLight(lightIndex: string, effect: Effect): void;
  17242. /**
  17243. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17244. * (eq to shadow prjection matrix * light transform matrix)
  17245. * @returns The transform matrix used to create the shadow map
  17246. */
  17247. getTransformMatrix(): Matrix;
  17248. /**
  17249. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17250. * Cube and 2D textures for instance.
  17251. */
  17252. recreateShadowMap(): void;
  17253. /**
  17254. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17255. * @param onCompiled Callback triggered at the and of the effects compilation
  17256. * @param options Sets of optional options forcing the compilation with different modes
  17257. */
  17258. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17259. useInstances: boolean;
  17260. }>): void;
  17261. /**
  17262. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17263. * @param options Sets of optional options forcing the compilation with different modes
  17264. * @returns A promise that resolves when the compilation completes
  17265. */
  17266. forceCompilationAsync(options?: Partial<{
  17267. useInstances: boolean;
  17268. }>): Promise<void>;
  17269. /**
  17270. * Serializes the shadow generator setup to a json object.
  17271. * @returns The serialized JSON object
  17272. */
  17273. serialize(): any;
  17274. /**
  17275. * Disposes the Shadow map and related Textures and effects.
  17276. */
  17277. dispose(): void;
  17278. }
  17279. /**
  17280. * Default implementation IShadowGenerator.
  17281. * This is the main object responsible of generating shadows in the framework.
  17282. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17283. */
  17284. export class ShadowGenerator implements IShadowGenerator {
  17285. /**
  17286. * Name of the shadow generator class
  17287. */
  17288. static CLASSNAME: string;
  17289. /**
  17290. * Shadow generator mode None: no filtering applied.
  17291. */
  17292. static readonly FILTER_NONE: number;
  17293. /**
  17294. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17295. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17296. */
  17297. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17298. /**
  17299. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17300. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17301. */
  17302. static readonly FILTER_POISSONSAMPLING: number;
  17303. /**
  17304. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17305. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17306. */
  17307. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17308. /**
  17309. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17310. * edge artifacts on steep falloff.
  17311. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17312. */
  17313. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17314. /**
  17315. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17316. * edge artifacts on steep falloff.
  17317. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17318. */
  17319. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17320. /**
  17321. * Shadow generator mode PCF: Percentage Closer Filtering
  17322. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17323. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17324. */
  17325. static readonly FILTER_PCF: number;
  17326. /**
  17327. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17328. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17329. * Contact Hardening
  17330. */
  17331. static readonly FILTER_PCSS: number;
  17332. /**
  17333. * Reserved for PCF and PCSS
  17334. * Highest Quality.
  17335. *
  17336. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17337. *
  17338. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17339. */
  17340. static readonly QUALITY_HIGH: number;
  17341. /**
  17342. * Reserved for PCF and PCSS
  17343. * Good tradeoff for quality/perf cross devices
  17344. *
  17345. * Execute PCF on a 3*3 kernel.
  17346. *
  17347. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17348. */
  17349. static readonly QUALITY_MEDIUM: number;
  17350. /**
  17351. * Reserved for PCF and PCSS
  17352. * The lowest quality but the fastest.
  17353. *
  17354. * Execute PCF on a 1*1 kernel.
  17355. *
  17356. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17357. */
  17358. static readonly QUALITY_LOW: number;
  17359. /** Gets or sets the custom shader name to use */
  17360. customShaderOptions: ICustomShaderOptions;
  17361. /**
  17362. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17363. */
  17364. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17365. /**
  17366. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17367. */
  17368. onAfterShadowMapRenderObservable: Observable<Effect>;
  17369. /**
  17370. * Observable triggered before a mesh is rendered in the shadow map.
  17371. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17372. */
  17373. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17374. /**
  17375. * Observable triggered after a mesh is rendered in the shadow map.
  17376. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17377. */
  17378. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17379. protected _bias: number;
  17380. /**
  17381. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17382. */
  17383. get bias(): number;
  17384. /**
  17385. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17386. */
  17387. set bias(bias: number);
  17388. protected _normalBias: number;
  17389. /**
  17390. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17391. */
  17392. get normalBias(): number;
  17393. /**
  17394. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17395. */
  17396. set normalBias(normalBias: number);
  17397. protected _blurBoxOffset: number;
  17398. /**
  17399. * Gets the blur box offset: offset applied during the blur pass.
  17400. * Only useful if useKernelBlur = false
  17401. */
  17402. get blurBoxOffset(): number;
  17403. /**
  17404. * Sets the blur box offset: offset applied during the blur pass.
  17405. * Only useful if useKernelBlur = false
  17406. */
  17407. set blurBoxOffset(value: number);
  17408. protected _blurScale: number;
  17409. /**
  17410. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17411. * 2 means half of the size.
  17412. */
  17413. get blurScale(): number;
  17414. /**
  17415. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17416. * 2 means half of the size.
  17417. */
  17418. set blurScale(value: number);
  17419. protected _blurKernel: number;
  17420. /**
  17421. * Gets the blur kernel: kernel size of the blur pass.
  17422. * Only useful if useKernelBlur = true
  17423. */
  17424. get blurKernel(): number;
  17425. /**
  17426. * Sets the blur kernel: kernel size of the blur pass.
  17427. * Only useful if useKernelBlur = true
  17428. */
  17429. set blurKernel(value: number);
  17430. protected _useKernelBlur: boolean;
  17431. /**
  17432. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17433. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17434. */
  17435. get useKernelBlur(): boolean;
  17436. /**
  17437. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17438. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17439. */
  17440. set useKernelBlur(value: boolean);
  17441. protected _depthScale: number;
  17442. /**
  17443. * Gets the depth scale used in ESM mode.
  17444. */
  17445. get depthScale(): number;
  17446. /**
  17447. * Sets the depth scale used in ESM mode.
  17448. * This can override the scale stored on the light.
  17449. */
  17450. set depthScale(value: number);
  17451. protected _validateFilter(filter: number): number;
  17452. protected _filter: number;
  17453. /**
  17454. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17455. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17456. */
  17457. get filter(): number;
  17458. /**
  17459. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17460. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17461. */
  17462. set filter(value: number);
  17463. /**
  17464. * Gets if the current filter is set to Poisson Sampling.
  17465. */
  17466. get usePoissonSampling(): boolean;
  17467. /**
  17468. * Sets the current filter to Poisson Sampling.
  17469. */
  17470. set usePoissonSampling(value: boolean);
  17471. /**
  17472. * Gets if the current filter is set to ESM.
  17473. */
  17474. get useExponentialShadowMap(): boolean;
  17475. /**
  17476. * Sets the current filter is to ESM.
  17477. */
  17478. set useExponentialShadowMap(value: boolean);
  17479. /**
  17480. * Gets if the current filter is set to filtered ESM.
  17481. */
  17482. get useBlurExponentialShadowMap(): boolean;
  17483. /**
  17484. * Gets if the current filter is set to filtered ESM.
  17485. */
  17486. set useBlurExponentialShadowMap(value: boolean);
  17487. /**
  17488. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17489. * exponential to prevent steep falloff artifacts).
  17490. */
  17491. get useCloseExponentialShadowMap(): boolean;
  17492. /**
  17493. * Sets the current filter to "close ESM" (using the inverse of the
  17494. * exponential to prevent steep falloff artifacts).
  17495. */
  17496. set useCloseExponentialShadowMap(value: boolean);
  17497. /**
  17498. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17499. * exponential to prevent steep falloff artifacts).
  17500. */
  17501. get useBlurCloseExponentialShadowMap(): boolean;
  17502. /**
  17503. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17504. * exponential to prevent steep falloff artifacts).
  17505. */
  17506. set useBlurCloseExponentialShadowMap(value: boolean);
  17507. /**
  17508. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17509. */
  17510. get usePercentageCloserFiltering(): boolean;
  17511. /**
  17512. * Sets the current filter to "PCF" (percentage closer filtering).
  17513. */
  17514. set usePercentageCloserFiltering(value: boolean);
  17515. protected _filteringQuality: number;
  17516. /**
  17517. * Gets the PCF or PCSS Quality.
  17518. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17519. */
  17520. get filteringQuality(): number;
  17521. /**
  17522. * Sets the PCF or PCSS Quality.
  17523. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17524. */
  17525. set filteringQuality(filteringQuality: number);
  17526. /**
  17527. * Gets if the current filter is set to "PCSS" (contact hardening).
  17528. */
  17529. get useContactHardeningShadow(): boolean;
  17530. /**
  17531. * Sets the current filter to "PCSS" (contact hardening).
  17532. */
  17533. set useContactHardeningShadow(value: boolean);
  17534. protected _contactHardeningLightSizeUVRatio: number;
  17535. /**
  17536. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17537. * Using a ratio helps keeping shape stability independently of the map size.
  17538. *
  17539. * It does not account for the light projection as it was having too much
  17540. * instability during the light setup or during light position changes.
  17541. *
  17542. * Only valid if useContactHardeningShadow is true.
  17543. */
  17544. get contactHardeningLightSizeUVRatio(): number;
  17545. /**
  17546. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17547. * Using a ratio helps keeping shape stability independently of the map size.
  17548. *
  17549. * It does not account for the light projection as it was having too much
  17550. * instability during the light setup or during light position changes.
  17551. *
  17552. * Only valid if useContactHardeningShadow is true.
  17553. */
  17554. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17555. protected _darkness: number;
  17556. /** Gets or sets the actual darkness of a shadow */
  17557. get darkness(): number;
  17558. set darkness(value: number);
  17559. /**
  17560. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17561. * 0 means strongest and 1 would means no shadow.
  17562. * @returns the darkness.
  17563. */
  17564. getDarkness(): number;
  17565. /**
  17566. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17567. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17568. * @returns the shadow generator allowing fluent coding.
  17569. */
  17570. setDarkness(darkness: number): ShadowGenerator;
  17571. protected _transparencyShadow: boolean;
  17572. /** Gets or sets the ability to have transparent shadow */
  17573. get transparencyShadow(): boolean;
  17574. set transparencyShadow(value: boolean);
  17575. /**
  17576. * Sets the ability to have transparent shadow (boolean).
  17577. * @param transparent True if transparent else False
  17578. * @returns the shadow generator allowing fluent coding
  17579. */
  17580. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17581. /**
  17582. * Enables or disables shadows with varying strength based on the transparency
  17583. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17584. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17585. * mesh.visibility * alphaTexture.a
  17586. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17587. */
  17588. enableSoftTransparentShadow: boolean;
  17589. protected _shadowMap: Nullable<RenderTargetTexture>;
  17590. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17591. /**
  17592. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17593. * @returns The render target texture if present otherwise, null
  17594. */
  17595. getShadowMap(): Nullable<RenderTargetTexture>;
  17596. /**
  17597. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17598. * @returns The render target texture if the shadow map is present otherwise, null
  17599. */
  17600. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17601. /**
  17602. * Gets the class name of that object
  17603. * @returns "ShadowGenerator"
  17604. */
  17605. getClassName(): string;
  17606. /**
  17607. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17608. * @param mesh Mesh to add
  17609. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17610. * @returns the Shadow Generator itself
  17611. */
  17612. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17613. /**
  17614. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17615. * @param mesh Mesh to remove
  17616. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17617. * @returns the Shadow Generator itself
  17618. */
  17619. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17620. /**
  17621. * Controls the extent to which the shadows fade out at the edge of the frustum
  17622. */
  17623. frustumEdgeFalloff: number;
  17624. protected _light: IShadowLight;
  17625. /**
  17626. * Returns the associated light object.
  17627. * @returns the light generating the shadow
  17628. */
  17629. getLight(): IShadowLight;
  17630. /**
  17631. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17632. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17633. * It might on the other hand introduce peter panning.
  17634. */
  17635. forceBackFacesOnly: boolean;
  17636. protected _scene: Scene;
  17637. protected _lightDirection: Vector3;
  17638. protected _effect: Effect;
  17639. protected _viewMatrix: Matrix;
  17640. protected _projectionMatrix: Matrix;
  17641. protected _transformMatrix: Matrix;
  17642. protected _cachedPosition: Vector3;
  17643. protected _cachedDirection: Vector3;
  17644. protected _cachedDefines: string;
  17645. protected _currentRenderID: number;
  17646. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17647. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17648. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17649. protected _blurPostProcesses: PostProcess[];
  17650. protected _mapSize: number;
  17651. protected _currentFaceIndex: number;
  17652. protected _currentFaceIndexCache: number;
  17653. protected _textureType: number;
  17654. protected _defaultTextureMatrix: Matrix;
  17655. protected _storedUniqueId: Nullable<number>;
  17656. /** @hidden */
  17657. static _SceneComponentInitialization: (scene: Scene) => void;
  17658. /**
  17659. * Creates a ShadowGenerator object.
  17660. * A ShadowGenerator is the required tool to use the shadows.
  17661. * Each light casting shadows needs to use its own ShadowGenerator.
  17662. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17663. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17664. * @param light The light object generating the shadows.
  17665. * @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.
  17666. */
  17667. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17668. protected _initializeGenerator(): void;
  17669. protected _createTargetRenderTexture(): void;
  17670. protected _initializeShadowMap(): void;
  17671. protected _initializeBlurRTTAndPostProcesses(): void;
  17672. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17673. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17674. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17675. protected _applyFilterValues(): void;
  17676. /**
  17677. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17678. * @param onCompiled Callback triggered at the and of the effects compilation
  17679. * @param options Sets of optional options forcing the compilation with different modes
  17680. */
  17681. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17682. useInstances: boolean;
  17683. }>): void;
  17684. /**
  17685. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17686. * @param options Sets of optional options forcing the compilation with different modes
  17687. * @returns A promise that resolves when the compilation completes
  17688. */
  17689. forceCompilationAsync(options?: Partial<{
  17690. useInstances: boolean;
  17691. }>): Promise<void>;
  17692. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17693. private _prepareShadowDefines;
  17694. /**
  17695. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17696. * @param subMesh The submesh we want to render in the shadow map
  17697. * @param useInstances Defines wether will draw in the map using instances
  17698. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17699. * @returns true if ready otherwise, false
  17700. */
  17701. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17702. /**
  17703. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17704. * @param defines Defines of the material we want to update
  17705. * @param lightIndex Index of the light in the enabled light list of the material
  17706. */
  17707. prepareDefines(defines: any, lightIndex: number): void;
  17708. /**
  17709. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17710. * defined in the generator but impacting the effect).
  17711. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17712. * @param effect The effect we are binfing the information for
  17713. */
  17714. bindShadowLight(lightIndex: string, effect: Effect): void;
  17715. /**
  17716. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17717. * (eq to shadow prjection matrix * light transform matrix)
  17718. * @returns The transform matrix used to create the shadow map
  17719. */
  17720. getTransformMatrix(): Matrix;
  17721. /**
  17722. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17723. * Cube and 2D textures for instance.
  17724. */
  17725. recreateShadowMap(): void;
  17726. protected _disposeBlurPostProcesses(): void;
  17727. protected _disposeRTTandPostProcesses(): void;
  17728. /**
  17729. * Disposes the ShadowGenerator.
  17730. * Returns nothing.
  17731. */
  17732. dispose(): void;
  17733. /**
  17734. * Serializes the shadow generator setup to a json object.
  17735. * @returns The serialized JSON object
  17736. */
  17737. serialize(): any;
  17738. /**
  17739. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17740. * @param parsedShadowGenerator The JSON object to parse
  17741. * @param scene The scene to create the shadow map for
  17742. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17743. * @returns The parsed shadow generator
  17744. */
  17745. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17746. }
  17747. }
  17748. declare module BABYLON {
  17749. /**
  17750. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17751. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17752. * 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.
  17753. */
  17754. export abstract class Light extends Node {
  17755. /**
  17756. * Falloff Default: light is falling off following the material specification:
  17757. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17758. */
  17759. static readonly FALLOFF_DEFAULT: number;
  17760. /**
  17761. * Falloff Physical: light is falling off following the inverse squared distance law.
  17762. */
  17763. static readonly FALLOFF_PHYSICAL: number;
  17764. /**
  17765. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17766. * to enhance interoperability with other engines.
  17767. */
  17768. static readonly FALLOFF_GLTF: number;
  17769. /**
  17770. * Falloff Standard: light is falling off like in the standard material
  17771. * to enhance interoperability with other materials.
  17772. */
  17773. static readonly FALLOFF_STANDARD: number;
  17774. /**
  17775. * If every light affecting the material is in this lightmapMode,
  17776. * material.lightmapTexture adds or multiplies
  17777. * (depends on material.useLightmapAsShadowmap)
  17778. * after every other light calculations.
  17779. */
  17780. static readonly LIGHTMAP_DEFAULT: number;
  17781. /**
  17782. * material.lightmapTexture as only diffuse lighting from this light
  17783. * adds only specular lighting from this light
  17784. * adds dynamic shadows
  17785. */
  17786. static readonly LIGHTMAP_SPECULAR: number;
  17787. /**
  17788. * material.lightmapTexture as only lighting
  17789. * no light calculation from this light
  17790. * only adds dynamic shadows from this light
  17791. */
  17792. static readonly LIGHTMAP_SHADOWSONLY: number;
  17793. /**
  17794. * Each light type uses the default quantity according to its type:
  17795. * point/spot lights use luminous intensity
  17796. * directional lights use illuminance
  17797. */
  17798. static readonly INTENSITYMODE_AUTOMATIC: number;
  17799. /**
  17800. * lumen (lm)
  17801. */
  17802. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17803. /**
  17804. * candela (lm/sr)
  17805. */
  17806. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17807. /**
  17808. * lux (lm/m^2)
  17809. */
  17810. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17811. /**
  17812. * nit (cd/m^2)
  17813. */
  17814. static readonly INTENSITYMODE_LUMINANCE: number;
  17815. /**
  17816. * Light type const id of the point light.
  17817. */
  17818. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17819. /**
  17820. * Light type const id of the directional light.
  17821. */
  17822. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17823. /**
  17824. * Light type const id of the spot light.
  17825. */
  17826. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17827. /**
  17828. * Light type const id of the hemispheric light.
  17829. */
  17830. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17831. /**
  17832. * Diffuse gives the basic color to an object.
  17833. */
  17834. diffuse: Color3;
  17835. /**
  17836. * Specular produces a highlight color on an object.
  17837. * Note: This is note affecting PBR materials.
  17838. */
  17839. specular: Color3;
  17840. /**
  17841. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17842. * falling off base on range or angle.
  17843. * This can be set to any values in Light.FALLOFF_x.
  17844. *
  17845. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17846. * other types of materials.
  17847. */
  17848. falloffType: number;
  17849. /**
  17850. * Strength of the light.
  17851. * Note: By default it is define in the framework own unit.
  17852. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17853. */
  17854. intensity: number;
  17855. private _range;
  17856. protected _inverseSquaredRange: number;
  17857. /**
  17858. * Defines how far from the source the light is impacting in scene units.
  17859. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17860. */
  17861. get range(): number;
  17862. /**
  17863. * Defines how far from the source the light is impacting in scene units.
  17864. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17865. */
  17866. set range(value: number);
  17867. /**
  17868. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17869. * of light.
  17870. */
  17871. private _photometricScale;
  17872. private _intensityMode;
  17873. /**
  17874. * Gets the photometric scale used to interpret the intensity.
  17875. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17876. */
  17877. get intensityMode(): number;
  17878. /**
  17879. * Sets the photometric scale used to interpret the intensity.
  17880. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17881. */
  17882. set intensityMode(value: number);
  17883. private _radius;
  17884. /**
  17885. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17886. */
  17887. get radius(): number;
  17888. /**
  17889. * sets the light radius used by PBR Materials to simulate soft area lights.
  17890. */
  17891. set radius(value: number);
  17892. private _renderPriority;
  17893. /**
  17894. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17895. * exceeding the number allowed of the materials.
  17896. */
  17897. renderPriority: number;
  17898. private _shadowEnabled;
  17899. /**
  17900. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17901. * the current shadow generator.
  17902. */
  17903. get shadowEnabled(): boolean;
  17904. /**
  17905. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17906. * the current shadow generator.
  17907. */
  17908. set shadowEnabled(value: boolean);
  17909. private _includedOnlyMeshes;
  17910. /**
  17911. * Gets the only meshes impacted by this light.
  17912. */
  17913. get includedOnlyMeshes(): AbstractMesh[];
  17914. /**
  17915. * Sets the only meshes impacted by this light.
  17916. */
  17917. set includedOnlyMeshes(value: AbstractMesh[]);
  17918. private _excludedMeshes;
  17919. /**
  17920. * Gets the meshes not impacted by this light.
  17921. */
  17922. get excludedMeshes(): AbstractMesh[];
  17923. /**
  17924. * Sets the meshes not impacted by this light.
  17925. */
  17926. set excludedMeshes(value: AbstractMesh[]);
  17927. private _excludeWithLayerMask;
  17928. /**
  17929. * Gets the layer id use to find what meshes are not impacted by the light.
  17930. * Inactive if 0
  17931. */
  17932. get excludeWithLayerMask(): number;
  17933. /**
  17934. * Sets the layer id use to find what meshes are not impacted by the light.
  17935. * Inactive if 0
  17936. */
  17937. set excludeWithLayerMask(value: number);
  17938. private _includeOnlyWithLayerMask;
  17939. /**
  17940. * Gets the layer id use to find what meshes are impacted by the light.
  17941. * Inactive if 0
  17942. */
  17943. get includeOnlyWithLayerMask(): number;
  17944. /**
  17945. * Sets the layer id use to find what meshes are impacted by the light.
  17946. * Inactive if 0
  17947. */
  17948. set includeOnlyWithLayerMask(value: number);
  17949. private _lightmapMode;
  17950. /**
  17951. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17952. */
  17953. get lightmapMode(): number;
  17954. /**
  17955. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17956. */
  17957. set lightmapMode(value: number);
  17958. /**
  17959. * Shadow generator associted to the light.
  17960. * @hidden Internal use only.
  17961. */
  17962. _shadowGenerator: Nullable<IShadowGenerator>;
  17963. /**
  17964. * @hidden Internal use only.
  17965. */
  17966. _excludedMeshesIds: string[];
  17967. /**
  17968. * @hidden Internal use only.
  17969. */
  17970. _includedOnlyMeshesIds: string[];
  17971. /**
  17972. * The current light unifom buffer.
  17973. * @hidden Internal use only.
  17974. */
  17975. _uniformBuffer: UniformBuffer;
  17976. /** @hidden */
  17977. _renderId: number;
  17978. /**
  17979. * Creates a Light object in the scene.
  17980. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17981. * @param name The firendly name of the light
  17982. * @param scene The scene the light belongs too
  17983. */
  17984. constructor(name: string, scene: Scene);
  17985. protected abstract _buildUniformLayout(): void;
  17986. /**
  17987. * Sets the passed Effect "effect" with the Light information.
  17988. * @param effect The effect to update
  17989. * @param lightIndex The index of the light in the effect to update
  17990. * @returns The light
  17991. */
  17992. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17993. /**
  17994. * Sets the passed Effect "effect" with the Light textures.
  17995. * @param effect The effect to update
  17996. * @param lightIndex The index of the light in the effect to update
  17997. * @returns The light
  17998. */
  17999. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18000. /**
  18001. * Binds the lights information from the scene to the effect for the given mesh.
  18002. * @param lightIndex Light index
  18003. * @param scene The scene where the light belongs to
  18004. * @param effect The effect we are binding the data to
  18005. * @param useSpecular Defines if specular is supported
  18006. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18007. */
  18008. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18009. /**
  18010. * Sets the passed Effect "effect" with the Light information.
  18011. * @param effect The effect to update
  18012. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18013. * @returns The light
  18014. */
  18015. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18016. /**
  18017. * Returns the string "Light".
  18018. * @returns the class name
  18019. */
  18020. getClassName(): string;
  18021. /** @hidden */
  18022. readonly _isLight: boolean;
  18023. /**
  18024. * Converts the light information to a readable string for debug purpose.
  18025. * @param fullDetails Supports for multiple levels of logging within scene loading
  18026. * @returns the human readable light info
  18027. */
  18028. toString(fullDetails?: boolean): string;
  18029. /** @hidden */
  18030. protected _syncParentEnabledState(): void;
  18031. /**
  18032. * Set the enabled state of this node.
  18033. * @param value - the new enabled state
  18034. */
  18035. setEnabled(value: boolean): void;
  18036. /**
  18037. * Returns the Light associated shadow generator if any.
  18038. * @return the associated shadow generator.
  18039. */
  18040. getShadowGenerator(): Nullable<IShadowGenerator>;
  18041. /**
  18042. * Returns a Vector3, the absolute light position in the World.
  18043. * @returns the world space position of the light
  18044. */
  18045. getAbsolutePosition(): Vector3;
  18046. /**
  18047. * Specifies if the light will affect the passed mesh.
  18048. * @param mesh The mesh to test against the light
  18049. * @return true the mesh is affected otherwise, false.
  18050. */
  18051. canAffectMesh(mesh: AbstractMesh): boolean;
  18052. /**
  18053. * Sort function to order lights for rendering.
  18054. * @param a First Light object to compare to second.
  18055. * @param b Second Light object to compare first.
  18056. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18057. */
  18058. static CompareLightsPriority(a: Light, b: Light): number;
  18059. /**
  18060. * Releases resources associated with this node.
  18061. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18062. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18063. */
  18064. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18065. /**
  18066. * Returns the light type ID (integer).
  18067. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18068. */
  18069. getTypeID(): number;
  18070. /**
  18071. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18072. * @returns the scaled intensity in intensity mode unit
  18073. */
  18074. getScaledIntensity(): number;
  18075. /**
  18076. * Returns a new Light object, named "name", from the current one.
  18077. * @param name The name of the cloned light
  18078. * @param newParent The parent of this light, if it has one
  18079. * @returns the new created light
  18080. */
  18081. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18082. /**
  18083. * Serializes the current light into a Serialization object.
  18084. * @returns the serialized object.
  18085. */
  18086. serialize(): any;
  18087. /**
  18088. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18089. * This new light is named "name" and added to the passed scene.
  18090. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18091. * @param name The friendly name of the light
  18092. * @param scene The scene the new light will belong to
  18093. * @returns the constructor function
  18094. */
  18095. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18096. /**
  18097. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18098. * @param parsedLight The JSON representation of the light
  18099. * @param scene The scene to create the parsed light in
  18100. * @returns the created light after parsing
  18101. */
  18102. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18103. private _hookArrayForExcluded;
  18104. private _hookArrayForIncludedOnly;
  18105. private _resyncMeshes;
  18106. /**
  18107. * Forces the meshes to update their light related information in their rendering used effects
  18108. * @hidden Internal Use Only
  18109. */
  18110. _markMeshesAsLightDirty(): void;
  18111. /**
  18112. * Recomputes the cached photometric scale if needed.
  18113. */
  18114. private _computePhotometricScale;
  18115. /**
  18116. * Returns the Photometric Scale according to the light type and intensity mode.
  18117. */
  18118. private _getPhotometricScale;
  18119. /**
  18120. * Reorder the light in the scene according to their defined priority.
  18121. * @hidden Internal Use Only
  18122. */
  18123. _reorderLightsInScene(): void;
  18124. /**
  18125. * Prepares the list of defines specific to the light type.
  18126. * @param defines the list of defines
  18127. * @param lightIndex defines the index of the light for the effect
  18128. */
  18129. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18130. }
  18131. }
  18132. declare module BABYLON {
  18133. /**
  18134. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18135. * This is the base of the follow, arc rotate cameras and Free camera
  18136. * @see https://doc.babylonjs.com/features/cameras
  18137. */
  18138. export class TargetCamera extends Camera {
  18139. private static _RigCamTransformMatrix;
  18140. private static _TargetTransformMatrix;
  18141. private static _TargetFocalPoint;
  18142. private _tmpUpVector;
  18143. private _tmpTargetVector;
  18144. /**
  18145. * Define the current direction the camera is moving to
  18146. */
  18147. cameraDirection: Vector3;
  18148. /**
  18149. * Define the current rotation the camera is rotating to
  18150. */
  18151. cameraRotation: Vector2;
  18152. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18153. ignoreParentScaling: boolean;
  18154. /**
  18155. * When set, the up vector of the camera will be updated by the rotation of the camera
  18156. */
  18157. updateUpVectorFromRotation: boolean;
  18158. private _tmpQuaternion;
  18159. /**
  18160. * Define the current rotation of the camera
  18161. */
  18162. rotation: Vector3;
  18163. /**
  18164. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18165. */
  18166. rotationQuaternion: Quaternion;
  18167. /**
  18168. * Define the current speed of the camera
  18169. */
  18170. speed: number;
  18171. /**
  18172. * Add constraint to the camera to prevent it to move freely in all directions and
  18173. * around all axis.
  18174. */
  18175. noRotationConstraint: boolean;
  18176. /**
  18177. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18178. * panning
  18179. */
  18180. invertRotation: boolean;
  18181. /**
  18182. * Speed multiplier for inverse camera panning
  18183. */
  18184. inverseRotationSpeed: number;
  18185. /**
  18186. * Define the current target of the camera as an object or a position.
  18187. */
  18188. lockedTarget: any;
  18189. /** @hidden */
  18190. _currentTarget: Vector3;
  18191. /** @hidden */
  18192. _initialFocalDistance: number;
  18193. /** @hidden */
  18194. _viewMatrix: Matrix;
  18195. /** @hidden */
  18196. _camMatrix: Matrix;
  18197. /** @hidden */
  18198. _cameraTransformMatrix: Matrix;
  18199. /** @hidden */
  18200. _cameraRotationMatrix: Matrix;
  18201. /** @hidden */
  18202. _referencePoint: Vector3;
  18203. /** @hidden */
  18204. _transformedReferencePoint: Vector3;
  18205. /** @hidden */
  18206. _reset: () => void;
  18207. private _defaultUp;
  18208. /**
  18209. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18210. * This is the base of the follow, arc rotate cameras and Free camera
  18211. * @see https://doc.babylonjs.com/features/cameras
  18212. * @param name Defines the name of the camera in the scene
  18213. * @param position Defines the start position of the camera in the scene
  18214. * @param scene Defines the scene the camera belongs to
  18215. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18216. */
  18217. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18218. /**
  18219. * Gets the position in front of the camera at a given distance.
  18220. * @param distance The distance from the camera we want the position to be
  18221. * @returns the position
  18222. */
  18223. getFrontPosition(distance: number): Vector3;
  18224. /** @hidden */
  18225. _getLockedTargetPosition(): Nullable<Vector3>;
  18226. private _storedPosition;
  18227. private _storedRotation;
  18228. private _storedRotationQuaternion;
  18229. /**
  18230. * Store current camera state of the camera (fov, position, rotation, etc..)
  18231. * @returns the camera
  18232. */
  18233. storeState(): Camera;
  18234. /**
  18235. * Restored camera state. You must call storeState() first
  18236. * @returns whether it was successful or not
  18237. * @hidden
  18238. */
  18239. _restoreStateValues(): boolean;
  18240. /** @hidden */
  18241. _initCache(): void;
  18242. /** @hidden */
  18243. _updateCache(ignoreParentClass?: boolean): void;
  18244. /** @hidden */
  18245. _isSynchronizedViewMatrix(): boolean;
  18246. /** @hidden */
  18247. _computeLocalCameraSpeed(): number;
  18248. /**
  18249. * Defines the target the camera should look at.
  18250. * @param target Defines the new target as a Vector or a mesh
  18251. */
  18252. setTarget(target: Vector3): void;
  18253. /**
  18254. * Return the current target position of the camera. This value is expressed in local space.
  18255. * @returns the target position
  18256. */
  18257. getTarget(): Vector3;
  18258. /** @hidden */
  18259. _decideIfNeedsToMove(): boolean;
  18260. /** @hidden */
  18261. _updatePosition(): void;
  18262. /** @hidden */
  18263. _checkInputs(): void;
  18264. protected _updateCameraRotationMatrix(): void;
  18265. /**
  18266. * 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)
  18267. * @returns the current camera
  18268. */
  18269. private _rotateUpVectorWithCameraRotationMatrix;
  18270. private _cachedRotationZ;
  18271. private _cachedQuaternionRotationZ;
  18272. /** @hidden */
  18273. _getViewMatrix(): Matrix;
  18274. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18275. /**
  18276. * @hidden
  18277. */
  18278. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18279. /**
  18280. * @hidden
  18281. */
  18282. _updateRigCameras(): void;
  18283. private _getRigCamPositionAndTarget;
  18284. /**
  18285. * Gets the current object class name.
  18286. * @return the class name
  18287. */
  18288. getClassName(): string;
  18289. }
  18290. }
  18291. declare module BABYLON {
  18292. /**
  18293. * Gather the list of keyboard event types as constants.
  18294. */
  18295. export class KeyboardEventTypes {
  18296. /**
  18297. * The keydown event is fired when a key becomes active (pressed).
  18298. */
  18299. static readonly KEYDOWN: number;
  18300. /**
  18301. * The keyup event is fired when a key has been released.
  18302. */
  18303. static readonly KEYUP: number;
  18304. }
  18305. /**
  18306. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18307. */
  18308. export class KeyboardInfo {
  18309. /**
  18310. * Defines the type of event (KeyboardEventTypes)
  18311. */
  18312. type: number;
  18313. /**
  18314. * Defines the related dom event
  18315. */
  18316. event: KeyboardEvent;
  18317. /**
  18318. * Instantiates a new keyboard info.
  18319. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18320. * @param type Defines the type of event (KeyboardEventTypes)
  18321. * @param event Defines the related dom event
  18322. */
  18323. constructor(
  18324. /**
  18325. * Defines the type of event (KeyboardEventTypes)
  18326. */
  18327. type: number,
  18328. /**
  18329. * Defines the related dom event
  18330. */
  18331. event: KeyboardEvent);
  18332. }
  18333. /**
  18334. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18335. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18336. */
  18337. export class KeyboardInfoPre extends KeyboardInfo {
  18338. /**
  18339. * Defines the type of event (KeyboardEventTypes)
  18340. */
  18341. type: number;
  18342. /**
  18343. * Defines the related dom event
  18344. */
  18345. event: KeyboardEvent;
  18346. /**
  18347. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18348. */
  18349. skipOnPointerObservable: boolean;
  18350. /**
  18351. * Instantiates a new keyboard pre info.
  18352. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18353. * @param type Defines the type of event (KeyboardEventTypes)
  18354. * @param event Defines the related dom event
  18355. */
  18356. constructor(
  18357. /**
  18358. * Defines the type of event (KeyboardEventTypes)
  18359. */
  18360. type: number,
  18361. /**
  18362. * Defines the related dom event
  18363. */
  18364. event: KeyboardEvent);
  18365. }
  18366. }
  18367. declare module BABYLON {
  18368. /**
  18369. * Manage the keyboard inputs to control the movement of a free camera.
  18370. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18371. */
  18372. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18373. /**
  18374. * Defines the camera the input is attached to.
  18375. */
  18376. camera: FreeCamera;
  18377. /**
  18378. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18379. */
  18380. keysUp: number[];
  18381. /**
  18382. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18383. */
  18384. keysUpward: number[];
  18385. /**
  18386. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18387. */
  18388. keysDown: number[];
  18389. /**
  18390. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18391. */
  18392. keysDownward: number[];
  18393. /**
  18394. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18395. */
  18396. keysLeft: number[];
  18397. /**
  18398. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18399. */
  18400. keysRight: number[];
  18401. private _keys;
  18402. private _onCanvasBlurObserver;
  18403. private _onKeyboardObserver;
  18404. private _engine;
  18405. private _scene;
  18406. /**
  18407. * Attach the input controls to a specific dom element to get the input from.
  18408. * @param element Defines the element the controls should be listened from
  18409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18410. */
  18411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18412. /**
  18413. * Detach the current controls from the specified dom element.
  18414. * @param element Defines the element to stop listening the inputs from
  18415. */
  18416. detachControl(element: Nullable<HTMLElement>): void;
  18417. /**
  18418. * Update the current camera state depending on the inputs that have been used this frame.
  18419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18420. */
  18421. checkInputs(): void;
  18422. /**
  18423. * Gets the class name of the current intput.
  18424. * @returns the class name
  18425. */
  18426. getClassName(): string;
  18427. /** @hidden */
  18428. _onLostFocus(): void;
  18429. /**
  18430. * Get the friendly name associated with the input class.
  18431. * @returns the input friendly name
  18432. */
  18433. getSimpleName(): string;
  18434. }
  18435. }
  18436. declare module BABYLON {
  18437. /**
  18438. * Gather the list of pointer event types as constants.
  18439. */
  18440. export class PointerEventTypes {
  18441. /**
  18442. * 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.
  18443. */
  18444. static readonly POINTERDOWN: number;
  18445. /**
  18446. * The pointerup event is fired when a pointer is no longer active.
  18447. */
  18448. static readonly POINTERUP: number;
  18449. /**
  18450. * The pointermove event is fired when a pointer changes coordinates.
  18451. */
  18452. static readonly POINTERMOVE: number;
  18453. /**
  18454. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18455. */
  18456. static readonly POINTERWHEEL: number;
  18457. /**
  18458. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18459. */
  18460. static readonly POINTERPICK: number;
  18461. /**
  18462. * The pointertap event is fired when a the object has been touched and released without drag.
  18463. */
  18464. static readonly POINTERTAP: number;
  18465. /**
  18466. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18467. */
  18468. static readonly POINTERDOUBLETAP: number;
  18469. }
  18470. /**
  18471. * Base class of pointer info types.
  18472. */
  18473. export class PointerInfoBase {
  18474. /**
  18475. * Defines the type of event (PointerEventTypes)
  18476. */
  18477. type: number;
  18478. /**
  18479. * Defines the related dom event
  18480. */
  18481. event: PointerEvent | MouseWheelEvent;
  18482. /**
  18483. * Instantiates the base class of pointers info.
  18484. * @param type Defines the type of event (PointerEventTypes)
  18485. * @param event Defines the related dom event
  18486. */
  18487. constructor(
  18488. /**
  18489. * Defines the type of event (PointerEventTypes)
  18490. */
  18491. type: number,
  18492. /**
  18493. * Defines the related dom event
  18494. */
  18495. event: PointerEvent | MouseWheelEvent);
  18496. }
  18497. /**
  18498. * This class is used to store pointer related info for the onPrePointerObservable event.
  18499. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18500. */
  18501. export class PointerInfoPre extends PointerInfoBase {
  18502. /**
  18503. * Ray from a pointer if availible (eg. 6dof controller)
  18504. */
  18505. ray: Nullable<Ray>;
  18506. /**
  18507. * Defines the local position of the pointer on the canvas.
  18508. */
  18509. localPosition: Vector2;
  18510. /**
  18511. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18512. */
  18513. skipOnPointerObservable: boolean;
  18514. /**
  18515. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18516. * @param type Defines the type of event (PointerEventTypes)
  18517. * @param event Defines the related dom event
  18518. * @param localX Defines the local x coordinates of the pointer when the event occured
  18519. * @param localY Defines the local y coordinates of the pointer when the event occured
  18520. */
  18521. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18522. }
  18523. /**
  18524. * This type contains all the data related to a pointer event in Babylon.js.
  18525. * 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.
  18526. */
  18527. export class PointerInfo extends PointerInfoBase {
  18528. /**
  18529. * Defines the picking info associated to the info (if any)\
  18530. */
  18531. pickInfo: Nullable<PickingInfo>;
  18532. /**
  18533. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18534. * @param type Defines the type of event (PointerEventTypes)
  18535. * @param event Defines the related dom event
  18536. * @param pickInfo Defines the picking info associated to the info (if any)\
  18537. */
  18538. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18539. /**
  18540. * Defines the picking info associated to the info (if any)\
  18541. */
  18542. pickInfo: Nullable<PickingInfo>);
  18543. }
  18544. /**
  18545. * Data relating to a touch event on the screen.
  18546. */
  18547. export interface PointerTouch {
  18548. /**
  18549. * X coordinate of touch.
  18550. */
  18551. x: number;
  18552. /**
  18553. * Y coordinate of touch.
  18554. */
  18555. y: number;
  18556. /**
  18557. * Id of touch. Unique for each finger.
  18558. */
  18559. pointerId: number;
  18560. /**
  18561. * Event type passed from DOM.
  18562. */
  18563. type: any;
  18564. }
  18565. }
  18566. declare module BABYLON {
  18567. /**
  18568. * Manage the mouse inputs to control the movement of a free camera.
  18569. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18570. */
  18571. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18572. /**
  18573. * Define if touch is enabled in the mouse input
  18574. */
  18575. touchEnabled: boolean;
  18576. /**
  18577. * Defines the camera the input is attached to.
  18578. */
  18579. camera: FreeCamera;
  18580. /**
  18581. * Defines the buttons associated with the input to handle camera move.
  18582. */
  18583. buttons: number[];
  18584. /**
  18585. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18586. */
  18587. angularSensibility: number;
  18588. private _pointerInput;
  18589. private _onMouseMove;
  18590. private _observer;
  18591. private previousPosition;
  18592. /**
  18593. * Observable for when a pointer move event occurs containing the move offset
  18594. */
  18595. onPointerMovedObservable: Observable<{
  18596. offsetX: number;
  18597. offsetY: number;
  18598. }>;
  18599. /**
  18600. * @hidden
  18601. * If the camera should be rotated automatically based on pointer movement
  18602. */
  18603. _allowCameraRotation: boolean;
  18604. /**
  18605. * Manage the mouse inputs to control the movement of a free camera.
  18606. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18607. * @param touchEnabled Defines if touch is enabled or not
  18608. */
  18609. constructor(
  18610. /**
  18611. * Define if touch is enabled in the mouse input
  18612. */
  18613. touchEnabled?: boolean);
  18614. /**
  18615. * Attach the input controls to a specific dom element to get the input from.
  18616. * @param element Defines the element the controls should be listened from
  18617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18618. */
  18619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18620. /**
  18621. * Called on JS contextmenu event.
  18622. * Override this method to provide functionality.
  18623. */
  18624. protected onContextMenu(evt: PointerEvent): void;
  18625. /**
  18626. * Detach the current controls from the specified dom element.
  18627. * @param element Defines the element to stop listening the inputs from
  18628. */
  18629. detachControl(element: Nullable<HTMLElement>): void;
  18630. /**
  18631. * Gets the class name of the current intput.
  18632. * @returns the class name
  18633. */
  18634. getClassName(): string;
  18635. /**
  18636. * Get the friendly name associated with the input class.
  18637. * @returns the input friendly name
  18638. */
  18639. getSimpleName(): string;
  18640. }
  18641. }
  18642. declare module BABYLON {
  18643. /**
  18644. * Manage the touch inputs to control the movement of a free camera.
  18645. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18646. */
  18647. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18648. /**
  18649. * Defines the camera the input is attached to.
  18650. */
  18651. camera: FreeCamera;
  18652. /**
  18653. * Defines the touch sensibility for rotation.
  18654. * The higher the faster.
  18655. */
  18656. touchAngularSensibility: number;
  18657. /**
  18658. * Defines the touch sensibility for move.
  18659. * The higher the faster.
  18660. */
  18661. touchMoveSensibility: number;
  18662. private _offsetX;
  18663. private _offsetY;
  18664. private _pointerPressed;
  18665. private _pointerInput;
  18666. private _observer;
  18667. private _onLostFocus;
  18668. /**
  18669. * Attach the input controls to a specific dom element to get the input from.
  18670. * @param element Defines the element the controls should be listened from
  18671. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18672. */
  18673. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18674. /**
  18675. * Detach the current controls from the specified dom element.
  18676. * @param element Defines the element to stop listening the inputs from
  18677. */
  18678. detachControl(element: Nullable<HTMLElement>): void;
  18679. /**
  18680. * Update the current camera state depending on the inputs that have been used this frame.
  18681. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18682. */
  18683. checkInputs(): void;
  18684. /**
  18685. * Gets the class name of the current intput.
  18686. * @returns the class name
  18687. */
  18688. getClassName(): string;
  18689. /**
  18690. * Get the friendly name associated with the input class.
  18691. * @returns the input friendly name
  18692. */
  18693. getSimpleName(): string;
  18694. }
  18695. }
  18696. declare module BABYLON {
  18697. /**
  18698. * Default Inputs manager for the FreeCamera.
  18699. * It groups all the default supported inputs for ease of use.
  18700. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18701. */
  18702. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18703. /**
  18704. * @hidden
  18705. */
  18706. _mouseInput: Nullable<FreeCameraMouseInput>;
  18707. /**
  18708. * Instantiates a new FreeCameraInputsManager.
  18709. * @param camera Defines the camera the inputs belong to
  18710. */
  18711. constructor(camera: FreeCamera);
  18712. /**
  18713. * Add keyboard input support to the input manager.
  18714. * @returns the current input manager
  18715. */
  18716. addKeyboard(): FreeCameraInputsManager;
  18717. /**
  18718. * Add mouse input support to the input manager.
  18719. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18720. * @returns the current input manager
  18721. */
  18722. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18723. /**
  18724. * Removes the mouse input support from the manager
  18725. * @returns the current input manager
  18726. */
  18727. removeMouse(): FreeCameraInputsManager;
  18728. /**
  18729. * Add touch input support to the input manager.
  18730. * @returns the current input manager
  18731. */
  18732. addTouch(): FreeCameraInputsManager;
  18733. /**
  18734. * Remove all attached input methods from a camera
  18735. */
  18736. clear(): void;
  18737. }
  18738. }
  18739. declare module BABYLON {
  18740. /**
  18741. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18742. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18743. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18744. */
  18745. export class FreeCamera extends TargetCamera {
  18746. /**
  18747. * Define the collision ellipsoid of the camera.
  18748. * This is helpful to simulate a camera body like the player body around the camera
  18749. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18750. */
  18751. ellipsoid: Vector3;
  18752. /**
  18753. * Define an offset for the position of the ellipsoid around the camera.
  18754. * This can be helpful to determine the center of the body near the gravity center of the body
  18755. * instead of its head.
  18756. */
  18757. ellipsoidOffset: Vector3;
  18758. /**
  18759. * Enable or disable collisions of the camera with the rest of the scene objects.
  18760. */
  18761. checkCollisions: boolean;
  18762. /**
  18763. * Enable or disable gravity on the camera.
  18764. */
  18765. applyGravity: boolean;
  18766. /**
  18767. * Define the input manager associated to the camera.
  18768. */
  18769. inputs: FreeCameraInputsManager;
  18770. /**
  18771. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18772. * Higher values reduce sensitivity.
  18773. */
  18774. get angularSensibility(): number;
  18775. /**
  18776. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18777. * Higher values reduce sensitivity.
  18778. */
  18779. set angularSensibility(value: number);
  18780. /**
  18781. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18782. */
  18783. get keysUp(): number[];
  18784. set keysUp(value: number[]);
  18785. /**
  18786. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18787. */
  18788. get keysUpward(): number[];
  18789. set keysUpward(value: number[]);
  18790. /**
  18791. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18792. */
  18793. get keysDown(): number[];
  18794. set keysDown(value: number[]);
  18795. /**
  18796. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18797. */
  18798. get keysDownward(): number[];
  18799. set keysDownward(value: number[]);
  18800. /**
  18801. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18802. */
  18803. get keysLeft(): number[];
  18804. set keysLeft(value: number[]);
  18805. /**
  18806. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18807. */
  18808. get keysRight(): number[];
  18809. set keysRight(value: number[]);
  18810. /**
  18811. * Event raised when the camera collide with a mesh in the scene.
  18812. */
  18813. onCollide: (collidedMesh: AbstractMesh) => void;
  18814. private _collider;
  18815. private _needMoveForGravity;
  18816. private _oldPosition;
  18817. private _diffPosition;
  18818. private _newPosition;
  18819. /** @hidden */
  18820. _localDirection: Vector3;
  18821. /** @hidden */
  18822. _transformedDirection: Vector3;
  18823. /**
  18824. * Instantiates a Free Camera.
  18825. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18826. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18827. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18828. * @param name Define the name of the camera in the scene
  18829. * @param position Define the start position of the camera in the scene
  18830. * @param scene Define the scene the camera belongs to
  18831. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18832. */
  18833. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18834. /**
  18835. * Attached controls to the current camera.
  18836. * @param element Defines the element the controls should be listened from
  18837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18838. */
  18839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18840. /**
  18841. * Detach the current controls from the camera.
  18842. * The camera will stop reacting to inputs.
  18843. * @param element Defines the element to stop listening the inputs from
  18844. */
  18845. detachControl(element: HTMLElement): void;
  18846. private _collisionMask;
  18847. /**
  18848. * Define a collision mask to limit the list of object the camera can collide with
  18849. */
  18850. get collisionMask(): number;
  18851. set collisionMask(mask: number);
  18852. /** @hidden */
  18853. _collideWithWorld(displacement: Vector3): void;
  18854. private _onCollisionPositionChange;
  18855. /** @hidden */
  18856. _checkInputs(): void;
  18857. /** @hidden */
  18858. _decideIfNeedsToMove(): boolean;
  18859. /** @hidden */
  18860. _updatePosition(): void;
  18861. /**
  18862. * Destroy the camera and release the current resources hold by it.
  18863. */
  18864. dispose(): void;
  18865. /**
  18866. * Gets the current object class name.
  18867. * @return the class name
  18868. */
  18869. getClassName(): string;
  18870. }
  18871. }
  18872. declare module BABYLON {
  18873. /**
  18874. * Represents a gamepad control stick position
  18875. */
  18876. export class StickValues {
  18877. /**
  18878. * The x component of the control stick
  18879. */
  18880. x: number;
  18881. /**
  18882. * The y component of the control stick
  18883. */
  18884. y: number;
  18885. /**
  18886. * Initializes the gamepad x and y control stick values
  18887. * @param x The x component of the gamepad control stick value
  18888. * @param y The y component of the gamepad control stick value
  18889. */
  18890. constructor(
  18891. /**
  18892. * The x component of the control stick
  18893. */
  18894. x: number,
  18895. /**
  18896. * The y component of the control stick
  18897. */
  18898. y: number);
  18899. }
  18900. /**
  18901. * An interface which manages callbacks for gamepad button changes
  18902. */
  18903. export interface GamepadButtonChanges {
  18904. /**
  18905. * Called when a gamepad has been changed
  18906. */
  18907. changed: boolean;
  18908. /**
  18909. * Called when a gamepad press event has been triggered
  18910. */
  18911. pressChanged: boolean;
  18912. /**
  18913. * Called when a touch event has been triggered
  18914. */
  18915. touchChanged: boolean;
  18916. /**
  18917. * Called when a value has changed
  18918. */
  18919. valueChanged: boolean;
  18920. }
  18921. /**
  18922. * Represents a gamepad
  18923. */
  18924. export class Gamepad {
  18925. /**
  18926. * The id of the gamepad
  18927. */
  18928. id: string;
  18929. /**
  18930. * The index of the gamepad
  18931. */
  18932. index: number;
  18933. /**
  18934. * The browser gamepad
  18935. */
  18936. browserGamepad: any;
  18937. /**
  18938. * Specifies what type of gamepad this represents
  18939. */
  18940. type: number;
  18941. private _leftStick;
  18942. private _rightStick;
  18943. /** @hidden */
  18944. _isConnected: boolean;
  18945. private _leftStickAxisX;
  18946. private _leftStickAxisY;
  18947. private _rightStickAxisX;
  18948. private _rightStickAxisY;
  18949. /**
  18950. * Triggered when the left control stick has been changed
  18951. */
  18952. private _onleftstickchanged;
  18953. /**
  18954. * Triggered when the right control stick has been changed
  18955. */
  18956. private _onrightstickchanged;
  18957. /**
  18958. * Represents a gamepad controller
  18959. */
  18960. static GAMEPAD: number;
  18961. /**
  18962. * Represents a generic controller
  18963. */
  18964. static GENERIC: number;
  18965. /**
  18966. * Represents an XBox controller
  18967. */
  18968. static XBOX: number;
  18969. /**
  18970. * Represents a pose-enabled controller
  18971. */
  18972. static POSE_ENABLED: number;
  18973. /**
  18974. * Represents an Dual Shock controller
  18975. */
  18976. static DUALSHOCK: number;
  18977. /**
  18978. * Specifies whether the left control stick should be Y-inverted
  18979. */
  18980. protected _invertLeftStickY: boolean;
  18981. /**
  18982. * Specifies if the gamepad has been connected
  18983. */
  18984. get isConnected(): boolean;
  18985. /**
  18986. * Initializes the gamepad
  18987. * @param id The id of the gamepad
  18988. * @param index The index of the gamepad
  18989. * @param browserGamepad The browser gamepad
  18990. * @param leftStickX The x component of the left joystick
  18991. * @param leftStickY The y component of the left joystick
  18992. * @param rightStickX The x component of the right joystick
  18993. * @param rightStickY The y component of the right joystick
  18994. */
  18995. constructor(
  18996. /**
  18997. * The id of the gamepad
  18998. */
  18999. id: string,
  19000. /**
  19001. * The index of the gamepad
  19002. */
  19003. index: number,
  19004. /**
  19005. * The browser gamepad
  19006. */
  19007. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19008. /**
  19009. * Callback triggered when the left joystick has changed
  19010. * @param callback
  19011. */
  19012. onleftstickchanged(callback: (values: StickValues) => void): void;
  19013. /**
  19014. * Callback triggered when the right joystick has changed
  19015. * @param callback
  19016. */
  19017. onrightstickchanged(callback: (values: StickValues) => void): void;
  19018. /**
  19019. * Gets the left joystick
  19020. */
  19021. get leftStick(): StickValues;
  19022. /**
  19023. * Sets the left joystick values
  19024. */
  19025. set leftStick(newValues: StickValues);
  19026. /**
  19027. * Gets the right joystick
  19028. */
  19029. get rightStick(): StickValues;
  19030. /**
  19031. * Sets the right joystick value
  19032. */
  19033. set rightStick(newValues: StickValues);
  19034. /**
  19035. * Updates the gamepad joystick positions
  19036. */
  19037. update(): void;
  19038. /**
  19039. * Disposes the gamepad
  19040. */
  19041. dispose(): void;
  19042. }
  19043. /**
  19044. * Represents a generic gamepad
  19045. */
  19046. export class GenericPad extends Gamepad {
  19047. private _buttons;
  19048. private _onbuttondown;
  19049. private _onbuttonup;
  19050. /**
  19051. * Observable triggered when a button has been pressed
  19052. */
  19053. onButtonDownObservable: Observable<number>;
  19054. /**
  19055. * Observable triggered when a button has been released
  19056. */
  19057. onButtonUpObservable: Observable<number>;
  19058. /**
  19059. * Callback triggered when a button has been pressed
  19060. * @param callback Called when a button has been pressed
  19061. */
  19062. onbuttondown(callback: (buttonPressed: number) => void): void;
  19063. /**
  19064. * Callback triggered when a button has been released
  19065. * @param callback Called when a button has been released
  19066. */
  19067. onbuttonup(callback: (buttonReleased: number) => void): void;
  19068. /**
  19069. * Initializes the generic gamepad
  19070. * @param id The id of the generic gamepad
  19071. * @param index The index of the generic gamepad
  19072. * @param browserGamepad The browser gamepad
  19073. */
  19074. constructor(id: string, index: number, browserGamepad: any);
  19075. private _setButtonValue;
  19076. /**
  19077. * Updates the generic gamepad
  19078. */
  19079. update(): void;
  19080. /**
  19081. * Disposes the generic gamepad
  19082. */
  19083. dispose(): void;
  19084. }
  19085. }
  19086. declare module BABYLON {
  19087. /**
  19088. * Defines the types of pose enabled controllers that are supported
  19089. */
  19090. export enum PoseEnabledControllerType {
  19091. /**
  19092. * HTC Vive
  19093. */
  19094. VIVE = 0,
  19095. /**
  19096. * Oculus Rift
  19097. */
  19098. OCULUS = 1,
  19099. /**
  19100. * Windows mixed reality
  19101. */
  19102. WINDOWS = 2,
  19103. /**
  19104. * Samsung gear VR
  19105. */
  19106. GEAR_VR = 3,
  19107. /**
  19108. * Google Daydream
  19109. */
  19110. DAYDREAM = 4,
  19111. /**
  19112. * Generic
  19113. */
  19114. GENERIC = 5
  19115. }
  19116. /**
  19117. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19118. */
  19119. export interface MutableGamepadButton {
  19120. /**
  19121. * Value of the button/trigger
  19122. */
  19123. value: number;
  19124. /**
  19125. * If the button/trigger is currently touched
  19126. */
  19127. touched: boolean;
  19128. /**
  19129. * If the button/trigger is currently pressed
  19130. */
  19131. pressed: boolean;
  19132. }
  19133. /**
  19134. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19135. * @hidden
  19136. */
  19137. export interface ExtendedGamepadButton extends GamepadButton {
  19138. /**
  19139. * If the button/trigger is currently pressed
  19140. */
  19141. readonly pressed: boolean;
  19142. /**
  19143. * If the button/trigger is currently touched
  19144. */
  19145. readonly touched: boolean;
  19146. /**
  19147. * Value of the button/trigger
  19148. */
  19149. readonly value: number;
  19150. }
  19151. /** @hidden */
  19152. export interface _GamePadFactory {
  19153. /**
  19154. * Returns whether or not the current gamepad can be created for this type of controller.
  19155. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19156. * @returns true if it can be created, otherwise false
  19157. */
  19158. canCreate(gamepadInfo: any): boolean;
  19159. /**
  19160. * Creates a new instance of the Gamepad.
  19161. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19162. * @returns the new gamepad instance
  19163. */
  19164. create(gamepadInfo: any): Gamepad;
  19165. }
  19166. /**
  19167. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19168. */
  19169. export class PoseEnabledControllerHelper {
  19170. /** @hidden */
  19171. static _ControllerFactories: _GamePadFactory[];
  19172. /** @hidden */
  19173. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19174. /**
  19175. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19176. * @param vrGamepad the gamepad to initialized
  19177. * @returns a vr controller of the type the gamepad identified as
  19178. */
  19179. static InitiateController(vrGamepad: any): Gamepad;
  19180. }
  19181. /**
  19182. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19183. */
  19184. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19185. /**
  19186. * If the controller is used in a webXR session
  19187. */
  19188. isXR: boolean;
  19189. private _deviceRoomPosition;
  19190. private _deviceRoomRotationQuaternion;
  19191. /**
  19192. * The device position in babylon space
  19193. */
  19194. devicePosition: Vector3;
  19195. /**
  19196. * The device rotation in babylon space
  19197. */
  19198. deviceRotationQuaternion: Quaternion;
  19199. /**
  19200. * The scale factor of the device in babylon space
  19201. */
  19202. deviceScaleFactor: number;
  19203. /**
  19204. * (Likely devicePosition should be used instead) The device position in its room space
  19205. */
  19206. position: Vector3;
  19207. /**
  19208. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19209. */
  19210. rotationQuaternion: Quaternion;
  19211. /**
  19212. * The type of controller (Eg. Windows mixed reality)
  19213. */
  19214. controllerType: PoseEnabledControllerType;
  19215. protected _calculatedPosition: Vector3;
  19216. private _calculatedRotation;
  19217. /**
  19218. * The raw pose from the device
  19219. */
  19220. rawPose: DevicePose;
  19221. private _trackPosition;
  19222. private _maxRotationDistFromHeadset;
  19223. private _draggedRoomRotation;
  19224. /**
  19225. * @hidden
  19226. */
  19227. _disableTrackPosition(fixedPosition: Vector3): void;
  19228. /**
  19229. * Internal, the mesh attached to the controller
  19230. * @hidden
  19231. */
  19232. _mesh: Nullable<AbstractMesh>;
  19233. private _poseControlledCamera;
  19234. private _leftHandSystemQuaternion;
  19235. /**
  19236. * Internal, matrix used to convert room space to babylon space
  19237. * @hidden
  19238. */
  19239. _deviceToWorld: Matrix;
  19240. /**
  19241. * Node to be used when casting a ray from the controller
  19242. * @hidden
  19243. */
  19244. _pointingPoseNode: Nullable<TransformNode>;
  19245. /**
  19246. * Name of the child mesh that can be used to cast a ray from the controller
  19247. */
  19248. static readonly POINTING_POSE: string;
  19249. /**
  19250. * Creates a new PoseEnabledController from a gamepad
  19251. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19252. */
  19253. constructor(browserGamepad: any);
  19254. private _workingMatrix;
  19255. /**
  19256. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19257. */
  19258. update(): void;
  19259. /**
  19260. * Updates only the pose device and mesh without doing any button event checking
  19261. */
  19262. protected _updatePoseAndMesh(): void;
  19263. /**
  19264. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19265. * @param poseData raw pose fromthe device
  19266. */
  19267. updateFromDevice(poseData: DevicePose): void;
  19268. /**
  19269. * @hidden
  19270. */
  19271. _meshAttachedObservable: Observable<AbstractMesh>;
  19272. /**
  19273. * Attaches a mesh to the controller
  19274. * @param mesh the mesh to be attached
  19275. */
  19276. attachToMesh(mesh: AbstractMesh): void;
  19277. /**
  19278. * Attaches the controllers mesh to a camera
  19279. * @param camera the camera the mesh should be attached to
  19280. */
  19281. attachToPoseControlledCamera(camera: TargetCamera): void;
  19282. /**
  19283. * Disposes of the controller
  19284. */
  19285. dispose(): void;
  19286. /**
  19287. * The mesh that is attached to the controller
  19288. */
  19289. get mesh(): Nullable<AbstractMesh>;
  19290. /**
  19291. * Gets the ray of the controller in the direction the controller is pointing
  19292. * @param length the length the resulting ray should be
  19293. * @returns a ray in the direction the controller is pointing
  19294. */
  19295. getForwardRay(length?: number): Ray;
  19296. }
  19297. }
  19298. declare module BABYLON {
  19299. /**
  19300. * Defines the WebVRController object that represents controllers tracked in 3D space
  19301. */
  19302. export abstract class WebVRController extends PoseEnabledController {
  19303. /**
  19304. * Internal, the default controller model for the controller
  19305. */
  19306. protected _defaultModel: Nullable<AbstractMesh>;
  19307. /**
  19308. * Fired when the trigger state has changed
  19309. */
  19310. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19311. /**
  19312. * Fired when the main button state has changed
  19313. */
  19314. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19315. /**
  19316. * Fired when the secondary button state has changed
  19317. */
  19318. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19319. /**
  19320. * Fired when the pad state has changed
  19321. */
  19322. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19323. /**
  19324. * Fired when controllers stick values have changed
  19325. */
  19326. onPadValuesChangedObservable: Observable<StickValues>;
  19327. /**
  19328. * Array of button availible on the controller
  19329. */
  19330. protected _buttons: Array<MutableGamepadButton>;
  19331. private _onButtonStateChange;
  19332. /**
  19333. * Fired when a controller button's state has changed
  19334. * @param callback the callback containing the button that was modified
  19335. */
  19336. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19337. /**
  19338. * X and Y axis corresponding to the controllers joystick
  19339. */
  19340. pad: StickValues;
  19341. /**
  19342. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19343. */
  19344. hand: string;
  19345. /**
  19346. * The default controller model for the controller
  19347. */
  19348. get defaultModel(): Nullable<AbstractMesh>;
  19349. /**
  19350. * Creates a new WebVRController from a gamepad
  19351. * @param vrGamepad the gamepad that the WebVRController should be created from
  19352. */
  19353. constructor(vrGamepad: any);
  19354. /**
  19355. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19356. */
  19357. update(): void;
  19358. /**
  19359. * Function to be called when a button is modified
  19360. */
  19361. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19362. /**
  19363. * Loads a mesh and attaches it to the controller
  19364. * @param scene the scene the mesh should be added to
  19365. * @param meshLoaded callback for when the mesh has been loaded
  19366. */
  19367. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19368. private _setButtonValue;
  19369. private _changes;
  19370. private _checkChanges;
  19371. /**
  19372. * Disposes of th webVRCOntroller
  19373. */
  19374. dispose(): void;
  19375. }
  19376. }
  19377. declare module BABYLON {
  19378. /**
  19379. * The HemisphericLight simulates the ambient environment light,
  19380. * so the passed direction is the light reflection direction, not the incoming direction.
  19381. */
  19382. export class HemisphericLight extends Light {
  19383. /**
  19384. * The groundColor is the light in the opposite direction to the one specified during creation.
  19385. * 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.
  19386. */
  19387. groundColor: Color3;
  19388. /**
  19389. * The light reflection direction, not the incoming direction.
  19390. */
  19391. direction: Vector3;
  19392. /**
  19393. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19394. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19395. * The HemisphericLight can't cast shadows.
  19396. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19397. * @param name The friendly name of the light
  19398. * @param direction The direction of the light reflection
  19399. * @param scene The scene the light belongs to
  19400. */
  19401. constructor(name: string, direction: Vector3, scene: Scene);
  19402. protected _buildUniformLayout(): void;
  19403. /**
  19404. * Returns the string "HemisphericLight".
  19405. * @return The class name
  19406. */
  19407. getClassName(): string;
  19408. /**
  19409. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19410. * Returns the updated direction.
  19411. * @param target The target the direction should point to
  19412. * @return The computed direction
  19413. */
  19414. setDirectionToTarget(target: Vector3): Vector3;
  19415. /**
  19416. * Returns the shadow generator associated to the light.
  19417. * @returns Always null for hemispheric lights because it does not support shadows.
  19418. */
  19419. getShadowGenerator(): Nullable<IShadowGenerator>;
  19420. /**
  19421. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19422. * @param effect The effect to update
  19423. * @param lightIndex The index of the light in the effect to update
  19424. * @returns The hemispheric light
  19425. */
  19426. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19427. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19428. /**
  19429. * Computes the world matrix of the node
  19430. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19431. * @param useWasUpdatedFlag defines a reserved property
  19432. * @returns the world matrix
  19433. */
  19434. computeWorldMatrix(): Matrix;
  19435. /**
  19436. * Returns the integer 3.
  19437. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19438. */
  19439. getTypeID(): number;
  19440. /**
  19441. * Prepares the list of defines specific to the light type.
  19442. * @param defines the list of defines
  19443. * @param lightIndex defines the index of the light for the effect
  19444. */
  19445. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19446. }
  19447. }
  19448. declare module BABYLON {
  19449. /** @hidden */
  19450. export var vrMultiviewToSingleviewPixelShader: {
  19451. name: string;
  19452. shader: string;
  19453. };
  19454. }
  19455. declare module BABYLON {
  19456. /**
  19457. * Renders to multiple views with a single draw call
  19458. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19459. */
  19460. export class MultiviewRenderTarget extends RenderTargetTexture {
  19461. /**
  19462. * Creates a multiview render target
  19463. * @param scene scene used with the render target
  19464. * @param size the size of the render target (used for each view)
  19465. */
  19466. constructor(scene: Scene, size?: number | {
  19467. width: number;
  19468. height: number;
  19469. } | {
  19470. ratio: number;
  19471. });
  19472. /**
  19473. * @hidden
  19474. * @param faceIndex the face index, if its a cube texture
  19475. */
  19476. _bindFrameBuffer(faceIndex?: number): void;
  19477. /**
  19478. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19479. * @returns the view count
  19480. */
  19481. getViewCount(): number;
  19482. }
  19483. }
  19484. declare module BABYLON {
  19485. interface Engine {
  19486. /**
  19487. * Creates a new multiview render target
  19488. * @param width defines the width of the texture
  19489. * @param height defines the height of the texture
  19490. * @returns the created multiview texture
  19491. */
  19492. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19493. /**
  19494. * Binds a multiview framebuffer to be drawn to
  19495. * @param multiviewTexture texture to bind
  19496. */
  19497. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19498. }
  19499. interface Camera {
  19500. /**
  19501. * @hidden
  19502. * 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)
  19503. */
  19504. _useMultiviewToSingleView: boolean;
  19505. /**
  19506. * @hidden
  19507. * 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)
  19508. */
  19509. _multiviewTexture: Nullable<RenderTargetTexture>;
  19510. /**
  19511. * @hidden
  19512. * ensures the multiview texture of the camera exists and has the specified width/height
  19513. * @param width height to set on the multiview texture
  19514. * @param height width to set on the multiview texture
  19515. */
  19516. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19517. }
  19518. interface Scene {
  19519. /** @hidden */
  19520. _transformMatrixR: Matrix;
  19521. /** @hidden */
  19522. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19523. /** @hidden */
  19524. _createMultiviewUbo(): void;
  19525. /** @hidden */
  19526. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19527. /** @hidden */
  19528. _renderMultiviewToSingleView(camera: Camera): void;
  19529. }
  19530. }
  19531. declare module BABYLON {
  19532. /**
  19533. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19534. * This will not be used for webXR as it supports displaying texture arrays directly
  19535. */
  19536. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19537. /**
  19538. * Initializes a VRMultiviewToSingleview
  19539. * @param name name of the post process
  19540. * @param camera camera to be applied to
  19541. * @param scaleFactor scaling factor to the size of the output texture
  19542. */
  19543. constructor(name: string, camera: Camera, scaleFactor: number);
  19544. }
  19545. }
  19546. declare module BABYLON {
  19547. /**
  19548. * Interface used to define additional presentation attributes
  19549. */
  19550. export interface IVRPresentationAttributes {
  19551. /**
  19552. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19553. */
  19554. highRefreshRate: boolean;
  19555. /**
  19556. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19557. */
  19558. foveationLevel: number;
  19559. }
  19560. interface Engine {
  19561. /** @hidden */
  19562. _vrDisplay: any;
  19563. /** @hidden */
  19564. _vrSupported: boolean;
  19565. /** @hidden */
  19566. _oldSize: Size;
  19567. /** @hidden */
  19568. _oldHardwareScaleFactor: number;
  19569. /** @hidden */
  19570. _vrExclusivePointerMode: boolean;
  19571. /** @hidden */
  19572. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19573. /** @hidden */
  19574. _onVRDisplayPointerRestricted: () => void;
  19575. /** @hidden */
  19576. _onVRDisplayPointerUnrestricted: () => void;
  19577. /** @hidden */
  19578. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19579. /** @hidden */
  19580. _onVrDisplayDisconnect: Nullable<() => void>;
  19581. /** @hidden */
  19582. _onVrDisplayPresentChange: Nullable<() => void>;
  19583. /**
  19584. * Observable signaled when VR display mode changes
  19585. */
  19586. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19587. /**
  19588. * Observable signaled when VR request present is complete
  19589. */
  19590. onVRRequestPresentComplete: Observable<boolean>;
  19591. /**
  19592. * Observable signaled when VR request present starts
  19593. */
  19594. onVRRequestPresentStart: Observable<Engine>;
  19595. /**
  19596. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19597. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19598. */
  19599. isInVRExclusivePointerMode: boolean;
  19600. /**
  19601. * Gets a boolean indicating if a webVR device was detected
  19602. * @returns true if a webVR device was detected
  19603. */
  19604. isVRDevicePresent(): boolean;
  19605. /**
  19606. * Gets the current webVR device
  19607. * @returns the current webVR device (or null)
  19608. */
  19609. getVRDevice(): any;
  19610. /**
  19611. * Initializes a webVR display and starts listening to display change events
  19612. * The onVRDisplayChangedObservable will be notified upon these changes
  19613. * @returns A promise containing a VRDisplay and if vr is supported
  19614. */
  19615. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19616. /** @hidden */
  19617. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19618. /**
  19619. * Gets or sets the presentation attributes used to configure VR rendering
  19620. */
  19621. vrPresentationAttributes?: IVRPresentationAttributes;
  19622. /**
  19623. * Call this function to switch to webVR mode
  19624. * Will do nothing if webVR is not supported or if there is no webVR device
  19625. * @param options the webvr options provided to the camera. mainly used for multiview
  19626. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19627. */
  19628. enableVR(options: WebVROptions): void;
  19629. /** @hidden */
  19630. _onVRFullScreenTriggered(): void;
  19631. }
  19632. }
  19633. declare module BABYLON {
  19634. /**
  19635. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19636. * IMPORTANT!! The data is right-hand data.
  19637. * @export
  19638. * @interface DevicePose
  19639. */
  19640. export interface DevicePose {
  19641. /**
  19642. * The position of the device, values in array are [x,y,z].
  19643. */
  19644. readonly position: Nullable<Float32Array>;
  19645. /**
  19646. * The linearVelocity of the device, values in array are [x,y,z].
  19647. */
  19648. readonly linearVelocity: Nullable<Float32Array>;
  19649. /**
  19650. * The linearAcceleration of the device, values in array are [x,y,z].
  19651. */
  19652. readonly linearAcceleration: Nullable<Float32Array>;
  19653. /**
  19654. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19655. */
  19656. readonly orientation: Nullable<Float32Array>;
  19657. /**
  19658. * The angularVelocity of the device, values in array are [x,y,z].
  19659. */
  19660. readonly angularVelocity: Nullable<Float32Array>;
  19661. /**
  19662. * The angularAcceleration of the device, values in array are [x,y,z].
  19663. */
  19664. readonly angularAcceleration: Nullable<Float32Array>;
  19665. }
  19666. /**
  19667. * Interface representing a pose controlled object in Babylon.
  19668. * A pose controlled object has both regular pose values as well as pose values
  19669. * from an external device such as a VR head mounted display
  19670. */
  19671. export interface PoseControlled {
  19672. /**
  19673. * The position of the object in babylon space.
  19674. */
  19675. position: Vector3;
  19676. /**
  19677. * The rotation quaternion of the object in babylon space.
  19678. */
  19679. rotationQuaternion: Quaternion;
  19680. /**
  19681. * The position of the device in babylon space.
  19682. */
  19683. devicePosition?: Vector3;
  19684. /**
  19685. * The rotation quaternion of the device in babylon space.
  19686. */
  19687. deviceRotationQuaternion: Quaternion;
  19688. /**
  19689. * The raw pose coming from the device.
  19690. */
  19691. rawPose: Nullable<DevicePose>;
  19692. /**
  19693. * The scale of the device to be used when translating from device space to babylon space.
  19694. */
  19695. deviceScaleFactor: number;
  19696. /**
  19697. * Updates the poseControlled values based on the input device pose.
  19698. * @param poseData the pose data to update the object with
  19699. */
  19700. updateFromDevice(poseData: DevicePose): void;
  19701. }
  19702. /**
  19703. * Set of options to customize the webVRCamera
  19704. */
  19705. export interface WebVROptions {
  19706. /**
  19707. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19708. */
  19709. trackPosition?: boolean;
  19710. /**
  19711. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19712. */
  19713. positionScale?: number;
  19714. /**
  19715. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19716. */
  19717. displayName?: string;
  19718. /**
  19719. * Should the native controller meshes be initialized. (default: true)
  19720. */
  19721. controllerMeshes?: boolean;
  19722. /**
  19723. * Creating a default HemiLight only on controllers. (default: true)
  19724. */
  19725. defaultLightingOnControllers?: boolean;
  19726. /**
  19727. * If you don't want to use the default VR button of the helper. (default: false)
  19728. */
  19729. useCustomVRButton?: boolean;
  19730. /**
  19731. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19732. */
  19733. customVRButton?: HTMLButtonElement;
  19734. /**
  19735. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19736. */
  19737. rayLength?: number;
  19738. /**
  19739. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19740. */
  19741. defaultHeight?: number;
  19742. /**
  19743. * If multiview should be used if availible (default: false)
  19744. */
  19745. useMultiview?: boolean;
  19746. }
  19747. /**
  19748. * This represents a WebVR camera.
  19749. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19750. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19751. */
  19752. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19753. private webVROptions;
  19754. /**
  19755. * @hidden
  19756. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19757. */
  19758. _vrDevice: any;
  19759. /**
  19760. * The rawPose of the vrDevice.
  19761. */
  19762. rawPose: Nullable<DevicePose>;
  19763. private _onVREnabled;
  19764. private _specsVersion;
  19765. private _attached;
  19766. private _frameData;
  19767. protected _descendants: Array<Node>;
  19768. private _deviceRoomPosition;
  19769. /** @hidden */
  19770. _deviceRoomRotationQuaternion: Quaternion;
  19771. private _standingMatrix;
  19772. /**
  19773. * Represents device position in babylon space.
  19774. */
  19775. devicePosition: Vector3;
  19776. /**
  19777. * Represents device rotation in babylon space.
  19778. */
  19779. deviceRotationQuaternion: Quaternion;
  19780. /**
  19781. * The scale of the device to be used when translating from device space to babylon space.
  19782. */
  19783. deviceScaleFactor: number;
  19784. private _deviceToWorld;
  19785. private _worldToDevice;
  19786. /**
  19787. * References to the webVR controllers for the vrDevice.
  19788. */
  19789. controllers: Array<WebVRController>;
  19790. /**
  19791. * Emits an event when a controller is attached.
  19792. */
  19793. onControllersAttachedObservable: Observable<WebVRController[]>;
  19794. /**
  19795. * Emits an event when a controller's mesh has been loaded;
  19796. */
  19797. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19798. /**
  19799. * Emits an event when the HMD's pose has been updated.
  19800. */
  19801. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19802. private _poseSet;
  19803. /**
  19804. * If the rig cameras be used as parent instead of this camera.
  19805. */
  19806. rigParenting: boolean;
  19807. private _lightOnControllers;
  19808. private _defaultHeight?;
  19809. /**
  19810. * Instantiates a WebVRFreeCamera.
  19811. * @param name The name of the WebVRFreeCamera
  19812. * @param position The starting anchor position for the camera
  19813. * @param scene The scene the camera belongs to
  19814. * @param webVROptions a set of customizable options for the webVRCamera
  19815. */
  19816. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19817. /**
  19818. * Gets the device distance from the ground in meters.
  19819. * @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.
  19820. */
  19821. deviceDistanceToRoomGround(): number;
  19822. /**
  19823. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19824. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19825. */
  19826. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19827. /**
  19828. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19829. * @returns A promise with a boolean set to if the standing matrix is supported.
  19830. */
  19831. useStandingMatrixAsync(): Promise<boolean>;
  19832. /**
  19833. * Disposes the camera
  19834. */
  19835. dispose(): void;
  19836. /**
  19837. * Gets a vrController by name.
  19838. * @param name The name of the controller to retreive
  19839. * @returns the controller matching the name specified or null if not found
  19840. */
  19841. getControllerByName(name: string): Nullable<WebVRController>;
  19842. private _leftController;
  19843. /**
  19844. * The controller corresponding to the users left hand.
  19845. */
  19846. get leftController(): Nullable<WebVRController>;
  19847. private _rightController;
  19848. /**
  19849. * The controller corresponding to the users right hand.
  19850. */
  19851. get rightController(): Nullable<WebVRController>;
  19852. /**
  19853. * Casts a ray forward from the vrCamera's gaze.
  19854. * @param length Length of the ray (default: 100)
  19855. * @returns the ray corresponding to the gaze
  19856. */
  19857. getForwardRay(length?: number): Ray;
  19858. /**
  19859. * @hidden
  19860. * Updates the camera based on device's frame data
  19861. */
  19862. _checkInputs(): void;
  19863. /**
  19864. * Updates the poseControlled values based on the input device pose.
  19865. * @param poseData Pose coming from the device
  19866. */
  19867. updateFromDevice(poseData: DevicePose): void;
  19868. private _htmlElementAttached;
  19869. private _detachIfAttached;
  19870. /**
  19871. * WebVR's attach control will start broadcasting frames to the device.
  19872. * Note that in certain browsers (chrome for example) this function must be called
  19873. * within a user-interaction callback. Example:
  19874. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19875. *
  19876. * @param element html element to attach the vrDevice to
  19877. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19878. */
  19879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19880. /**
  19881. * Detaches the camera from the html element and disables VR
  19882. *
  19883. * @param element html element to detach from
  19884. */
  19885. detachControl(element: HTMLElement): void;
  19886. /**
  19887. * @returns the name of this class
  19888. */
  19889. getClassName(): string;
  19890. /**
  19891. * Calls resetPose on the vrDisplay
  19892. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19893. */
  19894. resetToCurrentRotation(): void;
  19895. /**
  19896. * @hidden
  19897. * Updates the rig cameras (left and right eye)
  19898. */
  19899. _updateRigCameras(): void;
  19900. private _workingVector;
  19901. private _oneVector;
  19902. private _workingMatrix;
  19903. private updateCacheCalled;
  19904. private _correctPositionIfNotTrackPosition;
  19905. /**
  19906. * @hidden
  19907. * Updates the cached values of the camera
  19908. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19909. */
  19910. _updateCache(ignoreParentClass?: boolean): void;
  19911. /**
  19912. * @hidden
  19913. * Get current device position in babylon world
  19914. */
  19915. _computeDevicePosition(): void;
  19916. /**
  19917. * Updates the current device position and rotation in the babylon world
  19918. */
  19919. update(): void;
  19920. /**
  19921. * @hidden
  19922. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19923. * @returns an identity matrix
  19924. */
  19925. _getViewMatrix(): Matrix;
  19926. private _tmpMatrix;
  19927. /**
  19928. * This function is called by the two RIG cameras.
  19929. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19930. * @hidden
  19931. */
  19932. _getWebVRViewMatrix(): Matrix;
  19933. /** @hidden */
  19934. _getWebVRProjectionMatrix(): Matrix;
  19935. private _onGamepadConnectedObserver;
  19936. private _onGamepadDisconnectedObserver;
  19937. private _updateCacheWhenTrackingDisabledObserver;
  19938. /**
  19939. * Initializes the controllers and their meshes
  19940. */
  19941. initControllers(): void;
  19942. }
  19943. }
  19944. declare module BABYLON {
  19945. /**
  19946. * "Static Class" containing the most commonly used helper while dealing with material for
  19947. * rendering purpose.
  19948. *
  19949. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  19950. *
  19951. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  19952. */
  19953. export class MaterialHelper {
  19954. /**
  19955. * Bind the current view position to an effect.
  19956. * @param effect The effect to be bound
  19957. * @param scene The scene the eyes position is used from
  19958. * @param variableName name of the shader variable that will hold the eye position
  19959. */
  19960. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  19961. /**
  19962. * Helps preparing the defines values about the UVs in used in the effect.
  19963. * UVs are shared as much as we can accross channels in the shaders.
  19964. * @param texture The texture we are preparing the UVs for
  19965. * @param defines The defines to update
  19966. * @param key The channel key "diffuse", "specular"... used in the shader
  19967. */
  19968. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  19969. /**
  19970. * Binds a texture matrix value to its corrsponding uniform
  19971. * @param texture The texture to bind the matrix for
  19972. * @param uniformBuffer The uniform buffer receivin the data
  19973. * @param key The channel key "diffuse", "specular"... used in the shader
  19974. */
  19975. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  19976. /**
  19977. * Gets the current status of the fog (should it be enabled?)
  19978. * @param mesh defines the mesh to evaluate for fog support
  19979. * @param scene defines the hosting scene
  19980. * @returns true if fog must be enabled
  19981. */
  19982. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  19983. /**
  19984. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  19985. * @param mesh defines the current mesh
  19986. * @param scene defines the current scene
  19987. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  19988. * @param pointsCloud defines if point cloud rendering has to be turned on
  19989. * @param fogEnabled defines if fog has to be turned on
  19990. * @param alphaTest defines if alpha testing has to be turned on
  19991. * @param defines defines the current list of defines
  19992. */
  19993. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  19994. /**
  19995. * Helper used to prepare the list of defines associated with frame values for shader compilation
  19996. * @param scene defines the current scene
  19997. * @param engine defines the current engine
  19998. * @param defines specifies the list of active defines
  19999. * @param useInstances defines if instances have to be turned on
  20000. * @param useClipPlane defines if clip plane have to be turned on
  20001. * @param useInstances defines if instances have to be turned on
  20002. * @param useThinInstances defines if thin instances have to be turned on
  20003. */
  20004. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20005. /**
  20006. * Prepares the defines for bones
  20007. * @param mesh The mesh containing the geometry data we will draw
  20008. * @param defines The defines to update
  20009. */
  20010. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20011. /**
  20012. * Prepares the defines for morph targets
  20013. * @param mesh The mesh containing the geometry data we will draw
  20014. * @param defines The defines to update
  20015. */
  20016. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20017. /**
  20018. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20019. * @param mesh The mesh containing the geometry data we will draw
  20020. * @param defines The defines to update
  20021. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20022. * @param useBones Precise whether bones should be used or not (override mesh info)
  20023. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20024. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20025. * @returns false if defines are considered not dirty and have not been checked
  20026. */
  20027. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20028. /**
  20029. * Prepares the defines related to multiview
  20030. * @param scene The scene we are intending to draw
  20031. * @param defines The defines to update
  20032. */
  20033. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20034. /**
  20035. * Prepares the defines related to the prepass
  20036. * @param scene The scene we are intending to draw
  20037. * @param defines The defines to update
  20038. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  20039. */
  20040. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  20041. /**
  20042. * Prepares the defines related to the light information passed in parameter
  20043. * @param scene The scene we are intending to draw
  20044. * @param mesh The mesh the effect is compiling for
  20045. * @param light The light the effect is compiling for
  20046. * @param lightIndex The index of the light
  20047. * @param defines The defines to update
  20048. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20049. * @param state Defines the current state regarding what is needed (normals, etc...)
  20050. */
  20051. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20052. needNormals: boolean;
  20053. needRebuild: boolean;
  20054. shadowEnabled: boolean;
  20055. specularEnabled: boolean;
  20056. lightmapMode: boolean;
  20057. }): void;
  20058. /**
  20059. * Prepares the defines related to the light information passed in parameter
  20060. * @param scene The scene we are intending to draw
  20061. * @param mesh The mesh the effect is compiling for
  20062. * @param defines The defines to update
  20063. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20064. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20065. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20066. * @returns true if normals will be required for the rest of the effect
  20067. */
  20068. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20069. /**
  20070. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20071. * @param lightIndex defines the light index
  20072. * @param uniformsList The uniform list
  20073. * @param samplersList The sampler list
  20074. * @param projectedLightTexture defines if projected texture must be used
  20075. * @param uniformBuffersList defines an optional list of uniform buffers
  20076. */
  20077. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20078. /**
  20079. * Prepares the uniforms and samplers list to be used in the effect
  20080. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20081. * @param samplersList The sampler list
  20082. * @param defines The defines helping in the list generation
  20083. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20084. */
  20085. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20086. /**
  20087. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20088. * @param defines The defines to update while falling back
  20089. * @param fallbacks The authorized effect fallbacks
  20090. * @param maxSimultaneousLights The maximum number of lights allowed
  20091. * @param rank the current rank of the Effect
  20092. * @returns The newly affected rank
  20093. */
  20094. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20095. private static _TmpMorphInfluencers;
  20096. /**
  20097. * Prepares the list of attributes required for morph targets according to the effect defines.
  20098. * @param attribs The current list of supported attribs
  20099. * @param mesh The mesh to prepare the morph targets attributes for
  20100. * @param influencers The number of influencers
  20101. */
  20102. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20103. /**
  20104. * Prepares the list of attributes required for morph targets according to the effect defines.
  20105. * @param attribs The current list of supported attribs
  20106. * @param mesh The mesh to prepare the morph targets attributes for
  20107. * @param defines The current Defines of the effect
  20108. */
  20109. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20110. /**
  20111. * Prepares the list of attributes required for bones according to the effect defines.
  20112. * @param attribs The current list of supported attribs
  20113. * @param mesh The mesh to prepare the bones attributes for
  20114. * @param defines The current Defines of the effect
  20115. * @param fallbacks The current efffect fallback strategy
  20116. */
  20117. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20118. /**
  20119. * Check and prepare the list of attributes required for instances according to the effect defines.
  20120. * @param attribs The current list of supported attribs
  20121. * @param defines The current MaterialDefines of the effect
  20122. */
  20123. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20124. /**
  20125. * Add the list of attributes required for instances to the attribs array.
  20126. * @param attribs The current list of supported attribs
  20127. */
  20128. static PushAttributesForInstances(attribs: string[]): void;
  20129. /**
  20130. * Binds the light information to the effect.
  20131. * @param light The light containing the generator
  20132. * @param effect The effect we are binding the data to
  20133. * @param lightIndex The light index in the effect used to render
  20134. */
  20135. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20136. /**
  20137. * Binds the lights information from the scene to the effect for the given mesh.
  20138. * @param light Light to bind
  20139. * @param lightIndex Light index
  20140. * @param scene The scene where the light belongs to
  20141. * @param effect The effect we are binding the data to
  20142. * @param useSpecular Defines if specular is supported
  20143. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20144. */
  20145. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20146. /**
  20147. * Binds the lights information from the scene to the effect for the given mesh.
  20148. * @param scene The scene the lights belongs to
  20149. * @param mesh The mesh we are binding the information to render
  20150. * @param effect The effect we are binding the data to
  20151. * @param defines The generated defines for the effect
  20152. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20153. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20154. */
  20155. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20156. private static _tempFogColor;
  20157. /**
  20158. * Binds the fog information from the scene to the effect for the given mesh.
  20159. * @param scene The scene the lights belongs to
  20160. * @param mesh The mesh we are binding the information to render
  20161. * @param effect The effect we are binding the data to
  20162. * @param linearSpace Defines if the fog effect is applied in linear space
  20163. */
  20164. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20165. /**
  20166. * Binds the bones information from the mesh to the effect.
  20167. * @param mesh The mesh we are binding the information to render
  20168. * @param effect The effect we are binding the data to
  20169. */
  20170. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20171. /**
  20172. * Binds the morph targets information from the mesh to the effect.
  20173. * @param abstractMesh The mesh we are binding the information to render
  20174. * @param effect The effect we are binding the data to
  20175. */
  20176. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20177. /**
  20178. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20179. * @param defines The generated defines used in the effect
  20180. * @param effect The effect we are binding the data to
  20181. * @param scene The scene we are willing to render with logarithmic scale for
  20182. */
  20183. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20184. /**
  20185. * Binds the clip plane information from the scene to the effect.
  20186. * @param scene The scene the clip plane information are extracted from
  20187. * @param effect The effect we are binding the data to
  20188. */
  20189. static BindClipPlane(effect: Effect, scene: Scene): void;
  20190. }
  20191. }
  20192. declare module BABYLON {
  20193. /**
  20194. * Block used to expose an input value
  20195. */
  20196. export class InputBlock extends NodeMaterialBlock {
  20197. private _mode;
  20198. private _associatedVariableName;
  20199. private _storedValue;
  20200. private _valueCallback;
  20201. private _type;
  20202. private _animationType;
  20203. /** Gets or set a value used to limit the range of float values */
  20204. min: number;
  20205. /** Gets or set a value used to limit the range of float values */
  20206. max: number;
  20207. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20208. isBoolean: boolean;
  20209. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20210. matrixMode: number;
  20211. /** @hidden */
  20212. _systemValue: Nullable<NodeMaterialSystemValues>;
  20213. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20214. visibleInInspector: boolean;
  20215. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20216. isConstant: boolean;
  20217. /** Gets or sets the group to use to display this block in the Inspector */
  20218. groupInInspector: string;
  20219. /** Gets an observable raised when the value is changed */
  20220. onValueChangedObservable: Observable<InputBlock>;
  20221. /**
  20222. * Gets or sets the connection point type (default is float)
  20223. */
  20224. get type(): NodeMaterialBlockConnectionPointTypes;
  20225. /**
  20226. * Creates a new InputBlock
  20227. * @param name defines the block name
  20228. * @param target defines the target of that block (Vertex by default)
  20229. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20230. */
  20231. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20232. /**
  20233. * Gets the output component
  20234. */
  20235. get output(): NodeMaterialConnectionPoint;
  20236. /**
  20237. * Set the source of this connection point to a vertex attribute
  20238. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20239. * @returns the current connection point
  20240. */
  20241. setAsAttribute(attributeName?: string): InputBlock;
  20242. /**
  20243. * Set the source of this connection point to a system value
  20244. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20245. * @returns the current connection point
  20246. */
  20247. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20248. /**
  20249. * Gets or sets the value of that point.
  20250. * Please note that this value will be ignored if valueCallback is defined
  20251. */
  20252. get value(): any;
  20253. set value(value: any);
  20254. /**
  20255. * Gets or sets a callback used to get the value of that point.
  20256. * Please note that setting this value will force the connection point to ignore the value property
  20257. */
  20258. get valueCallback(): () => any;
  20259. set valueCallback(value: () => any);
  20260. /**
  20261. * Gets or sets the associated variable name in the shader
  20262. */
  20263. get associatedVariableName(): string;
  20264. set associatedVariableName(value: string);
  20265. /** Gets or sets the type of animation applied to the input */
  20266. get animationType(): AnimatedInputBlockTypes;
  20267. set animationType(value: AnimatedInputBlockTypes);
  20268. /**
  20269. * Gets a boolean indicating that this connection point not defined yet
  20270. */
  20271. get isUndefined(): boolean;
  20272. /**
  20273. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20274. * In this case the connection point name must be the name of the uniform to use.
  20275. * Can only be set on inputs
  20276. */
  20277. get isUniform(): boolean;
  20278. set isUniform(value: boolean);
  20279. /**
  20280. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20281. * In this case the connection point name must be the name of the attribute to use
  20282. * Can only be set on inputs
  20283. */
  20284. get isAttribute(): boolean;
  20285. set isAttribute(value: boolean);
  20286. /**
  20287. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20288. * Can only be set on exit points
  20289. */
  20290. get isVarying(): boolean;
  20291. set isVarying(value: boolean);
  20292. /**
  20293. * Gets a boolean indicating that the current connection point is a system value
  20294. */
  20295. get isSystemValue(): boolean;
  20296. /**
  20297. * Gets or sets the current well known value or null if not defined as a system value
  20298. */
  20299. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20300. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20301. /**
  20302. * Gets the current class name
  20303. * @returns the class name
  20304. */
  20305. getClassName(): string;
  20306. /**
  20307. * Animate the input if animationType !== None
  20308. * @param scene defines the rendering scene
  20309. */
  20310. animate(scene: Scene): void;
  20311. private _emitDefine;
  20312. initialize(state: NodeMaterialBuildState): void;
  20313. /**
  20314. * Set the input block to its default value (based on its type)
  20315. */
  20316. setDefaultValue(): void;
  20317. private _emitConstant;
  20318. /** @hidden */
  20319. get _noContextSwitch(): boolean;
  20320. private _emit;
  20321. /** @hidden */
  20322. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20323. /** @hidden */
  20324. _transmit(effect: Effect, scene: Scene): void;
  20325. protected _buildBlock(state: NodeMaterialBuildState): void;
  20326. protected _dumpPropertiesCode(): string;
  20327. dispose(): void;
  20328. serialize(): any;
  20329. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20330. }
  20331. }
  20332. declare module BABYLON {
  20333. /**
  20334. * Enum used to define the compatibility state between two connection points
  20335. */
  20336. export enum NodeMaterialConnectionPointCompatibilityStates {
  20337. /** Points are compatibles */
  20338. Compatible = 0,
  20339. /** Points are incompatible because of their types */
  20340. TypeIncompatible = 1,
  20341. /** Points are incompatible because of their targets (vertex vs fragment) */
  20342. TargetIncompatible = 2
  20343. }
  20344. /**
  20345. * Defines the direction of a connection point
  20346. */
  20347. export enum NodeMaterialConnectionPointDirection {
  20348. /** Input */
  20349. Input = 0,
  20350. /** Output */
  20351. Output = 1
  20352. }
  20353. /**
  20354. * Defines a connection point for a block
  20355. */
  20356. export class NodeMaterialConnectionPoint {
  20357. /** @hidden */
  20358. _ownerBlock: NodeMaterialBlock;
  20359. /** @hidden */
  20360. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20361. private _endpoints;
  20362. private _associatedVariableName;
  20363. private _direction;
  20364. /** @hidden */
  20365. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20366. /** @hidden */
  20367. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20368. private _type;
  20369. /** @hidden */
  20370. _enforceAssociatedVariableName: boolean;
  20371. /** Gets the direction of the point */
  20372. get direction(): NodeMaterialConnectionPointDirection;
  20373. /** Indicates that this connection point needs dual validation before being connected to another point */
  20374. needDualDirectionValidation: boolean;
  20375. /**
  20376. * Gets or sets the additional types supported by this connection point
  20377. */
  20378. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20379. /**
  20380. * Gets or sets the additional types excluded by this connection point
  20381. */
  20382. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20383. /**
  20384. * Observable triggered when this point is connected
  20385. */
  20386. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20387. /**
  20388. * Gets or sets the associated variable name in the shader
  20389. */
  20390. get associatedVariableName(): string;
  20391. set associatedVariableName(value: string);
  20392. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20393. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20394. /**
  20395. * Gets or sets the connection point type (default is float)
  20396. */
  20397. get type(): NodeMaterialBlockConnectionPointTypes;
  20398. set type(value: NodeMaterialBlockConnectionPointTypes);
  20399. /**
  20400. * Gets or sets the connection point name
  20401. */
  20402. name: string;
  20403. /**
  20404. * Gets or sets the connection point name
  20405. */
  20406. displayName: string;
  20407. /**
  20408. * Gets or sets a boolean indicating that this connection point can be omitted
  20409. */
  20410. isOptional: boolean;
  20411. /**
  20412. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20413. */
  20414. isExposedOnFrame: boolean;
  20415. /**
  20416. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20417. */
  20418. define: string;
  20419. /** @hidden */
  20420. _prioritizeVertex: boolean;
  20421. private _target;
  20422. /** Gets or sets the target of that connection point */
  20423. get target(): NodeMaterialBlockTargets;
  20424. set target(value: NodeMaterialBlockTargets);
  20425. /**
  20426. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20427. */
  20428. get isConnected(): boolean;
  20429. /**
  20430. * Gets a boolean indicating that the current point is connected to an input block
  20431. */
  20432. get isConnectedToInputBlock(): boolean;
  20433. /**
  20434. * Gets a the connected input block (if any)
  20435. */
  20436. get connectInputBlock(): Nullable<InputBlock>;
  20437. /** Get the other side of the connection (if any) */
  20438. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20439. /** Get the block that owns this connection point */
  20440. get ownerBlock(): NodeMaterialBlock;
  20441. /** Get the block connected on the other side of this connection (if any) */
  20442. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20443. /** Get the block connected on the endpoints of this connection (if any) */
  20444. get connectedBlocks(): Array<NodeMaterialBlock>;
  20445. /** Gets the list of connected endpoints */
  20446. get endpoints(): NodeMaterialConnectionPoint[];
  20447. /** Gets a boolean indicating if that output point is connected to at least one input */
  20448. get hasEndpoints(): boolean;
  20449. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20450. get isConnectedInVertexShader(): boolean;
  20451. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20452. get isConnectedInFragmentShader(): boolean;
  20453. /**
  20454. * Creates a block suitable to be used as an input for this input point.
  20455. * If null is returned, a block based on the point type will be created.
  20456. * @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
  20457. */
  20458. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20459. /**
  20460. * Creates a new connection point
  20461. * @param name defines the connection point name
  20462. * @param ownerBlock defines the block hosting this connection point
  20463. * @param direction defines the direction of the connection point
  20464. */
  20465. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20466. /**
  20467. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20468. * @returns the class name
  20469. */
  20470. getClassName(): string;
  20471. /**
  20472. * Gets a boolean indicating if the current point can be connected to another point
  20473. * @param connectionPoint defines the other connection point
  20474. * @returns a boolean
  20475. */
  20476. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20477. /**
  20478. * Gets a number indicating if the current point can be connected to another point
  20479. * @param connectionPoint defines the other connection point
  20480. * @returns a number defining the compatibility state
  20481. */
  20482. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20483. /**
  20484. * Connect this point to another connection point
  20485. * @param connectionPoint defines the other connection point
  20486. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20487. * @returns the current connection point
  20488. */
  20489. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20490. /**
  20491. * Disconnect this point from one of his endpoint
  20492. * @param endpoint defines the other connection point
  20493. * @returns the current connection point
  20494. */
  20495. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20496. /**
  20497. * Serializes this point in a JSON representation
  20498. * @param isInput defines if the connection point is an input (default is true)
  20499. * @returns the serialized point object
  20500. */
  20501. serialize(isInput?: boolean): any;
  20502. /**
  20503. * Release resources
  20504. */
  20505. dispose(): void;
  20506. }
  20507. }
  20508. declare module BABYLON {
  20509. /**
  20510. * Enum used to define the material modes
  20511. */
  20512. export enum NodeMaterialModes {
  20513. /** Regular material */
  20514. Material = 0,
  20515. /** For post process */
  20516. PostProcess = 1,
  20517. /** For particle system */
  20518. Particle = 2
  20519. }
  20520. }
  20521. declare module BABYLON {
  20522. /**
  20523. * Block used to read a texture from a sampler
  20524. */
  20525. export class TextureBlock extends NodeMaterialBlock {
  20526. private _defineName;
  20527. private _linearDefineName;
  20528. private _gammaDefineName;
  20529. private _tempTextureRead;
  20530. private _samplerName;
  20531. private _transformedUVName;
  20532. private _textureTransformName;
  20533. private _textureInfoName;
  20534. private _mainUVName;
  20535. private _mainUVDefineName;
  20536. private _fragmentOnly;
  20537. /**
  20538. * Gets or sets the texture associated with the node
  20539. */
  20540. texture: Nullable<Texture>;
  20541. /**
  20542. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20543. */
  20544. convertToGammaSpace: boolean;
  20545. /**
  20546. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20547. */
  20548. convertToLinearSpace: boolean;
  20549. /**
  20550. * Create a new TextureBlock
  20551. * @param name defines the block name
  20552. */
  20553. constructor(name: string, fragmentOnly?: boolean);
  20554. /**
  20555. * Gets the current class name
  20556. * @returns the class name
  20557. */
  20558. getClassName(): string;
  20559. /**
  20560. * Gets the uv input component
  20561. */
  20562. get uv(): NodeMaterialConnectionPoint;
  20563. /**
  20564. * Gets the rgba output component
  20565. */
  20566. get rgba(): NodeMaterialConnectionPoint;
  20567. /**
  20568. * Gets the rgb output component
  20569. */
  20570. get rgb(): NodeMaterialConnectionPoint;
  20571. /**
  20572. * Gets the r output component
  20573. */
  20574. get r(): NodeMaterialConnectionPoint;
  20575. /**
  20576. * Gets the g output component
  20577. */
  20578. get g(): NodeMaterialConnectionPoint;
  20579. /**
  20580. * Gets the b output component
  20581. */
  20582. get b(): NodeMaterialConnectionPoint;
  20583. /**
  20584. * Gets the a output component
  20585. */
  20586. get a(): NodeMaterialConnectionPoint;
  20587. get target(): NodeMaterialBlockTargets;
  20588. autoConfigure(material: NodeMaterial): void;
  20589. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20590. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20591. isReady(): boolean;
  20592. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20593. private get _isMixed();
  20594. private _injectVertexCode;
  20595. private _writeTextureRead;
  20596. private _writeOutput;
  20597. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20598. protected _dumpPropertiesCode(): string;
  20599. serialize(): any;
  20600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20601. }
  20602. }
  20603. declare module BABYLON {
  20604. /** @hidden */
  20605. export var reflectionFunction: {
  20606. name: string;
  20607. shader: string;
  20608. };
  20609. }
  20610. declare module BABYLON {
  20611. /**
  20612. * Base block used to read a reflection texture from a sampler
  20613. */
  20614. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20615. /** @hidden */
  20616. _define3DName: string;
  20617. /** @hidden */
  20618. _defineCubicName: string;
  20619. /** @hidden */
  20620. _defineExplicitName: string;
  20621. /** @hidden */
  20622. _defineProjectionName: string;
  20623. /** @hidden */
  20624. _defineLocalCubicName: string;
  20625. /** @hidden */
  20626. _defineSphericalName: string;
  20627. /** @hidden */
  20628. _definePlanarName: string;
  20629. /** @hidden */
  20630. _defineEquirectangularName: string;
  20631. /** @hidden */
  20632. _defineMirroredEquirectangularFixedName: string;
  20633. /** @hidden */
  20634. _defineEquirectangularFixedName: string;
  20635. /** @hidden */
  20636. _defineSkyboxName: string;
  20637. /** @hidden */
  20638. _defineOppositeZ: string;
  20639. /** @hidden */
  20640. _cubeSamplerName: string;
  20641. /** @hidden */
  20642. _2DSamplerName: string;
  20643. protected _positionUVWName: string;
  20644. protected _directionWName: string;
  20645. protected _reflectionVectorName: string;
  20646. /** @hidden */
  20647. _reflectionCoordsName: string;
  20648. /** @hidden */
  20649. _reflectionMatrixName: string;
  20650. protected _reflectionColorName: string;
  20651. /**
  20652. * Gets or sets the texture associated with the node
  20653. */
  20654. texture: Nullable<BaseTexture>;
  20655. /**
  20656. * Create a new ReflectionTextureBaseBlock
  20657. * @param name defines the block name
  20658. */
  20659. constructor(name: string);
  20660. /**
  20661. * Gets the current class name
  20662. * @returns the class name
  20663. */
  20664. getClassName(): string;
  20665. /**
  20666. * Gets the world position input component
  20667. */
  20668. abstract get position(): NodeMaterialConnectionPoint;
  20669. /**
  20670. * Gets the world position input component
  20671. */
  20672. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20673. /**
  20674. * Gets the world normal input component
  20675. */
  20676. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20677. /**
  20678. * Gets the world input component
  20679. */
  20680. abstract get world(): NodeMaterialConnectionPoint;
  20681. /**
  20682. * Gets the camera (or eye) position component
  20683. */
  20684. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20685. /**
  20686. * Gets the view input component
  20687. */
  20688. abstract get view(): NodeMaterialConnectionPoint;
  20689. protected _getTexture(): Nullable<BaseTexture>;
  20690. autoConfigure(material: NodeMaterial): void;
  20691. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20692. isReady(): boolean;
  20693. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20694. /**
  20695. * Gets the code to inject in the vertex shader
  20696. * @param state current state of the node material building
  20697. * @returns the shader code
  20698. */
  20699. handleVertexSide(state: NodeMaterialBuildState): string;
  20700. /**
  20701. * Handles the inits for the fragment code path
  20702. * @param state node material build state
  20703. */
  20704. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20705. /**
  20706. * Generates the reflection coords code for the fragment code path
  20707. * @param worldNormalVarName name of the world normal variable
  20708. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20709. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20710. * @returns the shader code
  20711. */
  20712. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20713. /**
  20714. * Generates the reflection color code for the fragment code path
  20715. * @param lodVarName name of the lod variable
  20716. * @param swizzleLookupTexture swizzle to use for the final color variable
  20717. * @returns the shader code
  20718. */
  20719. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20720. /**
  20721. * Generates the code corresponding to the connected output points
  20722. * @param state node material build state
  20723. * @param varName name of the variable to output
  20724. * @returns the shader code
  20725. */
  20726. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20727. protected _buildBlock(state: NodeMaterialBuildState): this;
  20728. protected _dumpPropertiesCode(): string;
  20729. serialize(): any;
  20730. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20731. }
  20732. }
  20733. declare module BABYLON {
  20734. /**
  20735. * Defines a connection point to be used for points with a custom object type
  20736. */
  20737. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20738. private _blockType;
  20739. private _blockName;
  20740. private _nameForCheking?;
  20741. /**
  20742. * Creates a new connection point
  20743. * @param name defines the connection point name
  20744. * @param ownerBlock defines the block hosting this connection point
  20745. * @param direction defines the direction of the connection point
  20746. */
  20747. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20748. /**
  20749. * Gets a number indicating if the current point can be connected to another point
  20750. * @param connectionPoint defines the other connection point
  20751. * @returns a number defining the compatibility state
  20752. */
  20753. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20754. /**
  20755. * Creates a block suitable to be used as an input for this input point.
  20756. * If null is returned, a block based on the point type will be created.
  20757. * @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
  20758. */
  20759. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20760. }
  20761. }
  20762. declare module BABYLON {
  20763. /**
  20764. * Enum defining the type of properties that can be edited in the property pages in the NME
  20765. */
  20766. export enum PropertyTypeForEdition {
  20767. /** property is a boolean */
  20768. Boolean = 0,
  20769. /** property is a float */
  20770. Float = 1,
  20771. /** property is a Vector2 */
  20772. Vector2 = 2,
  20773. /** property is a list of values */
  20774. List = 3
  20775. }
  20776. /**
  20777. * Interface that defines an option in a variable of type list
  20778. */
  20779. export interface IEditablePropertyListOption {
  20780. /** label of the option */
  20781. "label": string;
  20782. /** value of the option */
  20783. "value": number;
  20784. }
  20785. /**
  20786. * Interface that defines the options available for an editable property
  20787. */
  20788. export interface IEditablePropertyOption {
  20789. /** min value */
  20790. "min"?: number;
  20791. /** max value */
  20792. "max"?: number;
  20793. /** notifiers: indicates which actions to take when the property is changed */
  20794. "notifiers"?: {
  20795. /** the material should be rebuilt */
  20796. "rebuild"?: boolean;
  20797. /** the preview should be updated */
  20798. "update"?: boolean;
  20799. };
  20800. /** list of the options for a variable of type list */
  20801. "options"?: IEditablePropertyListOption[];
  20802. }
  20803. /**
  20804. * Interface that describes an editable property
  20805. */
  20806. export interface IPropertyDescriptionForEdition {
  20807. /** name of the property */
  20808. "propertyName": string;
  20809. /** display name of the property */
  20810. "displayName": string;
  20811. /** type of the property */
  20812. "type": PropertyTypeForEdition;
  20813. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20814. "groupName": string;
  20815. /** options for the property */
  20816. "options": IEditablePropertyOption;
  20817. }
  20818. /**
  20819. * Decorator that flags a property in a node material block as being editable
  20820. */
  20821. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20822. }
  20823. declare module BABYLON {
  20824. /**
  20825. * Block used to implement the refraction part of the sub surface module of the PBR material
  20826. */
  20827. export class RefractionBlock extends NodeMaterialBlock {
  20828. /** @hidden */
  20829. _define3DName: string;
  20830. /** @hidden */
  20831. _refractionMatrixName: string;
  20832. /** @hidden */
  20833. _defineLODRefractionAlpha: string;
  20834. /** @hidden */
  20835. _defineLinearSpecularRefraction: string;
  20836. /** @hidden */
  20837. _defineOppositeZ: string;
  20838. /** @hidden */
  20839. _cubeSamplerName: string;
  20840. /** @hidden */
  20841. _2DSamplerName: string;
  20842. /** @hidden */
  20843. _vRefractionMicrosurfaceInfosName: string;
  20844. /** @hidden */
  20845. _vRefractionInfosName: string;
  20846. private _scene;
  20847. /**
  20848. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20849. * Materials half opaque for instance using refraction could benefit from this control.
  20850. */
  20851. linkRefractionWithTransparency: boolean;
  20852. /**
  20853. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20854. */
  20855. invertRefractionY: boolean;
  20856. /**
  20857. * Gets or sets the texture associated with the node
  20858. */
  20859. texture: Nullable<BaseTexture>;
  20860. /**
  20861. * Create a new RefractionBlock
  20862. * @param name defines the block name
  20863. */
  20864. constructor(name: string);
  20865. /**
  20866. * Gets the current class name
  20867. * @returns the class name
  20868. */
  20869. getClassName(): string;
  20870. /**
  20871. * Gets the intensity input component
  20872. */
  20873. get intensity(): NodeMaterialConnectionPoint;
  20874. /**
  20875. * Gets the index of refraction input component
  20876. */
  20877. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20878. /**
  20879. * Gets the tint at distance input component
  20880. */
  20881. get tintAtDistance(): NodeMaterialConnectionPoint;
  20882. /**
  20883. * Gets the view input component
  20884. */
  20885. get view(): NodeMaterialConnectionPoint;
  20886. /**
  20887. * Gets the refraction object output component
  20888. */
  20889. get refraction(): NodeMaterialConnectionPoint;
  20890. /**
  20891. * Returns true if the block has a texture
  20892. */
  20893. get hasTexture(): boolean;
  20894. protected _getTexture(): Nullable<BaseTexture>;
  20895. autoConfigure(material: NodeMaterial): void;
  20896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20897. isReady(): boolean;
  20898. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20899. /**
  20900. * Gets the main code of the block (fragment side)
  20901. * @param state current state of the node material building
  20902. * @returns the shader code
  20903. */
  20904. getCode(state: NodeMaterialBuildState): string;
  20905. protected _buildBlock(state: NodeMaterialBuildState): this;
  20906. protected _dumpPropertiesCode(): string;
  20907. serialize(): any;
  20908. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20909. }
  20910. }
  20911. declare module BABYLON {
  20912. /**
  20913. * Base block used as input for post process
  20914. */
  20915. export class CurrentScreenBlock extends NodeMaterialBlock {
  20916. private _samplerName;
  20917. private _linearDefineName;
  20918. private _gammaDefineName;
  20919. private _mainUVName;
  20920. private _tempTextureRead;
  20921. /**
  20922. * Gets or sets the texture associated with the node
  20923. */
  20924. texture: Nullable<BaseTexture>;
  20925. /**
  20926. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20927. */
  20928. convertToGammaSpace: boolean;
  20929. /**
  20930. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20931. */
  20932. convertToLinearSpace: boolean;
  20933. /**
  20934. * Create a new CurrentScreenBlock
  20935. * @param name defines the block name
  20936. */
  20937. constructor(name: string);
  20938. /**
  20939. * Gets the current class name
  20940. * @returns the class name
  20941. */
  20942. getClassName(): string;
  20943. /**
  20944. * Gets the uv input component
  20945. */
  20946. get uv(): NodeMaterialConnectionPoint;
  20947. /**
  20948. * Gets the rgba output component
  20949. */
  20950. get rgba(): NodeMaterialConnectionPoint;
  20951. /**
  20952. * Gets the rgb output component
  20953. */
  20954. get rgb(): NodeMaterialConnectionPoint;
  20955. /**
  20956. * Gets the r output component
  20957. */
  20958. get r(): NodeMaterialConnectionPoint;
  20959. /**
  20960. * Gets the g output component
  20961. */
  20962. get g(): NodeMaterialConnectionPoint;
  20963. /**
  20964. * Gets the b output component
  20965. */
  20966. get b(): NodeMaterialConnectionPoint;
  20967. /**
  20968. * Gets the a output component
  20969. */
  20970. get a(): NodeMaterialConnectionPoint;
  20971. /**
  20972. * Initialize the block and prepare the context for build
  20973. * @param state defines the state that will be used for the build
  20974. */
  20975. initialize(state: NodeMaterialBuildState): void;
  20976. get target(): NodeMaterialBlockTargets;
  20977. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20978. isReady(): boolean;
  20979. private _injectVertexCode;
  20980. private _writeTextureRead;
  20981. private _writeOutput;
  20982. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20983. serialize(): any;
  20984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20985. }
  20986. }
  20987. declare module BABYLON {
  20988. /**
  20989. * Base block used for the particle texture
  20990. */
  20991. export class ParticleTextureBlock extends NodeMaterialBlock {
  20992. private _samplerName;
  20993. private _linearDefineName;
  20994. private _gammaDefineName;
  20995. private _tempTextureRead;
  20996. /**
  20997. * Gets or sets the texture associated with the node
  20998. */
  20999. texture: Nullable<BaseTexture>;
  21000. /**
  21001. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21002. */
  21003. convertToGammaSpace: boolean;
  21004. /**
  21005. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21006. */
  21007. convertToLinearSpace: boolean;
  21008. /**
  21009. * Create a new ParticleTextureBlock
  21010. * @param name defines the block name
  21011. */
  21012. constructor(name: string);
  21013. /**
  21014. * Gets the current class name
  21015. * @returns the class name
  21016. */
  21017. getClassName(): string;
  21018. /**
  21019. * Gets the uv input component
  21020. */
  21021. get uv(): NodeMaterialConnectionPoint;
  21022. /**
  21023. * Gets the rgba output component
  21024. */
  21025. get rgba(): NodeMaterialConnectionPoint;
  21026. /**
  21027. * Gets the rgb output component
  21028. */
  21029. get rgb(): NodeMaterialConnectionPoint;
  21030. /**
  21031. * Gets the r output component
  21032. */
  21033. get r(): NodeMaterialConnectionPoint;
  21034. /**
  21035. * Gets the g output component
  21036. */
  21037. get g(): NodeMaterialConnectionPoint;
  21038. /**
  21039. * Gets the b output component
  21040. */
  21041. get b(): NodeMaterialConnectionPoint;
  21042. /**
  21043. * Gets the a output component
  21044. */
  21045. get a(): NodeMaterialConnectionPoint;
  21046. /**
  21047. * Initialize the block and prepare the context for build
  21048. * @param state defines the state that will be used for the build
  21049. */
  21050. initialize(state: NodeMaterialBuildState): void;
  21051. autoConfigure(material: NodeMaterial): void;
  21052. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21053. isReady(): boolean;
  21054. private _writeOutput;
  21055. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21056. serialize(): any;
  21057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21058. }
  21059. }
  21060. declare module BABYLON {
  21061. /**
  21062. * Class used to store shared data between 2 NodeMaterialBuildState
  21063. */
  21064. export class NodeMaterialBuildStateSharedData {
  21065. /**
  21066. * Gets the list of emitted varyings
  21067. */
  21068. temps: string[];
  21069. /**
  21070. * Gets the list of emitted varyings
  21071. */
  21072. varyings: string[];
  21073. /**
  21074. * Gets the varying declaration string
  21075. */
  21076. varyingDeclaration: string;
  21077. /**
  21078. * Input blocks
  21079. */
  21080. inputBlocks: InputBlock[];
  21081. /**
  21082. * Input blocks
  21083. */
  21084. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21085. /**
  21086. * Bindable blocks (Blocks that need to set data to the effect)
  21087. */
  21088. bindableBlocks: NodeMaterialBlock[];
  21089. /**
  21090. * List of blocks that can provide a compilation fallback
  21091. */
  21092. blocksWithFallbacks: NodeMaterialBlock[];
  21093. /**
  21094. * List of blocks that can provide a define update
  21095. */
  21096. blocksWithDefines: NodeMaterialBlock[];
  21097. /**
  21098. * List of blocks that can provide a repeatable content
  21099. */
  21100. repeatableContentBlocks: NodeMaterialBlock[];
  21101. /**
  21102. * List of blocks that can provide a dynamic list of uniforms
  21103. */
  21104. dynamicUniformBlocks: NodeMaterialBlock[];
  21105. /**
  21106. * List of blocks that can block the isReady function for the material
  21107. */
  21108. blockingBlocks: NodeMaterialBlock[];
  21109. /**
  21110. * Gets the list of animated inputs
  21111. */
  21112. animatedInputs: InputBlock[];
  21113. /**
  21114. * Build Id used to avoid multiple recompilations
  21115. */
  21116. buildId: number;
  21117. /** List of emitted variables */
  21118. variableNames: {
  21119. [key: string]: number;
  21120. };
  21121. /** List of emitted defines */
  21122. defineNames: {
  21123. [key: string]: number;
  21124. };
  21125. /** Should emit comments? */
  21126. emitComments: boolean;
  21127. /** Emit build activity */
  21128. verbose: boolean;
  21129. /** Gets or sets the hosting scene */
  21130. scene: Scene;
  21131. /**
  21132. * Gets the compilation hints emitted at compilation time
  21133. */
  21134. hints: {
  21135. needWorldViewMatrix: boolean;
  21136. needWorldViewProjectionMatrix: boolean;
  21137. needAlphaBlending: boolean;
  21138. needAlphaTesting: boolean;
  21139. };
  21140. /**
  21141. * List of compilation checks
  21142. */
  21143. checks: {
  21144. emitVertex: boolean;
  21145. emitFragment: boolean;
  21146. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21147. };
  21148. /**
  21149. * Is vertex program allowed to be empty?
  21150. */
  21151. allowEmptyVertexProgram: boolean;
  21152. /** Creates a new shared data */
  21153. constructor();
  21154. /**
  21155. * Emits console errors and exceptions if there is a failing check
  21156. */
  21157. emitErrors(): void;
  21158. }
  21159. }
  21160. declare module BABYLON {
  21161. /**
  21162. * Class used to store node based material build state
  21163. */
  21164. export class NodeMaterialBuildState {
  21165. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21166. supportUniformBuffers: boolean;
  21167. /**
  21168. * Gets the list of emitted attributes
  21169. */
  21170. attributes: string[];
  21171. /**
  21172. * Gets the list of emitted uniforms
  21173. */
  21174. uniforms: string[];
  21175. /**
  21176. * Gets the list of emitted constants
  21177. */
  21178. constants: string[];
  21179. /**
  21180. * Gets the list of emitted samplers
  21181. */
  21182. samplers: string[];
  21183. /**
  21184. * Gets the list of emitted functions
  21185. */
  21186. functions: {
  21187. [key: string]: string;
  21188. };
  21189. /**
  21190. * Gets the list of emitted extensions
  21191. */
  21192. extensions: {
  21193. [key: string]: string;
  21194. };
  21195. /**
  21196. * Gets the target of the compilation state
  21197. */
  21198. target: NodeMaterialBlockTargets;
  21199. /**
  21200. * Gets the list of emitted counters
  21201. */
  21202. counters: {
  21203. [key: string]: number;
  21204. };
  21205. /**
  21206. * Shared data between multiple NodeMaterialBuildState instances
  21207. */
  21208. sharedData: NodeMaterialBuildStateSharedData;
  21209. /** @hidden */
  21210. _vertexState: NodeMaterialBuildState;
  21211. /** @hidden */
  21212. _attributeDeclaration: string;
  21213. /** @hidden */
  21214. _uniformDeclaration: string;
  21215. /** @hidden */
  21216. _constantDeclaration: string;
  21217. /** @hidden */
  21218. _samplerDeclaration: string;
  21219. /** @hidden */
  21220. _varyingTransfer: string;
  21221. /** @hidden */
  21222. _injectAtEnd: string;
  21223. private _repeatableContentAnchorIndex;
  21224. /** @hidden */
  21225. _builtCompilationString: string;
  21226. /**
  21227. * Gets the emitted compilation strings
  21228. */
  21229. compilationString: string;
  21230. /**
  21231. * Finalize the compilation strings
  21232. * @param state defines the current compilation state
  21233. */
  21234. finalize(state: NodeMaterialBuildState): void;
  21235. /** @hidden */
  21236. get _repeatableContentAnchor(): string;
  21237. /** @hidden */
  21238. _getFreeVariableName(prefix: string): string;
  21239. /** @hidden */
  21240. _getFreeDefineName(prefix: string): string;
  21241. /** @hidden */
  21242. _excludeVariableName(name: string): void;
  21243. /** @hidden */
  21244. _emit2DSampler(name: string): void;
  21245. /** @hidden */
  21246. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21247. /** @hidden */
  21248. _emitExtension(name: string, extension: string, define?: string): void;
  21249. /** @hidden */
  21250. _emitFunction(name: string, code: string, comments: string): void;
  21251. /** @hidden */
  21252. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21253. replaceStrings?: {
  21254. search: RegExp;
  21255. replace: string;
  21256. }[];
  21257. repeatKey?: string;
  21258. }): string;
  21259. /** @hidden */
  21260. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21261. repeatKey?: string;
  21262. removeAttributes?: boolean;
  21263. removeUniforms?: boolean;
  21264. removeVaryings?: boolean;
  21265. removeIfDef?: boolean;
  21266. replaceStrings?: {
  21267. search: RegExp;
  21268. replace: string;
  21269. }[];
  21270. }, storeKey?: string): void;
  21271. /** @hidden */
  21272. _registerTempVariable(name: string): boolean;
  21273. /** @hidden */
  21274. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21275. /** @hidden */
  21276. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21277. /** @hidden */
  21278. _emitFloat(value: number): string;
  21279. }
  21280. }
  21281. declare module BABYLON {
  21282. /**
  21283. * Helper class used to generate session unique ID
  21284. */
  21285. export class UniqueIdGenerator {
  21286. private static _UniqueIdCounter;
  21287. /**
  21288. * Gets an unique (relatively to the current scene) Id
  21289. */
  21290. static get UniqueId(): number;
  21291. }
  21292. }
  21293. declare module BABYLON {
  21294. /**
  21295. * Defines a block that can be used inside a node based material
  21296. */
  21297. export class NodeMaterialBlock {
  21298. private _buildId;
  21299. private _buildTarget;
  21300. private _target;
  21301. private _isFinalMerger;
  21302. private _isInput;
  21303. protected _isUnique: boolean;
  21304. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21305. inputsAreExclusive: boolean;
  21306. /** @hidden */
  21307. _codeVariableName: string;
  21308. /** @hidden */
  21309. _inputs: NodeMaterialConnectionPoint[];
  21310. /** @hidden */
  21311. _outputs: NodeMaterialConnectionPoint[];
  21312. /** @hidden */
  21313. _preparationId: number;
  21314. /**
  21315. * Gets or sets the name of the block
  21316. */
  21317. name: string;
  21318. /**
  21319. * Gets or sets the unique id of the node
  21320. */
  21321. uniqueId: number;
  21322. /**
  21323. * Gets or sets the comments associated with this block
  21324. */
  21325. comments: string;
  21326. /**
  21327. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21328. */
  21329. get isUnique(): boolean;
  21330. /**
  21331. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21332. */
  21333. get isFinalMerger(): boolean;
  21334. /**
  21335. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21336. */
  21337. get isInput(): boolean;
  21338. /**
  21339. * Gets or sets the build Id
  21340. */
  21341. get buildId(): number;
  21342. set buildId(value: number);
  21343. /**
  21344. * Gets or sets the target of the block
  21345. */
  21346. get target(): NodeMaterialBlockTargets;
  21347. set target(value: NodeMaterialBlockTargets);
  21348. /**
  21349. * Gets the list of input points
  21350. */
  21351. get inputs(): NodeMaterialConnectionPoint[];
  21352. /** Gets the list of output points */
  21353. get outputs(): NodeMaterialConnectionPoint[];
  21354. /**
  21355. * Find an input by its name
  21356. * @param name defines the name of the input to look for
  21357. * @returns the input or null if not found
  21358. */
  21359. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21360. /**
  21361. * Find an output by its name
  21362. * @param name defines the name of the outputto look for
  21363. * @returns the output or null if not found
  21364. */
  21365. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21366. /**
  21367. * Creates a new NodeMaterialBlock
  21368. * @param name defines the block name
  21369. * @param target defines the target of that block (Vertex by default)
  21370. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21371. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21372. */
  21373. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21374. /**
  21375. * Initialize the block and prepare the context for build
  21376. * @param state defines the state that will be used for the build
  21377. */
  21378. initialize(state: NodeMaterialBuildState): void;
  21379. /**
  21380. * Bind data to effect. Will only be called for blocks with isBindable === true
  21381. * @param effect defines the effect to bind data to
  21382. * @param nodeMaterial defines the hosting NodeMaterial
  21383. * @param mesh defines the mesh that will be rendered
  21384. * @param subMesh defines the submesh that will be rendered
  21385. */
  21386. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21387. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21388. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21389. protected _writeFloat(value: number): string;
  21390. /**
  21391. * Gets the current class name e.g. "NodeMaterialBlock"
  21392. * @returns the class name
  21393. */
  21394. getClassName(): string;
  21395. /**
  21396. * Register a new input. Must be called inside a block constructor
  21397. * @param name defines the connection point name
  21398. * @param type defines the connection point type
  21399. * @param isOptional defines a boolean indicating that this input can be omitted
  21400. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21401. * @param point an already created connection point. If not provided, create a new one
  21402. * @returns the current block
  21403. */
  21404. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21405. /**
  21406. * Register a new output. Must be called inside a block constructor
  21407. * @param name defines the connection point name
  21408. * @param type defines the connection point type
  21409. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21410. * @param point an already created connection point. If not provided, create a new one
  21411. * @returns the current block
  21412. */
  21413. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21414. /**
  21415. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21416. * @param forOutput defines an optional connection point to check compatibility with
  21417. * @returns the first available input or null
  21418. */
  21419. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21420. /**
  21421. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21422. * @param forBlock defines an optional block to check compatibility with
  21423. * @returns the first available input or null
  21424. */
  21425. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21426. /**
  21427. * Gets the sibling of the given output
  21428. * @param current defines the current output
  21429. * @returns the next output in the list or null
  21430. */
  21431. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21432. /**
  21433. * Connect current block with another block
  21434. * @param other defines the block to connect with
  21435. * @param options define the various options to help pick the right connections
  21436. * @returns the current block
  21437. */
  21438. connectTo(other: NodeMaterialBlock, options?: {
  21439. input?: string;
  21440. output?: string;
  21441. outputSwizzle?: string;
  21442. }): this | undefined;
  21443. protected _buildBlock(state: NodeMaterialBuildState): void;
  21444. /**
  21445. * Add uniforms, samplers and uniform buffers at compilation time
  21446. * @param state defines the state to update
  21447. * @param nodeMaterial defines the node material requesting the update
  21448. * @param defines defines the material defines to update
  21449. * @param uniformBuffers defines the list of uniform buffer names
  21450. */
  21451. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21452. /**
  21453. * Add potential fallbacks if shader compilation fails
  21454. * @param mesh defines the mesh to be rendered
  21455. * @param fallbacks defines the current prioritized list of fallbacks
  21456. */
  21457. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21458. /**
  21459. * Initialize defines for shader compilation
  21460. * @param mesh defines the mesh to be rendered
  21461. * @param nodeMaterial defines the node material requesting the update
  21462. * @param defines defines the material defines to update
  21463. * @param useInstances specifies that instances should be used
  21464. */
  21465. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21466. /**
  21467. * Update defines for shader compilation
  21468. * @param mesh defines the mesh to be rendered
  21469. * @param nodeMaterial defines the node material requesting the update
  21470. * @param defines defines the material defines to update
  21471. * @param useInstances specifies that instances should be used
  21472. * @param subMesh defines which submesh to render
  21473. */
  21474. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21475. /**
  21476. * Lets the block try to connect some inputs automatically
  21477. * @param material defines the hosting NodeMaterial
  21478. */
  21479. autoConfigure(material: NodeMaterial): void;
  21480. /**
  21481. * Function called when a block is declared as repeatable content generator
  21482. * @param vertexShaderState defines the current compilation state for the vertex shader
  21483. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21484. * @param mesh defines the mesh to be rendered
  21485. * @param defines defines the material defines to update
  21486. */
  21487. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21488. /**
  21489. * Checks if the block is ready
  21490. * @param mesh defines the mesh to be rendered
  21491. * @param nodeMaterial defines the node material requesting the update
  21492. * @param defines defines the material defines to update
  21493. * @param useInstances specifies that instances should be used
  21494. * @returns true if the block is ready
  21495. */
  21496. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21497. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21498. private _processBuild;
  21499. /**
  21500. * Compile the current node and generate the shader code
  21501. * @param state defines the current compilation state (uniforms, samplers, current string)
  21502. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21503. * @returns true if already built
  21504. */
  21505. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21506. protected _inputRename(name: string): string;
  21507. protected _outputRename(name: string): string;
  21508. protected _dumpPropertiesCode(): string;
  21509. /** @hidden */
  21510. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21511. /** @hidden */
  21512. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21513. /**
  21514. * Clone the current block to a new identical block
  21515. * @param scene defines the hosting scene
  21516. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21517. * @returns a copy of the current block
  21518. */
  21519. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21520. /**
  21521. * Serializes this block in a JSON representation
  21522. * @returns the serialized block object
  21523. */
  21524. serialize(): any;
  21525. /** @hidden */
  21526. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21527. private _deserializePortDisplayNamesAndExposedOnFrame;
  21528. /**
  21529. * Release resources
  21530. */
  21531. dispose(): void;
  21532. }
  21533. }
  21534. declare module BABYLON {
  21535. /**
  21536. * Base class of materials working in push mode in babylon JS
  21537. * @hidden
  21538. */
  21539. export class PushMaterial extends Material {
  21540. protected _activeEffect: Effect;
  21541. protected _normalMatrix: Matrix;
  21542. constructor(name: string, scene: Scene);
  21543. getEffect(): Effect;
  21544. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21545. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21546. /**
  21547. * Binds the given world matrix to the active effect
  21548. *
  21549. * @param world the matrix to bind
  21550. */
  21551. bindOnlyWorldMatrix(world: Matrix): void;
  21552. /**
  21553. * Binds the given normal matrix to the active effect
  21554. *
  21555. * @param normalMatrix the matrix to bind
  21556. */
  21557. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21558. bind(world: Matrix, mesh?: Mesh): void;
  21559. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21560. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21561. }
  21562. }
  21563. declare module BABYLON {
  21564. /**
  21565. * Root class for all node material optimizers
  21566. */
  21567. export class NodeMaterialOptimizer {
  21568. /**
  21569. * Function used to optimize a NodeMaterial graph
  21570. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21571. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21572. */
  21573. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21574. }
  21575. }
  21576. declare module BABYLON {
  21577. /**
  21578. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21579. */
  21580. export class TransformBlock extends NodeMaterialBlock {
  21581. /**
  21582. * Defines the value to use to complement W value to transform it to a Vector4
  21583. */
  21584. complementW: number;
  21585. /**
  21586. * Defines the value to use to complement z value to transform it to a Vector4
  21587. */
  21588. complementZ: number;
  21589. /**
  21590. * Creates a new TransformBlock
  21591. * @param name defines the block name
  21592. */
  21593. constructor(name: string);
  21594. /**
  21595. * Gets the current class name
  21596. * @returns the class name
  21597. */
  21598. getClassName(): string;
  21599. /**
  21600. * Gets the vector input
  21601. */
  21602. get vector(): NodeMaterialConnectionPoint;
  21603. /**
  21604. * Gets the output component
  21605. */
  21606. get output(): NodeMaterialConnectionPoint;
  21607. /**
  21608. * Gets the xyz output component
  21609. */
  21610. get xyz(): NodeMaterialConnectionPoint;
  21611. /**
  21612. * Gets the matrix transform input
  21613. */
  21614. get transform(): NodeMaterialConnectionPoint;
  21615. protected _buildBlock(state: NodeMaterialBuildState): this;
  21616. /**
  21617. * Update defines for shader compilation
  21618. * @param mesh defines the mesh to be rendered
  21619. * @param nodeMaterial defines the node material requesting the update
  21620. * @param defines defines the material defines to update
  21621. * @param useInstances specifies that instances should be used
  21622. * @param subMesh defines which submesh to render
  21623. */
  21624. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21625. serialize(): any;
  21626. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21627. protected _dumpPropertiesCode(): string;
  21628. }
  21629. }
  21630. declare module BABYLON {
  21631. /**
  21632. * Block used to output the vertex position
  21633. */
  21634. export class VertexOutputBlock extends NodeMaterialBlock {
  21635. /**
  21636. * Creates a new VertexOutputBlock
  21637. * @param name defines the block name
  21638. */
  21639. constructor(name: string);
  21640. /**
  21641. * Gets the current class name
  21642. * @returns the class name
  21643. */
  21644. getClassName(): string;
  21645. /**
  21646. * Gets the vector input component
  21647. */
  21648. get vector(): NodeMaterialConnectionPoint;
  21649. protected _buildBlock(state: NodeMaterialBuildState): this;
  21650. }
  21651. }
  21652. declare module BABYLON {
  21653. /**
  21654. * Block used to output the final color
  21655. */
  21656. export class FragmentOutputBlock extends NodeMaterialBlock {
  21657. /**
  21658. * Create a new FragmentOutputBlock
  21659. * @param name defines the block name
  21660. */
  21661. constructor(name: string);
  21662. /**
  21663. * Gets the current class name
  21664. * @returns the class name
  21665. */
  21666. getClassName(): string;
  21667. /**
  21668. * Gets the rgba input component
  21669. */
  21670. get rgba(): NodeMaterialConnectionPoint;
  21671. /**
  21672. * Gets the rgb input component
  21673. */
  21674. get rgb(): NodeMaterialConnectionPoint;
  21675. /**
  21676. * Gets the a input component
  21677. */
  21678. get a(): NodeMaterialConnectionPoint;
  21679. protected _buildBlock(state: NodeMaterialBuildState): this;
  21680. }
  21681. }
  21682. declare module BABYLON {
  21683. /**
  21684. * Block used for the particle ramp gradient section
  21685. */
  21686. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21687. /**
  21688. * Create a new ParticleRampGradientBlock
  21689. * @param name defines the block name
  21690. */
  21691. constructor(name: string);
  21692. /**
  21693. * Gets the current class name
  21694. * @returns the class name
  21695. */
  21696. getClassName(): string;
  21697. /**
  21698. * Gets the color input component
  21699. */
  21700. get color(): NodeMaterialConnectionPoint;
  21701. /**
  21702. * Gets the rampColor output component
  21703. */
  21704. get rampColor(): NodeMaterialConnectionPoint;
  21705. /**
  21706. * Initialize the block and prepare the context for build
  21707. * @param state defines the state that will be used for the build
  21708. */
  21709. initialize(state: NodeMaterialBuildState): void;
  21710. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21711. }
  21712. }
  21713. declare module BABYLON {
  21714. /**
  21715. * Block used for the particle blend multiply section
  21716. */
  21717. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21718. /**
  21719. * Create a new ParticleBlendMultiplyBlock
  21720. * @param name defines the block name
  21721. */
  21722. constructor(name: string);
  21723. /**
  21724. * Gets the current class name
  21725. * @returns the class name
  21726. */
  21727. getClassName(): string;
  21728. /**
  21729. * Gets the color input component
  21730. */
  21731. get color(): NodeMaterialConnectionPoint;
  21732. /**
  21733. * Gets the alphaTexture input component
  21734. */
  21735. get alphaTexture(): NodeMaterialConnectionPoint;
  21736. /**
  21737. * Gets the alphaColor input component
  21738. */
  21739. get alphaColor(): NodeMaterialConnectionPoint;
  21740. /**
  21741. * Gets the blendColor output component
  21742. */
  21743. get blendColor(): NodeMaterialConnectionPoint;
  21744. /**
  21745. * Initialize the block and prepare the context for build
  21746. * @param state defines the state that will be used for the build
  21747. */
  21748. initialize(state: NodeMaterialBuildState): void;
  21749. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21750. }
  21751. }
  21752. declare module BABYLON {
  21753. /**
  21754. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21755. */
  21756. export class VectorMergerBlock extends NodeMaterialBlock {
  21757. /**
  21758. * Create a new VectorMergerBlock
  21759. * @param name defines the block name
  21760. */
  21761. constructor(name: string);
  21762. /**
  21763. * Gets the current class name
  21764. * @returns the class name
  21765. */
  21766. getClassName(): string;
  21767. /**
  21768. * Gets the xyz component (input)
  21769. */
  21770. get xyzIn(): NodeMaterialConnectionPoint;
  21771. /**
  21772. * Gets the xy component (input)
  21773. */
  21774. get xyIn(): NodeMaterialConnectionPoint;
  21775. /**
  21776. * Gets the x component (input)
  21777. */
  21778. get x(): NodeMaterialConnectionPoint;
  21779. /**
  21780. * Gets the y component (input)
  21781. */
  21782. get y(): NodeMaterialConnectionPoint;
  21783. /**
  21784. * Gets the z component (input)
  21785. */
  21786. get z(): NodeMaterialConnectionPoint;
  21787. /**
  21788. * Gets the w component (input)
  21789. */
  21790. get w(): NodeMaterialConnectionPoint;
  21791. /**
  21792. * Gets the xyzw component (output)
  21793. */
  21794. get xyzw(): NodeMaterialConnectionPoint;
  21795. /**
  21796. * Gets the xyz component (output)
  21797. */
  21798. get xyzOut(): NodeMaterialConnectionPoint;
  21799. /**
  21800. * Gets the xy component (output)
  21801. */
  21802. get xyOut(): NodeMaterialConnectionPoint;
  21803. /**
  21804. * Gets the xy component (output)
  21805. * @deprecated Please use xyOut instead.
  21806. */
  21807. get xy(): NodeMaterialConnectionPoint;
  21808. /**
  21809. * Gets the xyz component (output)
  21810. * @deprecated Please use xyzOut instead.
  21811. */
  21812. get xyz(): NodeMaterialConnectionPoint;
  21813. protected _buildBlock(state: NodeMaterialBuildState): this;
  21814. }
  21815. }
  21816. declare module BABYLON {
  21817. /**
  21818. * Block used to remap a float from a range to a new one
  21819. */
  21820. export class RemapBlock extends NodeMaterialBlock {
  21821. /**
  21822. * Gets or sets the source range
  21823. */
  21824. sourceRange: Vector2;
  21825. /**
  21826. * Gets or sets the target range
  21827. */
  21828. targetRange: Vector2;
  21829. /**
  21830. * Creates a new RemapBlock
  21831. * @param name defines the block name
  21832. */
  21833. constructor(name: string);
  21834. /**
  21835. * Gets the current class name
  21836. * @returns the class name
  21837. */
  21838. getClassName(): string;
  21839. /**
  21840. * Gets the input component
  21841. */
  21842. get input(): NodeMaterialConnectionPoint;
  21843. /**
  21844. * Gets the source min input component
  21845. */
  21846. get sourceMin(): NodeMaterialConnectionPoint;
  21847. /**
  21848. * Gets the source max input component
  21849. */
  21850. get sourceMax(): NodeMaterialConnectionPoint;
  21851. /**
  21852. * Gets the target min input component
  21853. */
  21854. get targetMin(): NodeMaterialConnectionPoint;
  21855. /**
  21856. * Gets the target max input component
  21857. */
  21858. get targetMax(): NodeMaterialConnectionPoint;
  21859. /**
  21860. * Gets the output component
  21861. */
  21862. get output(): NodeMaterialConnectionPoint;
  21863. protected _buildBlock(state: NodeMaterialBuildState): this;
  21864. protected _dumpPropertiesCode(): string;
  21865. serialize(): any;
  21866. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21867. }
  21868. }
  21869. declare module BABYLON {
  21870. /**
  21871. * Block used to multiply 2 values
  21872. */
  21873. export class MultiplyBlock extends NodeMaterialBlock {
  21874. /**
  21875. * Creates a new MultiplyBlock
  21876. * @param name defines the block name
  21877. */
  21878. constructor(name: string);
  21879. /**
  21880. * Gets the current class name
  21881. * @returns the class name
  21882. */
  21883. getClassName(): string;
  21884. /**
  21885. * Gets the left operand input component
  21886. */
  21887. get left(): NodeMaterialConnectionPoint;
  21888. /**
  21889. * Gets the right operand input component
  21890. */
  21891. get right(): NodeMaterialConnectionPoint;
  21892. /**
  21893. * Gets the output component
  21894. */
  21895. get output(): NodeMaterialConnectionPoint;
  21896. protected _buildBlock(state: NodeMaterialBuildState): this;
  21897. }
  21898. }
  21899. declare module BABYLON {
  21900. /**
  21901. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21902. */
  21903. export class ColorSplitterBlock extends NodeMaterialBlock {
  21904. /**
  21905. * Create a new ColorSplitterBlock
  21906. * @param name defines the block name
  21907. */
  21908. constructor(name: string);
  21909. /**
  21910. * Gets the current class name
  21911. * @returns the class name
  21912. */
  21913. getClassName(): string;
  21914. /**
  21915. * Gets the rgba component (input)
  21916. */
  21917. get rgba(): NodeMaterialConnectionPoint;
  21918. /**
  21919. * Gets the rgb component (input)
  21920. */
  21921. get rgbIn(): NodeMaterialConnectionPoint;
  21922. /**
  21923. * Gets the rgb component (output)
  21924. */
  21925. get rgbOut(): NodeMaterialConnectionPoint;
  21926. /**
  21927. * Gets the r component (output)
  21928. */
  21929. get r(): NodeMaterialConnectionPoint;
  21930. /**
  21931. * Gets the g component (output)
  21932. */
  21933. get g(): NodeMaterialConnectionPoint;
  21934. /**
  21935. * Gets the b component (output)
  21936. */
  21937. get b(): NodeMaterialConnectionPoint;
  21938. /**
  21939. * Gets the a component (output)
  21940. */
  21941. get a(): NodeMaterialConnectionPoint;
  21942. protected _inputRename(name: string): string;
  21943. protected _outputRename(name: string): string;
  21944. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21945. }
  21946. }
  21947. declare module BABYLON {
  21948. /**
  21949. * Interface used to configure the node material editor
  21950. */
  21951. export interface INodeMaterialEditorOptions {
  21952. /** Define the URl to load node editor script */
  21953. editorURL?: string;
  21954. }
  21955. /** @hidden */
  21956. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  21957. NORMAL: boolean;
  21958. TANGENT: boolean;
  21959. UV1: boolean;
  21960. /** BONES */
  21961. NUM_BONE_INFLUENCERS: number;
  21962. BonesPerMesh: number;
  21963. BONETEXTURE: boolean;
  21964. /** MORPH TARGETS */
  21965. MORPHTARGETS: boolean;
  21966. MORPHTARGETS_NORMAL: boolean;
  21967. MORPHTARGETS_TANGENT: boolean;
  21968. MORPHTARGETS_UV: boolean;
  21969. NUM_MORPH_INFLUENCERS: number;
  21970. /** IMAGE PROCESSING */
  21971. IMAGEPROCESSING: boolean;
  21972. VIGNETTE: boolean;
  21973. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21974. VIGNETTEBLENDMODEOPAQUE: boolean;
  21975. TONEMAPPING: boolean;
  21976. TONEMAPPING_ACES: boolean;
  21977. CONTRAST: boolean;
  21978. EXPOSURE: boolean;
  21979. COLORCURVES: boolean;
  21980. COLORGRADING: boolean;
  21981. COLORGRADING3D: boolean;
  21982. SAMPLER3DGREENDEPTH: boolean;
  21983. SAMPLER3DBGRMAP: boolean;
  21984. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21985. /** MISC. */
  21986. BUMPDIRECTUV: number;
  21987. constructor();
  21988. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  21989. }
  21990. /**
  21991. * Class used to configure NodeMaterial
  21992. */
  21993. export interface INodeMaterialOptions {
  21994. /**
  21995. * Defines if blocks should emit comments
  21996. */
  21997. emitComments: boolean;
  21998. }
  21999. /**
  22000. * Class used to create a node based material built by assembling shader blocks
  22001. */
  22002. export class NodeMaterial extends PushMaterial {
  22003. private static _BuildIdGenerator;
  22004. private _options;
  22005. private _vertexCompilationState;
  22006. private _fragmentCompilationState;
  22007. private _sharedData;
  22008. private _buildId;
  22009. private _buildWasSuccessful;
  22010. private _cachedWorldViewMatrix;
  22011. private _cachedWorldViewProjectionMatrix;
  22012. private _optimizers;
  22013. private _animationFrame;
  22014. /** Define the Url to load node editor script */
  22015. static EditorURL: string;
  22016. /** Define the Url to load snippets */
  22017. static SnippetUrl: string;
  22018. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22019. static IgnoreTexturesAtLoadTime: boolean;
  22020. private BJSNODEMATERIALEDITOR;
  22021. /** Get the inspector from bundle or global */
  22022. private _getGlobalNodeMaterialEditor;
  22023. /**
  22024. * Snippet ID if the material was created from the snippet server
  22025. */
  22026. snippetId: string;
  22027. /**
  22028. * Gets or sets data used by visual editor
  22029. * @see https://nme.babylonjs.com
  22030. */
  22031. editorData: any;
  22032. /**
  22033. * 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)
  22034. */
  22035. ignoreAlpha: boolean;
  22036. /**
  22037. * Defines the maximum number of lights that can be used in the material
  22038. */
  22039. maxSimultaneousLights: number;
  22040. /**
  22041. * Observable raised when the material is built
  22042. */
  22043. onBuildObservable: Observable<NodeMaterial>;
  22044. /**
  22045. * Gets or sets the root nodes of the material vertex shader
  22046. */
  22047. _vertexOutputNodes: NodeMaterialBlock[];
  22048. /**
  22049. * Gets or sets the root nodes of the material fragment (pixel) shader
  22050. */
  22051. _fragmentOutputNodes: NodeMaterialBlock[];
  22052. /** Gets or sets options to control the node material overall behavior */
  22053. get options(): INodeMaterialOptions;
  22054. set options(options: INodeMaterialOptions);
  22055. /**
  22056. * Default configuration related to image processing available in the standard Material.
  22057. */
  22058. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22059. /**
  22060. * Gets the image processing configuration used either in this material.
  22061. */
  22062. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22063. /**
  22064. * Sets the Default image processing configuration used either in the this material.
  22065. *
  22066. * If sets to null, the scene one is in use.
  22067. */
  22068. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22069. /**
  22070. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22071. */
  22072. attachedBlocks: NodeMaterialBlock[];
  22073. /**
  22074. * Specifies the mode of the node material
  22075. * @hidden
  22076. */
  22077. _mode: NodeMaterialModes;
  22078. /**
  22079. * Gets the mode property
  22080. */
  22081. get mode(): NodeMaterialModes;
  22082. /**
  22083. * Create a new node based material
  22084. * @param name defines the material name
  22085. * @param scene defines the hosting scene
  22086. * @param options defines creation option
  22087. */
  22088. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22089. /**
  22090. * Gets the current class name of the material e.g. "NodeMaterial"
  22091. * @returns the class name
  22092. */
  22093. getClassName(): string;
  22094. /**
  22095. * Keep track of the image processing observer to allow dispose and replace.
  22096. */
  22097. private _imageProcessingObserver;
  22098. /**
  22099. * Attaches a new image processing configuration to the Standard Material.
  22100. * @param configuration
  22101. */
  22102. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22103. /**
  22104. * Get a block by its name
  22105. * @param name defines the name of the block to retrieve
  22106. * @returns the required block or null if not found
  22107. */
  22108. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22109. /**
  22110. * Get a block by its name
  22111. * @param predicate defines the predicate used to find the good candidate
  22112. * @returns the required block or null if not found
  22113. */
  22114. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22115. /**
  22116. * Get an input block by its name
  22117. * @param predicate defines the predicate used to find the good candidate
  22118. * @returns the required input block or null if not found
  22119. */
  22120. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22121. /**
  22122. * Gets the list of input blocks attached to this material
  22123. * @returns an array of InputBlocks
  22124. */
  22125. getInputBlocks(): InputBlock[];
  22126. /**
  22127. * Adds a new optimizer to the list of optimizers
  22128. * @param optimizer defines the optimizers to add
  22129. * @returns the current material
  22130. */
  22131. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22132. /**
  22133. * Remove an optimizer from the list of optimizers
  22134. * @param optimizer defines the optimizers to remove
  22135. * @returns the current material
  22136. */
  22137. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22138. /**
  22139. * Add a new block to the list of output nodes
  22140. * @param node defines the node to add
  22141. * @returns the current material
  22142. */
  22143. addOutputNode(node: NodeMaterialBlock): this;
  22144. /**
  22145. * Remove a block from the list of root nodes
  22146. * @param node defines the node to remove
  22147. * @returns the current material
  22148. */
  22149. removeOutputNode(node: NodeMaterialBlock): this;
  22150. private _addVertexOutputNode;
  22151. private _removeVertexOutputNode;
  22152. private _addFragmentOutputNode;
  22153. private _removeFragmentOutputNode;
  22154. /**
  22155. * Specifies if the material will require alpha blending
  22156. * @returns a boolean specifying if alpha blending is needed
  22157. */
  22158. needAlphaBlending(): boolean;
  22159. /**
  22160. * Specifies if this material should be rendered in alpha test mode
  22161. * @returns a boolean specifying if an alpha test is needed.
  22162. */
  22163. needAlphaTesting(): boolean;
  22164. private _initializeBlock;
  22165. private _resetDualBlocks;
  22166. /**
  22167. * Remove a block from the current node material
  22168. * @param block defines the block to remove
  22169. */
  22170. removeBlock(block: NodeMaterialBlock): void;
  22171. /**
  22172. * Build the material and generates the inner effect
  22173. * @param verbose defines if the build should log activity
  22174. */
  22175. build(verbose?: boolean): void;
  22176. /**
  22177. * Runs an otpimization phase to try to improve the shader code
  22178. */
  22179. optimize(): void;
  22180. private _prepareDefinesForAttributes;
  22181. /**
  22182. * Create a post process from the material
  22183. * @param camera The camera to apply the render pass to.
  22184. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22186. * @param engine The engine which the post process will be applied. (default: current engine)
  22187. * @param reusable If the post process can be reused on the same frame. (default: false)
  22188. * @param textureType Type of textures used when performing the post process. (default: 0)
  22189. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22190. * @returns the post process created
  22191. */
  22192. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22193. /**
  22194. * Create the post process effect from the material
  22195. * @param postProcess The post process to create the effect for
  22196. */
  22197. createEffectForPostProcess(postProcess: PostProcess): void;
  22198. private _createEffectOrPostProcess;
  22199. private _createEffectForParticles;
  22200. /**
  22201. * Create the effect to be used as the custom effect for a particle system
  22202. * @param particleSystem Particle system to create the effect for
  22203. * @param onCompiled defines a function to call when the effect creation is successful
  22204. * @param onError defines a function to call when the effect creation has failed
  22205. */
  22206. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22207. private _processDefines;
  22208. /**
  22209. * Get if the submesh is ready to be used and all its information available.
  22210. * Child classes can use it to update shaders
  22211. * @param mesh defines the mesh to check
  22212. * @param subMesh defines which submesh to check
  22213. * @param useInstances specifies that instances should be used
  22214. * @returns a boolean indicating that the submesh is ready or not
  22215. */
  22216. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22217. /**
  22218. * Get a string representing the shaders built by the current node graph
  22219. */
  22220. get compiledShaders(): string;
  22221. /**
  22222. * Binds the world matrix to the material
  22223. * @param world defines the world transformation matrix
  22224. */
  22225. bindOnlyWorldMatrix(world: Matrix): void;
  22226. /**
  22227. * Binds the submesh to this material by preparing the effect and shader to draw
  22228. * @param world defines the world transformation matrix
  22229. * @param mesh defines the mesh containing the submesh
  22230. * @param subMesh defines the submesh to bind the material to
  22231. */
  22232. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22233. /**
  22234. * Gets the active textures from the material
  22235. * @returns an array of textures
  22236. */
  22237. getActiveTextures(): BaseTexture[];
  22238. /**
  22239. * Gets the list of texture blocks
  22240. * @returns an array of texture blocks
  22241. */
  22242. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22243. /**
  22244. * Specifies if the material uses a texture
  22245. * @param texture defines the texture to check against the material
  22246. * @returns a boolean specifying if the material uses the texture
  22247. */
  22248. hasTexture(texture: BaseTexture): boolean;
  22249. /**
  22250. * Disposes the material
  22251. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22252. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22253. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22254. */
  22255. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22256. /** Creates the node editor window. */
  22257. private _createNodeEditor;
  22258. /**
  22259. * Launch the node material editor
  22260. * @param config Define the configuration of the editor
  22261. * @return a promise fulfilled when the node editor is visible
  22262. */
  22263. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22264. /**
  22265. * Clear the current material
  22266. */
  22267. clear(): void;
  22268. /**
  22269. * Clear the current material and set it to a default state
  22270. */
  22271. setToDefault(): void;
  22272. /**
  22273. * Clear the current material and set it to a default state for post process
  22274. */
  22275. setToDefaultPostProcess(): void;
  22276. /**
  22277. * Clear the current material and set it to a default state for particle
  22278. */
  22279. setToDefaultParticle(): void;
  22280. /**
  22281. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22282. * @param url defines the url to load from
  22283. * @returns a promise that will fullfil when the material is fully loaded
  22284. */
  22285. loadAsync(url: string): Promise<void>;
  22286. private _gatherBlocks;
  22287. /**
  22288. * Generate a string containing the code declaration required to create an equivalent of this material
  22289. * @returns a string
  22290. */
  22291. generateCode(): string;
  22292. /**
  22293. * Serializes this material in a JSON representation
  22294. * @returns the serialized material object
  22295. */
  22296. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22297. private _restoreConnections;
  22298. /**
  22299. * Clear the current graph and load a new one from a serialization object
  22300. * @param source defines the JSON representation of the material
  22301. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22302. * @param merge defines whether or not the source must be merged or replace the current content
  22303. */
  22304. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22305. /**
  22306. * Makes a duplicate of the current material.
  22307. * @param name - name to use for the new material.
  22308. */
  22309. clone(name: string): NodeMaterial;
  22310. /**
  22311. * Creates a node material from parsed material data
  22312. * @param source defines the JSON representation of the material
  22313. * @param scene defines the hosting scene
  22314. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22315. * @returns a new node material
  22316. */
  22317. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22318. /**
  22319. * Creates a node material from a snippet saved in a remote file
  22320. * @param name defines the name of the material to create
  22321. * @param url defines the url to load from
  22322. * @param scene defines the hosting scene
  22323. * @returns a promise that will resolve to the new node material
  22324. */
  22325. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22326. /**
  22327. * Creates a node material from a snippet saved by the node material editor
  22328. * @param snippetId defines the snippet to load
  22329. * @param scene defines the hosting scene
  22330. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22331. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22332. * @returns a promise that will resolve to the new node material
  22333. */
  22334. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22335. /**
  22336. * Creates a new node material set to default basic configuration
  22337. * @param name defines the name of the material
  22338. * @param scene defines the hosting scene
  22339. * @returns a new NodeMaterial
  22340. */
  22341. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22342. }
  22343. }
  22344. declare module BABYLON {
  22345. /**
  22346. * Size options for a post process
  22347. */
  22348. export type PostProcessOptions = {
  22349. width: number;
  22350. height: number;
  22351. };
  22352. /**
  22353. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22354. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22355. */
  22356. export class PostProcess {
  22357. /** Name of the PostProcess. */
  22358. name: string;
  22359. /**
  22360. * Gets or sets the unique id of the post process
  22361. */
  22362. uniqueId: number;
  22363. /**
  22364. * Width of the texture to apply the post process on
  22365. */
  22366. width: number;
  22367. /**
  22368. * Height of the texture to apply the post process on
  22369. */
  22370. height: number;
  22371. /**
  22372. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22373. */
  22374. nodeMaterialSource: Nullable<NodeMaterial>;
  22375. /**
  22376. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22377. * @hidden
  22378. */
  22379. _outputTexture: Nullable<InternalTexture>;
  22380. /**
  22381. * Sampling mode used by the shader
  22382. * See https://doc.babylonjs.com/classes/3.1/texture
  22383. */
  22384. renderTargetSamplingMode: number;
  22385. /**
  22386. * Clear color to use when screen clearing
  22387. */
  22388. clearColor: Color4;
  22389. /**
  22390. * If the buffer needs to be cleared before applying the post process. (default: true)
  22391. * Should be set to false if shader will overwrite all previous pixels.
  22392. */
  22393. autoClear: boolean;
  22394. /**
  22395. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22396. */
  22397. alphaMode: number;
  22398. /**
  22399. * Sets the setAlphaBlendConstants of the babylon engine
  22400. */
  22401. alphaConstants: Color4;
  22402. /**
  22403. * Animations to be used for the post processing
  22404. */
  22405. animations: Animation[];
  22406. /**
  22407. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22408. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22409. */
  22410. enablePixelPerfectMode: boolean;
  22411. /**
  22412. * Force the postprocess to be applied without taking in account viewport
  22413. */
  22414. forceFullscreenViewport: boolean;
  22415. /**
  22416. * List of inspectable custom properties (used by the Inspector)
  22417. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22418. */
  22419. inspectableCustomProperties: IInspectable[];
  22420. /**
  22421. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22422. *
  22423. * | Value | Type | Description |
  22424. * | ----- | ----------------------------------- | ----------- |
  22425. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22426. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22427. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22428. *
  22429. */
  22430. scaleMode: number;
  22431. /**
  22432. * Force textures to be a power of two (default: false)
  22433. */
  22434. alwaysForcePOT: boolean;
  22435. private _samples;
  22436. /**
  22437. * Number of sample textures (default: 1)
  22438. */
  22439. get samples(): number;
  22440. set samples(n: number);
  22441. /**
  22442. * Modify the scale of the post process to be the same as the viewport (default: false)
  22443. */
  22444. adaptScaleToCurrentViewport: boolean;
  22445. private _camera;
  22446. protected _scene: Scene;
  22447. private _engine;
  22448. private _options;
  22449. private _reusable;
  22450. private _textureType;
  22451. private _textureFormat;
  22452. /**
  22453. * Smart array of input and output textures for the post process.
  22454. * @hidden
  22455. */
  22456. _textures: SmartArray<InternalTexture>;
  22457. /**
  22458. * The index in _textures that corresponds to the output texture.
  22459. * @hidden
  22460. */
  22461. _currentRenderTextureInd: number;
  22462. private _effect;
  22463. private _samplers;
  22464. private _fragmentUrl;
  22465. private _vertexUrl;
  22466. private _parameters;
  22467. private _scaleRatio;
  22468. protected _indexParameters: any;
  22469. private _shareOutputWithPostProcess;
  22470. private _texelSize;
  22471. private _forcedOutputTexture;
  22472. /**
  22473. * Returns the fragment url or shader name used in the post process.
  22474. * @returns the fragment url or name in the shader store.
  22475. */
  22476. getEffectName(): string;
  22477. /**
  22478. * An event triggered when the postprocess is activated.
  22479. */
  22480. onActivateObservable: Observable<Camera>;
  22481. private _onActivateObserver;
  22482. /**
  22483. * A function that is added to the onActivateObservable
  22484. */
  22485. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22486. /**
  22487. * An event triggered when the postprocess changes its size.
  22488. */
  22489. onSizeChangedObservable: Observable<PostProcess>;
  22490. private _onSizeChangedObserver;
  22491. /**
  22492. * A function that is added to the onSizeChangedObservable
  22493. */
  22494. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22495. /**
  22496. * An event triggered when the postprocess applies its effect.
  22497. */
  22498. onApplyObservable: Observable<Effect>;
  22499. private _onApplyObserver;
  22500. /**
  22501. * A function that is added to the onApplyObservable
  22502. */
  22503. set onApply(callback: (effect: Effect) => void);
  22504. /**
  22505. * An event triggered before rendering the postprocess
  22506. */
  22507. onBeforeRenderObservable: Observable<Effect>;
  22508. private _onBeforeRenderObserver;
  22509. /**
  22510. * A function that is added to the onBeforeRenderObservable
  22511. */
  22512. set onBeforeRender(callback: (effect: Effect) => void);
  22513. /**
  22514. * An event triggered after rendering the postprocess
  22515. */
  22516. onAfterRenderObservable: Observable<Effect>;
  22517. private _onAfterRenderObserver;
  22518. /**
  22519. * A function that is added to the onAfterRenderObservable
  22520. */
  22521. set onAfterRender(callback: (efect: Effect) => void);
  22522. /**
  22523. * 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
  22524. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22525. */
  22526. get inputTexture(): InternalTexture;
  22527. set inputTexture(value: InternalTexture);
  22528. /**
  22529. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22530. * the only way to unset it is to use this function to restore its internal state
  22531. */
  22532. restoreDefaultInputTexture(): void;
  22533. /**
  22534. * Gets the camera which post process is applied to.
  22535. * @returns The camera the post process is applied to.
  22536. */
  22537. getCamera(): Camera;
  22538. /**
  22539. * Gets the texel size of the postprocess.
  22540. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22541. */
  22542. get texelSize(): Vector2;
  22543. /**
  22544. * Creates a new instance PostProcess
  22545. * @param name The name of the PostProcess.
  22546. * @param fragmentUrl The url of the fragment shader to be used.
  22547. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22548. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22549. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22550. * @param camera The camera to apply the render pass to.
  22551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22552. * @param engine The engine which the post process will be applied. (default: current engine)
  22553. * @param reusable If the post process can be reused on the same frame. (default: false)
  22554. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22555. * @param textureType Type of textures used when performing the post process. (default: 0)
  22556. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22557. * @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
  22558. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22559. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22560. */
  22561. constructor(
  22562. /** Name of the PostProcess. */
  22563. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  22564. /**
  22565. * Gets a string idenfifying the name of the class
  22566. * @returns "PostProcess" string
  22567. */
  22568. getClassName(): string;
  22569. /**
  22570. * Gets the engine which this post process belongs to.
  22571. * @returns The engine the post process was enabled with.
  22572. */
  22573. getEngine(): Engine;
  22574. /**
  22575. * The effect that is created when initializing the post process.
  22576. * @returns The created effect corresponding the the postprocess.
  22577. */
  22578. getEffect(): Effect;
  22579. /**
  22580. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22581. * @param postProcess The post process to share the output with.
  22582. * @returns This post process.
  22583. */
  22584. shareOutputWith(postProcess: PostProcess): PostProcess;
  22585. /**
  22586. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22587. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22588. */
  22589. useOwnOutput(): void;
  22590. /**
  22591. * Updates the effect with the current post process compile time values and recompiles the shader.
  22592. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22593. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22594. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22595. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  22596. * @param onCompiled Called when the shader has been compiled.
  22597. * @param onError Called if there is an error when compiling a shader.
  22598. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22599. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22600. */
  22601. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  22602. /**
  22603. * The post process is reusable if it can be used multiple times within one frame.
  22604. * @returns If the post process is reusable
  22605. */
  22606. isReusable(): boolean;
  22607. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22608. markTextureDirty(): void;
  22609. /**
  22610. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22611. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  22612. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22613. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22614. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22615. * @returns The target texture that was bound to be written to.
  22616. */
  22617. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22618. /**
  22619. * If the post process is supported.
  22620. */
  22621. get isSupported(): boolean;
  22622. /**
  22623. * The aspect ratio of the output texture.
  22624. */
  22625. get aspectRatio(): number;
  22626. /**
  22627. * Get a value indicating if the post-process is ready to be used
  22628. * @returns true if the post-process is ready (shader is compiled)
  22629. */
  22630. isReady(): boolean;
  22631. /**
  22632. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22633. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22634. */
  22635. apply(): Nullable<Effect>;
  22636. private _disposeTextures;
  22637. /**
  22638. * Disposes the post process.
  22639. * @param camera The camera to dispose the post process on.
  22640. */
  22641. dispose(camera?: Camera): void;
  22642. }
  22643. }
  22644. declare module BABYLON {
  22645. /** @hidden */
  22646. export var kernelBlurVaryingDeclaration: {
  22647. name: string;
  22648. shader: string;
  22649. };
  22650. }
  22651. declare module BABYLON {
  22652. /** @hidden */
  22653. export var kernelBlurFragment: {
  22654. name: string;
  22655. shader: string;
  22656. };
  22657. }
  22658. declare module BABYLON {
  22659. /** @hidden */
  22660. export var kernelBlurFragment2: {
  22661. name: string;
  22662. shader: string;
  22663. };
  22664. }
  22665. declare module BABYLON {
  22666. /** @hidden */
  22667. export var kernelBlurPixelShader: {
  22668. name: string;
  22669. shader: string;
  22670. };
  22671. }
  22672. declare module BABYLON {
  22673. /** @hidden */
  22674. export var kernelBlurVertex: {
  22675. name: string;
  22676. shader: string;
  22677. };
  22678. }
  22679. declare module BABYLON {
  22680. /** @hidden */
  22681. export var kernelBlurVertexShader: {
  22682. name: string;
  22683. shader: string;
  22684. };
  22685. }
  22686. declare module BABYLON {
  22687. /**
  22688. * The Blur Post Process which blurs an image based on a kernel and direction.
  22689. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22690. */
  22691. export class BlurPostProcess extends PostProcess {
  22692. /** The direction in which to blur the image. */
  22693. direction: Vector2;
  22694. private blockCompilation;
  22695. protected _kernel: number;
  22696. protected _idealKernel: number;
  22697. protected _packedFloat: boolean;
  22698. private _staticDefines;
  22699. /**
  22700. * Sets the length in pixels of the blur sample region
  22701. */
  22702. set kernel(v: number);
  22703. /**
  22704. * Gets the length in pixels of the blur sample region
  22705. */
  22706. get kernel(): number;
  22707. /**
  22708. * Sets wether or not the blur needs to unpack/repack floats
  22709. */
  22710. set packedFloat(v: boolean);
  22711. /**
  22712. * Gets wether or not the blur is unpacking/repacking floats
  22713. */
  22714. get packedFloat(): boolean;
  22715. /**
  22716. * Creates a new instance BlurPostProcess
  22717. * @param name The name of the effect.
  22718. * @param direction The direction in which to blur the image.
  22719. * @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.
  22720. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22721. * @param camera The camera to apply the render pass to.
  22722. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22723. * @param engine The engine which the post process will be applied. (default: current engine)
  22724. * @param reusable If the post process can be reused on the same frame. (default: false)
  22725. * @param textureType Type of textures used when performing the post process. (default: 0)
  22726. * @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)
  22727. */
  22728. constructor(name: string,
  22729. /** The direction in which to blur the image. */
  22730. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22731. /**
  22732. * Updates the effect with the current post process compile time values and recompiles the shader.
  22733. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22734. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22735. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22736. * @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
  22737. * @param onCompiled Called when the shader has been compiled.
  22738. * @param onError Called if there is an error when compiling a shader.
  22739. */
  22740. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22741. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22742. /**
  22743. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22744. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22745. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22746. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22747. * The gaps between physical kernels are compensated for in the weighting of the samples
  22748. * @param idealKernel Ideal blur kernel.
  22749. * @return Nearest best kernel.
  22750. */
  22751. protected _nearestBestKernel(idealKernel: number): number;
  22752. /**
  22753. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22754. * @param x The point on the Gaussian distribution to sample.
  22755. * @return the value of the Gaussian function at x.
  22756. */
  22757. protected _gaussianWeight(x: number): number;
  22758. /**
  22759. * Generates a string that can be used as a floating point number in GLSL.
  22760. * @param x Value to print.
  22761. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22762. * @return GLSL float string.
  22763. */
  22764. protected _glslFloat(x: number, decimalFigures?: number): string;
  22765. }
  22766. }
  22767. declare module BABYLON {
  22768. /**
  22769. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22770. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22771. * You can then easily use it as a reflectionTexture on a flat surface.
  22772. * In case the surface is not a plane, please consider relying on reflection probes.
  22773. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22774. */
  22775. export class MirrorTexture extends RenderTargetTexture {
  22776. private scene;
  22777. /**
  22778. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22779. * 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.
  22780. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22781. */
  22782. mirrorPlane: Plane;
  22783. /**
  22784. * Define the blur ratio used to blur the reflection if needed.
  22785. */
  22786. set blurRatio(value: number);
  22787. get blurRatio(): number;
  22788. /**
  22789. * Define the adaptive blur kernel used to blur the reflection if needed.
  22790. * This will autocompute the closest best match for the `blurKernel`
  22791. */
  22792. set adaptiveBlurKernel(value: number);
  22793. /**
  22794. * Define the blur kernel used to blur the reflection if needed.
  22795. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22796. */
  22797. set blurKernel(value: number);
  22798. /**
  22799. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22800. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22801. */
  22802. set blurKernelX(value: number);
  22803. get blurKernelX(): number;
  22804. /**
  22805. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22806. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22807. */
  22808. set blurKernelY(value: number);
  22809. get blurKernelY(): number;
  22810. private _autoComputeBlurKernel;
  22811. protected _onRatioRescale(): void;
  22812. private _updateGammaSpace;
  22813. private _imageProcessingConfigChangeObserver;
  22814. private _transformMatrix;
  22815. private _mirrorMatrix;
  22816. private _savedViewMatrix;
  22817. private _blurX;
  22818. private _blurY;
  22819. private _adaptiveBlurKernel;
  22820. private _blurKernelX;
  22821. private _blurKernelY;
  22822. private _blurRatio;
  22823. /**
  22824. * Instantiates a Mirror Texture.
  22825. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22826. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22827. * You can then easily use it as a reflectionTexture on a flat surface.
  22828. * In case the surface is not a plane, please consider relying on reflection probes.
  22829. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22830. * @param name
  22831. * @param size
  22832. * @param scene
  22833. * @param generateMipMaps
  22834. * @param type
  22835. * @param samplingMode
  22836. * @param generateDepthBuffer
  22837. */
  22838. constructor(name: string, size: number | {
  22839. width: number;
  22840. height: number;
  22841. } | {
  22842. ratio: number;
  22843. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22844. private _preparePostProcesses;
  22845. /**
  22846. * Clone the mirror texture.
  22847. * @returns the cloned texture
  22848. */
  22849. clone(): MirrorTexture;
  22850. /**
  22851. * Serialize the texture to a JSON representation you could use in Parse later on
  22852. * @returns the serialized JSON representation
  22853. */
  22854. serialize(): any;
  22855. /**
  22856. * Dispose the texture and release its associated resources.
  22857. */
  22858. dispose(): void;
  22859. }
  22860. }
  22861. declare module BABYLON {
  22862. /**
  22863. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22864. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22865. */
  22866. export class Texture extends BaseTexture {
  22867. /**
  22868. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22869. */
  22870. static SerializeBuffers: boolean;
  22871. /** @hidden */
  22872. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22873. /** @hidden */
  22874. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22875. /** @hidden */
  22876. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22877. /** nearest is mag = nearest and min = nearest and mip = linear */
  22878. static readonly NEAREST_SAMPLINGMODE: number;
  22879. /** nearest is mag = nearest and min = nearest and mip = linear */
  22880. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22881. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22882. static readonly BILINEAR_SAMPLINGMODE: number;
  22883. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22884. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22885. /** Trilinear is mag = linear and min = linear and mip = linear */
  22886. static readonly TRILINEAR_SAMPLINGMODE: number;
  22887. /** Trilinear is mag = linear and min = linear and mip = linear */
  22888. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22889. /** mag = nearest and min = nearest and mip = nearest */
  22890. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22891. /** mag = nearest and min = linear and mip = nearest */
  22892. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22893. /** mag = nearest and min = linear and mip = linear */
  22894. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22895. /** mag = nearest and min = linear and mip = none */
  22896. static readonly NEAREST_LINEAR: number;
  22897. /** mag = nearest and min = nearest and mip = none */
  22898. static readonly NEAREST_NEAREST: number;
  22899. /** mag = linear and min = nearest and mip = nearest */
  22900. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22901. /** mag = linear and min = nearest and mip = linear */
  22902. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22903. /** mag = linear and min = linear and mip = none */
  22904. static readonly LINEAR_LINEAR: number;
  22905. /** mag = linear and min = nearest and mip = none */
  22906. static readonly LINEAR_NEAREST: number;
  22907. /** Explicit coordinates mode */
  22908. static readonly EXPLICIT_MODE: number;
  22909. /** Spherical coordinates mode */
  22910. static readonly SPHERICAL_MODE: number;
  22911. /** Planar coordinates mode */
  22912. static readonly PLANAR_MODE: number;
  22913. /** Cubic coordinates mode */
  22914. static readonly CUBIC_MODE: number;
  22915. /** Projection coordinates mode */
  22916. static readonly PROJECTION_MODE: number;
  22917. /** Inverse Cubic coordinates mode */
  22918. static readonly SKYBOX_MODE: number;
  22919. /** Inverse Cubic coordinates mode */
  22920. static readonly INVCUBIC_MODE: number;
  22921. /** Equirectangular coordinates mode */
  22922. static readonly EQUIRECTANGULAR_MODE: number;
  22923. /** Equirectangular Fixed coordinates mode */
  22924. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  22925. /** Equirectangular Fixed Mirrored coordinates mode */
  22926. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  22927. /** Texture is not repeating outside of 0..1 UVs */
  22928. static readonly CLAMP_ADDRESSMODE: number;
  22929. /** Texture is repeating outside of 0..1 UVs */
  22930. static readonly WRAP_ADDRESSMODE: number;
  22931. /** Texture is repeating and mirrored */
  22932. static readonly MIRROR_ADDRESSMODE: number;
  22933. /**
  22934. * 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
  22935. */
  22936. static UseSerializedUrlIfAny: boolean;
  22937. /**
  22938. * Define the url of the texture.
  22939. */
  22940. url: Nullable<string>;
  22941. /**
  22942. * Define an offset on the texture to offset the u coordinates of the UVs
  22943. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22944. */
  22945. uOffset: number;
  22946. /**
  22947. * Define an offset on the texture to offset the v coordinates of the UVs
  22948. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  22949. */
  22950. vOffset: number;
  22951. /**
  22952. * Define an offset on the texture to scale the u coordinates of the UVs
  22953. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22954. */
  22955. uScale: number;
  22956. /**
  22957. * Define an offset on the texture to scale the v coordinates of the UVs
  22958. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  22959. */
  22960. vScale: number;
  22961. /**
  22962. * Define an offset on the texture to rotate around the u coordinates of the UVs
  22963. * @see https://doc.babylonjs.com/how_to/more_materials
  22964. */
  22965. uAng: number;
  22966. /**
  22967. * Define an offset on the texture to rotate around the v coordinates of the UVs
  22968. * @see https://doc.babylonjs.com/how_to/more_materials
  22969. */
  22970. vAng: number;
  22971. /**
  22972. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  22973. * @see https://doc.babylonjs.com/how_to/more_materials
  22974. */
  22975. wAng: number;
  22976. /**
  22977. * Defines the center of rotation (U)
  22978. */
  22979. uRotationCenter: number;
  22980. /**
  22981. * Defines the center of rotation (V)
  22982. */
  22983. vRotationCenter: number;
  22984. /**
  22985. * Defines the center of rotation (W)
  22986. */
  22987. wRotationCenter: number;
  22988. /**
  22989. * Are mip maps generated for this texture or not.
  22990. */
  22991. get noMipmap(): boolean;
  22992. /**
  22993. * List of inspectable custom properties (used by the Inspector)
  22994. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22995. */
  22996. inspectableCustomProperties: Nullable<IInspectable[]>;
  22997. private _noMipmap;
  22998. /** @hidden */
  22999. _invertY: boolean;
  23000. private _rowGenerationMatrix;
  23001. private _cachedTextureMatrix;
  23002. private _projectionModeMatrix;
  23003. private _t0;
  23004. private _t1;
  23005. private _t2;
  23006. private _cachedUOffset;
  23007. private _cachedVOffset;
  23008. private _cachedUScale;
  23009. private _cachedVScale;
  23010. private _cachedUAng;
  23011. private _cachedVAng;
  23012. private _cachedWAng;
  23013. private _cachedProjectionMatrixId;
  23014. private _cachedCoordinatesMode;
  23015. /** @hidden */
  23016. protected _initialSamplingMode: number;
  23017. /** @hidden */
  23018. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23019. private _deleteBuffer;
  23020. protected _format: Nullable<number>;
  23021. private _delayedOnLoad;
  23022. private _delayedOnError;
  23023. private _mimeType?;
  23024. /**
  23025. * Observable triggered once the texture has been loaded.
  23026. */
  23027. onLoadObservable: Observable<Texture>;
  23028. protected _isBlocking: boolean;
  23029. /**
  23030. * Is the texture preventing material to render while loading.
  23031. * If false, a default texture will be used instead of the loading one during the preparation step.
  23032. */
  23033. set isBlocking(value: boolean);
  23034. get isBlocking(): boolean;
  23035. /**
  23036. * Get the current sampling mode associated with the texture.
  23037. */
  23038. get samplingMode(): number;
  23039. /**
  23040. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23041. */
  23042. get invertY(): boolean;
  23043. /**
  23044. * Instantiates a new texture.
  23045. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23046. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23047. * @param url defines the url of the picture to load as a texture
  23048. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23049. * @param noMipmap defines if the texture will require mip maps or not
  23050. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23051. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23052. * @param onLoad defines a callback triggered when the texture has been loaded
  23053. * @param onError defines a callback triggered when an error occurred during the loading session
  23054. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23055. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23056. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23057. * @param mimeType defines an optional mime type information
  23058. */
  23059. 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);
  23060. /**
  23061. * Update the url (and optional buffer) of this texture if url was null during construction.
  23062. * @param url the url of the texture
  23063. * @param buffer the buffer of the texture (defaults to null)
  23064. * @param onLoad callback called when the texture is loaded (defaults to null)
  23065. */
  23066. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23067. /**
  23068. * Finish the loading sequence of a texture flagged as delayed load.
  23069. * @hidden
  23070. */
  23071. delayLoad(): void;
  23072. private _prepareRowForTextureGeneration;
  23073. /**
  23074. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23075. * @returns the transform matrix of the texture.
  23076. */
  23077. getTextureMatrix(uBase?: number): Matrix;
  23078. /**
  23079. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23080. * @returns The reflection texture transform
  23081. */
  23082. getReflectionTextureMatrix(): Matrix;
  23083. /**
  23084. * Clones the texture.
  23085. * @returns the cloned texture
  23086. */
  23087. clone(): Texture;
  23088. /**
  23089. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23090. * @returns The JSON representation of the texture
  23091. */
  23092. serialize(): any;
  23093. /**
  23094. * Get the current class name of the texture useful for serialization or dynamic coding.
  23095. * @returns "Texture"
  23096. */
  23097. getClassName(): string;
  23098. /**
  23099. * Dispose the texture and release its associated resources.
  23100. */
  23101. dispose(): void;
  23102. /**
  23103. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23104. * @param parsedTexture Define the JSON representation of the texture
  23105. * @param scene Define the scene the parsed texture should be instantiated in
  23106. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23107. * @returns The parsed texture if successful
  23108. */
  23109. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23110. /**
  23111. * Creates a texture from its base 64 representation.
  23112. * @param data Define the base64 payload without the data: prefix
  23113. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23114. * @param scene Define the scene the texture should belong to
  23115. * @param noMipmap Forces the texture to not create mip map information if true
  23116. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23117. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23118. * @param onLoad define a callback triggered when the texture has been loaded
  23119. * @param onError define a callback triggered when an error occurred during the loading session
  23120. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23121. * @returns the created texture
  23122. */
  23123. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23124. /**
  23125. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23126. * @param data Define the base64 payload without the data: prefix
  23127. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23128. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23129. * @param scene Define the scene the texture should belong to
  23130. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23131. * @param noMipmap Forces the texture to not create mip map information if true
  23132. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23133. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23134. * @param onLoad define a callback triggered when the texture has been loaded
  23135. * @param onError define a callback triggered when an error occurred during the loading session
  23136. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23137. * @returns the created texture
  23138. */
  23139. 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;
  23140. }
  23141. }
  23142. declare module BABYLON {
  23143. /**
  23144. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23145. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23146. */
  23147. export class PostProcessManager {
  23148. private _scene;
  23149. private _indexBuffer;
  23150. private _vertexBuffers;
  23151. /**
  23152. * Creates a new instance PostProcess
  23153. * @param scene The scene that the post process is associated with.
  23154. */
  23155. constructor(scene: Scene);
  23156. private _prepareBuffers;
  23157. private _buildIndexBuffer;
  23158. /**
  23159. * Rebuilds the vertex buffers of the manager.
  23160. * @hidden
  23161. */
  23162. _rebuild(): void;
  23163. /**
  23164. * Prepares a frame to be run through a post process.
  23165. * @param sourceTexture The input texture to the post procesess. (default: null)
  23166. * @param postProcesses An array of post processes to be run. (default: null)
  23167. * @returns True if the post processes were able to be run.
  23168. * @hidden
  23169. */
  23170. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23171. /**
  23172. * Manually render a set of post processes to a texture.
  23173. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23174. * @param postProcesses An array of post processes to be run.
  23175. * @param targetTexture The target texture to render to.
  23176. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23177. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23178. * @param lodLevel defines which lod of the texture to render to
  23179. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23180. */
  23181. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23182. /**
  23183. * Finalize the result of the output of the postprocesses.
  23184. * @param doNotPresent If true the result will not be displayed to the screen.
  23185. * @param targetTexture The target texture to render to.
  23186. * @param faceIndex The index of the face to bind the target texture to.
  23187. * @param postProcesses The array of post processes to render.
  23188. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23189. * @hidden
  23190. */
  23191. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23192. /**
  23193. * Disposes of the post process manager.
  23194. */
  23195. dispose(): void;
  23196. }
  23197. }
  23198. declare module BABYLON {
  23199. /**
  23200. * This Helps creating a texture that will be created from a camera in your scene.
  23201. * It is basically a dynamic texture that could be used to create special effects for instance.
  23202. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23203. */
  23204. export class RenderTargetTexture extends Texture {
  23205. isCube: boolean;
  23206. /**
  23207. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23208. */
  23209. static readonly REFRESHRATE_RENDER_ONCE: number;
  23210. /**
  23211. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23212. */
  23213. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23214. /**
  23215. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23216. * the central point of your effect and can save a lot of performances.
  23217. */
  23218. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23219. /**
  23220. * Use this predicate to dynamically define the list of mesh you want to render.
  23221. * If set, the renderList property will be overwritten.
  23222. */
  23223. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23224. private _renderList;
  23225. /**
  23226. * Use this list to define the list of mesh you want to render.
  23227. */
  23228. get renderList(): Nullable<Array<AbstractMesh>>;
  23229. set renderList(value: Nullable<Array<AbstractMesh>>);
  23230. /**
  23231. * Use this function to overload the renderList array at rendering time.
  23232. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23233. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23234. * the cube (if the RTT is a cube, else layerOrFace=0).
  23235. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23236. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23237. * hold dummy elements!
  23238. */
  23239. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23240. private _hookArray;
  23241. /**
  23242. * Define if particles should be rendered in your texture.
  23243. */
  23244. renderParticles: boolean;
  23245. /**
  23246. * Define if sprites should be rendered in your texture.
  23247. */
  23248. renderSprites: boolean;
  23249. /**
  23250. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23251. */
  23252. coordinatesMode: number;
  23253. /**
  23254. * Define the camera used to render the texture.
  23255. */
  23256. activeCamera: Nullable<Camera>;
  23257. /**
  23258. * Override the mesh isReady function with your own one.
  23259. */
  23260. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23261. /**
  23262. * Override the render function of the texture with your own one.
  23263. */
  23264. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23265. /**
  23266. * Define if camera post processes should be use while rendering the texture.
  23267. */
  23268. useCameraPostProcesses: boolean;
  23269. /**
  23270. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23271. */
  23272. ignoreCameraViewport: boolean;
  23273. private _postProcessManager;
  23274. private _postProcesses;
  23275. private _resizeObserver;
  23276. /**
  23277. * An event triggered when the texture is unbind.
  23278. */
  23279. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23280. /**
  23281. * An event triggered when the texture is unbind.
  23282. */
  23283. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23284. private _onAfterUnbindObserver;
  23285. /**
  23286. * Set a after unbind callback in the texture.
  23287. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23288. */
  23289. set onAfterUnbind(callback: () => void);
  23290. /**
  23291. * An event triggered before rendering the texture
  23292. */
  23293. onBeforeRenderObservable: Observable<number>;
  23294. private _onBeforeRenderObserver;
  23295. /**
  23296. * Set a before render callback in the texture.
  23297. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23298. */
  23299. set onBeforeRender(callback: (faceIndex: number) => void);
  23300. /**
  23301. * An event triggered after rendering the texture
  23302. */
  23303. onAfterRenderObservable: Observable<number>;
  23304. private _onAfterRenderObserver;
  23305. /**
  23306. * Set a after render callback in the texture.
  23307. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23308. */
  23309. set onAfterRender(callback: (faceIndex: number) => void);
  23310. /**
  23311. * An event triggered after the texture clear
  23312. */
  23313. onClearObservable: Observable<Engine>;
  23314. private _onClearObserver;
  23315. /**
  23316. * Set a clear callback in the texture.
  23317. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23318. */
  23319. set onClear(callback: (Engine: Engine) => void);
  23320. /**
  23321. * An event triggered when the texture is resized.
  23322. */
  23323. onResizeObservable: Observable<RenderTargetTexture>;
  23324. /**
  23325. * Define the clear color of the Render Target if it should be different from the scene.
  23326. */
  23327. clearColor: Color4;
  23328. protected _size: number | {
  23329. width: number;
  23330. height: number;
  23331. layers?: number;
  23332. };
  23333. protected _initialSizeParameter: number | {
  23334. width: number;
  23335. height: number;
  23336. } | {
  23337. ratio: number;
  23338. };
  23339. protected _sizeRatio: Nullable<number>;
  23340. /** @hidden */
  23341. _generateMipMaps: boolean;
  23342. protected _renderingManager: RenderingManager;
  23343. /** @hidden */
  23344. _waitingRenderList: string[];
  23345. protected _doNotChangeAspectRatio: boolean;
  23346. protected _currentRefreshId: number;
  23347. protected _refreshRate: number;
  23348. protected _textureMatrix: Matrix;
  23349. protected _samples: number;
  23350. protected _renderTargetOptions: RenderTargetCreationOptions;
  23351. /**
  23352. * Gets render target creation options that were used.
  23353. */
  23354. get renderTargetOptions(): RenderTargetCreationOptions;
  23355. protected _onRatioRescale(): void;
  23356. /**
  23357. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23358. * It must define where the camera used to render the texture is set
  23359. */
  23360. boundingBoxPosition: Vector3;
  23361. private _boundingBoxSize;
  23362. /**
  23363. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23364. * When defined, the cubemap will switch to local mode
  23365. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23366. * @example https://www.babylonjs-playground.com/#RNASML
  23367. */
  23368. set boundingBoxSize(value: Vector3);
  23369. get boundingBoxSize(): Vector3;
  23370. /**
  23371. * In case the RTT has been created with a depth texture, get the associated
  23372. * depth texture.
  23373. * Otherwise, return null.
  23374. */
  23375. get depthStencilTexture(): Nullable<InternalTexture>;
  23376. /**
  23377. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23378. * or used a shadow, depth texture...
  23379. * @param name The friendly name of the texture
  23380. * @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)
  23381. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23382. * @param generateMipMaps True if mip maps need to be generated after render.
  23383. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23384. * @param type The type of the buffer in the RTT (int, half float, float...)
  23385. * @param isCube True if a cube texture needs to be created
  23386. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23387. * @param generateDepthBuffer True to generate a depth buffer
  23388. * @param generateStencilBuffer True to generate a stencil buffer
  23389. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23390. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23391. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23392. */
  23393. constructor(name: string, size: number | {
  23394. width: number;
  23395. height: number;
  23396. layers?: number;
  23397. } | {
  23398. ratio: number;
  23399. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23400. /**
  23401. * Creates a depth stencil texture.
  23402. * This is only available in WebGL 2 or with the depth texture extension available.
  23403. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23404. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23405. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23406. */
  23407. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23408. private _processSizeParameter;
  23409. /**
  23410. * Define the number of samples to use in case of MSAA.
  23411. * It defaults to one meaning no MSAA has been enabled.
  23412. */
  23413. get samples(): number;
  23414. set samples(value: number);
  23415. /**
  23416. * Resets the refresh counter of the texture and start bak from scratch.
  23417. * Could be useful to regenerate the texture if it is setup to render only once.
  23418. */
  23419. resetRefreshCounter(): void;
  23420. /**
  23421. * Define the refresh rate of the texture or the rendering frequency.
  23422. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23423. */
  23424. get refreshRate(): number;
  23425. set refreshRate(value: number);
  23426. /**
  23427. * Adds a post process to the render target rendering passes.
  23428. * @param postProcess define the post process to add
  23429. */
  23430. addPostProcess(postProcess: PostProcess): void;
  23431. /**
  23432. * Clear all the post processes attached to the render target
  23433. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23434. */
  23435. clearPostProcesses(dispose?: boolean): void;
  23436. /**
  23437. * Remove one of the post process from the list of attached post processes to the texture
  23438. * @param postProcess define the post process to remove from the list
  23439. */
  23440. removePostProcess(postProcess: PostProcess): void;
  23441. /** @hidden */
  23442. _shouldRender(): boolean;
  23443. /**
  23444. * Gets the actual render size of the texture.
  23445. * @returns the width of the render size
  23446. */
  23447. getRenderSize(): number;
  23448. /**
  23449. * Gets the actual render width of the texture.
  23450. * @returns the width of the render size
  23451. */
  23452. getRenderWidth(): number;
  23453. /**
  23454. * Gets the actual render height of the texture.
  23455. * @returns the height of the render size
  23456. */
  23457. getRenderHeight(): number;
  23458. /**
  23459. * Gets the actual number of layers of the texture.
  23460. * @returns the number of layers
  23461. */
  23462. getRenderLayers(): number;
  23463. /**
  23464. * Get if the texture can be rescaled or not.
  23465. */
  23466. get canRescale(): boolean;
  23467. /**
  23468. * Resize the texture using a ratio.
  23469. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23470. */
  23471. scale(ratio: number): void;
  23472. /**
  23473. * Get the texture reflection matrix used to rotate/transform the reflection.
  23474. * @returns the reflection matrix
  23475. */
  23476. getReflectionTextureMatrix(): Matrix;
  23477. /**
  23478. * Resize the texture to a new desired size.
  23479. * Be carrefull as it will recreate all the data in the new texture.
  23480. * @param size Define the new size. It can be:
  23481. * - a number for squared texture,
  23482. * - an object containing { width: number, height: number }
  23483. * - or an object containing a ratio { ratio: number }
  23484. */
  23485. resize(size: number | {
  23486. width: number;
  23487. height: number;
  23488. } | {
  23489. ratio: number;
  23490. }): void;
  23491. private _defaultRenderListPrepared;
  23492. /**
  23493. * Renders all the objects from the render list into the texture.
  23494. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23495. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23496. */
  23497. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23498. private _bestReflectionRenderTargetDimension;
  23499. private _prepareRenderingManager;
  23500. /**
  23501. * @hidden
  23502. * @param faceIndex face index to bind to if this is a cubetexture
  23503. * @param layer defines the index of the texture to bind in the array
  23504. */
  23505. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23506. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23507. private renderToTarget;
  23508. /**
  23509. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23510. * This allowed control for front to back rendering or reversly depending of the special needs.
  23511. *
  23512. * @param renderingGroupId The rendering group id corresponding to its index
  23513. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23514. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23515. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23516. */
  23517. 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;
  23518. /**
  23519. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23520. *
  23521. * @param renderingGroupId The rendering group id corresponding to its index
  23522. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23523. */
  23524. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23525. /**
  23526. * Clones the texture.
  23527. * @returns the cloned texture
  23528. */
  23529. clone(): RenderTargetTexture;
  23530. /**
  23531. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23532. * @returns The JSON representation of the texture
  23533. */
  23534. serialize(): any;
  23535. /**
  23536. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23537. */
  23538. disposeFramebufferObjects(): void;
  23539. /**
  23540. * Dispose the texture and release its associated resources.
  23541. */
  23542. dispose(): void;
  23543. /** @hidden */
  23544. _rebuild(): void;
  23545. /**
  23546. * Clear the info related to rendering groups preventing retention point in material dispose.
  23547. */
  23548. freeRenderingGroups(): void;
  23549. /**
  23550. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23551. * @returns the view count
  23552. */
  23553. getViewCount(): number;
  23554. }
  23555. }
  23556. declare module BABYLON {
  23557. /**
  23558. * Class used to manipulate GUIDs
  23559. */
  23560. export class GUID {
  23561. /**
  23562. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23563. * Be aware Math.random() could cause collisions, but:
  23564. * "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"
  23565. * @returns a pseudo random id
  23566. */
  23567. static RandomId(): string;
  23568. }
  23569. }
  23570. declare module BABYLON {
  23571. /**
  23572. * Options to be used when creating a shadow depth material
  23573. */
  23574. export interface IIOptionShadowDepthMaterial {
  23575. /** Variables in the vertex shader code that need to have their names remapped.
  23576. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23577. * "var_name" should be either: worldPos or vNormalW
  23578. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23579. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23580. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23581. */
  23582. remappedVariables?: string[];
  23583. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23584. standalone?: boolean;
  23585. }
  23586. /**
  23587. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23588. */
  23589. export class ShadowDepthWrapper {
  23590. private _scene;
  23591. private _options?;
  23592. private _baseMaterial;
  23593. private _onEffectCreatedObserver;
  23594. private _subMeshToEffect;
  23595. private _subMeshToDepthEffect;
  23596. private _meshes;
  23597. /** @hidden */
  23598. _matriceNames: any;
  23599. /** Gets the standalone status of the wrapper */
  23600. get standalone(): boolean;
  23601. /** Gets the base material the wrapper is built upon */
  23602. get baseMaterial(): Material;
  23603. /**
  23604. * Instantiate a new shadow depth wrapper.
  23605. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23606. * generate the shadow depth map. For more information, please refer to the documentation:
  23607. * https://doc.babylonjs.com/babylon101/shadows
  23608. * @param baseMaterial Material to wrap
  23609. * @param scene Define the scene the material belongs to
  23610. * @param options Options used to create the wrapper
  23611. */
  23612. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23613. /**
  23614. * Gets the effect to use to generate the depth map
  23615. * @param subMesh subMesh to get the effect for
  23616. * @param shadowGenerator shadow generator to get the effect for
  23617. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23618. */
  23619. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23620. /**
  23621. * Specifies that the submesh is ready to be used for depth rendering
  23622. * @param subMesh submesh to check
  23623. * @param defines the list of defines to take into account when checking the effect
  23624. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23625. * @param useInstances specifies that instances should be used
  23626. * @returns a boolean indicating that the submesh is ready or not
  23627. */
  23628. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23629. /**
  23630. * Disposes the resources
  23631. */
  23632. dispose(): void;
  23633. private _makeEffect;
  23634. }
  23635. }
  23636. declare module BABYLON {
  23637. /**
  23638. * Options for compiling materials.
  23639. */
  23640. export interface IMaterialCompilationOptions {
  23641. /**
  23642. * Defines whether clip planes are enabled.
  23643. */
  23644. clipPlane: boolean;
  23645. /**
  23646. * Defines whether instances are enabled.
  23647. */
  23648. useInstances: boolean;
  23649. }
  23650. /**
  23651. * Options passed when calling customShaderNameResolve
  23652. */
  23653. export interface ICustomShaderNameResolveOptions {
  23654. /**
  23655. * 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
  23656. */
  23657. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  23658. }
  23659. /**
  23660. * Base class for the main features of a material in Babylon.js
  23661. */
  23662. export class Material implements IAnimatable {
  23663. /**
  23664. * Returns the triangle fill mode
  23665. */
  23666. static readonly TriangleFillMode: number;
  23667. /**
  23668. * Returns the wireframe mode
  23669. */
  23670. static readonly WireFrameFillMode: number;
  23671. /**
  23672. * Returns the point fill mode
  23673. */
  23674. static readonly PointFillMode: number;
  23675. /**
  23676. * Returns the point list draw mode
  23677. */
  23678. static readonly PointListDrawMode: number;
  23679. /**
  23680. * Returns the line list draw mode
  23681. */
  23682. static readonly LineListDrawMode: number;
  23683. /**
  23684. * Returns the line loop draw mode
  23685. */
  23686. static readonly LineLoopDrawMode: number;
  23687. /**
  23688. * Returns the line strip draw mode
  23689. */
  23690. static readonly LineStripDrawMode: number;
  23691. /**
  23692. * Returns the triangle strip draw mode
  23693. */
  23694. static readonly TriangleStripDrawMode: number;
  23695. /**
  23696. * Returns the triangle fan draw mode
  23697. */
  23698. static readonly TriangleFanDrawMode: number;
  23699. /**
  23700. * Stores the clock-wise side orientation
  23701. */
  23702. static readonly ClockWiseSideOrientation: number;
  23703. /**
  23704. * Stores the counter clock-wise side orientation
  23705. */
  23706. static readonly CounterClockWiseSideOrientation: number;
  23707. /**
  23708. * The dirty texture flag value
  23709. */
  23710. static readonly TextureDirtyFlag: number;
  23711. /**
  23712. * The dirty light flag value
  23713. */
  23714. static readonly LightDirtyFlag: number;
  23715. /**
  23716. * The dirty fresnel flag value
  23717. */
  23718. static readonly FresnelDirtyFlag: number;
  23719. /**
  23720. * The dirty attribute flag value
  23721. */
  23722. static readonly AttributesDirtyFlag: number;
  23723. /**
  23724. * The dirty misc flag value
  23725. */
  23726. static readonly MiscDirtyFlag: number;
  23727. /**
  23728. * The all dirty flag value
  23729. */
  23730. static readonly AllDirtyFlag: number;
  23731. /**
  23732. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  23733. */
  23734. static readonly MATERIAL_OPAQUE: number;
  23735. /**
  23736. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  23737. */
  23738. static readonly MATERIAL_ALPHATEST: number;
  23739. /**
  23740. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23741. */
  23742. static readonly MATERIAL_ALPHABLEND: number;
  23743. /**
  23744. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  23745. * They are also discarded below the alpha cutoff threshold to improve performances.
  23746. */
  23747. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  23748. /**
  23749. * The Whiteout method is used to blend normals.
  23750. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23751. */
  23752. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  23753. /**
  23754. * The Reoriented Normal Mapping method is used to blend normals.
  23755. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  23756. */
  23757. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  23758. /**
  23759. * Custom callback helping to override the default shader used in the material.
  23760. */
  23761. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  23762. /**
  23763. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  23764. */
  23765. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  23766. /**
  23767. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  23768. * This means that the material can keep using a previous shader while a new one is being compiled.
  23769. * This is mostly used when shader parallel compilation is supported (true by default)
  23770. */
  23771. allowShaderHotSwapping: boolean;
  23772. /**
  23773. * The ID of the material
  23774. */
  23775. id: string;
  23776. /**
  23777. * Gets or sets the unique id of the material
  23778. */
  23779. uniqueId: number;
  23780. /**
  23781. * The name of the material
  23782. */
  23783. name: string;
  23784. /**
  23785. * Gets or sets user defined metadata
  23786. */
  23787. metadata: any;
  23788. /**
  23789. * For internal use only. Please do not use.
  23790. */
  23791. reservedDataStore: any;
  23792. /**
  23793. * Specifies if the ready state should be checked on each call
  23794. */
  23795. checkReadyOnEveryCall: boolean;
  23796. /**
  23797. * Specifies if the ready state should be checked once
  23798. */
  23799. checkReadyOnlyOnce: boolean;
  23800. /**
  23801. * The state of the material
  23802. */
  23803. state: string;
  23804. /**
  23805. * If the material should be rendered to several textures with MRT extension
  23806. */
  23807. get shouldRenderToMRT(): boolean;
  23808. /**
  23809. * The alpha value of the material
  23810. */
  23811. protected _alpha: number;
  23812. /**
  23813. * List of inspectable custom properties (used by the Inspector)
  23814. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23815. */
  23816. inspectableCustomProperties: IInspectable[];
  23817. /**
  23818. * Sets the alpha value of the material
  23819. */
  23820. set alpha(value: number);
  23821. /**
  23822. * Gets the alpha value of the material
  23823. */
  23824. get alpha(): number;
  23825. /**
  23826. * Specifies if back face culling is enabled
  23827. */
  23828. protected _backFaceCulling: boolean;
  23829. /**
  23830. * Sets the back-face culling state
  23831. */
  23832. set backFaceCulling(value: boolean);
  23833. /**
  23834. * Gets the back-face culling state
  23835. */
  23836. get backFaceCulling(): boolean;
  23837. /**
  23838. * Stores the value for side orientation
  23839. */
  23840. sideOrientation: number;
  23841. /**
  23842. * Callback triggered when the material is compiled
  23843. */
  23844. onCompiled: Nullable<(effect: Effect) => void>;
  23845. /**
  23846. * Callback triggered when an error occurs
  23847. */
  23848. onError: Nullable<(effect: Effect, errors: string) => void>;
  23849. /**
  23850. * Callback triggered to get the render target textures
  23851. */
  23852. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  23853. /**
  23854. * Gets a boolean indicating that current material needs to register RTT
  23855. */
  23856. get hasRenderTargetTextures(): boolean;
  23857. /**
  23858. * Specifies if the material should be serialized
  23859. */
  23860. doNotSerialize: boolean;
  23861. /**
  23862. * @hidden
  23863. */
  23864. _storeEffectOnSubMeshes: boolean;
  23865. /**
  23866. * Stores the animations for the material
  23867. */
  23868. animations: Nullable<Array<Animation>>;
  23869. /**
  23870. * An event triggered when the material is disposed
  23871. */
  23872. onDisposeObservable: Observable<Material>;
  23873. /**
  23874. * An observer which watches for dispose events
  23875. */
  23876. private _onDisposeObserver;
  23877. private _onUnBindObservable;
  23878. /**
  23879. * Called during a dispose event
  23880. */
  23881. set onDispose(callback: () => void);
  23882. private _onBindObservable;
  23883. /**
  23884. * An event triggered when the material is bound
  23885. */
  23886. get onBindObservable(): Observable<AbstractMesh>;
  23887. /**
  23888. * An observer which watches for bind events
  23889. */
  23890. private _onBindObserver;
  23891. /**
  23892. * Called during a bind event
  23893. */
  23894. set onBind(callback: (Mesh: AbstractMesh) => void);
  23895. /**
  23896. * An event triggered when the material is unbound
  23897. */
  23898. get onUnBindObservable(): Observable<Material>;
  23899. protected _onEffectCreatedObservable: Nullable<Observable<{
  23900. effect: Effect;
  23901. subMesh: Nullable<SubMesh>;
  23902. }>>;
  23903. /**
  23904. * An event triggered when the effect is (re)created
  23905. */
  23906. get onEffectCreatedObservable(): Observable<{
  23907. effect: Effect;
  23908. subMesh: Nullable<SubMesh>;
  23909. }>;
  23910. /**
  23911. * Stores the value of the alpha mode
  23912. */
  23913. private _alphaMode;
  23914. /**
  23915. * Sets the value of the alpha mode.
  23916. *
  23917. * | Value | Type | Description |
  23918. * | --- | --- | --- |
  23919. * | 0 | ALPHA_DISABLE | |
  23920. * | 1 | ALPHA_ADD | |
  23921. * | 2 | ALPHA_COMBINE | |
  23922. * | 3 | ALPHA_SUBTRACT | |
  23923. * | 4 | ALPHA_MULTIPLY | |
  23924. * | 5 | ALPHA_MAXIMIZED | |
  23925. * | 6 | ALPHA_ONEONE | |
  23926. * | 7 | ALPHA_PREMULTIPLIED | |
  23927. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  23928. * | 9 | ALPHA_INTERPOLATE | |
  23929. * | 10 | ALPHA_SCREENMODE | |
  23930. *
  23931. */
  23932. set alphaMode(value: number);
  23933. /**
  23934. * Gets the value of the alpha mode
  23935. */
  23936. get alphaMode(): number;
  23937. /**
  23938. * Stores the state of the need depth pre-pass value
  23939. */
  23940. private _needDepthPrePass;
  23941. /**
  23942. * Sets the need depth pre-pass value
  23943. */
  23944. set needDepthPrePass(value: boolean);
  23945. /**
  23946. * Gets the depth pre-pass value
  23947. */
  23948. get needDepthPrePass(): boolean;
  23949. /**
  23950. * Specifies if depth writing should be disabled
  23951. */
  23952. disableDepthWrite: boolean;
  23953. /**
  23954. * Specifies if color writing should be disabled
  23955. */
  23956. disableColorWrite: boolean;
  23957. /**
  23958. * Specifies if depth writing should be forced
  23959. */
  23960. forceDepthWrite: boolean;
  23961. /**
  23962. * Specifies the depth function that should be used. 0 means the default engine function
  23963. */
  23964. depthFunction: number;
  23965. /**
  23966. * Specifies if there should be a separate pass for culling
  23967. */
  23968. separateCullingPass: boolean;
  23969. /**
  23970. * Stores the state specifing if fog should be enabled
  23971. */
  23972. private _fogEnabled;
  23973. /**
  23974. * Sets the state for enabling fog
  23975. */
  23976. set fogEnabled(value: boolean);
  23977. /**
  23978. * Gets the value of the fog enabled state
  23979. */
  23980. get fogEnabled(): boolean;
  23981. /**
  23982. * Stores the size of points
  23983. */
  23984. pointSize: number;
  23985. /**
  23986. * Stores the z offset value
  23987. */
  23988. zOffset: number;
  23989. get wireframe(): boolean;
  23990. /**
  23991. * Sets the state of wireframe mode
  23992. */
  23993. set wireframe(value: boolean);
  23994. /**
  23995. * Gets the value specifying if point clouds are enabled
  23996. */
  23997. get pointsCloud(): boolean;
  23998. /**
  23999. * Sets the state of point cloud mode
  24000. */
  24001. set pointsCloud(value: boolean);
  24002. /**
  24003. * Gets the material fill mode
  24004. */
  24005. get fillMode(): number;
  24006. /**
  24007. * Sets the material fill mode
  24008. */
  24009. set fillMode(value: number);
  24010. /**
  24011. * @hidden
  24012. * Stores the effects for the material
  24013. */
  24014. _effect: Nullable<Effect>;
  24015. /**
  24016. * Specifies if uniform buffers should be used
  24017. */
  24018. private _useUBO;
  24019. /**
  24020. * Stores a reference to the scene
  24021. */
  24022. private _scene;
  24023. /**
  24024. * Stores the fill mode state
  24025. */
  24026. private _fillMode;
  24027. /**
  24028. * Specifies if the depth write state should be cached
  24029. */
  24030. private _cachedDepthWriteState;
  24031. /**
  24032. * Specifies if the color write state should be cached
  24033. */
  24034. private _cachedColorWriteState;
  24035. /**
  24036. * Specifies if the depth function state should be cached
  24037. */
  24038. private _cachedDepthFunctionState;
  24039. /**
  24040. * Stores the uniform buffer
  24041. */
  24042. protected _uniformBuffer: UniformBuffer;
  24043. /** @hidden */
  24044. _indexInSceneMaterialArray: number;
  24045. /** @hidden */
  24046. meshMap: Nullable<{
  24047. [id: string]: AbstractMesh | undefined;
  24048. }>;
  24049. /**
  24050. * Creates a material instance
  24051. * @param name defines the name of the material
  24052. * @param scene defines the scene to reference
  24053. * @param doNotAdd specifies if the material should be added to the scene
  24054. */
  24055. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24056. /**
  24057. * Returns a string representation of the current material
  24058. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24059. * @returns a string with material information
  24060. */
  24061. toString(fullDetails?: boolean): string;
  24062. /**
  24063. * Gets the class name of the material
  24064. * @returns a string with the class name of the material
  24065. */
  24066. getClassName(): string;
  24067. /**
  24068. * Specifies if updates for the material been locked
  24069. */
  24070. get isFrozen(): boolean;
  24071. /**
  24072. * Locks updates for the material
  24073. */
  24074. freeze(): void;
  24075. /**
  24076. * Unlocks updates for the material
  24077. */
  24078. unfreeze(): void;
  24079. /**
  24080. * Specifies if the material is ready to be used
  24081. * @param mesh defines the mesh to check
  24082. * @param useInstances specifies if instances should be used
  24083. * @returns a boolean indicating if the material is ready to be used
  24084. */
  24085. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24086. /**
  24087. * Specifies that the submesh is ready to be used
  24088. * @param mesh defines the mesh to check
  24089. * @param subMesh defines which submesh to check
  24090. * @param useInstances specifies that instances should be used
  24091. * @returns a boolean indicating that the submesh is ready or not
  24092. */
  24093. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24094. /**
  24095. * Returns the material effect
  24096. * @returns the effect associated with the material
  24097. */
  24098. getEffect(): Nullable<Effect>;
  24099. /**
  24100. * Returns the current scene
  24101. * @returns a Scene
  24102. */
  24103. getScene(): Scene;
  24104. /**
  24105. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24106. */
  24107. protected _forceAlphaTest: boolean;
  24108. /**
  24109. * The transparency mode of the material.
  24110. */
  24111. protected _transparencyMode: Nullable<number>;
  24112. /**
  24113. * Gets the current transparency mode.
  24114. */
  24115. get transparencyMode(): Nullable<number>;
  24116. /**
  24117. * Sets the transparency mode of the material.
  24118. *
  24119. * | Value | Type | Description |
  24120. * | ----- | ----------------------------------- | ----------- |
  24121. * | 0 | OPAQUE | |
  24122. * | 1 | ALPHATEST | |
  24123. * | 2 | ALPHABLEND | |
  24124. * | 3 | ALPHATESTANDBLEND | |
  24125. *
  24126. */
  24127. set transparencyMode(value: Nullable<number>);
  24128. /**
  24129. * Returns true if alpha blending should be disabled.
  24130. */
  24131. protected get _disableAlphaBlending(): boolean;
  24132. /**
  24133. * Specifies whether or not this material should be rendered in alpha blend mode.
  24134. * @returns a boolean specifying if alpha blending is needed
  24135. */
  24136. needAlphaBlending(): boolean;
  24137. /**
  24138. * Specifies if the mesh will require alpha blending
  24139. * @param mesh defines the mesh to check
  24140. * @returns a boolean specifying if alpha blending is needed for the mesh
  24141. */
  24142. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24143. /**
  24144. * Specifies whether or not this material should be rendered in alpha test mode.
  24145. * @returns a boolean specifying if an alpha test is needed.
  24146. */
  24147. needAlphaTesting(): boolean;
  24148. /**
  24149. * Specifies if material alpha testing should be turned on for the mesh
  24150. * @param mesh defines the mesh to check
  24151. */
  24152. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24153. /**
  24154. * Gets the texture used for the alpha test
  24155. * @returns the texture to use for alpha testing
  24156. */
  24157. getAlphaTestTexture(): Nullable<BaseTexture>;
  24158. /**
  24159. * Marks the material to indicate that it needs to be re-calculated
  24160. */
  24161. markDirty(): void;
  24162. /** @hidden */
  24163. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24164. /**
  24165. * Binds the material to the mesh
  24166. * @param world defines the world transformation matrix
  24167. * @param mesh defines the mesh to bind the material to
  24168. */
  24169. bind(world: Matrix, mesh?: Mesh): void;
  24170. /**
  24171. * Binds the submesh to the material
  24172. * @param world defines the world transformation matrix
  24173. * @param mesh defines the mesh containing the submesh
  24174. * @param subMesh defines the submesh to bind the material to
  24175. */
  24176. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24177. /**
  24178. * Binds the world matrix to the material
  24179. * @param world defines the world transformation matrix
  24180. */
  24181. bindOnlyWorldMatrix(world: Matrix): void;
  24182. /**
  24183. * Binds the scene's uniform buffer to the effect.
  24184. * @param effect defines the effect to bind to the scene uniform buffer
  24185. * @param sceneUbo defines the uniform buffer storing scene data
  24186. */
  24187. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24188. /**
  24189. * Binds the view matrix to the effect
  24190. * @param effect defines the effect to bind the view matrix to
  24191. */
  24192. bindView(effect: Effect): void;
  24193. /**
  24194. * Binds the view projection matrix to the effect
  24195. * @param effect defines the effect to bind the view projection matrix to
  24196. */
  24197. bindViewProjection(effect: Effect): void;
  24198. /**
  24199. * Processes to execute after binding the material to a mesh
  24200. * @param mesh defines the rendered mesh
  24201. */
  24202. protected _afterBind(mesh?: Mesh): void;
  24203. /**
  24204. * Unbinds the material from the mesh
  24205. */
  24206. unbind(): void;
  24207. /**
  24208. * Gets the active textures from the material
  24209. * @returns an array of textures
  24210. */
  24211. getActiveTextures(): BaseTexture[];
  24212. /**
  24213. * Specifies if the material uses a texture
  24214. * @param texture defines the texture to check against the material
  24215. * @returns a boolean specifying if the material uses the texture
  24216. */
  24217. hasTexture(texture: BaseTexture): boolean;
  24218. /**
  24219. * Makes a duplicate of the material, and gives it a new name
  24220. * @param name defines the new name for the duplicated material
  24221. * @returns the cloned material
  24222. */
  24223. clone(name: string): Nullable<Material>;
  24224. /**
  24225. * Gets the meshes bound to the material
  24226. * @returns an array of meshes bound to the material
  24227. */
  24228. getBindedMeshes(): AbstractMesh[];
  24229. /**
  24230. * Force shader compilation
  24231. * @param mesh defines the mesh associated with this material
  24232. * @param onCompiled defines a function to execute once the material is compiled
  24233. * @param options defines the options to configure the compilation
  24234. * @param onError defines a function to execute if the material fails compiling
  24235. */
  24236. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24237. /**
  24238. * Force shader compilation
  24239. * @param mesh defines the mesh that will use this material
  24240. * @param options defines additional options for compiling the shaders
  24241. * @returns a promise that resolves when the compilation completes
  24242. */
  24243. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24244. private static readonly _AllDirtyCallBack;
  24245. private static readonly _ImageProcessingDirtyCallBack;
  24246. private static readonly _TextureDirtyCallBack;
  24247. private static readonly _FresnelDirtyCallBack;
  24248. private static readonly _MiscDirtyCallBack;
  24249. private static readonly _LightsDirtyCallBack;
  24250. private static readonly _AttributeDirtyCallBack;
  24251. private static _FresnelAndMiscDirtyCallBack;
  24252. private static _TextureAndMiscDirtyCallBack;
  24253. private static readonly _DirtyCallbackArray;
  24254. private static readonly _RunDirtyCallBacks;
  24255. /**
  24256. * Marks a define in the material to indicate that it needs to be re-computed
  24257. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24258. */
  24259. markAsDirty(flag: number): void;
  24260. /**
  24261. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24262. * @param func defines a function which checks material defines against the submeshes
  24263. */
  24264. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24265. /**
  24266. * Indicates that the scene should check if the rendering now needs a prepass
  24267. */
  24268. protected _markScenePrePassDirty(): void;
  24269. /**
  24270. * Indicates that we need to re-calculated for all submeshes
  24271. */
  24272. protected _markAllSubMeshesAsAllDirty(): void;
  24273. /**
  24274. * Indicates that image processing needs to be re-calculated for all submeshes
  24275. */
  24276. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24277. /**
  24278. * Indicates that textures need to be re-calculated for all submeshes
  24279. */
  24280. protected _markAllSubMeshesAsTexturesDirty(): void;
  24281. /**
  24282. * Indicates that fresnel needs to be re-calculated for all submeshes
  24283. */
  24284. protected _markAllSubMeshesAsFresnelDirty(): void;
  24285. /**
  24286. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24287. */
  24288. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24289. /**
  24290. * Indicates that lights need to be re-calculated for all submeshes
  24291. */
  24292. protected _markAllSubMeshesAsLightsDirty(): void;
  24293. /**
  24294. * Indicates that attributes need to be re-calculated for all submeshes
  24295. */
  24296. protected _markAllSubMeshesAsAttributesDirty(): void;
  24297. /**
  24298. * Indicates that misc needs to be re-calculated for all submeshes
  24299. */
  24300. protected _markAllSubMeshesAsMiscDirty(): void;
  24301. /**
  24302. * Indicates that textures and misc need to be re-calculated for all submeshes
  24303. */
  24304. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24305. /**
  24306. * Disposes the material
  24307. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24308. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24309. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  24310. */
  24311. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  24312. /** @hidden */
  24313. private releaseVertexArrayObject;
  24314. /**
  24315. * Serializes this material
  24316. * @returns the serialized material object
  24317. */
  24318. serialize(): any;
  24319. /**
  24320. * Creates a material from parsed material data
  24321. * @param parsedMaterial defines parsed material data
  24322. * @param scene defines the hosting scene
  24323. * @param rootUrl defines the root URL to use to load textures
  24324. * @returns a new material
  24325. */
  24326. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  24327. }
  24328. }
  24329. declare module BABYLON {
  24330. /**
  24331. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24332. * separate meshes. This can be use to improve performances.
  24333. * @see https://doc.babylonjs.com/how_to/multi_materials
  24334. */
  24335. export class MultiMaterial extends Material {
  24336. private _subMaterials;
  24337. /**
  24338. * Gets or Sets the list of Materials used within the multi material.
  24339. * They need to be ordered according to the submeshes order in the associated mesh
  24340. */
  24341. get subMaterials(): Nullable<Material>[];
  24342. set subMaterials(value: Nullable<Material>[]);
  24343. /**
  24344. * Function used to align with Node.getChildren()
  24345. * @returns the list of Materials used within the multi material
  24346. */
  24347. getChildren(): Nullable<Material>[];
  24348. /**
  24349. * Instantiates a new Multi Material
  24350. * A multi-material is used to apply different materials to different parts of the same object without the need of
  24351. * separate meshes. This can be use to improve performances.
  24352. * @see https://doc.babylonjs.com/how_to/multi_materials
  24353. * @param name Define the name in the scene
  24354. * @param scene Define the scene the material belongs to
  24355. */
  24356. constructor(name: string, scene: Scene);
  24357. private _hookArray;
  24358. /**
  24359. * Get one of the submaterial by its index in the submaterials array
  24360. * @param index The index to look the sub material at
  24361. * @returns The Material if the index has been defined
  24362. */
  24363. getSubMaterial(index: number): Nullable<Material>;
  24364. /**
  24365. * Get the list of active textures for the whole sub materials list.
  24366. * @returns All the textures that will be used during the rendering
  24367. */
  24368. getActiveTextures(): BaseTexture[];
  24369. /**
  24370. * Gets the current class name of the material e.g. "MultiMaterial"
  24371. * Mainly use in serialization.
  24372. * @returns the class name
  24373. */
  24374. getClassName(): string;
  24375. /**
  24376. * Checks if the material is ready to render the requested sub mesh
  24377. * @param mesh Define the mesh the submesh belongs to
  24378. * @param subMesh Define the sub mesh to look readyness for
  24379. * @param useInstances Define whether or not the material is used with instances
  24380. * @returns true if ready, otherwise false
  24381. */
  24382. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24383. /**
  24384. * Clones the current material and its related sub materials
  24385. * @param name Define the name of the newly cloned material
  24386. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  24387. * @returns the cloned material
  24388. */
  24389. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  24390. /**
  24391. * Serializes the materials into a JSON representation.
  24392. * @returns the JSON representation
  24393. */
  24394. serialize(): any;
  24395. /**
  24396. * Dispose the material and release its associated resources
  24397. * @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)
  24398. * @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)
  24399. * @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)
  24400. */
  24401. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  24402. /**
  24403. * Creates a MultiMaterial from parsed MultiMaterial data.
  24404. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  24405. * @param scene defines the hosting scene
  24406. * @returns a new MultiMaterial
  24407. */
  24408. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  24409. }
  24410. }
  24411. declare module BABYLON {
  24412. /**
  24413. * Defines a subdivision inside a mesh
  24414. */
  24415. export class SubMesh implements ICullable {
  24416. /** the material index to use */
  24417. materialIndex: number;
  24418. /** vertex index start */
  24419. verticesStart: number;
  24420. /** vertices count */
  24421. verticesCount: number;
  24422. /** index start */
  24423. indexStart: number;
  24424. /** indices count */
  24425. indexCount: number;
  24426. /** @hidden */
  24427. _materialDefines: Nullable<MaterialDefines>;
  24428. /** @hidden */
  24429. _materialEffect: Nullable<Effect>;
  24430. /** @hidden */
  24431. _effectOverride: Nullable<Effect>;
  24432. /**
  24433. * Gets material defines used by the effect associated to the sub mesh
  24434. */
  24435. get materialDefines(): Nullable<MaterialDefines>;
  24436. /**
  24437. * Sets material defines used by the effect associated to the sub mesh
  24438. */
  24439. set materialDefines(defines: Nullable<MaterialDefines>);
  24440. /**
  24441. * Gets associated effect
  24442. */
  24443. get effect(): Nullable<Effect>;
  24444. /**
  24445. * Sets associated effect (effect used to render this submesh)
  24446. * @param effect defines the effect to associate with
  24447. * @param defines defines the set of defines used to compile this effect
  24448. */
  24449. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  24450. /** @hidden */
  24451. _linesIndexCount: number;
  24452. private _mesh;
  24453. private _renderingMesh;
  24454. private _boundingInfo;
  24455. private _linesIndexBuffer;
  24456. /** @hidden */
  24457. _lastColliderWorldVertices: Nullable<Vector3[]>;
  24458. /** @hidden */
  24459. _trianglePlanes: Plane[];
  24460. /** @hidden */
  24461. _lastColliderTransformMatrix: Nullable<Matrix>;
  24462. /** @hidden */
  24463. _renderId: number;
  24464. /** @hidden */
  24465. _alphaIndex: number;
  24466. /** @hidden */
  24467. _distanceToCamera: number;
  24468. /** @hidden */
  24469. _id: number;
  24470. private _currentMaterial;
  24471. /**
  24472. * Add a new submesh to a mesh
  24473. * @param materialIndex defines the material index to use
  24474. * @param verticesStart defines vertex index start
  24475. * @param verticesCount defines vertices count
  24476. * @param indexStart defines index start
  24477. * @param indexCount defines indices count
  24478. * @param mesh defines the parent mesh
  24479. * @param renderingMesh defines an optional rendering mesh
  24480. * @param createBoundingBox defines if bounding box should be created for this submesh
  24481. * @returns the new submesh
  24482. */
  24483. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  24484. /**
  24485. * Creates a new submesh
  24486. * @param materialIndex defines the material index to use
  24487. * @param verticesStart defines vertex index start
  24488. * @param verticesCount defines vertices count
  24489. * @param indexStart defines index start
  24490. * @param indexCount defines indices count
  24491. * @param mesh defines the parent mesh
  24492. * @param renderingMesh defines an optional rendering mesh
  24493. * @param createBoundingBox defines if bounding box should be created for this submesh
  24494. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  24495. */
  24496. constructor(
  24497. /** the material index to use */
  24498. materialIndex: number,
  24499. /** vertex index start */
  24500. verticesStart: number,
  24501. /** vertices count */
  24502. verticesCount: number,
  24503. /** index start */
  24504. indexStart: number,
  24505. /** indices count */
  24506. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  24507. /**
  24508. * Returns true if this submesh covers the entire parent mesh
  24509. * @ignorenaming
  24510. */
  24511. get IsGlobal(): boolean;
  24512. /**
  24513. * Returns the submesh BoudingInfo object
  24514. * @returns current bounding info (or mesh's one if the submesh is global)
  24515. */
  24516. getBoundingInfo(): BoundingInfo;
  24517. /**
  24518. * Sets the submesh BoundingInfo
  24519. * @param boundingInfo defines the new bounding info to use
  24520. * @returns the SubMesh
  24521. */
  24522. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  24523. /**
  24524. * Returns the mesh of the current submesh
  24525. * @return the parent mesh
  24526. */
  24527. getMesh(): AbstractMesh;
  24528. /**
  24529. * Returns the rendering mesh of the submesh
  24530. * @returns the rendering mesh (could be different from parent mesh)
  24531. */
  24532. getRenderingMesh(): Mesh;
  24533. /**
  24534. * Returns the replacement mesh of the submesh
  24535. * @returns the replacement mesh (could be different from parent mesh)
  24536. */
  24537. getReplacementMesh(): Nullable<AbstractMesh>;
  24538. /**
  24539. * Returns the effective mesh of the submesh
  24540. * @returns the effective mesh (could be different from parent mesh)
  24541. */
  24542. getEffectiveMesh(): AbstractMesh;
  24543. /**
  24544. * Returns the submesh material
  24545. * @returns null or the current material
  24546. */
  24547. getMaterial(): Nullable<Material>;
  24548. private _IsMultiMaterial;
  24549. /**
  24550. * Sets a new updated BoundingInfo object to the submesh
  24551. * @param data defines an optional position array to use to determine the bounding info
  24552. * @returns the SubMesh
  24553. */
  24554. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  24555. /** @hidden */
  24556. _checkCollision(collider: Collider): boolean;
  24557. /**
  24558. * Updates the submesh BoundingInfo
  24559. * @param world defines the world matrix to use to update the bounding info
  24560. * @returns the submesh
  24561. */
  24562. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  24563. /**
  24564. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  24565. * @param frustumPlanes defines the frustum planes
  24566. * @returns true if the submesh is intersecting with the frustum
  24567. */
  24568. isInFrustum(frustumPlanes: Plane[]): boolean;
  24569. /**
  24570. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  24571. * @param frustumPlanes defines the frustum planes
  24572. * @returns true if the submesh is inside the frustum
  24573. */
  24574. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24575. /**
  24576. * Renders the submesh
  24577. * @param enableAlphaMode defines if alpha needs to be used
  24578. * @returns the submesh
  24579. */
  24580. render(enableAlphaMode: boolean): SubMesh;
  24581. /**
  24582. * @hidden
  24583. */
  24584. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  24585. /**
  24586. * Checks if the submesh intersects with a ray
  24587. * @param ray defines the ray to test
  24588. * @returns true is the passed ray intersects the submesh bounding box
  24589. */
  24590. canIntersects(ray: Ray): boolean;
  24591. /**
  24592. * Intersects current submesh with a ray
  24593. * @param ray defines the ray to test
  24594. * @param positions defines mesh's positions array
  24595. * @param indices defines mesh's indices array
  24596. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24597. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24598. * @returns intersection info or null if no intersection
  24599. */
  24600. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  24601. /** @hidden */
  24602. private _intersectLines;
  24603. /** @hidden */
  24604. private _intersectUnIndexedLines;
  24605. /** @hidden */
  24606. private _intersectTriangles;
  24607. /** @hidden */
  24608. private _intersectUnIndexedTriangles;
  24609. /** @hidden */
  24610. _rebuild(): void;
  24611. /**
  24612. * Creates a new submesh from the passed mesh
  24613. * @param newMesh defines the new hosting mesh
  24614. * @param newRenderingMesh defines an optional rendering mesh
  24615. * @returns the new submesh
  24616. */
  24617. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  24618. /**
  24619. * Release associated resources
  24620. */
  24621. dispose(): void;
  24622. /**
  24623. * Gets the class name
  24624. * @returns the string "SubMesh".
  24625. */
  24626. getClassName(): string;
  24627. /**
  24628. * Creates a new submesh from indices data
  24629. * @param materialIndex the index of the main mesh material
  24630. * @param startIndex the index where to start the copy in the mesh indices array
  24631. * @param indexCount the number of indices to copy then from the startIndex
  24632. * @param mesh the main mesh to create the submesh from
  24633. * @param renderingMesh the optional rendering mesh
  24634. * @returns a new submesh
  24635. */
  24636. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  24637. }
  24638. }
  24639. declare module BABYLON {
  24640. /**
  24641. * Class used to represent data loading progression
  24642. */
  24643. export class SceneLoaderFlags {
  24644. private static _ForceFullSceneLoadingForIncremental;
  24645. private static _ShowLoadingScreen;
  24646. private static _CleanBoneMatrixWeights;
  24647. private static _loggingLevel;
  24648. /**
  24649. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  24650. */
  24651. static get ForceFullSceneLoadingForIncremental(): boolean;
  24652. static set ForceFullSceneLoadingForIncremental(value: boolean);
  24653. /**
  24654. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  24655. */
  24656. static get ShowLoadingScreen(): boolean;
  24657. static set ShowLoadingScreen(value: boolean);
  24658. /**
  24659. * Defines the current logging level (while loading the scene)
  24660. * @ignorenaming
  24661. */
  24662. static get loggingLevel(): number;
  24663. static set loggingLevel(value: number);
  24664. /**
  24665. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  24666. */
  24667. static get CleanBoneMatrixWeights(): boolean;
  24668. static set CleanBoneMatrixWeights(value: boolean);
  24669. }
  24670. }
  24671. declare module BABYLON {
  24672. /**
  24673. * Class used to store geometry data (vertex buffers + index buffer)
  24674. */
  24675. export class Geometry implements IGetSetVerticesData {
  24676. /**
  24677. * Gets or sets the ID of the geometry
  24678. */
  24679. id: string;
  24680. /**
  24681. * Gets or sets the unique ID of the geometry
  24682. */
  24683. uniqueId: number;
  24684. /**
  24685. * Gets the delay loading state of the geometry (none by default which means not delayed)
  24686. */
  24687. delayLoadState: number;
  24688. /**
  24689. * Gets the file containing the data to load when running in delay load state
  24690. */
  24691. delayLoadingFile: Nullable<string>;
  24692. /**
  24693. * Callback called when the geometry is updated
  24694. */
  24695. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  24696. private _scene;
  24697. private _engine;
  24698. private _meshes;
  24699. private _totalVertices;
  24700. /** @hidden */
  24701. _indices: IndicesArray;
  24702. /** @hidden */
  24703. _vertexBuffers: {
  24704. [key: string]: VertexBuffer;
  24705. };
  24706. private _isDisposed;
  24707. private _extend;
  24708. private _boundingBias;
  24709. /** @hidden */
  24710. _delayInfo: Array<string>;
  24711. private _indexBuffer;
  24712. private _indexBufferIsUpdatable;
  24713. /** @hidden */
  24714. _boundingInfo: Nullable<BoundingInfo>;
  24715. /** @hidden */
  24716. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  24717. /** @hidden */
  24718. _softwareSkinningFrameId: number;
  24719. private _vertexArrayObjects;
  24720. private _updatable;
  24721. /** @hidden */
  24722. _positions: Nullable<Vector3[]>;
  24723. /**
  24724. * 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
  24725. */
  24726. get boundingBias(): Vector2;
  24727. /**
  24728. * 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
  24729. */
  24730. set boundingBias(value: Vector2);
  24731. /**
  24732. * Static function used to attach a new empty geometry to a mesh
  24733. * @param mesh defines the mesh to attach the geometry to
  24734. * @returns the new Geometry
  24735. */
  24736. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  24737. /** Get the list of meshes using this geometry */
  24738. get meshes(): Mesh[];
  24739. /**
  24740. * 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
  24741. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  24742. */
  24743. useBoundingInfoFromGeometry: boolean;
  24744. /**
  24745. * Creates a new geometry
  24746. * @param id defines the unique ID
  24747. * @param scene defines the hosting scene
  24748. * @param vertexData defines the VertexData used to get geometry data
  24749. * @param updatable defines if geometry must be updatable (false by default)
  24750. * @param mesh defines the mesh that will be associated with the geometry
  24751. */
  24752. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  24753. /**
  24754. * Gets the current extend of the geometry
  24755. */
  24756. get extend(): {
  24757. minimum: Vector3;
  24758. maximum: Vector3;
  24759. };
  24760. /**
  24761. * Gets the hosting scene
  24762. * @returns the hosting Scene
  24763. */
  24764. getScene(): Scene;
  24765. /**
  24766. * Gets the hosting engine
  24767. * @returns the hosting Engine
  24768. */
  24769. getEngine(): Engine;
  24770. /**
  24771. * Defines if the geometry is ready to use
  24772. * @returns true if the geometry is ready to be used
  24773. */
  24774. isReady(): boolean;
  24775. /**
  24776. * Gets a value indicating that the geometry should not be serialized
  24777. */
  24778. get doNotSerialize(): boolean;
  24779. /** @hidden */
  24780. _rebuild(): void;
  24781. /**
  24782. * Affects all geometry data in one call
  24783. * @param vertexData defines the geometry data
  24784. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  24785. */
  24786. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  24787. /**
  24788. * Set specific vertex data
  24789. * @param kind defines the data kind (Position, normal, etc...)
  24790. * @param data defines the vertex data to use
  24791. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  24792. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  24793. */
  24794. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  24795. /**
  24796. * Removes a specific vertex data
  24797. * @param kind defines the data kind (Position, normal, etc...)
  24798. */
  24799. removeVerticesData(kind: string): void;
  24800. /**
  24801. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  24802. * @param buffer defines the vertex buffer to use
  24803. * @param totalVertices defines the total number of vertices for position kind (could be null)
  24804. */
  24805. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  24806. /**
  24807. * Update a specific vertex buffer
  24808. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  24809. * It will do nothing if the buffer is not updatable
  24810. * @param kind defines the data kind (Position, normal, etc...)
  24811. * @param data defines the data to use
  24812. * @param offset defines the offset in the target buffer where to store the data
  24813. * @param useBytes set to true if the offset is in bytes
  24814. */
  24815. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  24816. /**
  24817. * Update a specific vertex buffer
  24818. * This function will create a new buffer if the current one is not updatable
  24819. * @param kind defines the data kind (Position, normal, etc...)
  24820. * @param data defines the data to use
  24821. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  24822. */
  24823. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  24824. private _updateBoundingInfo;
  24825. /** @hidden */
  24826. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  24827. /**
  24828. * Gets total number of vertices
  24829. * @returns the total number of vertices
  24830. */
  24831. getTotalVertices(): number;
  24832. /**
  24833. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  24834. * @param kind defines the data kind (Position, normal, etc...)
  24835. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24836. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24837. * @returns a float array containing vertex data
  24838. */
  24839. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24840. /**
  24841. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  24842. * @param kind defines the data kind (Position, normal, etc...)
  24843. * @returns true if the vertex buffer with the specified kind is updatable
  24844. */
  24845. isVertexBufferUpdatable(kind: string): boolean;
  24846. /**
  24847. * Gets a specific vertex buffer
  24848. * @param kind defines the data kind (Position, normal, etc...)
  24849. * @returns a VertexBuffer
  24850. */
  24851. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24852. /**
  24853. * Returns all vertex buffers
  24854. * @return an object holding all vertex buffers indexed by kind
  24855. */
  24856. getVertexBuffers(): Nullable<{
  24857. [key: string]: VertexBuffer;
  24858. }>;
  24859. /**
  24860. * Gets a boolean indicating if specific vertex buffer is present
  24861. * @param kind defines the data kind (Position, normal, etc...)
  24862. * @returns true if data is present
  24863. */
  24864. isVerticesDataPresent(kind: string): boolean;
  24865. /**
  24866. * Gets a list of all attached data kinds (Position, normal, etc...)
  24867. * @returns a list of string containing all kinds
  24868. */
  24869. getVerticesDataKinds(): string[];
  24870. /**
  24871. * Update index buffer
  24872. * @param indices defines the indices to store in the index buffer
  24873. * @param offset defines the offset in the target buffer where to store the data
  24874. * @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)
  24875. */
  24876. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  24877. /**
  24878. * Creates a new index buffer
  24879. * @param indices defines the indices to store in the index buffer
  24880. * @param totalVertices defines the total number of vertices (could be null)
  24881. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  24882. */
  24883. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  24884. /**
  24885. * Return the total number of indices
  24886. * @returns the total number of indices
  24887. */
  24888. getTotalIndices(): number;
  24889. /**
  24890. * Gets the index buffer array
  24891. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24892. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24893. * @returns the index buffer array
  24894. */
  24895. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24896. /**
  24897. * Gets the index buffer
  24898. * @return the index buffer
  24899. */
  24900. getIndexBuffer(): Nullable<DataBuffer>;
  24901. /** @hidden */
  24902. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  24903. /**
  24904. * Release the associated resources for a specific mesh
  24905. * @param mesh defines the source mesh
  24906. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  24907. */
  24908. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  24909. /**
  24910. * Apply current geometry to a given mesh
  24911. * @param mesh defines the mesh to apply geometry to
  24912. */
  24913. applyToMesh(mesh: Mesh): void;
  24914. private _updateExtend;
  24915. private _applyToMesh;
  24916. private notifyUpdate;
  24917. /**
  24918. * Load the geometry if it was flagged as delay loaded
  24919. * @param scene defines the hosting scene
  24920. * @param onLoaded defines a callback called when the geometry is loaded
  24921. */
  24922. load(scene: Scene, onLoaded?: () => void): void;
  24923. private _queueLoad;
  24924. /**
  24925. * Invert the geometry to move from a right handed system to a left handed one.
  24926. */
  24927. toLeftHanded(): void;
  24928. /** @hidden */
  24929. _resetPointsArrayCache(): void;
  24930. /** @hidden */
  24931. _generatePointsArray(): boolean;
  24932. /**
  24933. * Gets a value indicating if the geometry is disposed
  24934. * @returns true if the geometry was disposed
  24935. */
  24936. isDisposed(): boolean;
  24937. private _disposeVertexArrayObjects;
  24938. /**
  24939. * Free all associated resources
  24940. */
  24941. dispose(): void;
  24942. /**
  24943. * Clone the current geometry into a new geometry
  24944. * @param id defines the unique ID of the new geometry
  24945. * @returns a new geometry object
  24946. */
  24947. copy(id: string): Geometry;
  24948. /**
  24949. * Serialize the current geometry info (and not the vertices data) into a JSON object
  24950. * @return a JSON representation of the current geometry data (without the vertices data)
  24951. */
  24952. serialize(): any;
  24953. private toNumberArray;
  24954. /**
  24955. * Serialize all vertices data into a JSON oject
  24956. * @returns a JSON representation of the current geometry data
  24957. */
  24958. serializeVerticeData(): any;
  24959. /**
  24960. * Extracts a clone of a mesh geometry
  24961. * @param mesh defines the source mesh
  24962. * @param id defines the unique ID of the new geometry object
  24963. * @returns the new geometry object
  24964. */
  24965. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  24966. /**
  24967. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  24968. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24969. * Be aware Math.random() could cause collisions, but:
  24970. * "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"
  24971. * @returns a string containing a new GUID
  24972. */
  24973. static RandomId(): string;
  24974. /** @hidden */
  24975. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  24976. private static _CleanMatricesWeights;
  24977. /**
  24978. * Create a new geometry from persisted data (Using .babylon file format)
  24979. * @param parsedVertexData defines the persisted data
  24980. * @param scene defines the hosting scene
  24981. * @param rootUrl defines the root url to use to load assets (like delayed data)
  24982. * @returns the new geometry object
  24983. */
  24984. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  24985. }
  24986. }
  24987. declare module BABYLON {
  24988. /**
  24989. * Define an interface for all classes that will get and set the data on vertices
  24990. */
  24991. export interface IGetSetVerticesData {
  24992. /**
  24993. * Gets a boolean indicating if specific vertex data is present
  24994. * @param kind defines the vertex data kind to use
  24995. * @returns true is data kind is present
  24996. */
  24997. isVerticesDataPresent(kind: string): boolean;
  24998. /**
  24999. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25000. * @param kind defines the data kind (Position, normal, etc...)
  25001. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25002. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25003. * @returns a float array containing vertex data
  25004. */
  25005. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25006. /**
  25007. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25008. * @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.
  25009. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25010. * @returns the indices array or an empty array if the mesh has no geometry
  25011. */
  25012. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25013. /**
  25014. * Set specific vertex data
  25015. * @param kind defines the data kind (Position, normal, etc...)
  25016. * @param data defines the vertex data to use
  25017. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25018. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25019. */
  25020. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25021. /**
  25022. * Update a specific associated vertex buffer
  25023. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25024. * - VertexBuffer.PositionKind
  25025. * - VertexBuffer.UVKind
  25026. * - VertexBuffer.UV2Kind
  25027. * - VertexBuffer.UV3Kind
  25028. * - VertexBuffer.UV4Kind
  25029. * - VertexBuffer.UV5Kind
  25030. * - VertexBuffer.UV6Kind
  25031. * - VertexBuffer.ColorKind
  25032. * - VertexBuffer.MatricesIndicesKind
  25033. * - VertexBuffer.MatricesIndicesExtraKind
  25034. * - VertexBuffer.MatricesWeightsKind
  25035. * - VertexBuffer.MatricesWeightsExtraKind
  25036. * @param data defines the data source
  25037. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25038. * @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)
  25039. */
  25040. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25041. /**
  25042. * Creates a new index buffer
  25043. * @param indices defines the indices to store in the index buffer
  25044. * @param totalVertices defines the total number of vertices (could be null)
  25045. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25046. */
  25047. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25048. }
  25049. /**
  25050. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25051. */
  25052. export class VertexData {
  25053. /**
  25054. * Mesh side orientation : usually the external or front surface
  25055. */
  25056. static readonly FRONTSIDE: number;
  25057. /**
  25058. * Mesh side orientation : usually the internal or back surface
  25059. */
  25060. static readonly BACKSIDE: number;
  25061. /**
  25062. * Mesh side orientation : both internal and external or front and back surfaces
  25063. */
  25064. static readonly DOUBLESIDE: number;
  25065. /**
  25066. * Mesh side orientation : by default, `FRONTSIDE`
  25067. */
  25068. static readonly DEFAULTSIDE: number;
  25069. /**
  25070. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25071. */
  25072. positions: Nullable<FloatArray>;
  25073. /**
  25074. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25075. */
  25076. normals: Nullable<FloatArray>;
  25077. /**
  25078. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25079. */
  25080. tangents: Nullable<FloatArray>;
  25081. /**
  25082. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25083. */
  25084. uvs: Nullable<FloatArray>;
  25085. /**
  25086. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25087. */
  25088. uvs2: Nullable<FloatArray>;
  25089. /**
  25090. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25091. */
  25092. uvs3: Nullable<FloatArray>;
  25093. /**
  25094. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25095. */
  25096. uvs4: Nullable<FloatArray>;
  25097. /**
  25098. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25099. */
  25100. uvs5: Nullable<FloatArray>;
  25101. /**
  25102. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25103. */
  25104. uvs6: Nullable<FloatArray>;
  25105. /**
  25106. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25107. */
  25108. colors: Nullable<FloatArray>;
  25109. /**
  25110. * 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).
  25111. */
  25112. matricesIndices: Nullable<FloatArray>;
  25113. /**
  25114. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25115. */
  25116. matricesWeights: Nullable<FloatArray>;
  25117. /**
  25118. * An array extending the number of possible indices
  25119. */
  25120. matricesIndicesExtra: Nullable<FloatArray>;
  25121. /**
  25122. * An array extending the number of possible weights when the number of indices is extended
  25123. */
  25124. matricesWeightsExtra: Nullable<FloatArray>;
  25125. /**
  25126. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25127. */
  25128. indices: Nullable<IndicesArray>;
  25129. /**
  25130. * Uses the passed data array to set the set the values for the specified kind of data
  25131. * @param data a linear array of floating numbers
  25132. * @param kind the type of data that is being set, eg positions, colors etc
  25133. */
  25134. set(data: FloatArray, kind: string): void;
  25135. /**
  25136. * Associates the vertexData to the passed Mesh.
  25137. * Sets it as updatable or not (default `false`)
  25138. * @param mesh the mesh the vertexData is applied to
  25139. * @param updatable when used and having the value true allows new data to update the vertexData
  25140. * @returns the VertexData
  25141. */
  25142. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25143. /**
  25144. * Associates the vertexData to the passed Geometry.
  25145. * Sets it as updatable or not (default `false`)
  25146. * @param geometry the geometry the vertexData is applied to
  25147. * @param updatable when used and having the value true allows new data to update the vertexData
  25148. * @returns VertexData
  25149. */
  25150. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25151. /**
  25152. * Updates the associated mesh
  25153. * @param mesh the mesh to be updated
  25154. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25155. * @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
  25156. * @returns VertexData
  25157. */
  25158. updateMesh(mesh: Mesh): VertexData;
  25159. /**
  25160. * Updates the associated geometry
  25161. * @param geometry the geometry to be updated
  25162. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25163. * @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
  25164. * @returns VertexData.
  25165. */
  25166. updateGeometry(geometry: Geometry): VertexData;
  25167. private _applyTo;
  25168. private _update;
  25169. /**
  25170. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25171. * @param matrix the transforming matrix
  25172. * @returns the VertexData
  25173. */
  25174. transform(matrix: Matrix): VertexData;
  25175. /**
  25176. * Merges the passed VertexData into the current one
  25177. * @param other the VertexData to be merged into the current one
  25178. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25179. * @returns the modified VertexData
  25180. */
  25181. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25182. private _mergeElement;
  25183. private _validate;
  25184. /**
  25185. * Serializes the VertexData
  25186. * @returns a serialized object
  25187. */
  25188. serialize(): any;
  25189. /**
  25190. * Extracts the vertexData from a mesh
  25191. * @param mesh the mesh from which to extract the VertexData
  25192. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25193. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25194. * @returns the object VertexData associated to the passed mesh
  25195. */
  25196. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25197. /**
  25198. * Extracts the vertexData from the geometry
  25199. * @param geometry the geometry from which to extract the VertexData
  25200. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25201. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25202. * @returns the object VertexData associated to the passed mesh
  25203. */
  25204. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25205. private static _ExtractFrom;
  25206. /**
  25207. * Creates the VertexData for a Ribbon
  25208. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25209. * * pathArray array of paths, each of which an array of successive Vector3
  25210. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25211. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25212. * * 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
  25213. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25214. * * 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)
  25215. * * 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)
  25216. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25217. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25218. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25219. * @returns the VertexData of the ribbon
  25220. */
  25221. static CreateRibbon(options: {
  25222. pathArray: Vector3[][];
  25223. closeArray?: boolean;
  25224. closePath?: boolean;
  25225. offset?: number;
  25226. sideOrientation?: number;
  25227. frontUVs?: Vector4;
  25228. backUVs?: Vector4;
  25229. invertUV?: boolean;
  25230. uvs?: Vector2[];
  25231. colors?: Color4[];
  25232. }): VertexData;
  25233. /**
  25234. * Creates the VertexData for a box
  25235. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25236. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25237. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25238. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25239. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25240. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25241. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25243. * * 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)
  25244. * * 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)
  25245. * @returns the VertexData of the box
  25246. */
  25247. static CreateBox(options: {
  25248. size?: number;
  25249. width?: number;
  25250. height?: number;
  25251. depth?: number;
  25252. faceUV?: Vector4[];
  25253. faceColors?: Color4[];
  25254. sideOrientation?: number;
  25255. frontUVs?: Vector4;
  25256. backUVs?: Vector4;
  25257. }): VertexData;
  25258. /**
  25259. * Creates the VertexData for a tiled box
  25260. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25261. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25262. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25263. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25265. * @returns the VertexData of the box
  25266. */
  25267. static CreateTiledBox(options: {
  25268. pattern?: number;
  25269. width?: number;
  25270. height?: number;
  25271. depth?: number;
  25272. tileSize?: number;
  25273. tileWidth?: number;
  25274. tileHeight?: number;
  25275. alignHorizontal?: number;
  25276. alignVertical?: number;
  25277. faceUV?: Vector4[];
  25278. faceColors?: Color4[];
  25279. sideOrientation?: number;
  25280. }): VertexData;
  25281. /**
  25282. * Creates the VertexData for a tiled plane
  25283. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25284. * * pattern a limited pattern arrangement depending on the number
  25285. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25286. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25287. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25289. * * 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)
  25290. * * 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)
  25291. * @returns the VertexData of the tiled plane
  25292. */
  25293. static CreateTiledPlane(options: {
  25294. pattern?: number;
  25295. tileSize?: number;
  25296. tileWidth?: number;
  25297. tileHeight?: number;
  25298. size?: number;
  25299. width?: number;
  25300. height?: number;
  25301. alignHorizontal?: number;
  25302. alignVertical?: number;
  25303. sideOrientation?: number;
  25304. frontUVs?: Vector4;
  25305. backUVs?: Vector4;
  25306. }): VertexData;
  25307. /**
  25308. * Creates the VertexData for an ellipsoid, defaults to a sphere
  25309. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25310. * * segments sets the number of horizontal strips optional, default 32
  25311. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  25312. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  25313. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  25314. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  25315. * * 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
  25316. * * 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
  25317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25318. * * 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)
  25319. * * 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)
  25320. * @returns the VertexData of the ellipsoid
  25321. */
  25322. static CreateSphere(options: {
  25323. segments?: number;
  25324. diameter?: number;
  25325. diameterX?: number;
  25326. diameterY?: number;
  25327. diameterZ?: number;
  25328. arc?: number;
  25329. slice?: number;
  25330. sideOrientation?: number;
  25331. frontUVs?: Vector4;
  25332. backUVs?: Vector4;
  25333. }): VertexData;
  25334. /**
  25335. * Creates the VertexData for a cylinder, cone or prism
  25336. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25337. * * height sets the height (y direction) of the cylinder, optional, default 2
  25338. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  25339. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  25340. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  25341. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25342. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  25343. * * 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
  25344. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25345. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25346. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  25347. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  25348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25349. * * 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)
  25350. * * 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)
  25351. * @returns the VertexData of the cylinder, cone or prism
  25352. */
  25353. static CreateCylinder(options: {
  25354. height?: number;
  25355. diameterTop?: number;
  25356. diameterBottom?: number;
  25357. diameter?: number;
  25358. tessellation?: number;
  25359. subdivisions?: number;
  25360. arc?: number;
  25361. faceColors?: Color4[];
  25362. faceUV?: Vector4[];
  25363. hasRings?: boolean;
  25364. enclose?: boolean;
  25365. sideOrientation?: number;
  25366. frontUVs?: Vector4;
  25367. backUVs?: Vector4;
  25368. }): VertexData;
  25369. /**
  25370. * Creates the VertexData for a torus
  25371. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25372. * * diameter the diameter of the torus, optional default 1
  25373. * * thickness the diameter of the tube forming the torus, optional default 0.5
  25374. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  25375. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25376. * * 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)
  25377. * * 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)
  25378. * @returns the VertexData of the torus
  25379. */
  25380. static CreateTorus(options: {
  25381. diameter?: number;
  25382. thickness?: number;
  25383. tessellation?: number;
  25384. sideOrientation?: number;
  25385. frontUVs?: Vector4;
  25386. backUVs?: Vector4;
  25387. }): VertexData;
  25388. /**
  25389. * Creates the VertexData of the LineSystem
  25390. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  25391. * - lines an array of lines, each line being an array of successive Vector3
  25392. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  25393. * @returns the VertexData of the LineSystem
  25394. */
  25395. static CreateLineSystem(options: {
  25396. lines: Vector3[][];
  25397. colors?: Nullable<Color4[][]>;
  25398. }): VertexData;
  25399. /**
  25400. * Create the VertexData for a DashedLines
  25401. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  25402. * - points an array successive Vector3
  25403. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  25404. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  25405. * - dashNb the intended total number of dashes, optional, default 200
  25406. * @returns the VertexData for the DashedLines
  25407. */
  25408. static CreateDashedLines(options: {
  25409. points: Vector3[];
  25410. dashSize?: number;
  25411. gapSize?: number;
  25412. dashNb?: number;
  25413. }): VertexData;
  25414. /**
  25415. * Creates the VertexData for a Ground
  25416. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25417. * - width the width (x direction) of the ground, optional, default 1
  25418. * - height the height (z direction) of the ground, optional, default 1
  25419. * - subdivisions the number of subdivisions per side, optional, default 1
  25420. * @returns the VertexData of the Ground
  25421. */
  25422. static CreateGround(options: {
  25423. width?: number;
  25424. height?: number;
  25425. subdivisions?: number;
  25426. subdivisionsX?: number;
  25427. subdivisionsY?: number;
  25428. }): VertexData;
  25429. /**
  25430. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  25431. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  25432. * * xmin the ground minimum X coordinate, optional, default -1
  25433. * * zmin the ground minimum Z coordinate, optional, default -1
  25434. * * xmax the ground maximum X coordinate, optional, default 1
  25435. * * zmax the ground maximum Z coordinate, optional, default 1
  25436. * * 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}
  25437. * * 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}
  25438. * @returns the VertexData of the TiledGround
  25439. */
  25440. static CreateTiledGround(options: {
  25441. xmin: number;
  25442. zmin: number;
  25443. xmax: number;
  25444. zmax: number;
  25445. subdivisions?: {
  25446. w: number;
  25447. h: number;
  25448. };
  25449. precision?: {
  25450. w: number;
  25451. h: number;
  25452. };
  25453. }): VertexData;
  25454. /**
  25455. * Creates the VertexData of the Ground designed from a heightmap
  25456. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  25457. * * width the width (x direction) of the ground
  25458. * * height the height (z direction) of the ground
  25459. * * subdivisions the number of subdivisions per side
  25460. * * minHeight the minimum altitude on the ground, optional, default 0
  25461. * * maxHeight the maximum altitude on the ground, optional default 1
  25462. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  25463. * * buffer the array holding the image color data
  25464. * * bufferWidth the width of image
  25465. * * bufferHeight the height of image
  25466. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  25467. * @returns the VertexData of the Ground designed from a heightmap
  25468. */
  25469. static CreateGroundFromHeightMap(options: {
  25470. width: number;
  25471. height: number;
  25472. subdivisions: number;
  25473. minHeight: number;
  25474. maxHeight: number;
  25475. colorFilter: Color3;
  25476. buffer: Uint8Array;
  25477. bufferWidth: number;
  25478. bufferHeight: number;
  25479. alphaFilter: number;
  25480. }): VertexData;
  25481. /**
  25482. * Creates the VertexData for a Plane
  25483. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  25484. * * size sets the width and height of the plane to the value of size, optional default 1
  25485. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  25486. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  25487. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25488. * * 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)
  25489. * * 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)
  25490. * @returns the VertexData of the box
  25491. */
  25492. static CreatePlane(options: {
  25493. size?: number;
  25494. width?: number;
  25495. height?: number;
  25496. sideOrientation?: number;
  25497. frontUVs?: Vector4;
  25498. backUVs?: Vector4;
  25499. }): VertexData;
  25500. /**
  25501. * Creates the VertexData of the Disc or regular Polygon
  25502. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  25503. * * radius the radius of the disc, optional default 0.5
  25504. * * tessellation the number of polygon sides, optional, default 64
  25505. * * 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
  25506. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25507. * * 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)
  25508. * * 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)
  25509. * @returns the VertexData of the box
  25510. */
  25511. static CreateDisc(options: {
  25512. radius?: number;
  25513. tessellation?: number;
  25514. arc?: number;
  25515. sideOrientation?: number;
  25516. frontUVs?: Vector4;
  25517. backUVs?: Vector4;
  25518. }): VertexData;
  25519. /**
  25520. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  25521. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  25522. * @param polygon a mesh built from polygonTriangulation.build()
  25523. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25524. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25525. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25526. * @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)
  25527. * @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)
  25528. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  25529. * @returns the VertexData of the Polygon
  25530. */
  25531. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  25532. /**
  25533. * Creates the VertexData of the IcoSphere
  25534. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  25535. * * radius the radius of the IcoSphere, optional default 1
  25536. * * radiusX allows stretching in the x direction, optional, default radius
  25537. * * radiusY allows stretching in the y direction, optional, default radius
  25538. * * radiusZ allows stretching in the z direction, optional, default radius
  25539. * * flat when true creates a flat shaded mesh, optional, default true
  25540. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25542. * * 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)
  25543. * * 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)
  25544. * @returns the VertexData of the IcoSphere
  25545. */
  25546. static CreateIcoSphere(options: {
  25547. radius?: number;
  25548. radiusX?: number;
  25549. radiusY?: number;
  25550. radiusZ?: number;
  25551. flat?: boolean;
  25552. subdivisions?: number;
  25553. sideOrientation?: number;
  25554. frontUVs?: Vector4;
  25555. backUVs?: Vector4;
  25556. }): VertexData;
  25557. /**
  25558. * Creates the VertexData for a Polyhedron
  25559. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  25560. * * type provided types are:
  25561. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  25562. * * 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)
  25563. * * size the size of the IcoSphere, optional default 1
  25564. * * sizeX allows stretching in the x direction, optional, default size
  25565. * * sizeY allows stretching in the y direction, optional, default size
  25566. * * sizeZ allows stretching in the z direction, optional, default size
  25567. * * 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
  25568. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  25569. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  25570. * * flat when true creates a flat shaded mesh, optional, default true
  25571. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  25572. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25573. * * 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)
  25574. * * 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)
  25575. * @returns the VertexData of the Polyhedron
  25576. */
  25577. static CreatePolyhedron(options: {
  25578. type?: number;
  25579. size?: number;
  25580. sizeX?: number;
  25581. sizeY?: number;
  25582. sizeZ?: number;
  25583. custom?: any;
  25584. faceUV?: Vector4[];
  25585. faceColors?: Color4[];
  25586. flat?: boolean;
  25587. sideOrientation?: number;
  25588. frontUVs?: Vector4;
  25589. backUVs?: Vector4;
  25590. }): VertexData;
  25591. /**
  25592. * Creates the VertexData for a TorusKnot
  25593. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  25594. * * radius the radius of the torus knot, optional, default 2
  25595. * * tube the thickness of the tube, optional, default 0.5
  25596. * * radialSegments the number of sides on each tube segments, optional, default 32
  25597. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  25598. * * p the number of windings around the z axis, optional, default 2
  25599. * * q the number of windings around the x axis, optional, default 3
  25600. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25601. * * 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)
  25602. * * 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)
  25603. * @returns the VertexData of the Torus Knot
  25604. */
  25605. static CreateTorusKnot(options: {
  25606. radius?: number;
  25607. tube?: number;
  25608. radialSegments?: number;
  25609. tubularSegments?: number;
  25610. p?: number;
  25611. q?: number;
  25612. sideOrientation?: number;
  25613. frontUVs?: Vector4;
  25614. backUVs?: Vector4;
  25615. }): VertexData;
  25616. /**
  25617. * Compute normals for given positions and indices
  25618. * @param positions an array of vertex positions, [...., x, y, z, ......]
  25619. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  25620. * @param normals an array of vertex normals, [...., x, y, z, ......]
  25621. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  25622. * * facetNormals : optional array of facet normals (vector3)
  25623. * * facetPositions : optional array of facet positions (vector3)
  25624. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  25625. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  25626. * * bInfo : optional bounding info, required for facetPartitioning computation
  25627. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  25628. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  25629. * * useRightHandedSystem: optional boolean to for right handed system computation
  25630. * * depthSort : optional boolean to enable the facet depth sort computation
  25631. * * distanceTo : optional Vector3 to compute the facet depth from this location
  25632. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  25633. */
  25634. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  25635. facetNormals?: any;
  25636. facetPositions?: any;
  25637. facetPartitioning?: any;
  25638. ratio?: number;
  25639. bInfo?: any;
  25640. bbSize?: Vector3;
  25641. subDiv?: any;
  25642. useRightHandedSystem?: boolean;
  25643. depthSort?: boolean;
  25644. distanceTo?: Vector3;
  25645. depthSortedFacets?: any;
  25646. }): void;
  25647. /** @hidden */
  25648. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  25649. /**
  25650. * Applies VertexData created from the imported parameters to the geometry
  25651. * @param parsedVertexData the parsed data from an imported file
  25652. * @param geometry the geometry to apply the VertexData to
  25653. */
  25654. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  25655. }
  25656. }
  25657. declare module BABYLON {
  25658. /**
  25659. * Defines a target to use with MorphTargetManager
  25660. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25661. */
  25662. export class MorphTarget implements IAnimatable {
  25663. /** defines the name of the target */
  25664. name: string;
  25665. /**
  25666. * Gets or sets the list of animations
  25667. */
  25668. animations: Animation[];
  25669. private _scene;
  25670. private _positions;
  25671. private _normals;
  25672. private _tangents;
  25673. private _uvs;
  25674. private _influence;
  25675. private _uniqueId;
  25676. /**
  25677. * Observable raised when the influence changes
  25678. */
  25679. onInfluenceChanged: Observable<boolean>;
  25680. /** @hidden */
  25681. _onDataLayoutChanged: Observable<void>;
  25682. /**
  25683. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  25684. */
  25685. get influence(): number;
  25686. set influence(influence: number);
  25687. /**
  25688. * Gets or sets the id of the morph Target
  25689. */
  25690. id: string;
  25691. private _animationPropertiesOverride;
  25692. /**
  25693. * Gets or sets the animation properties override
  25694. */
  25695. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25696. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25697. /**
  25698. * Creates a new MorphTarget
  25699. * @param name defines the name of the target
  25700. * @param influence defines the influence to use
  25701. * @param scene defines the scene the morphtarget belongs to
  25702. */
  25703. constructor(
  25704. /** defines the name of the target */
  25705. name: string, influence?: number, scene?: Nullable<Scene>);
  25706. /**
  25707. * Gets the unique ID of this manager
  25708. */
  25709. get uniqueId(): number;
  25710. /**
  25711. * Gets a boolean defining if the target contains position data
  25712. */
  25713. get hasPositions(): boolean;
  25714. /**
  25715. * Gets a boolean defining if the target contains normal data
  25716. */
  25717. get hasNormals(): boolean;
  25718. /**
  25719. * Gets a boolean defining if the target contains tangent data
  25720. */
  25721. get hasTangents(): boolean;
  25722. /**
  25723. * Gets a boolean defining if the target contains texture coordinates data
  25724. */
  25725. get hasUVs(): boolean;
  25726. /**
  25727. * Affects position data to this target
  25728. * @param data defines the position data to use
  25729. */
  25730. setPositions(data: Nullable<FloatArray>): void;
  25731. /**
  25732. * Gets the position data stored in this target
  25733. * @returns a FloatArray containing the position data (or null if not present)
  25734. */
  25735. getPositions(): Nullable<FloatArray>;
  25736. /**
  25737. * Affects normal data to this target
  25738. * @param data defines the normal data to use
  25739. */
  25740. setNormals(data: Nullable<FloatArray>): void;
  25741. /**
  25742. * Gets the normal data stored in this target
  25743. * @returns a FloatArray containing the normal data (or null if not present)
  25744. */
  25745. getNormals(): Nullable<FloatArray>;
  25746. /**
  25747. * Affects tangent data to this target
  25748. * @param data defines the tangent data to use
  25749. */
  25750. setTangents(data: Nullable<FloatArray>): void;
  25751. /**
  25752. * Gets the tangent data stored in this target
  25753. * @returns a FloatArray containing the tangent data (or null if not present)
  25754. */
  25755. getTangents(): Nullable<FloatArray>;
  25756. /**
  25757. * Affects texture coordinates data to this target
  25758. * @param data defines the texture coordinates data to use
  25759. */
  25760. setUVs(data: Nullable<FloatArray>): void;
  25761. /**
  25762. * Gets the texture coordinates data stored in this target
  25763. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  25764. */
  25765. getUVs(): Nullable<FloatArray>;
  25766. /**
  25767. * Clone the current target
  25768. * @returns a new MorphTarget
  25769. */
  25770. clone(): MorphTarget;
  25771. /**
  25772. * Serializes the current target into a Serialization object
  25773. * @returns the serialized object
  25774. */
  25775. serialize(): any;
  25776. /**
  25777. * Returns the string "MorphTarget"
  25778. * @returns "MorphTarget"
  25779. */
  25780. getClassName(): string;
  25781. /**
  25782. * Creates a new target from serialized data
  25783. * @param serializationObject defines the serialized data to use
  25784. * @returns a new MorphTarget
  25785. */
  25786. static Parse(serializationObject: any): MorphTarget;
  25787. /**
  25788. * Creates a MorphTarget from mesh data
  25789. * @param mesh defines the source mesh
  25790. * @param name defines the name to use for the new target
  25791. * @param influence defines the influence to attach to the target
  25792. * @returns a new MorphTarget
  25793. */
  25794. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  25795. }
  25796. }
  25797. declare module BABYLON {
  25798. /**
  25799. * This class is used to deform meshes using morphing between different targets
  25800. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25801. */
  25802. export class MorphTargetManager {
  25803. private _targets;
  25804. private _targetInfluenceChangedObservers;
  25805. private _targetDataLayoutChangedObservers;
  25806. private _activeTargets;
  25807. private _scene;
  25808. private _influences;
  25809. private _supportsNormals;
  25810. private _supportsTangents;
  25811. private _supportsUVs;
  25812. private _vertexCount;
  25813. private _uniqueId;
  25814. private _tempInfluences;
  25815. /**
  25816. * Gets or sets a boolean indicating if normals must be morphed
  25817. */
  25818. enableNormalMorphing: boolean;
  25819. /**
  25820. * Gets or sets a boolean indicating if tangents must be morphed
  25821. */
  25822. enableTangentMorphing: boolean;
  25823. /**
  25824. * Gets or sets a boolean indicating if UV must be morphed
  25825. */
  25826. enableUVMorphing: boolean;
  25827. /**
  25828. * Creates a new MorphTargetManager
  25829. * @param scene defines the current scene
  25830. */
  25831. constructor(scene?: Nullable<Scene>);
  25832. /**
  25833. * Gets the unique ID of this manager
  25834. */
  25835. get uniqueId(): number;
  25836. /**
  25837. * Gets the number of vertices handled by this manager
  25838. */
  25839. get vertexCount(): number;
  25840. /**
  25841. * Gets a boolean indicating if this manager supports morphing of normals
  25842. */
  25843. get supportsNormals(): boolean;
  25844. /**
  25845. * Gets a boolean indicating if this manager supports morphing of tangents
  25846. */
  25847. get supportsTangents(): boolean;
  25848. /**
  25849. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  25850. */
  25851. get supportsUVs(): boolean;
  25852. /**
  25853. * Gets the number of targets stored in this manager
  25854. */
  25855. get numTargets(): number;
  25856. /**
  25857. * Gets the number of influencers (ie. the number of targets with influences > 0)
  25858. */
  25859. get numInfluencers(): number;
  25860. /**
  25861. * Gets the list of influences (one per target)
  25862. */
  25863. get influences(): Float32Array;
  25864. /**
  25865. * Gets the active target at specified index. An active target is a target with an influence > 0
  25866. * @param index defines the index to check
  25867. * @returns the requested target
  25868. */
  25869. getActiveTarget(index: number): MorphTarget;
  25870. /**
  25871. * Gets the target at specified index
  25872. * @param index defines the index to check
  25873. * @returns the requested target
  25874. */
  25875. getTarget(index: number): MorphTarget;
  25876. /**
  25877. * Add a new target to this manager
  25878. * @param target defines the target to add
  25879. */
  25880. addTarget(target: MorphTarget): void;
  25881. /**
  25882. * Removes a target from the manager
  25883. * @param target defines the target to remove
  25884. */
  25885. removeTarget(target: MorphTarget): void;
  25886. /**
  25887. * Clone the current manager
  25888. * @returns a new MorphTargetManager
  25889. */
  25890. clone(): MorphTargetManager;
  25891. /**
  25892. * Serializes the current manager into a Serialization object
  25893. * @returns the serialized object
  25894. */
  25895. serialize(): any;
  25896. private _syncActiveTargets;
  25897. /**
  25898. * Syncrhonize the targets with all the meshes using this morph target manager
  25899. */
  25900. synchronize(): void;
  25901. /**
  25902. * Creates a new MorphTargetManager from serialized data
  25903. * @param serializationObject defines the serialized data
  25904. * @param scene defines the hosting scene
  25905. * @returns the new MorphTargetManager
  25906. */
  25907. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  25908. }
  25909. }
  25910. declare module BABYLON {
  25911. /**
  25912. * Class used to represent a specific level of detail of a mesh
  25913. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25914. */
  25915. export class MeshLODLevel {
  25916. /** Defines the distance where this level should start being displayed */
  25917. distance: number;
  25918. /** Defines the mesh to use to render this level */
  25919. mesh: Nullable<Mesh>;
  25920. /**
  25921. * Creates a new LOD level
  25922. * @param distance defines the distance where this level should star being displayed
  25923. * @param mesh defines the mesh to use to render this level
  25924. */
  25925. constructor(
  25926. /** Defines the distance where this level should start being displayed */
  25927. distance: number,
  25928. /** Defines the mesh to use to render this level */
  25929. mesh: Nullable<Mesh>);
  25930. }
  25931. }
  25932. declare module BABYLON {
  25933. /**
  25934. * Helper class used to generate a canvas to manipulate images
  25935. */
  25936. export class CanvasGenerator {
  25937. /**
  25938. * Create a new canvas (or offscreen canvas depending on the context)
  25939. * @param width defines the expected width
  25940. * @param height defines the expected height
  25941. * @return a new canvas or offscreen canvas
  25942. */
  25943. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  25944. }
  25945. }
  25946. declare module BABYLON {
  25947. /**
  25948. * Mesh representing the gorund
  25949. */
  25950. export class GroundMesh extends Mesh {
  25951. /** If octree should be generated */
  25952. generateOctree: boolean;
  25953. private _heightQuads;
  25954. /** @hidden */
  25955. _subdivisionsX: number;
  25956. /** @hidden */
  25957. _subdivisionsY: number;
  25958. /** @hidden */
  25959. _width: number;
  25960. /** @hidden */
  25961. _height: number;
  25962. /** @hidden */
  25963. _minX: number;
  25964. /** @hidden */
  25965. _maxX: number;
  25966. /** @hidden */
  25967. _minZ: number;
  25968. /** @hidden */
  25969. _maxZ: number;
  25970. constructor(name: string, scene: Scene);
  25971. /**
  25972. * "GroundMesh"
  25973. * @returns "GroundMesh"
  25974. */
  25975. getClassName(): string;
  25976. /**
  25977. * The minimum of x and y subdivisions
  25978. */
  25979. get subdivisions(): number;
  25980. /**
  25981. * X subdivisions
  25982. */
  25983. get subdivisionsX(): number;
  25984. /**
  25985. * Y subdivisions
  25986. */
  25987. get subdivisionsY(): number;
  25988. /**
  25989. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  25990. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  25991. * @param chunksCount the number of subdivisions for x and y
  25992. * @param octreeBlocksSize (Default: 32)
  25993. */
  25994. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  25995. /**
  25996. * Returns a height (y) value in the Worl system :
  25997. * the ground altitude at the coordinates (x, z) expressed in the World system.
  25998. * @param x x coordinate
  25999. * @param z z coordinate
  26000. * @returns the ground y position if (x, z) are outside the ground surface.
  26001. */
  26002. getHeightAtCoordinates(x: number, z: number): number;
  26003. /**
  26004. * Returns a normalized vector (Vector3) orthogonal to the ground
  26005. * at the ground coordinates (x, z) expressed in the World system.
  26006. * @param x x coordinate
  26007. * @param z z coordinate
  26008. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26009. */
  26010. getNormalAtCoordinates(x: number, z: number): Vector3;
  26011. /**
  26012. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26013. * at the ground coordinates (x, z) expressed in the World system.
  26014. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26015. * @param x x coordinate
  26016. * @param z z coordinate
  26017. * @param ref vector to store the result
  26018. * @returns the GroundMesh.
  26019. */
  26020. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26021. /**
  26022. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26023. * if the ground has been updated.
  26024. * This can be used in the render loop.
  26025. * @returns the GroundMesh.
  26026. */
  26027. updateCoordinateHeights(): GroundMesh;
  26028. private _getFacetAt;
  26029. private _initHeightQuads;
  26030. private _computeHeightQuads;
  26031. /**
  26032. * Serializes this ground mesh
  26033. * @param serializationObject object to write serialization to
  26034. */
  26035. serialize(serializationObject: any): void;
  26036. /**
  26037. * Parses a serialized ground mesh
  26038. * @param parsedMesh the serialized mesh
  26039. * @param scene the scene to create the ground mesh in
  26040. * @returns the created ground mesh
  26041. */
  26042. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26043. }
  26044. }
  26045. declare module BABYLON {
  26046. /**
  26047. * Interface for Physics-Joint data
  26048. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26049. */
  26050. export interface PhysicsJointData {
  26051. /**
  26052. * The main pivot of the joint
  26053. */
  26054. mainPivot?: Vector3;
  26055. /**
  26056. * The connected pivot of the joint
  26057. */
  26058. connectedPivot?: Vector3;
  26059. /**
  26060. * The main axis of the joint
  26061. */
  26062. mainAxis?: Vector3;
  26063. /**
  26064. * The connected axis of the joint
  26065. */
  26066. connectedAxis?: Vector3;
  26067. /**
  26068. * The collision of the joint
  26069. */
  26070. collision?: boolean;
  26071. /**
  26072. * Native Oimo/Cannon/Energy data
  26073. */
  26074. nativeParams?: any;
  26075. }
  26076. /**
  26077. * This is a holder class for the physics joint created by the physics plugin
  26078. * It holds a set of functions to control the underlying joint
  26079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26080. */
  26081. export class PhysicsJoint {
  26082. /**
  26083. * The type of the physics joint
  26084. */
  26085. type: number;
  26086. /**
  26087. * The data for the physics joint
  26088. */
  26089. jointData: PhysicsJointData;
  26090. private _physicsJoint;
  26091. protected _physicsPlugin: IPhysicsEnginePlugin;
  26092. /**
  26093. * Initializes the physics joint
  26094. * @param type The type of the physics joint
  26095. * @param jointData The data for the physics joint
  26096. */
  26097. constructor(
  26098. /**
  26099. * The type of the physics joint
  26100. */
  26101. type: number,
  26102. /**
  26103. * The data for the physics joint
  26104. */
  26105. jointData: PhysicsJointData);
  26106. /**
  26107. * Gets the physics joint
  26108. */
  26109. get physicsJoint(): any;
  26110. /**
  26111. * Sets the physics joint
  26112. */
  26113. set physicsJoint(newJoint: any);
  26114. /**
  26115. * Sets the physics plugin
  26116. */
  26117. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26118. /**
  26119. * Execute a function that is physics-plugin specific.
  26120. * @param {Function} func the function that will be executed.
  26121. * It accepts two parameters: the physics world and the physics joint
  26122. */
  26123. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26124. /**
  26125. * Distance-Joint type
  26126. */
  26127. static DistanceJoint: number;
  26128. /**
  26129. * Hinge-Joint type
  26130. */
  26131. static HingeJoint: number;
  26132. /**
  26133. * Ball-and-Socket joint type
  26134. */
  26135. static BallAndSocketJoint: number;
  26136. /**
  26137. * Wheel-Joint type
  26138. */
  26139. static WheelJoint: number;
  26140. /**
  26141. * Slider-Joint type
  26142. */
  26143. static SliderJoint: number;
  26144. /**
  26145. * Prismatic-Joint type
  26146. */
  26147. static PrismaticJoint: number;
  26148. /**
  26149. * Universal-Joint type
  26150. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26151. */
  26152. static UniversalJoint: number;
  26153. /**
  26154. * Hinge-Joint 2 type
  26155. */
  26156. static Hinge2Joint: number;
  26157. /**
  26158. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26159. */
  26160. static PointToPointJoint: number;
  26161. /**
  26162. * Spring-Joint type
  26163. */
  26164. static SpringJoint: number;
  26165. /**
  26166. * Lock-Joint type
  26167. */
  26168. static LockJoint: number;
  26169. }
  26170. /**
  26171. * A class representing a physics distance joint
  26172. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26173. */
  26174. export class DistanceJoint extends PhysicsJoint {
  26175. /**
  26176. *
  26177. * @param jointData The data for the Distance-Joint
  26178. */
  26179. constructor(jointData: DistanceJointData);
  26180. /**
  26181. * Update the predefined distance.
  26182. * @param maxDistance The maximum preferred distance
  26183. * @param minDistance The minimum preferred distance
  26184. */
  26185. updateDistance(maxDistance: number, minDistance?: number): void;
  26186. }
  26187. /**
  26188. * Represents a Motor-Enabled Joint
  26189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26190. */
  26191. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26192. /**
  26193. * Initializes the Motor-Enabled Joint
  26194. * @param type The type of the joint
  26195. * @param jointData The physica joint data for the joint
  26196. */
  26197. constructor(type: number, jointData: PhysicsJointData);
  26198. /**
  26199. * Set the motor values.
  26200. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26201. * @param force the force to apply
  26202. * @param maxForce max force for this motor.
  26203. */
  26204. setMotor(force?: number, maxForce?: number): void;
  26205. /**
  26206. * Set the motor's limits.
  26207. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26208. * @param upperLimit The upper limit of the motor
  26209. * @param lowerLimit The lower limit of the motor
  26210. */
  26211. setLimit(upperLimit: number, lowerLimit?: number): void;
  26212. }
  26213. /**
  26214. * This class represents a single physics Hinge-Joint
  26215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26216. */
  26217. export class HingeJoint extends MotorEnabledJoint {
  26218. /**
  26219. * Initializes the Hinge-Joint
  26220. * @param jointData The joint data for the Hinge-Joint
  26221. */
  26222. constructor(jointData: PhysicsJointData);
  26223. /**
  26224. * Set the motor values.
  26225. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26226. * @param {number} force the force to apply
  26227. * @param {number} maxForce max force for this motor.
  26228. */
  26229. setMotor(force?: number, maxForce?: number): void;
  26230. /**
  26231. * Set the motor's limits.
  26232. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26233. * @param upperLimit The upper limit of the motor
  26234. * @param lowerLimit The lower limit of the motor
  26235. */
  26236. setLimit(upperLimit: number, lowerLimit?: number): void;
  26237. }
  26238. /**
  26239. * This class represents a dual hinge physics joint (same as wheel joint)
  26240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26241. */
  26242. export class Hinge2Joint extends MotorEnabledJoint {
  26243. /**
  26244. * Initializes the Hinge2-Joint
  26245. * @param jointData The joint data for the Hinge2-Joint
  26246. */
  26247. constructor(jointData: PhysicsJointData);
  26248. /**
  26249. * Set the motor values.
  26250. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26251. * @param {number} targetSpeed the speed the motor is to reach
  26252. * @param {number} maxForce max force for this motor.
  26253. * @param {motorIndex} the motor's index, 0 or 1.
  26254. */
  26255. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26256. /**
  26257. * Set the motor limits.
  26258. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26259. * @param {number} upperLimit the upper limit
  26260. * @param {number} lowerLimit lower limit
  26261. * @param {motorIndex} the motor's index, 0 or 1.
  26262. */
  26263. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26264. }
  26265. /**
  26266. * Interface for a motor enabled joint
  26267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26268. */
  26269. export interface IMotorEnabledJoint {
  26270. /**
  26271. * Physics joint
  26272. */
  26273. physicsJoint: any;
  26274. /**
  26275. * Sets the motor of the motor-enabled joint
  26276. * @param force The force of the motor
  26277. * @param maxForce The maximum force of the motor
  26278. * @param motorIndex The index of the motor
  26279. */
  26280. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26281. /**
  26282. * Sets the limit of the motor
  26283. * @param upperLimit The upper limit of the motor
  26284. * @param lowerLimit The lower limit of the motor
  26285. * @param motorIndex The index of the motor
  26286. */
  26287. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26288. }
  26289. /**
  26290. * Joint data for a Distance-Joint
  26291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26292. */
  26293. export interface DistanceJointData extends PhysicsJointData {
  26294. /**
  26295. * Max distance the 2 joint objects can be apart
  26296. */
  26297. maxDistance: number;
  26298. }
  26299. /**
  26300. * Joint data from a spring joint
  26301. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26302. */
  26303. export interface SpringJointData extends PhysicsJointData {
  26304. /**
  26305. * Length of the spring
  26306. */
  26307. length: number;
  26308. /**
  26309. * Stiffness of the spring
  26310. */
  26311. stiffness: number;
  26312. /**
  26313. * Damping of the spring
  26314. */
  26315. damping: number;
  26316. /** this callback will be called when applying the force to the impostors. */
  26317. forceApplicationCallback: () => void;
  26318. }
  26319. }
  26320. declare module BABYLON {
  26321. /**
  26322. * Holds the data for the raycast result
  26323. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26324. */
  26325. export class PhysicsRaycastResult {
  26326. private _hasHit;
  26327. private _hitDistance;
  26328. private _hitNormalWorld;
  26329. private _hitPointWorld;
  26330. private _rayFromWorld;
  26331. private _rayToWorld;
  26332. /**
  26333. * Gets if there was a hit
  26334. */
  26335. get hasHit(): boolean;
  26336. /**
  26337. * Gets the distance from the hit
  26338. */
  26339. get hitDistance(): number;
  26340. /**
  26341. * Gets the hit normal/direction in the world
  26342. */
  26343. get hitNormalWorld(): Vector3;
  26344. /**
  26345. * Gets the hit point in the world
  26346. */
  26347. get hitPointWorld(): Vector3;
  26348. /**
  26349. * Gets the ray "start point" of the ray in the world
  26350. */
  26351. get rayFromWorld(): Vector3;
  26352. /**
  26353. * Gets the ray "end point" of the ray in the world
  26354. */
  26355. get rayToWorld(): Vector3;
  26356. /**
  26357. * Sets the hit data (normal & point in world space)
  26358. * @param hitNormalWorld defines the normal in world space
  26359. * @param hitPointWorld defines the point in world space
  26360. */
  26361. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  26362. /**
  26363. * Sets the distance from the start point to the hit point
  26364. * @param distance
  26365. */
  26366. setHitDistance(distance: number): void;
  26367. /**
  26368. * Calculates the distance manually
  26369. */
  26370. calculateHitDistance(): void;
  26371. /**
  26372. * Resets all the values to default
  26373. * @param from The from point on world space
  26374. * @param to The to point on world space
  26375. */
  26376. reset(from?: Vector3, to?: Vector3): void;
  26377. }
  26378. /**
  26379. * Interface for the size containing width and height
  26380. */
  26381. interface IXYZ {
  26382. /**
  26383. * X
  26384. */
  26385. x: number;
  26386. /**
  26387. * Y
  26388. */
  26389. y: number;
  26390. /**
  26391. * Z
  26392. */
  26393. z: number;
  26394. }
  26395. }
  26396. declare module BABYLON {
  26397. /**
  26398. * Interface used to describe a physics joint
  26399. */
  26400. export interface PhysicsImpostorJoint {
  26401. /** Defines the main impostor to which the joint is linked */
  26402. mainImpostor: PhysicsImpostor;
  26403. /** Defines the impostor that is connected to the main impostor using this joint */
  26404. connectedImpostor: PhysicsImpostor;
  26405. /** Defines the joint itself */
  26406. joint: PhysicsJoint;
  26407. }
  26408. /** @hidden */
  26409. export interface IPhysicsEnginePlugin {
  26410. world: any;
  26411. name: string;
  26412. setGravity(gravity: Vector3): void;
  26413. setTimeStep(timeStep: number): void;
  26414. getTimeStep(): number;
  26415. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  26416. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26417. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  26418. generatePhysicsBody(impostor: PhysicsImpostor): void;
  26419. removePhysicsBody(impostor: PhysicsImpostor): void;
  26420. generateJoint(joint: PhysicsImpostorJoint): void;
  26421. removeJoint(joint: PhysicsImpostorJoint): void;
  26422. isSupported(): boolean;
  26423. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  26424. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  26425. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26426. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  26427. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26428. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  26429. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  26430. getBodyMass(impostor: PhysicsImpostor): number;
  26431. getBodyFriction(impostor: PhysicsImpostor): number;
  26432. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  26433. getBodyRestitution(impostor: PhysicsImpostor): number;
  26434. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  26435. getBodyPressure?(impostor: PhysicsImpostor): number;
  26436. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  26437. getBodyStiffness?(impostor: PhysicsImpostor): number;
  26438. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  26439. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  26440. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  26441. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  26442. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  26443. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26444. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  26445. sleepBody(impostor: PhysicsImpostor): void;
  26446. wakeUpBody(impostor: PhysicsImpostor): void;
  26447. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26448. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  26449. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  26450. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26451. getRadius(impostor: PhysicsImpostor): number;
  26452. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  26453. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  26454. dispose(): void;
  26455. }
  26456. /**
  26457. * Interface used to define a physics engine
  26458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26459. */
  26460. export interface IPhysicsEngine {
  26461. /**
  26462. * Gets the gravity vector used by the simulation
  26463. */
  26464. gravity: Vector3;
  26465. /**
  26466. * Sets the gravity vector used by the simulation
  26467. * @param gravity defines the gravity vector to use
  26468. */
  26469. setGravity(gravity: Vector3): void;
  26470. /**
  26471. * Set the time step of the physics engine.
  26472. * Default is 1/60.
  26473. * To slow it down, enter 1/600 for example.
  26474. * To speed it up, 1/30
  26475. * @param newTimeStep the new timestep to apply to this world.
  26476. */
  26477. setTimeStep(newTimeStep: number): void;
  26478. /**
  26479. * Get the time step of the physics engine.
  26480. * @returns the current time step
  26481. */
  26482. getTimeStep(): number;
  26483. /**
  26484. * Set the sub time step of the physics engine.
  26485. * Default is 0 meaning there is no sub steps
  26486. * To increase physics resolution precision, set a small value (like 1 ms)
  26487. * @param subTimeStep defines the new sub timestep used for physics resolution.
  26488. */
  26489. setSubTimeStep(subTimeStep: number): void;
  26490. /**
  26491. * Get the sub time step of the physics engine.
  26492. * @returns the current sub time step
  26493. */
  26494. getSubTimeStep(): number;
  26495. /**
  26496. * Release all resources
  26497. */
  26498. dispose(): void;
  26499. /**
  26500. * Gets the name of the current physics plugin
  26501. * @returns the name of the plugin
  26502. */
  26503. getPhysicsPluginName(): string;
  26504. /**
  26505. * Adding a new impostor for the impostor tracking.
  26506. * This will be done by the impostor itself.
  26507. * @param impostor the impostor to add
  26508. */
  26509. addImpostor(impostor: PhysicsImpostor): void;
  26510. /**
  26511. * Remove an impostor from the engine.
  26512. * This impostor and its mesh will not longer be updated by the physics engine.
  26513. * @param impostor the impostor to remove
  26514. */
  26515. removeImpostor(impostor: PhysicsImpostor): void;
  26516. /**
  26517. * Add a joint to the physics engine
  26518. * @param mainImpostor defines the main impostor to which the joint is added.
  26519. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  26520. * @param joint defines the joint that will connect both impostors.
  26521. */
  26522. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26523. /**
  26524. * Removes a joint from the simulation
  26525. * @param mainImpostor defines the impostor used with the joint
  26526. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  26527. * @param joint defines the joint to remove
  26528. */
  26529. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  26530. /**
  26531. * Gets the current plugin used to run the simulation
  26532. * @returns current plugin
  26533. */
  26534. getPhysicsPlugin(): IPhysicsEnginePlugin;
  26535. /**
  26536. * Gets the list of physic impostors
  26537. * @returns an array of PhysicsImpostor
  26538. */
  26539. getImpostors(): Array<PhysicsImpostor>;
  26540. /**
  26541. * Gets the impostor for a physics enabled object
  26542. * @param object defines the object impersonated by the impostor
  26543. * @returns the PhysicsImpostor or null if not found
  26544. */
  26545. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  26546. /**
  26547. * Gets the impostor for a physics body object
  26548. * @param body defines physics body used by the impostor
  26549. * @returns the PhysicsImpostor or null if not found
  26550. */
  26551. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  26552. /**
  26553. * Does a raycast in the physics world
  26554. * @param from when should the ray start?
  26555. * @param to when should the ray end?
  26556. * @returns PhysicsRaycastResult
  26557. */
  26558. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  26559. /**
  26560. * Called by the scene. No need to call it.
  26561. * @param delta defines the timespam between frames
  26562. */
  26563. _step(delta: number): void;
  26564. }
  26565. }
  26566. declare module BABYLON {
  26567. /**
  26568. * The interface for the physics imposter parameters
  26569. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26570. */
  26571. export interface PhysicsImpostorParameters {
  26572. /**
  26573. * The mass of the physics imposter
  26574. */
  26575. mass: number;
  26576. /**
  26577. * The friction of the physics imposter
  26578. */
  26579. friction?: number;
  26580. /**
  26581. * The coefficient of restitution of the physics imposter
  26582. */
  26583. restitution?: number;
  26584. /**
  26585. * The native options of the physics imposter
  26586. */
  26587. nativeOptions?: any;
  26588. /**
  26589. * Specifies if the parent should be ignored
  26590. */
  26591. ignoreParent?: boolean;
  26592. /**
  26593. * Specifies if bi-directional transformations should be disabled
  26594. */
  26595. disableBidirectionalTransformation?: boolean;
  26596. /**
  26597. * The pressure inside the physics imposter, soft object only
  26598. */
  26599. pressure?: number;
  26600. /**
  26601. * The stiffness the physics imposter, soft object only
  26602. */
  26603. stiffness?: number;
  26604. /**
  26605. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  26606. */
  26607. velocityIterations?: number;
  26608. /**
  26609. * The number of iterations used in maintaining consistent vertex positions, soft object only
  26610. */
  26611. positionIterations?: number;
  26612. /**
  26613. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  26614. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  26615. * Add to fix multiple points
  26616. */
  26617. fixedPoints?: number;
  26618. /**
  26619. * The collision margin around a soft object
  26620. */
  26621. margin?: number;
  26622. /**
  26623. * The collision margin around a soft object
  26624. */
  26625. damping?: number;
  26626. /**
  26627. * The path for a rope based on an extrusion
  26628. */
  26629. path?: any;
  26630. /**
  26631. * The shape of an extrusion used for a rope based on an extrusion
  26632. */
  26633. shape?: any;
  26634. }
  26635. /**
  26636. * Interface for a physics-enabled object
  26637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26638. */
  26639. export interface IPhysicsEnabledObject {
  26640. /**
  26641. * The position of the physics-enabled object
  26642. */
  26643. position: Vector3;
  26644. /**
  26645. * The rotation of the physics-enabled object
  26646. */
  26647. rotationQuaternion: Nullable<Quaternion>;
  26648. /**
  26649. * The scale of the physics-enabled object
  26650. */
  26651. scaling: Vector3;
  26652. /**
  26653. * The rotation of the physics-enabled object
  26654. */
  26655. rotation?: Vector3;
  26656. /**
  26657. * The parent of the physics-enabled object
  26658. */
  26659. parent?: any;
  26660. /**
  26661. * The bounding info of the physics-enabled object
  26662. * @returns The bounding info of the physics-enabled object
  26663. */
  26664. getBoundingInfo(): BoundingInfo;
  26665. /**
  26666. * Computes the world matrix
  26667. * @param force Specifies if the world matrix should be computed by force
  26668. * @returns A world matrix
  26669. */
  26670. computeWorldMatrix(force: boolean): Matrix;
  26671. /**
  26672. * Gets the world matrix
  26673. * @returns A world matrix
  26674. */
  26675. getWorldMatrix?(): Matrix;
  26676. /**
  26677. * Gets the child meshes
  26678. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  26679. * @returns An array of abstract meshes
  26680. */
  26681. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  26682. /**
  26683. * Gets the vertex data
  26684. * @param kind The type of vertex data
  26685. * @returns A nullable array of numbers, or a float32 array
  26686. */
  26687. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  26688. /**
  26689. * Gets the indices from the mesh
  26690. * @returns A nullable array of index arrays
  26691. */
  26692. getIndices?(): Nullable<IndicesArray>;
  26693. /**
  26694. * Gets the scene from the mesh
  26695. * @returns the indices array or null
  26696. */
  26697. getScene?(): Scene;
  26698. /**
  26699. * Gets the absolute position from the mesh
  26700. * @returns the absolute position
  26701. */
  26702. getAbsolutePosition(): Vector3;
  26703. /**
  26704. * Gets the absolute pivot point from the mesh
  26705. * @returns the absolute pivot point
  26706. */
  26707. getAbsolutePivotPoint(): Vector3;
  26708. /**
  26709. * Rotates the mesh
  26710. * @param axis The axis of rotation
  26711. * @param amount The amount of rotation
  26712. * @param space The space of the rotation
  26713. * @returns The rotation transform node
  26714. */
  26715. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26716. /**
  26717. * Translates the mesh
  26718. * @param axis The axis of translation
  26719. * @param distance The distance of translation
  26720. * @param space The space of the translation
  26721. * @returns The transform node
  26722. */
  26723. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26724. /**
  26725. * Sets the absolute position of the mesh
  26726. * @param absolutePosition The absolute position of the mesh
  26727. * @returns The transform node
  26728. */
  26729. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26730. /**
  26731. * Gets the class name of the mesh
  26732. * @returns The class name
  26733. */
  26734. getClassName(): string;
  26735. }
  26736. /**
  26737. * Represents a physics imposter
  26738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26739. */
  26740. export class PhysicsImpostor {
  26741. /**
  26742. * The physics-enabled object used as the physics imposter
  26743. */
  26744. object: IPhysicsEnabledObject;
  26745. /**
  26746. * The type of the physics imposter
  26747. */
  26748. type: number;
  26749. private _options;
  26750. private _scene?;
  26751. /**
  26752. * The default object size of the imposter
  26753. */
  26754. static DEFAULT_OBJECT_SIZE: Vector3;
  26755. /**
  26756. * The identity quaternion of the imposter
  26757. */
  26758. static IDENTITY_QUATERNION: Quaternion;
  26759. /** @hidden */
  26760. _pluginData: any;
  26761. private _physicsEngine;
  26762. private _physicsBody;
  26763. private _bodyUpdateRequired;
  26764. private _onBeforePhysicsStepCallbacks;
  26765. private _onAfterPhysicsStepCallbacks;
  26766. /** @hidden */
  26767. _onPhysicsCollideCallbacks: Array<{
  26768. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  26769. otherImpostors: Array<PhysicsImpostor>;
  26770. }>;
  26771. private _deltaPosition;
  26772. private _deltaRotation;
  26773. private _deltaRotationConjugated;
  26774. /** @hidden */
  26775. _isFromLine: boolean;
  26776. private _parent;
  26777. private _isDisposed;
  26778. private static _tmpVecs;
  26779. private static _tmpQuat;
  26780. /**
  26781. * Specifies if the physics imposter is disposed
  26782. */
  26783. get isDisposed(): boolean;
  26784. /**
  26785. * Gets the mass of the physics imposter
  26786. */
  26787. get mass(): number;
  26788. set mass(value: number);
  26789. /**
  26790. * Gets the coefficient of friction
  26791. */
  26792. get friction(): number;
  26793. /**
  26794. * Sets the coefficient of friction
  26795. */
  26796. set friction(value: number);
  26797. /**
  26798. * Gets the coefficient of restitution
  26799. */
  26800. get restitution(): number;
  26801. /**
  26802. * Sets the coefficient of restitution
  26803. */
  26804. set restitution(value: number);
  26805. /**
  26806. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  26807. */
  26808. get pressure(): number;
  26809. /**
  26810. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  26811. */
  26812. set pressure(value: number);
  26813. /**
  26814. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26815. */
  26816. get stiffness(): number;
  26817. /**
  26818. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  26819. */
  26820. set stiffness(value: number);
  26821. /**
  26822. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26823. */
  26824. get velocityIterations(): number;
  26825. /**
  26826. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  26827. */
  26828. set velocityIterations(value: number);
  26829. /**
  26830. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26831. */
  26832. get positionIterations(): number;
  26833. /**
  26834. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  26835. */
  26836. set positionIterations(value: number);
  26837. /**
  26838. * The unique id of the physics imposter
  26839. * set by the physics engine when adding this impostor to the array
  26840. */
  26841. uniqueId: number;
  26842. /**
  26843. * @hidden
  26844. */
  26845. soft: boolean;
  26846. /**
  26847. * @hidden
  26848. */
  26849. segments: number;
  26850. private _joints;
  26851. /**
  26852. * Initializes the physics imposter
  26853. * @param object The physics-enabled object used as the physics imposter
  26854. * @param type The type of the physics imposter
  26855. * @param _options The options for the physics imposter
  26856. * @param _scene The Babylon scene
  26857. */
  26858. constructor(
  26859. /**
  26860. * The physics-enabled object used as the physics imposter
  26861. */
  26862. object: IPhysicsEnabledObject,
  26863. /**
  26864. * The type of the physics imposter
  26865. */
  26866. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  26867. /**
  26868. * This function will completly initialize this impostor.
  26869. * It will create a new body - but only if this mesh has no parent.
  26870. * If it has, this impostor will not be used other than to define the impostor
  26871. * of the child mesh.
  26872. * @hidden
  26873. */
  26874. _init(): void;
  26875. private _getPhysicsParent;
  26876. /**
  26877. * Should a new body be generated.
  26878. * @returns boolean specifying if body initialization is required
  26879. */
  26880. isBodyInitRequired(): boolean;
  26881. /**
  26882. * Sets the updated scaling
  26883. * @param updated Specifies if the scaling is updated
  26884. */
  26885. setScalingUpdated(): void;
  26886. /**
  26887. * Force a regeneration of this or the parent's impostor's body.
  26888. * Use under cautious - This will remove all joints already implemented.
  26889. */
  26890. forceUpdate(): void;
  26891. /**
  26892. * Gets the body that holds this impostor. Either its own, or its parent.
  26893. */
  26894. get physicsBody(): any;
  26895. /**
  26896. * Get the parent of the physics imposter
  26897. * @returns Physics imposter or null
  26898. */
  26899. get parent(): Nullable<PhysicsImpostor>;
  26900. /**
  26901. * Sets the parent of the physics imposter
  26902. */
  26903. set parent(value: Nullable<PhysicsImpostor>);
  26904. /**
  26905. * Set the physics body. Used mainly by the physics engine/plugin
  26906. */
  26907. set physicsBody(physicsBody: any);
  26908. /**
  26909. * Resets the update flags
  26910. */
  26911. resetUpdateFlags(): void;
  26912. /**
  26913. * Gets the object extend size
  26914. * @returns the object extend size
  26915. */
  26916. getObjectExtendSize(): Vector3;
  26917. /**
  26918. * Gets the object center
  26919. * @returns The object center
  26920. */
  26921. getObjectCenter(): Vector3;
  26922. /**
  26923. * Get a specific parameter from the options parameters
  26924. * @param paramName The object parameter name
  26925. * @returns The object parameter
  26926. */
  26927. getParam(paramName: string): any;
  26928. /**
  26929. * Sets a specific parameter in the options given to the physics plugin
  26930. * @param paramName The parameter name
  26931. * @param value The value of the parameter
  26932. */
  26933. setParam(paramName: string, value: number): void;
  26934. /**
  26935. * Specifically change the body's mass option. Won't recreate the physics body object
  26936. * @param mass The mass of the physics imposter
  26937. */
  26938. setMass(mass: number): void;
  26939. /**
  26940. * Gets the linear velocity
  26941. * @returns linear velocity or null
  26942. */
  26943. getLinearVelocity(): Nullable<Vector3>;
  26944. /**
  26945. * Sets the linear velocity
  26946. * @param velocity linear velocity or null
  26947. */
  26948. setLinearVelocity(velocity: Nullable<Vector3>): void;
  26949. /**
  26950. * Gets the angular velocity
  26951. * @returns angular velocity or null
  26952. */
  26953. getAngularVelocity(): Nullable<Vector3>;
  26954. /**
  26955. * Sets the angular velocity
  26956. * @param velocity The velocity or null
  26957. */
  26958. setAngularVelocity(velocity: Nullable<Vector3>): void;
  26959. /**
  26960. * Execute a function with the physics plugin native code
  26961. * Provide a function the will have two variables - the world object and the physics body object
  26962. * @param func The function to execute with the physics plugin native code
  26963. */
  26964. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  26965. /**
  26966. * Register a function that will be executed before the physics world is stepping forward
  26967. * @param func The function to execute before the physics world is stepped forward
  26968. */
  26969. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26970. /**
  26971. * Unregister a function that will be executed before the physics world is stepping forward
  26972. * @param func The function to execute before the physics world is stepped forward
  26973. */
  26974. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26975. /**
  26976. * Register a function that will be executed after the physics step
  26977. * @param func The function to execute after physics step
  26978. */
  26979. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26980. /**
  26981. * Unregisters a function that will be executed after the physics step
  26982. * @param func The function to execute after physics step
  26983. */
  26984. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  26985. /**
  26986. * register a function that will be executed when this impostor collides against a different body
  26987. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  26988. * @param func Callback that is executed on collision
  26989. */
  26990. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  26991. /**
  26992. * Unregisters the physics imposter on contact
  26993. * @param collideAgainst The physics object to collide against
  26994. * @param func Callback to execute on collision
  26995. */
  26996. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  26997. private _tmpQuat;
  26998. private _tmpQuat2;
  26999. /**
  27000. * Get the parent rotation
  27001. * @returns The parent rotation
  27002. */
  27003. getParentsRotation(): Quaternion;
  27004. /**
  27005. * this function is executed by the physics engine.
  27006. */
  27007. beforeStep: () => void;
  27008. /**
  27009. * this function is executed by the physics engine
  27010. */
  27011. afterStep: () => void;
  27012. /**
  27013. * Legacy collision detection event support
  27014. */
  27015. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27016. /**
  27017. * event and body object due to cannon's event-based architecture.
  27018. */
  27019. onCollide: (e: {
  27020. body: any;
  27021. }) => void;
  27022. /**
  27023. * Apply a force
  27024. * @param force The force to apply
  27025. * @param contactPoint The contact point for the force
  27026. * @returns The physics imposter
  27027. */
  27028. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27029. /**
  27030. * Apply an impulse
  27031. * @param force The impulse force
  27032. * @param contactPoint The contact point for the impulse force
  27033. * @returns The physics imposter
  27034. */
  27035. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27036. /**
  27037. * A help function to create a joint
  27038. * @param otherImpostor A physics imposter used to create a joint
  27039. * @param jointType The type of joint
  27040. * @param jointData The data for the joint
  27041. * @returns The physics imposter
  27042. */
  27043. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27044. /**
  27045. * Add a joint to this impostor with a different impostor
  27046. * @param otherImpostor A physics imposter used to add a joint
  27047. * @param joint The joint to add
  27048. * @returns The physics imposter
  27049. */
  27050. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27051. /**
  27052. * Add an anchor to a cloth impostor
  27053. * @param otherImpostor rigid impostor to anchor to
  27054. * @param width ratio across width from 0 to 1
  27055. * @param height ratio up height from 0 to 1
  27056. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27057. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27058. * @returns impostor the soft imposter
  27059. */
  27060. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27061. /**
  27062. * Add a hook to a rope impostor
  27063. * @param otherImpostor rigid impostor to anchor to
  27064. * @param length ratio across rope from 0 to 1
  27065. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27066. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27067. * @returns impostor the rope imposter
  27068. */
  27069. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27070. /**
  27071. * Will keep this body still, in a sleep mode.
  27072. * @returns the physics imposter
  27073. */
  27074. sleep(): PhysicsImpostor;
  27075. /**
  27076. * Wake the body up.
  27077. * @returns The physics imposter
  27078. */
  27079. wakeUp(): PhysicsImpostor;
  27080. /**
  27081. * Clones the physics imposter
  27082. * @param newObject The physics imposter clones to this physics-enabled object
  27083. * @returns A nullable physics imposter
  27084. */
  27085. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27086. /**
  27087. * Disposes the physics imposter
  27088. */
  27089. dispose(): void;
  27090. /**
  27091. * Sets the delta position
  27092. * @param position The delta position amount
  27093. */
  27094. setDeltaPosition(position: Vector3): void;
  27095. /**
  27096. * Sets the delta rotation
  27097. * @param rotation The delta rotation amount
  27098. */
  27099. setDeltaRotation(rotation: Quaternion): void;
  27100. /**
  27101. * Gets the box size of the physics imposter and stores the result in the input parameter
  27102. * @param result Stores the box size
  27103. * @returns The physics imposter
  27104. */
  27105. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27106. /**
  27107. * Gets the radius of the physics imposter
  27108. * @returns Radius of the physics imposter
  27109. */
  27110. getRadius(): number;
  27111. /**
  27112. * Sync a bone with this impostor
  27113. * @param bone The bone to sync to the impostor.
  27114. * @param boneMesh The mesh that the bone is influencing.
  27115. * @param jointPivot The pivot of the joint / bone in local space.
  27116. * @param distToJoint Optional distance from the impostor to the joint.
  27117. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27118. */
  27119. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27120. /**
  27121. * Sync impostor to a bone
  27122. * @param bone The bone that the impostor will be synced to.
  27123. * @param boneMesh The mesh that the bone is influencing.
  27124. * @param jointPivot The pivot of the joint / bone in local space.
  27125. * @param distToJoint Optional distance from the impostor to the joint.
  27126. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27127. * @param boneAxis Optional vector3 axis the bone is aligned with
  27128. */
  27129. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27130. /**
  27131. * No-Imposter type
  27132. */
  27133. static NoImpostor: number;
  27134. /**
  27135. * Sphere-Imposter type
  27136. */
  27137. static SphereImpostor: number;
  27138. /**
  27139. * Box-Imposter type
  27140. */
  27141. static BoxImpostor: number;
  27142. /**
  27143. * Plane-Imposter type
  27144. */
  27145. static PlaneImpostor: number;
  27146. /**
  27147. * Mesh-imposter type
  27148. */
  27149. static MeshImpostor: number;
  27150. /**
  27151. * Capsule-Impostor type (Ammo.js plugin only)
  27152. */
  27153. static CapsuleImpostor: number;
  27154. /**
  27155. * Cylinder-Imposter type
  27156. */
  27157. static CylinderImpostor: number;
  27158. /**
  27159. * Particle-Imposter type
  27160. */
  27161. static ParticleImpostor: number;
  27162. /**
  27163. * Heightmap-Imposter type
  27164. */
  27165. static HeightmapImpostor: number;
  27166. /**
  27167. * ConvexHull-Impostor type (Ammo.js plugin only)
  27168. */
  27169. static ConvexHullImpostor: number;
  27170. /**
  27171. * Custom-Imposter type (Ammo.js plugin only)
  27172. */
  27173. static CustomImpostor: number;
  27174. /**
  27175. * Rope-Imposter type
  27176. */
  27177. static RopeImpostor: number;
  27178. /**
  27179. * Cloth-Imposter type
  27180. */
  27181. static ClothImpostor: number;
  27182. /**
  27183. * Softbody-Imposter type
  27184. */
  27185. static SoftbodyImpostor: number;
  27186. }
  27187. }
  27188. declare module BABYLON {
  27189. /**
  27190. * @hidden
  27191. **/
  27192. export class _CreationDataStorage {
  27193. closePath?: boolean;
  27194. closeArray?: boolean;
  27195. idx: number[];
  27196. dashSize: number;
  27197. gapSize: number;
  27198. path3D: Path3D;
  27199. pathArray: Vector3[][];
  27200. arc: number;
  27201. radius: number;
  27202. cap: number;
  27203. tessellation: number;
  27204. }
  27205. /**
  27206. * @hidden
  27207. **/
  27208. class _InstanceDataStorage {
  27209. visibleInstances: any;
  27210. batchCache: _InstancesBatch;
  27211. instancesBufferSize: number;
  27212. instancesBuffer: Nullable<Buffer>;
  27213. instancesData: Float32Array;
  27214. overridenInstanceCount: number;
  27215. isFrozen: boolean;
  27216. previousBatch: Nullable<_InstancesBatch>;
  27217. hardwareInstancedRendering: boolean;
  27218. sideOrientation: number;
  27219. manualUpdate: boolean;
  27220. }
  27221. /**
  27222. * @hidden
  27223. **/
  27224. export class _InstancesBatch {
  27225. mustReturn: boolean;
  27226. visibleInstances: Nullable<InstancedMesh[]>[];
  27227. renderSelf: boolean[];
  27228. hardwareInstancedRendering: boolean[];
  27229. }
  27230. /**
  27231. * @hidden
  27232. **/
  27233. class _ThinInstanceDataStorage {
  27234. instancesCount: number;
  27235. matrixBuffer: Nullable<Buffer>;
  27236. matrixBufferSize: number;
  27237. matrixData: Nullable<Float32Array>;
  27238. boundingVectors: Array<Vector3>;
  27239. }
  27240. /**
  27241. * Class used to represent renderable models
  27242. */
  27243. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27244. /**
  27245. * Mesh side orientation : usually the external or front surface
  27246. */
  27247. static readonly FRONTSIDE: number;
  27248. /**
  27249. * Mesh side orientation : usually the internal or back surface
  27250. */
  27251. static readonly BACKSIDE: number;
  27252. /**
  27253. * Mesh side orientation : both internal and external or front and back surfaces
  27254. */
  27255. static readonly DOUBLESIDE: number;
  27256. /**
  27257. * Mesh side orientation : by default, `FRONTSIDE`
  27258. */
  27259. static readonly DEFAULTSIDE: number;
  27260. /**
  27261. * Mesh cap setting : no cap
  27262. */
  27263. static readonly NO_CAP: number;
  27264. /**
  27265. * Mesh cap setting : one cap at the beginning of the mesh
  27266. */
  27267. static readonly CAP_START: number;
  27268. /**
  27269. * Mesh cap setting : one cap at the end of the mesh
  27270. */
  27271. static readonly CAP_END: number;
  27272. /**
  27273. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27274. */
  27275. static readonly CAP_ALL: number;
  27276. /**
  27277. * Mesh pattern setting : no flip or rotate
  27278. */
  27279. static readonly NO_FLIP: number;
  27280. /**
  27281. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27282. */
  27283. static readonly FLIP_TILE: number;
  27284. /**
  27285. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27286. */
  27287. static readonly ROTATE_TILE: number;
  27288. /**
  27289. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27290. */
  27291. static readonly FLIP_ROW: number;
  27292. /**
  27293. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27294. */
  27295. static readonly ROTATE_ROW: number;
  27296. /**
  27297. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27298. */
  27299. static readonly FLIP_N_ROTATE_TILE: number;
  27300. /**
  27301. * Mesh pattern setting : rotate pattern and rotate
  27302. */
  27303. static readonly FLIP_N_ROTATE_ROW: number;
  27304. /**
  27305. * Mesh tile positioning : part tiles same on left/right or top/bottom
  27306. */
  27307. static readonly CENTER: number;
  27308. /**
  27309. * Mesh tile positioning : part tiles on left
  27310. */
  27311. static readonly LEFT: number;
  27312. /**
  27313. * Mesh tile positioning : part tiles on right
  27314. */
  27315. static readonly RIGHT: number;
  27316. /**
  27317. * Mesh tile positioning : part tiles on top
  27318. */
  27319. static readonly TOP: number;
  27320. /**
  27321. * Mesh tile positioning : part tiles on bottom
  27322. */
  27323. static readonly BOTTOM: number;
  27324. /**
  27325. * Gets the default side orientation.
  27326. * @param orientation the orientation to value to attempt to get
  27327. * @returns the default orientation
  27328. * @hidden
  27329. */
  27330. static _GetDefaultSideOrientation(orientation?: number): number;
  27331. private _internalMeshDataInfo;
  27332. /**
  27333. * An event triggered before rendering the mesh
  27334. */
  27335. get onBeforeRenderObservable(): Observable<Mesh>;
  27336. /**
  27337. * An event triggered before binding the mesh
  27338. */
  27339. get onBeforeBindObservable(): Observable<Mesh>;
  27340. /**
  27341. * An event triggered after rendering the mesh
  27342. */
  27343. get onAfterRenderObservable(): Observable<Mesh>;
  27344. /**
  27345. * An event triggered before drawing the mesh
  27346. */
  27347. get onBeforeDrawObservable(): Observable<Mesh>;
  27348. private _onBeforeDrawObserver;
  27349. /**
  27350. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  27351. */
  27352. set onBeforeDraw(callback: () => void);
  27353. get hasInstances(): boolean;
  27354. get hasThinInstances(): boolean;
  27355. /**
  27356. * Gets the delay loading state of the mesh (when delay loading is turned on)
  27357. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  27358. */
  27359. delayLoadState: number;
  27360. /**
  27361. * Gets the list of instances created from this mesh
  27362. * it is not supposed to be modified manually.
  27363. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  27364. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27365. */
  27366. instances: InstancedMesh[];
  27367. /**
  27368. * Gets the file containing delay loading data for this mesh
  27369. */
  27370. delayLoadingFile: string;
  27371. /** @hidden */
  27372. _binaryInfo: any;
  27373. /**
  27374. * User defined function used to change how LOD level selection is done
  27375. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27376. */
  27377. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  27378. /**
  27379. * Gets or sets the morph target manager
  27380. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27381. */
  27382. get morphTargetManager(): Nullable<MorphTargetManager>;
  27383. set morphTargetManager(value: Nullable<MorphTargetManager>);
  27384. /** @hidden */
  27385. _creationDataStorage: Nullable<_CreationDataStorage>;
  27386. /** @hidden */
  27387. _geometry: Nullable<Geometry>;
  27388. /** @hidden */
  27389. _delayInfo: Array<string>;
  27390. /** @hidden */
  27391. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  27392. /** @hidden */
  27393. _instanceDataStorage: _InstanceDataStorage;
  27394. /** @hidden */
  27395. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  27396. private _effectiveMaterial;
  27397. /** @hidden */
  27398. _shouldGenerateFlatShading: boolean;
  27399. /** @hidden */
  27400. _originalBuilderSideOrientation: number;
  27401. /**
  27402. * Use this property to change the original side orientation defined at construction time
  27403. */
  27404. overrideMaterialSideOrientation: Nullable<number>;
  27405. /**
  27406. * Gets the source mesh (the one used to clone this one from)
  27407. */
  27408. get source(): Nullable<Mesh>;
  27409. /**
  27410. * Gets or sets a boolean indicating that this mesh does not use index buffer
  27411. */
  27412. get isUnIndexed(): boolean;
  27413. set isUnIndexed(value: boolean);
  27414. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  27415. get worldMatrixInstancedBuffer(): Float32Array;
  27416. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  27417. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  27418. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  27419. /**
  27420. * @constructor
  27421. * @param name The value used by scene.getMeshByName() to do a lookup.
  27422. * @param scene The scene to add this mesh to.
  27423. * @param parent The parent of this mesh, if it has one
  27424. * @param source An optional Mesh from which geometry is shared, cloned.
  27425. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  27426. * When false, achieved by calling a clone(), also passing False.
  27427. * This will make creation of children, recursive.
  27428. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  27429. */
  27430. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  27431. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  27432. doNotInstantiate: boolean;
  27433. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  27434. /**
  27435. * Gets the class name
  27436. * @returns the string "Mesh".
  27437. */
  27438. getClassName(): string;
  27439. /** @hidden */
  27440. get _isMesh(): boolean;
  27441. /**
  27442. * Returns a description of this mesh
  27443. * @param fullDetails define if full details about this mesh must be used
  27444. * @returns a descriptive string representing this mesh
  27445. */
  27446. toString(fullDetails?: boolean): string;
  27447. /** @hidden */
  27448. _unBindEffect(): void;
  27449. /**
  27450. * Gets a boolean indicating if this mesh has LOD
  27451. */
  27452. get hasLODLevels(): boolean;
  27453. /**
  27454. * Gets the list of MeshLODLevel associated with the current mesh
  27455. * @returns an array of MeshLODLevel
  27456. */
  27457. getLODLevels(): MeshLODLevel[];
  27458. private _sortLODLevels;
  27459. /**
  27460. * Add a mesh as LOD level triggered at the given distance.
  27461. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27462. * @param distance The distance from the center of the object to show this level
  27463. * @param mesh The mesh to be added as LOD level (can be null)
  27464. * @return This mesh (for chaining)
  27465. */
  27466. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  27467. /**
  27468. * Returns the LOD level mesh at the passed distance or null if not found.
  27469. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27470. * @param distance The distance from the center of the object to show this level
  27471. * @returns a Mesh or `null`
  27472. */
  27473. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  27474. /**
  27475. * Remove a mesh from the LOD array
  27476. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27477. * @param mesh defines the mesh to be removed
  27478. * @return This mesh (for chaining)
  27479. */
  27480. removeLODLevel(mesh: Mesh): Mesh;
  27481. /**
  27482. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  27483. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27484. * @param camera defines the camera to use to compute distance
  27485. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  27486. * @return This mesh (for chaining)
  27487. */
  27488. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  27489. /**
  27490. * Gets the mesh internal Geometry object
  27491. */
  27492. get geometry(): Nullable<Geometry>;
  27493. /**
  27494. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  27495. * @returns the total number of vertices
  27496. */
  27497. getTotalVertices(): number;
  27498. /**
  27499. * Returns the content of an associated vertex buffer
  27500. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27501. * - VertexBuffer.PositionKind
  27502. * - VertexBuffer.UVKind
  27503. * - VertexBuffer.UV2Kind
  27504. * - VertexBuffer.UV3Kind
  27505. * - VertexBuffer.UV4Kind
  27506. * - VertexBuffer.UV5Kind
  27507. * - VertexBuffer.UV6Kind
  27508. * - VertexBuffer.ColorKind
  27509. * - VertexBuffer.MatricesIndicesKind
  27510. * - VertexBuffer.MatricesIndicesExtraKind
  27511. * - VertexBuffer.MatricesWeightsKind
  27512. * - VertexBuffer.MatricesWeightsExtraKind
  27513. * @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
  27514. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  27515. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  27516. */
  27517. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  27518. /**
  27519. * Returns the mesh VertexBuffer object from the requested `kind`
  27520. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27521. * - VertexBuffer.PositionKind
  27522. * - VertexBuffer.NormalKind
  27523. * - VertexBuffer.UVKind
  27524. * - VertexBuffer.UV2Kind
  27525. * - VertexBuffer.UV3Kind
  27526. * - VertexBuffer.UV4Kind
  27527. * - VertexBuffer.UV5Kind
  27528. * - VertexBuffer.UV6Kind
  27529. * - VertexBuffer.ColorKind
  27530. * - VertexBuffer.MatricesIndicesKind
  27531. * - VertexBuffer.MatricesIndicesExtraKind
  27532. * - VertexBuffer.MatricesWeightsKind
  27533. * - VertexBuffer.MatricesWeightsExtraKind
  27534. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  27535. */
  27536. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  27537. /**
  27538. * Tests if a specific vertex buffer is associated with this mesh
  27539. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27540. * - VertexBuffer.PositionKind
  27541. * - VertexBuffer.NormalKind
  27542. * - VertexBuffer.UVKind
  27543. * - VertexBuffer.UV2Kind
  27544. * - VertexBuffer.UV3Kind
  27545. * - VertexBuffer.UV4Kind
  27546. * - VertexBuffer.UV5Kind
  27547. * - VertexBuffer.UV6Kind
  27548. * - VertexBuffer.ColorKind
  27549. * - VertexBuffer.MatricesIndicesKind
  27550. * - VertexBuffer.MatricesIndicesExtraKind
  27551. * - VertexBuffer.MatricesWeightsKind
  27552. * - VertexBuffer.MatricesWeightsExtraKind
  27553. * @returns a boolean
  27554. */
  27555. isVerticesDataPresent(kind: string): boolean;
  27556. /**
  27557. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  27558. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  27559. * - VertexBuffer.PositionKind
  27560. * - VertexBuffer.UVKind
  27561. * - VertexBuffer.UV2Kind
  27562. * - VertexBuffer.UV3Kind
  27563. * - VertexBuffer.UV4Kind
  27564. * - VertexBuffer.UV5Kind
  27565. * - VertexBuffer.UV6Kind
  27566. * - VertexBuffer.ColorKind
  27567. * - VertexBuffer.MatricesIndicesKind
  27568. * - VertexBuffer.MatricesIndicesExtraKind
  27569. * - VertexBuffer.MatricesWeightsKind
  27570. * - VertexBuffer.MatricesWeightsExtraKind
  27571. * @returns a boolean
  27572. */
  27573. isVertexBufferUpdatable(kind: string): boolean;
  27574. /**
  27575. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  27576. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  27577. * - VertexBuffer.PositionKind
  27578. * - VertexBuffer.NormalKind
  27579. * - VertexBuffer.UVKind
  27580. * - VertexBuffer.UV2Kind
  27581. * - VertexBuffer.UV3Kind
  27582. * - VertexBuffer.UV4Kind
  27583. * - VertexBuffer.UV5Kind
  27584. * - VertexBuffer.UV6Kind
  27585. * - VertexBuffer.ColorKind
  27586. * - VertexBuffer.MatricesIndicesKind
  27587. * - VertexBuffer.MatricesIndicesExtraKind
  27588. * - VertexBuffer.MatricesWeightsKind
  27589. * - VertexBuffer.MatricesWeightsExtraKind
  27590. * @returns an array of strings
  27591. */
  27592. getVerticesDataKinds(): string[];
  27593. /**
  27594. * Returns a positive integer : the total number of indices in this mesh geometry.
  27595. * @returns the numner of indices or zero if the mesh has no geometry.
  27596. */
  27597. getTotalIndices(): number;
  27598. /**
  27599. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  27600. * @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.
  27601. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  27602. * @returns the indices array or an empty array if the mesh has no geometry
  27603. */
  27604. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  27605. get isBlocked(): boolean;
  27606. /**
  27607. * Determine if the current mesh is ready to be rendered
  27608. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27609. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  27610. * @returns true if all associated assets are ready (material, textures, shaders)
  27611. */
  27612. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  27613. /**
  27614. * 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.
  27615. */
  27616. get areNormalsFrozen(): boolean;
  27617. /**
  27618. * 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.
  27619. * @returns the current mesh
  27620. */
  27621. freezeNormals(): Mesh;
  27622. /**
  27623. * 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
  27624. * @returns the current mesh
  27625. */
  27626. unfreezeNormals(): Mesh;
  27627. /**
  27628. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  27629. */
  27630. set overridenInstanceCount(count: number);
  27631. /** @hidden */
  27632. _preActivate(): Mesh;
  27633. /** @hidden */
  27634. _preActivateForIntermediateRendering(renderId: number): Mesh;
  27635. /** @hidden */
  27636. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  27637. protected _afterComputeWorldMatrix(): void;
  27638. /** @hidden */
  27639. _postActivate(): void;
  27640. /**
  27641. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27642. * This means the mesh underlying bounding box and sphere are recomputed.
  27643. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27644. * @returns the current mesh
  27645. */
  27646. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  27647. /** @hidden */
  27648. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  27649. /**
  27650. * This function will subdivide the mesh into multiple submeshes
  27651. * @param count defines the expected number of submeshes
  27652. */
  27653. subdivide(count: number): void;
  27654. /**
  27655. * Copy a FloatArray into a specific associated vertex buffer
  27656. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27657. * - VertexBuffer.PositionKind
  27658. * - VertexBuffer.UVKind
  27659. * - VertexBuffer.UV2Kind
  27660. * - VertexBuffer.UV3Kind
  27661. * - VertexBuffer.UV4Kind
  27662. * - VertexBuffer.UV5Kind
  27663. * - VertexBuffer.UV6Kind
  27664. * - VertexBuffer.ColorKind
  27665. * - VertexBuffer.MatricesIndicesKind
  27666. * - VertexBuffer.MatricesIndicesExtraKind
  27667. * - VertexBuffer.MatricesWeightsKind
  27668. * - VertexBuffer.MatricesWeightsExtraKind
  27669. * @param data defines the data source
  27670. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27671. * @param stride defines the data stride size (can be null)
  27672. * @returns the current mesh
  27673. */
  27674. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27675. /**
  27676. * Delete a vertex buffer associated with this mesh
  27677. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  27678. * - VertexBuffer.PositionKind
  27679. * - VertexBuffer.UVKind
  27680. * - VertexBuffer.UV2Kind
  27681. * - VertexBuffer.UV3Kind
  27682. * - VertexBuffer.UV4Kind
  27683. * - VertexBuffer.UV5Kind
  27684. * - VertexBuffer.UV6Kind
  27685. * - VertexBuffer.ColorKind
  27686. * - VertexBuffer.MatricesIndicesKind
  27687. * - VertexBuffer.MatricesIndicesExtraKind
  27688. * - VertexBuffer.MatricesWeightsKind
  27689. * - VertexBuffer.MatricesWeightsExtraKind
  27690. */
  27691. removeVerticesData(kind: string): void;
  27692. /**
  27693. * Flags an associated vertex buffer as updatable
  27694. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  27695. * - VertexBuffer.PositionKind
  27696. * - VertexBuffer.UVKind
  27697. * - VertexBuffer.UV2Kind
  27698. * - VertexBuffer.UV3Kind
  27699. * - VertexBuffer.UV4Kind
  27700. * - VertexBuffer.UV5Kind
  27701. * - VertexBuffer.UV6Kind
  27702. * - VertexBuffer.ColorKind
  27703. * - VertexBuffer.MatricesIndicesKind
  27704. * - VertexBuffer.MatricesIndicesExtraKind
  27705. * - VertexBuffer.MatricesWeightsKind
  27706. * - VertexBuffer.MatricesWeightsExtraKind
  27707. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  27708. */
  27709. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  27710. /**
  27711. * Sets the mesh global Vertex Buffer
  27712. * @param buffer defines the buffer to use
  27713. * @returns the current mesh
  27714. */
  27715. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  27716. /**
  27717. * Update a specific associated vertex buffer
  27718. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27719. * - VertexBuffer.PositionKind
  27720. * - VertexBuffer.UVKind
  27721. * - VertexBuffer.UV2Kind
  27722. * - VertexBuffer.UV3Kind
  27723. * - VertexBuffer.UV4Kind
  27724. * - VertexBuffer.UV5Kind
  27725. * - VertexBuffer.UV6Kind
  27726. * - VertexBuffer.ColorKind
  27727. * - VertexBuffer.MatricesIndicesKind
  27728. * - VertexBuffer.MatricesIndicesExtraKind
  27729. * - VertexBuffer.MatricesWeightsKind
  27730. * - VertexBuffer.MatricesWeightsExtraKind
  27731. * @param data defines the data source
  27732. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27733. * @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)
  27734. * @returns the current mesh
  27735. */
  27736. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27737. /**
  27738. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  27739. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  27740. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  27741. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  27742. * @returns the current mesh
  27743. */
  27744. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  27745. /**
  27746. * Creates a un-shared specific occurence of the geometry for the mesh.
  27747. * @returns the current mesh
  27748. */
  27749. makeGeometryUnique(): Mesh;
  27750. /**
  27751. * Set the index buffer of this mesh
  27752. * @param indices defines the source data
  27753. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  27754. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  27755. * @returns the current mesh
  27756. */
  27757. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  27758. /**
  27759. * Update the current index buffer
  27760. * @param indices defines the source data
  27761. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27762. * @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)
  27763. * @returns the current mesh
  27764. */
  27765. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27766. /**
  27767. * Invert the geometry to move from a right handed system to a left handed one.
  27768. * @returns the current mesh
  27769. */
  27770. toLeftHanded(): Mesh;
  27771. /** @hidden */
  27772. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  27773. /** @hidden */
  27774. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  27775. /**
  27776. * Registers for this mesh a javascript function called just before the rendering process
  27777. * @param func defines the function to call before rendering this mesh
  27778. * @returns the current mesh
  27779. */
  27780. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27781. /**
  27782. * Disposes a previously registered javascript function called before the rendering
  27783. * @param func defines the function to remove
  27784. * @returns the current mesh
  27785. */
  27786. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  27787. /**
  27788. * Registers for this mesh a javascript function called just after the rendering is complete
  27789. * @param func defines the function to call after rendering this mesh
  27790. * @returns the current mesh
  27791. */
  27792. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27793. /**
  27794. * Disposes a previously registered javascript function called after the rendering.
  27795. * @param func defines the function to remove
  27796. * @returns the current mesh
  27797. */
  27798. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  27799. /** @hidden */
  27800. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  27801. /** @hidden */
  27802. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  27803. /** @hidden */
  27804. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  27805. /** @hidden */
  27806. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  27807. /** @hidden */
  27808. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  27809. /** @hidden */
  27810. _rebuild(): void;
  27811. /** @hidden */
  27812. _freeze(): void;
  27813. /** @hidden */
  27814. _unFreeze(): void;
  27815. /**
  27816. * 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
  27817. * @param subMesh defines the subMesh to render
  27818. * @param enableAlphaMode defines if alpha mode can be changed
  27819. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  27820. * @returns the current mesh
  27821. */
  27822. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  27823. private _onBeforeDraw;
  27824. /**
  27825. * Renormalize the mesh and patch it up if there are no weights
  27826. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  27827. * However in the case of zero weights then we set just a single influence to 1.
  27828. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  27829. */
  27830. cleanMatrixWeights(): void;
  27831. private normalizeSkinFourWeights;
  27832. private normalizeSkinWeightsAndExtra;
  27833. /**
  27834. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  27835. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  27836. * the user know there was an issue with importing the mesh
  27837. * @returns a validation object with skinned, valid and report string
  27838. */
  27839. validateSkinning(): {
  27840. skinned: boolean;
  27841. valid: boolean;
  27842. report: string;
  27843. };
  27844. /** @hidden */
  27845. _checkDelayState(): Mesh;
  27846. private _queueLoad;
  27847. /**
  27848. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27849. * A mesh is in the frustum if its bounding box intersects the frustum
  27850. * @param frustumPlanes defines the frustum to test
  27851. * @returns true if the mesh is in the frustum planes
  27852. */
  27853. isInFrustum(frustumPlanes: Plane[]): boolean;
  27854. /**
  27855. * Sets the mesh material by the material or multiMaterial `id` property
  27856. * @param id is a string identifying the material or the multiMaterial
  27857. * @returns the current mesh
  27858. */
  27859. setMaterialByID(id: string): Mesh;
  27860. /**
  27861. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  27862. * @returns an array of IAnimatable
  27863. */
  27864. getAnimatables(): IAnimatable[];
  27865. /**
  27866. * Modifies the mesh geometry according to the passed transformation matrix.
  27867. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  27868. * The mesh normals are modified using the same transformation.
  27869. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27870. * @param transform defines the transform matrix to use
  27871. * @see https://doc.babylonjs.com/resources/baking_transformations
  27872. * @returns the current mesh
  27873. */
  27874. bakeTransformIntoVertices(transform: Matrix): Mesh;
  27875. /**
  27876. * Modifies the mesh geometry according to its own current World Matrix.
  27877. * The mesh World Matrix is then reset.
  27878. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  27879. * Note that, under the hood, this method sets a new VertexBuffer each call.
  27880. * @see https://doc.babylonjs.com/resources/baking_transformations
  27881. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  27882. * @returns the current mesh
  27883. */
  27884. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  27885. /** @hidden */
  27886. get _positions(): Nullable<Vector3[]>;
  27887. /** @hidden */
  27888. _resetPointsArrayCache(): Mesh;
  27889. /** @hidden */
  27890. _generatePointsArray(): boolean;
  27891. /**
  27892. * Returns a new Mesh object generated from the current mesh properties.
  27893. * This method must not get confused with createInstance()
  27894. * @param name is a string, the name given to the new mesh
  27895. * @param newParent can be any Node object (default `null`)
  27896. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  27897. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  27898. * @returns a new mesh
  27899. */
  27900. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  27901. /**
  27902. * Releases resources associated with this mesh.
  27903. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27904. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27905. */
  27906. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27907. /** @hidden */
  27908. _disposeInstanceSpecificData(): void;
  27909. /** @hidden */
  27910. _disposeThinInstanceSpecificData(): void;
  27911. /**
  27912. * Modifies the mesh geometry according to a displacement map.
  27913. * 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.
  27914. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27915. * @param url is a string, the URL from the image file is to be downloaded.
  27916. * @param minHeight is the lower limit of the displacement.
  27917. * @param maxHeight is the upper limit of the displacement.
  27918. * @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.
  27919. * @param uvOffset is an optional vector2 used to offset UV.
  27920. * @param uvScale is an optional vector2 used to scale UV.
  27921. * @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.
  27922. * @returns the Mesh.
  27923. */
  27924. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27925. /**
  27926. * Modifies the mesh geometry according to a displacementMap buffer.
  27927. * 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.
  27928. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  27929. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  27930. * @param heightMapWidth is the width of the buffer image.
  27931. * @param heightMapHeight is the height of the buffer image.
  27932. * @param minHeight is the lower limit of the displacement.
  27933. * @param maxHeight is the upper limit of the displacement.
  27934. * @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.
  27935. * @param uvOffset is an optional vector2 used to offset UV.
  27936. * @param uvScale is an optional vector2 used to scale UV.
  27937. * @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.
  27938. * @returns the Mesh.
  27939. */
  27940. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  27941. /**
  27942. * Modify the mesh to get a flat shading rendering.
  27943. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  27944. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  27945. * @returns current mesh
  27946. */
  27947. convertToFlatShadedMesh(): Mesh;
  27948. /**
  27949. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  27950. * In other words, more vertices, no more indices and a single bigger VBO.
  27951. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  27952. * @returns current mesh
  27953. */
  27954. convertToUnIndexedMesh(): Mesh;
  27955. /**
  27956. * Inverses facet orientations.
  27957. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27958. * @param flipNormals will also inverts the normals
  27959. * @returns current mesh
  27960. */
  27961. flipFaces(flipNormals?: boolean): Mesh;
  27962. /**
  27963. * Increase the number of facets and hence vertices in a mesh
  27964. * Vertex normals are interpolated from existing vertex normals
  27965. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27966. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  27967. */
  27968. increaseVertices(numberPerEdge: number): void;
  27969. /**
  27970. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  27971. * This will undo any application of covertToFlatShadedMesh
  27972. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  27973. */
  27974. forceSharedVertices(): void;
  27975. /** @hidden */
  27976. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  27977. /** @hidden */
  27978. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  27979. /**
  27980. * Creates a new InstancedMesh object from the mesh model.
  27981. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  27982. * @param name defines the name of the new instance
  27983. * @returns a new InstancedMesh
  27984. */
  27985. createInstance(name: string): InstancedMesh;
  27986. /**
  27987. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  27988. * After this call, all the mesh instances have the same submeshes than the current mesh.
  27989. * @returns the current mesh
  27990. */
  27991. synchronizeInstances(): Mesh;
  27992. /**
  27993. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  27994. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  27995. * This should be used together with the simplification to avoid disappearing triangles.
  27996. * @param successCallback an optional success callback to be called after the optimization finished.
  27997. * @returns the current mesh
  27998. */
  27999. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28000. /**
  28001. * Serialize current mesh
  28002. * @param serializationObject defines the object which will receive the serialization data
  28003. */
  28004. serialize(serializationObject: any): void;
  28005. /** @hidden */
  28006. _syncGeometryWithMorphTargetManager(): void;
  28007. /** @hidden */
  28008. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28009. /**
  28010. * Returns a new Mesh object parsed from the source provided.
  28011. * @param parsedMesh is the source
  28012. * @param scene defines the hosting scene
  28013. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28014. * @returns a new Mesh
  28015. */
  28016. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28017. /**
  28018. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28019. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28020. * @param name defines the name of the mesh to create
  28021. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28022. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28023. * @param closePath creates a seam between the first and the last points of each path of the path array
  28024. * @param offset is taken in account only if the `pathArray` is containing a single path
  28025. * @param scene defines the hosting scene
  28026. * @param updatable defines if the mesh must be flagged as updatable
  28027. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28028. * @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)
  28029. * @returns a new Mesh
  28030. */
  28031. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28032. /**
  28033. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28034. * @param name defines the name of the mesh to create
  28035. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28036. * @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
  28037. * @param scene defines the hosting scene
  28038. * @param updatable defines if the mesh must be flagged as updatable
  28039. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28040. * @returns a new Mesh
  28041. */
  28042. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28043. /**
  28044. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28045. * @param name defines the name of the mesh to create
  28046. * @param size sets the size (float) of each box side (default 1)
  28047. * @param scene defines the hosting scene
  28048. * @param updatable defines if the mesh must be flagged as updatable
  28049. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28050. * @returns a new Mesh
  28051. */
  28052. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28053. /**
  28054. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28055. * @param name defines the name of the mesh to create
  28056. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28057. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28058. * @param scene defines the hosting scene
  28059. * @param updatable defines if the mesh must be flagged as updatable
  28060. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28061. * @returns a new Mesh
  28062. */
  28063. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28064. /**
  28065. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28066. * @param name defines the name of the mesh to create
  28067. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28068. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28069. * @param scene defines the hosting scene
  28070. * @returns a new Mesh
  28071. */
  28072. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28073. /**
  28074. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28075. * @param name defines the name of the mesh to create
  28076. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28077. * @param diameterTop set the top cap diameter (floats, default 1)
  28078. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28079. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28080. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28081. * @param scene defines the hosting scene
  28082. * @param updatable defines if the mesh must be flagged as updatable
  28083. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28084. * @returns a new Mesh
  28085. */
  28086. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28087. /**
  28088. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28089. * @param name defines the name of the mesh to create
  28090. * @param diameter sets the diameter size (float) of the torus (default 1)
  28091. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28092. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28093. * @param scene defines the hosting scene
  28094. * @param updatable defines if the mesh must be flagged as updatable
  28095. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28096. * @returns a new Mesh
  28097. */
  28098. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28099. /**
  28100. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28101. * @param name defines the name of the mesh to create
  28102. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28103. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28104. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28105. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28106. * @param p the number of windings on X axis (positive integers, default 2)
  28107. * @param q the number of windings on Y axis (positive integers, default 3)
  28108. * @param scene defines the hosting scene
  28109. * @param updatable defines if the mesh must be flagged as updatable
  28110. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28111. * @returns a new Mesh
  28112. */
  28113. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28114. /**
  28115. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28116. * @param name defines the name of the mesh to create
  28117. * @param points is an array successive Vector3
  28118. * @param scene defines the hosting scene
  28119. * @param updatable defines if the mesh must be flagged as updatable
  28120. * @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).
  28121. * @returns a new Mesh
  28122. */
  28123. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28124. /**
  28125. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28126. * @param name defines the name of the mesh to create
  28127. * @param points is an array successive Vector3
  28128. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28129. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28130. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28131. * @param scene defines the hosting scene
  28132. * @param updatable defines if the mesh must be flagged as updatable
  28133. * @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)
  28134. * @returns a new Mesh
  28135. */
  28136. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28137. /**
  28138. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28139. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28140. * 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.
  28141. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28142. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28143. * Remember you can only change the shape positions, not their number when updating a polygon.
  28144. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28145. * @param name defines the name of the mesh to create
  28146. * @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
  28147. * @param scene defines the hosting scene
  28148. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28149. * @param updatable defines if the mesh must be flagged as updatable
  28150. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28151. * @param earcutInjection can be used to inject your own earcut reference
  28152. * @returns a new Mesh
  28153. */
  28154. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28155. /**
  28156. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28157. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28158. * @param name defines the name of the mesh to create
  28159. * @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
  28160. * @param depth defines the height of extrusion
  28161. * @param scene defines the hosting scene
  28162. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28163. * @param updatable defines if the mesh must be flagged as updatable
  28164. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28165. * @param earcutInjection can be used to inject your own earcut reference
  28166. * @returns a new Mesh
  28167. */
  28168. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28169. /**
  28170. * Creates an extruded shape mesh.
  28171. * 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
  28172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28174. * @param name defines the name of the mesh to create
  28175. * @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
  28176. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28177. * @param scale is the value to scale the shape
  28178. * @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
  28179. * @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
  28180. * @param scene defines the hosting scene
  28181. * @param updatable defines if the mesh must be flagged as updatable
  28182. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28183. * @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)
  28184. * @returns a new Mesh
  28185. */
  28186. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28187. /**
  28188. * Creates an custom extruded shape mesh.
  28189. * The custom extrusion is a parametric shape.
  28190. * It has no predefined shape. Its final shape will depend on the input parameters.
  28191. * Please consider using the same method from the MeshBuilder class instead
  28192. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28193. * @param name defines the name of the mesh to create
  28194. * @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
  28195. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28196. * @param scaleFunction is a custom Javascript function called on each path point
  28197. * @param rotationFunction is a custom Javascript function called on each path point
  28198. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28199. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28200. * @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
  28201. * @param scene defines the hosting scene
  28202. * @param updatable defines if the mesh must be flagged as updatable
  28203. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28204. * @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)
  28205. * @returns a new Mesh
  28206. */
  28207. 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;
  28208. /**
  28209. * Creates lathe mesh.
  28210. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28211. * Please consider using the same method from the MeshBuilder class instead
  28212. * @param name defines the name of the mesh to create
  28213. * @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
  28214. * @param radius is the radius value of the lathe
  28215. * @param tessellation is the side number of the lathe.
  28216. * @param scene defines the hosting scene
  28217. * @param updatable defines if the mesh must be flagged as updatable
  28218. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28219. * @returns a new Mesh
  28220. */
  28221. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28222. /**
  28223. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28224. * @param name defines the name of the mesh to create
  28225. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28226. * @param scene defines the hosting scene
  28227. * @param updatable defines if the mesh must be flagged as updatable
  28228. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28229. * @returns a new Mesh
  28230. */
  28231. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28232. /**
  28233. * Creates a ground mesh.
  28234. * Please consider using the same method from the MeshBuilder class instead
  28235. * @param name defines the name of the mesh to create
  28236. * @param width set the width of the ground
  28237. * @param height set the height of the ground
  28238. * @param subdivisions sets the number of subdivisions per side
  28239. * @param scene defines the hosting scene
  28240. * @param updatable defines if the mesh must be flagged as updatable
  28241. * @returns a new Mesh
  28242. */
  28243. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28244. /**
  28245. * Creates a tiled ground mesh.
  28246. * Please consider using the same method from the MeshBuilder class instead
  28247. * @param name defines the name of the mesh to create
  28248. * @param xmin set the ground minimum X coordinate
  28249. * @param zmin set the ground minimum Y coordinate
  28250. * @param xmax set the ground maximum X coordinate
  28251. * @param zmax set the ground maximum Z coordinate
  28252. * @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
  28253. * @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
  28254. * @param scene defines the hosting scene
  28255. * @param updatable defines if the mesh must be flagged as updatable
  28256. * @returns a new Mesh
  28257. */
  28258. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28259. w: number;
  28260. h: number;
  28261. }, precision: {
  28262. w: number;
  28263. h: number;
  28264. }, scene: Scene, updatable?: boolean): Mesh;
  28265. /**
  28266. * Creates a ground mesh from a height map.
  28267. * Please consider using the same method from the MeshBuilder class instead
  28268. * @see https://doc.babylonjs.com/babylon101/height_map
  28269. * @param name defines the name of the mesh to create
  28270. * @param url sets the URL of the height map image resource
  28271. * @param width set the ground width size
  28272. * @param height set the ground height size
  28273. * @param subdivisions sets the number of subdivision per side
  28274. * @param minHeight is the minimum altitude on the ground
  28275. * @param maxHeight is the maximum altitude on the ground
  28276. * @param scene defines the hosting scene
  28277. * @param updatable defines if the mesh must be flagged as updatable
  28278. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28279. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28280. * @returns a new Mesh
  28281. */
  28282. 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;
  28283. /**
  28284. * Creates a tube mesh.
  28285. * The tube is a parametric shape.
  28286. * It has no predefined shape. Its final shape will depend on the input parameters.
  28287. * Please consider using the same method from the MeshBuilder class instead
  28288. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28289. * @param name defines the name of the mesh to create
  28290. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28291. * @param radius sets the tube radius size
  28292. * @param tessellation is the number of sides on the tubular surface
  28293. * @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
  28294. * @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
  28295. * @param scene defines the hosting scene
  28296. * @param updatable defines if the mesh must be flagged as updatable
  28297. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28298. * @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)
  28299. * @returns a new Mesh
  28300. */
  28301. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28302. (i: number, distance: number): number;
  28303. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28304. /**
  28305. * Creates a polyhedron mesh.
  28306. * Please consider using the same method from the MeshBuilder class instead.
  28307. * * 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
  28308. * * The parameter `size` (positive float, default 1) sets the polygon size
  28309. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  28310. * * 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`
  28311. * * 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
  28312. * * 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)`)
  28313. * * 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
  28314. * * 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
  28315. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28316. * * 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
  28317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28318. * @param name defines the name of the mesh to create
  28319. * @param options defines the options used to create the mesh
  28320. * @param scene defines the hosting scene
  28321. * @returns a new Mesh
  28322. */
  28323. static CreatePolyhedron(name: string, options: {
  28324. type?: number;
  28325. size?: number;
  28326. sizeX?: number;
  28327. sizeY?: number;
  28328. sizeZ?: number;
  28329. custom?: any;
  28330. faceUV?: Vector4[];
  28331. faceColors?: Color4[];
  28332. updatable?: boolean;
  28333. sideOrientation?: number;
  28334. }, scene: Scene): Mesh;
  28335. /**
  28336. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  28337. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  28338. * * 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`)
  28339. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  28340. * * 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
  28341. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28342. * * 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
  28343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28344. * @param name defines the name of the mesh
  28345. * @param options defines the options used to create the mesh
  28346. * @param scene defines the hosting scene
  28347. * @returns a new Mesh
  28348. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  28349. */
  28350. static CreateIcoSphere(name: string, options: {
  28351. radius?: number;
  28352. flat?: boolean;
  28353. subdivisions?: number;
  28354. sideOrientation?: number;
  28355. updatable?: boolean;
  28356. }, scene: Scene): Mesh;
  28357. /**
  28358. * Creates a decal mesh.
  28359. * Please consider using the same method from the MeshBuilder class instead.
  28360. * A decal is a mesh usually applied as a model onto the surface of another mesh
  28361. * @param name defines the name of the mesh
  28362. * @param sourceMesh defines the mesh receiving the decal
  28363. * @param position sets the position of the decal in world coordinates
  28364. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  28365. * @param size sets the decal scaling
  28366. * @param angle sets the angle to rotate the decal
  28367. * @returns a new Mesh
  28368. */
  28369. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  28370. /**
  28371. * Prepare internal position array for software CPU skinning
  28372. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  28373. */
  28374. setPositionsForCPUSkinning(): Float32Array;
  28375. /**
  28376. * Prepare internal normal array for software CPU skinning
  28377. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  28378. */
  28379. setNormalsForCPUSkinning(): Float32Array;
  28380. /**
  28381. * Updates the vertex buffer by applying transformation from the bones
  28382. * @param skeleton defines the skeleton to apply to current mesh
  28383. * @returns the current mesh
  28384. */
  28385. applySkeleton(skeleton: Skeleton): Mesh;
  28386. /**
  28387. * 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
  28388. * @param meshes defines the list of meshes to scan
  28389. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  28390. */
  28391. static MinMax(meshes: AbstractMesh[]): {
  28392. min: Vector3;
  28393. max: Vector3;
  28394. };
  28395. /**
  28396. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  28397. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  28398. * @returns a vector3
  28399. */
  28400. static Center(meshesOrMinMaxVector: {
  28401. min: Vector3;
  28402. max: Vector3;
  28403. } | AbstractMesh[]): Vector3;
  28404. /**
  28405. * Merge the array of meshes into a single mesh for performance reasons.
  28406. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  28407. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  28408. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  28409. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  28410. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  28411. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  28412. * @returns a new mesh
  28413. */
  28414. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  28415. /** @hidden */
  28416. addInstance(instance: InstancedMesh): void;
  28417. /** @hidden */
  28418. removeInstance(instance: InstancedMesh): void;
  28419. }
  28420. }
  28421. declare module BABYLON {
  28422. /**
  28423. * This is the base class of all the camera used in the application.
  28424. * @see https://doc.babylonjs.com/features/cameras
  28425. */
  28426. export class Camera extends Node {
  28427. /** @hidden */
  28428. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  28429. /**
  28430. * This is the default projection mode used by the cameras.
  28431. * It helps recreating a feeling of perspective and better appreciate depth.
  28432. * This is the best way to simulate real life cameras.
  28433. */
  28434. static readonly PERSPECTIVE_CAMERA: number;
  28435. /**
  28436. * This helps creating camera with an orthographic mode.
  28437. * 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.
  28438. */
  28439. static readonly ORTHOGRAPHIC_CAMERA: number;
  28440. /**
  28441. * This is the default FOV mode for perspective cameras.
  28442. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  28443. */
  28444. static readonly FOVMODE_VERTICAL_FIXED: number;
  28445. /**
  28446. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  28447. */
  28448. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  28449. /**
  28450. * This specifies ther is no need for a camera rig.
  28451. * Basically only one eye is rendered corresponding to the camera.
  28452. */
  28453. static readonly RIG_MODE_NONE: number;
  28454. /**
  28455. * Simulates a camera Rig with one blue eye and one red eye.
  28456. * This can be use with 3d blue and red glasses.
  28457. */
  28458. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  28459. /**
  28460. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  28461. */
  28462. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  28463. /**
  28464. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  28465. */
  28466. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  28467. /**
  28468. * Defines that both eyes of the camera will be rendered over under each other.
  28469. */
  28470. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  28471. /**
  28472. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  28473. */
  28474. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  28475. /**
  28476. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  28477. */
  28478. static readonly RIG_MODE_VR: number;
  28479. /**
  28480. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  28481. */
  28482. static readonly RIG_MODE_WEBVR: number;
  28483. /**
  28484. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  28485. */
  28486. static readonly RIG_MODE_CUSTOM: number;
  28487. /**
  28488. * Defines if by default attaching controls should prevent the default javascript event to continue.
  28489. */
  28490. static ForceAttachControlToAlwaysPreventDefault: boolean;
  28491. /**
  28492. * Define the input manager associated with the camera.
  28493. */
  28494. inputs: CameraInputsManager<Camera>;
  28495. /** @hidden */
  28496. _position: Vector3;
  28497. /**
  28498. * Define the current local position of the camera in the scene
  28499. */
  28500. get position(): Vector3;
  28501. set position(newPosition: Vector3);
  28502. /**
  28503. * The vector the camera should consider as up.
  28504. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  28505. */
  28506. upVector: Vector3;
  28507. /**
  28508. * Define the current limit on the left side for an orthographic camera
  28509. * In scene unit
  28510. */
  28511. orthoLeft: Nullable<number>;
  28512. /**
  28513. * Define the current limit on the right side for an orthographic camera
  28514. * In scene unit
  28515. */
  28516. orthoRight: Nullable<number>;
  28517. /**
  28518. * Define the current limit on the bottom side for an orthographic camera
  28519. * In scene unit
  28520. */
  28521. orthoBottom: Nullable<number>;
  28522. /**
  28523. * Define the current limit on the top side for an orthographic camera
  28524. * In scene unit
  28525. */
  28526. orthoTop: Nullable<number>;
  28527. /**
  28528. * Field Of View is set in Radians. (default is 0.8)
  28529. */
  28530. fov: number;
  28531. /**
  28532. * Define the minimum distance the camera can see from.
  28533. * This is important to note that the depth buffer are not infinite and the closer it starts
  28534. * the more your scene might encounter depth fighting issue.
  28535. */
  28536. minZ: number;
  28537. /**
  28538. * Define the maximum distance the camera can see to.
  28539. * This is important to note that the depth buffer are not infinite and the further it end
  28540. * the more your scene might encounter depth fighting issue.
  28541. */
  28542. maxZ: number;
  28543. /**
  28544. * Define the default inertia of the camera.
  28545. * This helps giving a smooth feeling to the camera movement.
  28546. */
  28547. inertia: number;
  28548. /**
  28549. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  28550. */
  28551. mode: number;
  28552. /**
  28553. * Define whether the camera is intermediate.
  28554. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  28555. */
  28556. isIntermediate: boolean;
  28557. /**
  28558. * Define the viewport of the camera.
  28559. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  28560. */
  28561. viewport: Viewport;
  28562. /**
  28563. * Restricts the camera to viewing objects with the same layerMask.
  28564. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  28565. */
  28566. layerMask: number;
  28567. /**
  28568. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  28569. */
  28570. fovMode: number;
  28571. /**
  28572. * Rig mode of the camera.
  28573. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  28574. * This is normally controlled byt the camera themselves as internal use.
  28575. */
  28576. cameraRigMode: number;
  28577. /**
  28578. * Defines the distance between both "eyes" in case of a RIG
  28579. */
  28580. interaxialDistance: number;
  28581. /**
  28582. * Defines if stereoscopic rendering is done side by side or over under.
  28583. */
  28584. isStereoscopicSideBySide: boolean;
  28585. /**
  28586. * 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
  28587. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  28588. * else in the scene. (Eg. security camera)
  28589. *
  28590. * 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)
  28591. */
  28592. customRenderTargets: RenderTargetTexture[];
  28593. /**
  28594. * When set, the camera will render to this render target instead of the default canvas
  28595. *
  28596. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  28597. */
  28598. outputRenderTarget: Nullable<RenderTargetTexture>;
  28599. /**
  28600. * Observable triggered when the camera view matrix has changed.
  28601. */
  28602. onViewMatrixChangedObservable: Observable<Camera>;
  28603. /**
  28604. * Observable triggered when the camera Projection matrix has changed.
  28605. */
  28606. onProjectionMatrixChangedObservable: Observable<Camera>;
  28607. /**
  28608. * Observable triggered when the inputs have been processed.
  28609. */
  28610. onAfterCheckInputsObservable: Observable<Camera>;
  28611. /**
  28612. * Observable triggered when reset has been called and applied to the camera.
  28613. */
  28614. onRestoreStateObservable: Observable<Camera>;
  28615. /**
  28616. * Is this camera a part of a rig system?
  28617. */
  28618. isRigCamera: boolean;
  28619. /**
  28620. * If isRigCamera set to true this will be set with the parent camera.
  28621. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  28622. */
  28623. rigParent?: Camera;
  28624. /** @hidden */
  28625. _cameraRigParams: any;
  28626. /** @hidden */
  28627. _rigCameras: Camera[];
  28628. /** @hidden */
  28629. _rigPostProcess: Nullable<PostProcess>;
  28630. protected _webvrViewMatrix: Matrix;
  28631. /** @hidden */
  28632. _skipRendering: boolean;
  28633. /** @hidden */
  28634. _projectionMatrix: Matrix;
  28635. /** @hidden */
  28636. _postProcesses: Nullable<PostProcess>[];
  28637. /** @hidden */
  28638. _activeMeshes: SmartArray<AbstractMesh>;
  28639. protected _globalPosition: Vector3;
  28640. /** @hidden */
  28641. _computedViewMatrix: Matrix;
  28642. private _doNotComputeProjectionMatrix;
  28643. private _transformMatrix;
  28644. private _frustumPlanes;
  28645. private _refreshFrustumPlanes;
  28646. private _storedFov;
  28647. private _stateStored;
  28648. /**
  28649. * Instantiates a new camera object.
  28650. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  28651. * @see https://doc.babylonjs.com/features/cameras
  28652. * @param name Defines the name of the camera in the scene
  28653. * @param position Defines the position of the camera
  28654. * @param scene Defines the scene the camera belongs too
  28655. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  28656. */
  28657. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  28658. /**
  28659. * Store current camera state (fov, position, etc..)
  28660. * @returns the camera
  28661. */
  28662. storeState(): Camera;
  28663. /**
  28664. * Restores the camera state values if it has been stored. You must call storeState() first
  28665. */
  28666. protected _restoreStateValues(): boolean;
  28667. /**
  28668. * Restored camera state. You must call storeState() first.
  28669. * @returns true if restored and false otherwise
  28670. */
  28671. restoreState(): boolean;
  28672. /**
  28673. * Gets the class name of the camera.
  28674. * @returns the class name
  28675. */
  28676. getClassName(): string;
  28677. /** @hidden */
  28678. readonly _isCamera: boolean;
  28679. /**
  28680. * Gets a string representation of the camera useful for debug purpose.
  28681. * @param fullDetails Defines that a more verboe level of logging is required
  28682. * @returns the string representation
  28683. */
  28684. toString(fullDetails?: boolean): string;
  28685. /**
  28686. * Gets the current world space position of the camera.
  28687. */
  28688. get globalPosition(): Vector3;
  28689. /**
  28690. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  28691. * @returns the active meshe list
  28692. */
  28693. getActiveMeshes(): SmartArray<AbstractMesh>;
  28694. /**
  28695. * Check whether a mesh is part of the current active mesh list of the camera
  28696. * @param mesh Defines the mesh to check
  28697. * @returns true if active, false otherwise
  28698. */
  28699. isActiveMesh(mesh: Mesh): boolean;
  28700. /**
  28701. * Is this camera ready to be used/rendered
  28702. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  28703. * @return true if the camera is ready
  28704. */
  28705. isReady(completeCheck?: boolean): boolean;
  28706. /** @hidden */
  28707. _initCache(): void;
  28708. /** @hidden */
  28709. _updateCache(ignoreParentClass?: boolean): void;
  28710. /** @hidden */
  28711. _isSynchronized(): boolean;
  28712. /** @hidden */
  28713. _isSynchronizedViewMatrix(): boolean;
  28714. /** @hidden */
  28715. _isSynchronizedProjectionMatrix(): boolean;
  28716. /**
  28717. * Attach the input controls to a specific dom element to get the input from.
  28718. * @param element Defines the element the controls should be listened from
  28719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  28720. */
  28721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  28722. /**
  28723. * Detach the current controls from the specified dom element.
  28724. * @param element Defines the element to stop listening the inputs from
  28725. */
  28726. detachControl(element: HTMLElement): void;
  28727. /**
  28728. * Update the camera state according to the different inputs gathered during the frame.
  28729. */
  28730. update(): void;
  28731. /** @hidden */
  28732. _checkInputs(): void;
  28733. /** @hidden */
  28734. get rigCameras(): Camera[];
  28735. /**
  28736. * Gets the post process used by the rig cameras
  28737. */
  28738. get rigPostProcess(): Nullable<PostProcess>;
  28739. /**
  28740. * Internal, gets the first post proces.
  28741. * @returns the first post process to be run on this camera.
  28742. */
  28743. _getFirstPostProcess(): Nullable<PostProcess>;
  28744. private _cascadePostProcessesToRigCams;
  28745. /**
  28746. * Attach a post process to the camera.
  28747. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28748. * @param postProcess The post process to attach to the camera
  28749. * @param insertAt The position of the post process in case several of them are in use in the scene
  28750. * @returns the position the post process has been inserted at
  28751. */
  28752. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  28753. /**
  28754. * Detach a post process to the camera.
  28755. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  28756. * @param postProcess The post process to detach from the camera
  28757. */
  28758. detachPostProcess(postProcess: PostProcess): void;
  28759. /**
  28760. * Gets the current world matrix of the camera
  28761. */
  28762. getWorldMatrix(): Matrix;
  28763. /** @hidden */
  28764. _getViewMatrix(): Matrix;
  28765. /**
  28766. * Gets the current view matrix of the camera.
  28767. * @param force forces the camera to recompute the matrix without looking at the cached state
  28768. * @returns the view matrix
  28769. */
  28770. getViewMatrix(force?: boolean): Matrix;
  28771. /**
  28772. * Freeze the projection matrix.
  28773. * It will prevent the cache check of the camera projection compute and can speed up perf
  28774. * if no parameter of the camera are meant to change
  28775. * @param projection Defines manually a projection if necessary
  28776. */
  28777. freezeProjectionMatrix(projection?: Matrix): void;
  28778. /**
  28779. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  28780. */
  28781. unfreezeProjectionMatrix(): void;
  28782. /**
  28783. * Gets the current projection matrix of the camera.
  28784. * @param force forces the camera to recompute the matrix without looking at the cached state
  28785. * @returns the projection matrix
  28786. */
  28787. getProjectionMatrix(force?: boolean): Matrix;
  28788. /**
  28789. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  28790. * @returns a Matrix
  28791. */
  28792. getTransformationMatrix(): Matrix;
  28793. private _updateFrustumPlanes;
  28794. /**
  28795. * Checks if a cullable object (mesh...) is in the camera frustum
  28796. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  28797. * @param target The object to check
  28798. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  28799. * @returns true if the object is in frustum otherwise false
  28800. */
  28801. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  28802. /**
  28803. * Checks if a cullable object (mesh...) is in the camera frustum
  28804. * Unlike isInFrustum this cheks the full bounding box
  28805. * @param target The object to check
  28806. * @returns true if the object is in frustum otherwise false
  28807. */
  28808. isCompletelyInFrustum(target: ICullable): boolean;
  28809. /**
  28810. * Gets a ray in the forward direction from the camera.
  28811. * @param length Defines the length of the ray to create
  28812. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  28813. * @param origin Defines the start point of the ray which defaults to the camera position
  28814. * @returns the forward ray
  28815. */
  28816. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  28817. /**
  28818. * Releases resources associated with this node.
  28819. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28820. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28821. */
  28822. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28823. /** @hidden */
  28824. _isLeftCamera: boolean;
  28825. /**
  28826. * Gets the left camera of a rig setup in case of Rigged Camera
  28827. */
  28828. get isLeftCamera(): boolean;
  28829. /** @hidden */
  28830. _isRightCamera: boolean;
  28831. /**
  28832. * Gets the right camera of a rig setup in case of Rigged Camera
  28833. */
  28834. get isRightCamera(): boolean;
  28835. /**
  28836. * Gets the left camera of a rig setup in case of Rigged Camera
  28837. */
  28838. get leftCamera(): Nullable<FreeCamera>;
  28839. /**
  28840. * Gets the right camera of a rig setup in case of Rigged Camera
  28841. */
  28842. get rightCamera(): Nullable<FreeCamera>;
  28843. /**
  28844. * Gets the left camera target of a rig setup in case of Rigged Camera
  28845. * @returns the target position
  28846. */
  28847. getLeftTarget(): Nullable<Vector3>;
  28848. /**
  28849. * Gets the right camera target of a rig setup in case of Rigged Camera
  28850. * @returns the target position
  28851. */
  28852. getRightTarget(): Nullable<Vector3>;
  28853. /**
  28854. * @hidden
  28855. */
  28856. setCameraRigMode(mode: number, rigParams: any): void;
  28857. /** @hidden */
  28858. static _setStereoscopicRigMode(camera: Camera): void;
  28859. /** @hidden */
  28860. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  28861. /** @hidden */
  28862. static _setVRRigMode(camera: Camera, rigParams: any): void;
  28863. /** @hidden */
  28864. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  28865. /** @hidden */
  28866. _getVRProjectionMatrix(): Matrix;
  28867. protected _updateCameraRotationMatrix(): void;
  28868. protected _updateWebVRCameraRotationMatrix(): void;
  28869. /**
  28870. * This function MUST be overwritten by the different WebVR cameras available.
  28871. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28872. * @hidden
  28873. */
  28874. _getWebVRProjectionMatrix(): Matrix;
  28875. /**
  28876. * This function MUST be overwritten by the different WebVR cameras available.
  28877. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  28878. * @hidden
  28879. */
  28880. _getWebVRViewMatrix(): Matrix;
  28881. /** @hidden */
  28882. setCameraRigParameter(name: string, value: any): void;
  28883. /**
  28884. * needs to be overridden by children so sub has required properties to be copied
  28885. * @hidden
  28886. */
  28887. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  28888. /**
  28889. * May need to be overridden by children
  28890. * @hidden
  28891. */
  28892. _updateRigCameras(): void;
  28893. /** @hidden */
  28894. _setupInputs(): void;
  28895. /**
  28896. * Serialiaze the camera setup to a json represention
  28897. * @returns the JSON representation
  28898. */
  28899. serialize(): any;
  28900. /**
  28901. * Clones the current camera.
  28902. * @param name The cloned camera name
  28903. * @returns the cloned camera
  28904. */
  28905. clone(name: string): Camera;
  28906. /**
  28907. * Gets the direction of the camera relative to a given local axis.
  28908. * @param localAxis Defines the reference axis to provide a relative direction.
  28909. * @return the direction
  28910. */
  28911. getDirection(localAxis: Vector3): Vector3;
  28912. /**
  28913. * Returns the current camera absolute rotation
  28914. */
  28915. get absoluteRotation(): Quaternion;
  28916. /**
  28917. * Gets the direction of the camera relative to a given local axis into a passed vector.
  28918. * @param localAxis Defines the reference axis to provide a relative direction.
  28919. * @param result Defines the vector to store the result in
  28920. */
  28921. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  28922. /**
  28923. * Gets a camera constructor for a given camera type
  28924. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  28925. * @param name The name of the camera the result will be able to instantiate
  28926. * @param scene The scene the result will construct the camera in
  28927. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  28928. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  28929. * @returns a factory method to construc the camera
  28930. */
  28931. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  28932. /**
  28933. * Compute the world matrix of the camera.
  28934. * @returns the camera world matrix
  28935. */
  28936. computeWorldMatrix(): Matrix;
  28937. /**
  28938. * Parse a JSON and creates the camera from the parsed information
  28939. * @param parsedCamera The JSON to parse
  28940. * @param scene The scene to instantiate the camera in
  28941. * @returns the newly constructed camera
  28942. */
  28943. static Parse(parsedCamera: any, scene: Scene): Camera;
  28944. }
  28945. }
  28946. declare module BABYLON {
  28947. /**
  28948. * Class containing static functions to help procedurally build meshes
  28949. */
  28950. export class DiscBuilder {
  28951. /**
  28952. * Creates a plane polygonal mesh. By default, this is a disc
  28953. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  28954. * * 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
  28955. * * 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
  28956. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  28957. * * 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
  28958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  28959. * @param name defines the name of the mesh
  28960. * @param options defines the options used to create the mesh
  28961. * @param scene defines the hosting scene
  28962. * @returns the plane polygonal mesh
  28963. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  28964. */
  28965. static CreateDisc(name: string, options: {
  28966. radius?: number;
  28967. tessellation?: number;
  28968. arc?: number;
  28969. updatable?: boolean;
  28970. sideOrientation?: number;
  28971. frontUVs?: Vector4;
  28972. backUVs?: Vector4;
  28973. }, scene?: Nullable<Scene>): Mesh;
  28974. }
  28975. }
  28976. declare module BABYLON {
  28977. /**
  28978. * Options to be used when creating a FresnelParameters.
  28979. */
  28980. export type IFresnelParametersCreationOptions = {
  28981. /**
  28982. * Define the color used on edges (grazing angle)
  28983. */
  28984. leftColor?: Color3;
  28985. /**
  28986. * Define the color used on center
  28987. */
  28988. rightColor?: Color3;
  28989. /**
  28990. * Define bias applied to computed fresnel term
  28991. */
  28992. bias?: number;
  28993. /**
  28994. * Defined the power exponent applied to fresnel term
  28995. */
  28996. power?: number;
  28997. /**
  28998. * Define if the fresnel effect is enable or not.
  28999. */
  29000. isEnabled?: boolean;
  29001. };
  29002. /**
  29003. * Serialized format for FresnelParameters.
  29004. */
  29005. export type IFresnelParametersSerialized = {
  29006. /**
  29007. * Define the color used on edges (grazing angle) [as an array]
  29008. */
  29009. leftColor: number[];
  29010. /**
  29011. * Define the color used on center [as an array]
  29012. */
  29013. rightColor: number[];
  29014. /**
  29015. * Define bias applied to computed fresnel term
  29016. */
  29017. bias: number;
  29018. /**
  29019. * Defined the power exponent applied to fresnel term
  29020. */
  29021. power?: number;
  29022. /**
  29023. * Define if the fresnel effect is enable or not.
  29024. */
  29025. isEnabled: boolean;
  29026. };
  29027. /**
  29028. * This represents all the required information to add a fresnel effect on a material:
  29029. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29030. */
  29031. export class FresnelParameters {
  29032. private _isEnabled;
  29033. /**
  29034. * Define if the fresnel effect is enable or not.
  29035. */
  29036. get isEnabled(): boolean;
  29037. set isEnabled(value: boolean);
  29038. /**
  29039. * Define the color used on edges (grazing angle)
  29040. */
  29041. leftColor: Color3;
  29042. /**
  29043. * Define the color used on center
  29044. */
  29045. rightColor: Color3;
  29046. /**
  29047. * Define bias applied to computed fresnel term
  29048. */
  29049. bias: number;
  29050. /**
  29051. * Defined the power exponent applied to fresnel term
  29052. */
  29053. power: number;
  29054. /**
  29055. * Creates a new FresnelParameters object.
  29056. *
  29057. * @param options provide your own settings to optionally to override defaults
  29058. */
  29059. constructor(options?: IFresnelParametersCreationOptions);
  29060. /**
  29061. * Clones the current fresnel and its valuues
  29062. * @returns a clone fresnel configuration
  29063. */
  29064. clone(): FresnelParameters;
  29065. /**
  29066. * Determines equality between FresnelParameters objects
  29067. * @param otherFresnelParameters defines the second operand
  29068. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29069. */
  29070. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29071. /**
  29072. * Serializes the current fresnel parameters to a JSON representation.
  29073. * @return the JSON serialization
  29074. */
  29075. serialize(): IFresnelParametersSerialized;
  29076. /**
  29077. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29078. * @param parsedFresnelParameters Define the JSON representation
  29079. * @returns the parsed parameters
  29080. */
  29081. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29082. }
  29083. }
  29084. declare module BABYLON {
  29085. /**
  29086. * This groups all the flags used to control the materials channel.
  29087. */
  29088. export class MaterialFlags {
  29089. private static _DiffuseTextureEnabled;
  29090. /**
  29091. * Are diffuse textures enabled in the application.
  29092. */
  29093. static get DiffuseTextureEnabled(): boolean;
  29094. static set DiffuseTextureEnabled(value: boolean);
  29095. private static _DetailTextureEnabled;
  29096. /**
  29097. * Are detail textures enabled in the application.
  29098. */
  29099. static get DetailTextureEnabled(): boolean;
  29100. static set DetailTextureEnabled(value: boolean);
  29101. private static _AmbientTextureEnabled;
  29102. /**
  29103. * Are ambient textures enabled in the application.
  29104. */
  29105. static get AmbientTextureEnabled(): boolean;
  29106. static set AmbientTextureEnabled(value: boolean);
  29107. private static _OpacityTextureEnabled;
  29108. /**
  29109. * Are opacity textures enabled in the application.
  29110. */
  29111. static get OpacityTextureEnabled(): boolean;
  29112. static set OpacityTextureEnabled(value: boolean);
  29113. private static _ReflectionTextureEnabled;
  29114. /**
  29115. * Are reflection textures enabled in the application.
  29116. */
  29117. static get ReflectionTextureEnabled(): boolean;
  29118. static set ReflectionTextureEnabled(value: boolean);
  29119. private static _EmissiveTextureEnabled;
  29120. /**
  29121. * Are emissive textures enabled in the application.
  29122. */
  29123. static get EmissiveTextureEnabled(): boolean;
  29124. static set EmissiveTextureEnabled(value: boolean);
  29125. private static _SpecularTextureEnabled;
  29126. /**
  29127. * Are specular textures enabled in the application.
  29128. */
  29129. static get SpecularTextureEnabled(): boolean;
  29130. static set SpecularTextureEnabled(value: boolean);
  29131. private static _BumpTextureEnabled;
  29132. /**
  29133. * Are bump textures enabled in the application.
  29134. */
  29135. static get BumpTextureEnabled(): boolean;
  29136. static set BumpTextureEnabled(value: boolean);
  29137. private static _LightmapTextureEnabled;
  29138. /**
  29139. * Are lightmap textures enabled in the application.
  29140. */
  29141. static get LightmapTextureEnabled(): boolean;
  29142. static set LightmapTextureEnabled(value: boolean);
  29143. private static _RefractionTextureEnabled;
  29144. /**
  29145. * Are refraction textures enabled in the application.
  29146. */
  29147. static get RefractionTextureEnabled(): boolean;
  29148. static set RefractionTextureEnabled(value: boolean);
  29149. private static _ColorGradingTextureEnabled;
  29150. /**
  29151. * Are color grading textures enabled in the application.
  29152. */
  29153. static get ColorGradingTextureEnabled(): boolean;
  29154. static set ColorGradingTextureEnabled(value: boolean);
  29155. private static _FresnelEnabled;
  29156. /**
  29157. * Are fresnels enabled in the application.
  29158. */
  29159. static get FresnelEnabled(): boolean;
  29160. static set FresnelEnabled(value: boolean);
  29161. private static _ClearCoatTextureEnabled;
  29162. /**
  29163. * Are clear coat textures enabled in the application.
  29164. */
  29165. static get ClearCoatTextureEnabled(): boolean;
  29166. static set ClearCoatTextureEnabled(value: boolean);
  29167. private static _ClearCoatBumpTextureEnabled;
  29168. /**
  29169. * Are clear coat bump textures enabled in the application.
  29170. */
  29171. static get ClearCoatBumpTextureEnabled(): boolean;
  29172. static set ClearCoatBumpTextureEnabled(value: boolean);
  29173. private static _ClearCoatTintTextureEnabled;
  29174. /**
  29175. * Are clear coat tint textures enabled in the application.
  29176. */
  29177. static get ClearCoatTintTextureEnabled(): boolean;
  29178. static set ClearCoatTintTextureEnabled(value: boolean);
  29179. private static _SheenTextureEnabled;
  29180. /**
  29181. * Are sheen textures enabled in the application.
  29182. */
  29183. static get SheenTextureEnabled(): boolean;
  29184. static set SheenTextureEnabled(value: boolean);
  29185. private static _AnisotropicTextureEnabled;
  29186. /**
  29187. * Are anisotropic textures enabled in the application.
  29188. */
  29189. static get AnisotropicTextureEnabled(): boolean;
  29190. static set AnisotropicTextureEnabled(value: boolean);
  29191. private static _ThicknessTextureEnabled;
  29192. /**
  29193. * Are thickness textures enabled in the application.
  29194. */
  29195. static get ThicknessTextureEnabled(): boolean;
  29196. static set ThicknessTextureEnabled(value: boolean);
  29197. }
  29198. }
  29199. declare module BABYLON {
  29200. /** @hidden */
  29201. export var defaultFragmentDeclaration: {
  29202. name: string;
  29203. shader: string;
  29204. };
  29205. }
  29206. declare module BABYLON {
  29207. /** @hidden */
  29208. export var defaultUboDeclaration: {
  29209. name: string;
  29210. shader: string;
  29211. };
  29212. }
  29213. declare module BABYLON {
  29214. /** @hidden */
  29215. export var prePassDeclaration: {
  29216. name: string;
  29217. shader: string;
  29218. };
  29219. }
  29220. declare module BABYLON {
  29221. /** @hidden */
  29222. export var lightFragmentDeclaration: {
  29223. name: string;
  29224. shader: string;
  29225. };
  29226. }
  29227. declare module BABYLON {
  29228. /** @hidden */
  29229. export var lightUboDeclaration: {
  29230. name: string;
  29231. shader: string;
  29232. };
  29233. }
  29234. declare module BABYLON {
  29235. /** @hidden */
  29236. export var lightsFragmentFunctions: {
  29237. name: string;
  29238. shader: string;
  29239. };
  29240. }
  29241. declare module BABYLON {
  29242. /** @hidden */
  29243. export var shadowsFragmentFunctions: {
  29244. name: string;
  29245. shader: string;
  29246. };
  29247. }
  29248. declare module BABYLON {
  29249. /** @hidden */
  29250. export var fresnelFunction: {
  29251. name: string;
  29252. shader: string;
  29253. };
  29254. }
  29255. declare module BABYLON {
  29256. /** @hidden */
  29257. export var bumpFragmentMainFunctions: {
  29258. name: string;
  29259. shader: string;
  29260. };
  29261. }
  29262. declare module BABYLON {
  29263. /** @hidden */
  29264. export var bumpFragmentFunctions: {
  29265. name: string;
  29266. shader: string;
  29267. };
  29268. }
  29269. declare module BABYLON {
  29270. /** @hidden */
  29271. export var logDepthDeclaration: {
  29272. name: string;
  29273. shader: string;
  29274. };
  29275. }
  29276. declare module BABYLON {
  29277. /** @hidden */
  29278. export var bumpFragment: {
  29279. name: string;
  29280. shader: string;
  29281. };
  29282. }
  29283. declare module BABYLON {
  29284. /** @hidden */
  29285. export var depthPrePass: {
  29286. name: string;
  29287. shader: string;
  29288. };
  29289. }
  29290. declare module BABYLON {
  29291. /** @hidden */
  29292. export var lightFragment: {
  29293. name: string;
  29294. shader: string;
  29295. };
  29296. }
  29297. declare module BABYLON {
  29298. /** @hidden */
  29299. export var logDepthFragment: {
  29300. name: string;
  29301. shader: string;
  29302. };
  29303. }
  29304. declare module BABYLON {
  29305. /** @hidden */
  29306. export var defaultPixelShader: {
  29307. name: string;
  29308. shader: string;
  29309. };
  29310. }
  29311. declare module BABYLON {
  29312. /** @hidden */
  29313. export var defaultVertexDeclaration: {
  29314. name: string;
  29315. shader: string;
  29316. };
  29317. }
  29318. declare module BABYLON {
  29319. /** @hidden */
  29320. export var bumpVertexDeclaration: {
  29321. name: string;
  29322. shader: string;
  29323. };
  29324. }
  29325. declare module BABYLON {
  29326. /** @hidden */
  29327. export var bumpVertex: {
  29328. name: string;
  29329. shader: string;
  29330. };
  29331. }
  29332. declare module BABYLON {
  29333. /** @hidden */
  29334. export var fogVertex: {
  29335. name: string;
  29336. shader: string;
  29337. };
  29338. }
  29339. declare module BABYLON {
  29340. /** @hidden */
  29341. export var shadowsVertex: {
  29342. name: string;
  29343. shader: string;
  29344. };
  29345. }
  29346. declare module BABYLON {
  29347. /** @hidden */
  29348. export var pointCloudVertex: {
  29349. name: string;
  29350. shader: string;
  29351. };
  29352. }
  29353. declare module BABYLON {
  29354. /** @hidden */
  29355. export var logDepthVertex: {
  29356. name: string;
  29357. shader: string;
  29358. };
  29359. }
  29360. declare module BABYLON {
  29361. /** @hidden */
  29362. export var defaultVertexShader: {
  29363. name: string;
  29364. shader: string;
  29365. };
  29366. }
  29367. declare module BABYLON {
  29368. /**
  29369. * @hidden
  29370. */
  29371. export interface IMaterialDetailMapDefines {
  29372. DETAIL: boolean;
  29373. DETAILDIRECTUV: number;
  29374. DETAIL_NORMALBLENDMETHOD: number;
  29375. /** @hidden */
  29376. _areTexturesDirty: boolean;
  29377. }
  29378. /**
  29379. * Define the code related to the detail map parameters of a material
  29380. *
  29381. * Inspired from:
  29382. * 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
  29383. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  29384. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  29385. */
  29386. export class DetailMapConfiguration {
  29387. private _texture;
  29388. /**
  29389. * The detail texture of the material.
  29390. */
  29391. texture: Nullable<BaseTexture>;
  29392. /**
  29393. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  29394. * Bigger values mean stronger blending
  29395. */
  29396. diffuseBlendLevel: number;
  29397. /**
  29398. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  29399. * Bigger values mean stronger blending. Only used with PBR materials
  29400. */
  29401. roughnessBlendLevel: number;
  29402. /**
  29403. * Defines how strong the bump effect from the detail map is
  29404. * Bigger values mean stronger effect
  29405. */
  29406. bumpLevel: number;
  29407. private _normalBlendMethod;
  29408. /**
  29409. * The method used to blend the bump and detail normals together
  29410. */
  29411. normalBlendMethod: number;
  29412. private _isEnabled;
  29413. /**
  29414. * Enable or disable the detail map on this material
  29415. */
  29416. isEnabled: boolean;
  29417. /** @hidden */
  29418. private _internalMarkAllSubMeshesAsTexturesDirty;
  29419. /** @hidden */
  29420. _markAllSubMeshesAsTexturesDirty(): void;
  29421. /**
  29422. * Instantiate a new detail map
  29423. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  29424. */
  29425. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  29426. /**
  29427. * Gets whether the submesh is ready to be used or not.
  29428. * @param defines the list of "defines" to update.
  29429. * @param scene defines the scene the material belongs to.
  29430. * @returns - boolean indicating that the submesh is ready or not.
  29431. */
  29432. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  29433. /**
  29434. * Update the defines for detail map usage
  29435. * @param defines the list of "defines" to update.
  29436. * @param scene defines the scene the material belongs to.
  29437. */
  29438. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  29439. /**
  29440. * Binds the material data.
  29441. * @param uniformBuffer defines the Uniform buffer to fill in.
  29442. * @param scene defines the scene the material belongs to.
  29443. * @param isFrozen defines whether the material is frozen or not.
  29444. */
  29445. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  29446. /**
  29447. * Checks to see if a texture is used in the material.
  29448. * @param texture - Base texture to use.
  29449. * @returns - Boolean specifying if a texture is used in the material.
  29450. */
  29451. hasTexture(texture: BaseTexture): boolean;
  29452. /**
  29453. * Returns an array of the actively used textures.
  29454. * @param activeTextures Array of BaseTextures
  29455. */
  29456. getActiveTextures(activeTextures: BaseTexture[]): void;
  29457. /**
  29458. * Returns the animatable textures.
  29459. * @param animatables Array of animatable textures.
  29460. */
  29461. getAnimatables(animatables: IAnimatable[]): void;
  29462. /**
  29463. * Disposes the resources of the material.
  29464. * @param forceDisposeTextures - Forces the disposal of all textures.
  29465. */
  29466. dispose(forceDisposeTextures?: boolean): void;
  29467. /**
  29468. * Get the current class name useful for serialization or dynamic coding.
  29469. * @returns "DetailMap"
  29470. */
  29471. getClassName(): string;
  29472. /**
  29473. * Add the required uniforms to the current list.
  29474. * @param uniforms defines the current uniform list.
  29475. */
  29476. static AddUniforms(uniforms: string[]): void;
  29477. /**
  29478. * Add the required samplers to the current list.
  29479. * @param samplers defines the current sampler list.
  29480. */
  29481. static AddSamplers(samplers: string[]): void;
  29482. /**
  29483. * Add the required uniforms to the current buffer.
  29484. * @param uniformBuffer defines the current uniform buffer.
  29485. */
  29486. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  29487. /**
  29488. * Makes a duplicate of the current instance into another one.
  29489. * @param detailMap define the instance where to copy the info
  29490. */
  29491. copyTo(detailMap: DetailMapConfiguration): void;
  29492. /**
  29493. * Serializes this detail map instance
  29494. * @returns - An object with the serialized instance.
  29495. */
  29496. serialize(): any;
  29497. /**
  29498. * Parses a detail map setting from a serialized object.
  29499. * @param source - Serialized object.
  29500. * @param scene Defines the scene we are parsing for
  29501. * @param rootUrl Defines the rootUrl to load from
  29502. */
  29503. parse(source: any, scene: Scene, rootUrl: string): void;
  29504. }
  29505. }
  29506. declare module BABYLON {
  29507. /** @hidden */
  29508. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  29509. MAINUV1: boolean;
  29510. MAINUV2: boolean;
  29511. DIFFUSE: boolean;
  29512. DIFFUSEDIRECTUV: number;
  29513. DETAIL: boolean;
  29514. DETAILDIRECTUV: number;
  29515. DETAIL_NORMALBLENDMETHOD: number;
  29516. AMBIENT: boolean;
  29517. AMBIENTDIRECTUV: number;
  29518. OPACITY: boolean;
  29519. OPACITYDIRECTUV: number;
  29520. OPACITYRGB: boolean;
  29521. REFLECTION: boolean;
  29522. EMISSIVE: boolean;
  29523. EMISSIVEDIRECTUV: number;
  29524. SPECULAR: boolean;
  29525. SPECULARDIRECTUV: number;
  29526. BUMP: boolean;
  29527. BUMPDIRECTUV: number;
  29528. PARALLAX: boolean;
  29529. PARALLAXOCCLUSION: boolean;
  29530. SPECULAROVERALPHA: boolean;
  29531. CLIPPLANE: boolean;
  29532. CLIPPLANE2: boolean;
  29533. CLIPPLANE3: boolean;
  29534. CLIPPLANE4: boolean;
  29535. CLIPPLANE5: boolean;
  29536. CLIPPLANE6: boolean;
  29537. ALPHATEST: boolean;
  29538. DEPTHPREPASS: boolean;
  29539. ALPHAFROMDIFFUSE: boolean;
  29540. POINTSIZE: boolean;
  29541. FOG: boolean;
  29542. SPECULARTERM: boolean;
  29543. DIFFUSEFRESNEL: boolean;
  29544. OPACITYFRESNEL: boolean;
  29545. REFLECTIONFRESNEL: boolean;
  29546. REFRACTIONFRESNEL: boolean;
  29547. EMISSIVEFRESNEL: boolean;
  29548. FRESNEL: boolean;
  29549. NORMAL: boolean;
  29550. UV1: boolean;
  29551. UV2: boolean;
  29552. VERTEXCOLOR: boolean;
  29553. VERTEXALPHA: boolean;
  29554. NUM_BONE_INFLUENCERS: number;
  29555. BonesPerMesh: number;
  29556. BONETEXTURE: boolean;
  29557. INSTANCES: boolean;
  29558. THIN_INSTANCES: boolean;
  29559. GLOSSINESS: boolean;
  29560. ROUGHNESS: boolean;
  29561. EMISSIVEASILLUMINATION: boolean;
  29562. LINKEMISSIVEWITHDIFFUSE: boolean;
  29563. REFLECTIONFRESNELFROMSPECULAR: boolean;
  29564. LIGHTMAP: boolean;
  29565. LIGHTMAPDIRECTUV: number;
  29566. OBJECTSPACE_NORMALMAP: boolean;
  29567. USELIGHTMAPASSHADOWMAP: boolean;
  29568. REFLECTIONMAP_3D: boolean;
  29569. REFLECTIONMAP_SPHERICAL: boolean;
  29570. REFLECTIONMAP_PLANAR: boolean;
  29571. REFLECTIONMAP_CUBIC: boolean;
  29572. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  29573. REFLECTIONMAP_PROJECTION: boolean;
  29574. REFLECTIONMAP_SKYBOX: boolean;
  29575. REFLECTIONMAP_EXPLICIT: boolean;
  29576. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  29577. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  29578. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  29579. INVERTCUBICMAP: boolean;
  29580. LOGARITHMICDEPTH: boolean;
  29581. REFRACTION: boolean;
  29582. REFRACTIONMAP_3D: boolean;
  29583. REFLECTIONOVERALPHA: boolean;
  29584. TWOSIDEDLIGHTING: boolean;
  29585. SHADOWFLOAT: boolean;
  29586. MORPHTARGETS: boolean;
  29587. MORPHTARGETS_NORMAL: boolean;
  29588. MORPHTARGETS_TANGENT: boolean;
  29589. MORPHTARGETS_UV: boolean;
  29590. NUM_MORPH_INFLUENCERS: number;
  29591. NONUNIFORMSCALING: boolean;
  29592. PREMULTIPLYALPHA: boolean;
  29593. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  29594. ALPHABLEND: boolean;
  29595. PREPASS: boolean;
  29596. SCENE_MRT_COUNT: number;
  29597. RGBDLIGHTMAP: boolean;
  29598. RGBDREFLECTION: boolean;
  29599. RGBDREFRACTION: boolean;
  29600. IMAGEPROCESSING: boolean;
  29601. VIGNETTE: boolean;
  29602. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29603. VIGNETTEBLENDMODEOPAQUE: boolean;
  29604. TONEMAPPING: boolean;
  29605. TONEMAPPING_ACES: boolean;
  29606. CONTRAST: boolean;
  29607. COLORCURVES: boolean;
  29608. COLORGRADING: boolean;
  29609. COLORGRADING3D: boolean;
  29610. SAMPLER3DGREENDEPTH: boolean;
  29611. SAMPLER3DBGRMAP: boolean;
  29612. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29613. MULTIVIEW: boolean;
  29614. /**
  29615. * If the reflection texture on this material is in linear color space
  29616. * @hidden
  29617. */
  29618. IS_REFLECTION_LINEAR: boolean;
  29619. /**
  29620. * If the refraction texture on this material is in linear color space
  29621. * @hidden
  29622. */
  29623. IS_REFRACTION_LINEAR: boolean;
  29624. EXPOSURE: boolean;
  29625. constructor();
  29626. setReflectionMode(modeToEnable: string): void;
  29627. }
  29628. /**
  29629. * This is the default material used in Babylon. It is the best trade off between quality
  29630. * and performances.
  29631. * @see https://doc.babylonjs.com/babylon101/materials
  29632. */
  29633. export class StandardMaterial extends PushMaterial {
  29634. private _diffuseTexture;
  29635. /**
  29636. * The basic texture of the material as viewed under a light.
  29637. */
  29638. diffuseTexture: Nullable<BaseTexture>;
  29639. private _ambientTexture;
  29640. /**
  29641. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  29642. */
  29643. ambientTexture: Nullable<BaseTexture>;
  29644. private _opacityTexture;
  29645. /**
  29646. * Define the transparency of the material from a texture.
  29647. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  29648. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  29649. */
  29650. opacityTexture: Nullable<BaseTexture>;
  29651. private _reflectionTexture;
  29652. /**
  29653. * Define the texture used to display the reflection.
  29654. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29655. */
  29656. reflectionTexture: Nullable<BaseTexture>;
  29657. private _emissiveTexture;
  29658. /**
  29659. * Define texture of the material as if self lit.
  29660. * This will be mixed in the final result even in the absence of light.
  29661. */
  29662. emissiveTexture: Nullable<BaseTexture>;
  29663. private _specularTexture;
  29664. /**
  29665. * Define how the color and intensity of the highlight given by the light in the material.
  29666. */
  29667. specularTexture: Nullable<BaseTexture>;
  29668. private _bumpTexture;
  29669. /**
  29670. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  29671. * 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.
  29672. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  29673. */
  29674. bumpTexture: Nullable<BaseTexture>;
  29675. private _lightmapTexture;
  29676. /**
  29677. * Complex lighting can be computationally expensive to compute at runtime.
  29678. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  29679. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  29680. */
  29681. lightmapTexture: Nullable<BaseTexture>;
  29682. private _refractionTexture;
  29683. /**
  29684. * Define the texture used to display the refraction.
  29685. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29686. */
  29687. refractionTexture: Nullable<BaseTexture>;
  29688. /**
  29689. * The color of the material lit by the environmental background lighting.
  29690. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  29691. */
  29692. ambientColor: Color3;
  29693. /**
  29694. * The basic color of the material as viewed under a light.
  29695. */
  29696. diffuseColor: Color3;
  29697. /**
  29698. * Define how the color and intensity of the highlight given by the light in the material.
  29699. */
  29700. specularColor: Color3;
  29701. /**
  29702. * Define the color of the material as if self lit.
  29703. * This will be mixed in the final result even in the absence of light.
  29704. */
  29705. emissiveColor: Color3;
  29706. /**
  29707. * Defines how sharp are the highlights in the material.
  29708. * The bigger the value the sharper giving a more glossy feeling to the result.
  29709. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  29710. */
  29711. specularPower: number;
  29712. private _useAlphaFromDiffuseTexture;
  29713. /**
  29714. * Does the transparency come from the diffuse texture alpha channel.
  29715. */
  29716. useAlphaFromDiffuseTexture: boolean;
  29717. private _useEmissiveAsIllumination;
  29718. /**
  29719. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  29720. */
  29721. useEmissiveAsIllumination: boolean;
  29722. private _linkEmissiveWithDiffuse;
  29723. /**
  29724. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  29725. * the emissive level when the final color is close to one.
  29726. */
  29727. linkEmissiveWithDiffuse: boolean;
  29728. private _useSpecularOverAlpha;
  29729. /**
  29730. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  29731. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  29732. */
  29733. useSpecularOverAlpha: boolean;
  29734. private _useReflectionOverAlpha;
  29735. /**
  29736. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  29737. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  29738. */
  29739. useReflectionOverAlpha: boolean;
  29740. private _disableLighting;
  29741. /**
  29742. * Does lights from the scene impacts this material.
  29743. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  29744. */
  29745. disableLighting: boolean;
  29746. private _useObjectSpaceNormalMap;
  29747. /**
  29748. * Allows using an object space normal map (instead of tangent space).
  29749. */
  29750. useObjectSpaceNormalMap: boolean;
  29751. private _useParallax;
  29752. /**
  29753. * Is parallax enabled or not.
  29754. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  29755. */
  29756. useParallax: boolean;
  29757. private _useParallaxOcclusion;
  29758. /**
  29759. * Is parallax occlusion enabled or not.
  29760. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  29761. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  29762. */
  29763. useParallaxOcclusion: boolean;
  29764. /**
  29765. * 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.
  29766. */
  29767. parallaxScaleBias: number;
  29768. private _roughness;
  29769. /**
  29770. * Helps to define how blurry the reflections should appears in the material.
  29771. */
  29772. roughness: number;
  29773. /**
  29774. * In case of refraction, define the value of the index of refraction.
  29775. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29776. */
  29777. indexOfRefraction: number;
  29778. /**
  29779. * Invert the refraction texture alongside the y axis.
  29780. * It can be useful with procedural textures or probe for instance.
  29781. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  29782. */
  29783. invertRefractionY: boolean;
  29784. /**
  29785. * Defines the alpha limits in alpha test mode.
  29786. */
  29787. alphaCutOff: number;
  29788. private _useLightmapAsShadowmap;
  29789. /**
  29790. * In case of light mapping, define whether the map contains light or shadow informations.
  29791. */
  29792. useLightmapAsShadowmap: boolean;
  29793. private _diffuseFresnelParameters;
  29794. /**
  29795. * Define the diffuse fresnel parameters of the material.
  29796. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29797. */
  29798. diffuseFresnelParameters: FresnelParameters;
  29799. private _opacityFresnelParameters;
  29800. /**
  29801. * Define the opacity fresnel parameters of the material.
  29802. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29803. */
  29804. opacityFresnelParameters: FresnelParameters;
  29805. private _reflectionFresnelParameters;
  29806. /**
  29807. * Define the reflection fresnel parameters of the material.
  29808. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29809. */
  29810. reflectionFresnelParameters: FresnelParameters;
  29811. private _refractionFresnelParameters;
  29812. /**
  29813. * Define the refraction fresnel parameters of the material.
  29814. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29815. */
  29816. refractionFresnelParameters: FresnelParameters;
  29817. private _emissiveFresnelParameters;
  29818. /**
  29819. * Define the emissive fresnel parameters of the material.
  29820. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29821. */
  29822. emissiveFresnelParameters: FresnelParameters;
  29823. private _useReflectionFresnelFromSpecular;
  29824. /**
  29825. * If true automatically deducts the fresnels values from the material specularity.
  29826. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29827. */
  29828. useReflectionFresnelFromSpecular: boolean;
  29829. private _useGlossinessFromSpecularMapAlpha;
  29830. /**
  29831. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  29832. */
  29833. useGlossinessFromSpecularMapAlpha: boolean;
  29834. private _maxSimultaneousLights;
  29835. /**
  29836. * Defines the maximum number of lights that can be used in the material
  29837. */
  29838. maxSimultaneousLights: number;
  29839. private _invertNormalMapX;
  29840. /**
  29841. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  29842. */
  29843. invertNormalMapX: boolean;
  29844. private _invertNormalMapY;
  29845. /**
  29846. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  29847. */
  29848. invertNormalMapY: boolean;
  29849. private _twoSidedLighting;
  29850. /**
  29851. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  29852. */
  29853. twoSidedLighting: boolean;
  29854. /**
  29855. * Default configuration related to image processing available in the standard Material.
  29856. */
  29857. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  29858. /**
  29859. * Gets the image processing configuration used either in this material.
  29860. */
  29861. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  29862. /**
  29863. * Sets the Default image processing configuration used either in the this material.
  29864. *
  29865. * If sets to null, the scene one is in use.
  29866. */
  29867. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  29868. /**
  29869. * Keep track of the image processing observer to allow dispose and replace.
  29870. */
  29871. private _imageProcessingObserver;
  29872. /**
  29873. * Attaches a new image processing configuration to the Standard Material.
  29874. * @param configuration
  29875. */
  29876. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  29877. /**
  29878. * Gets wether the color curves effect is enabled.
  29879. */
  29880. get cameraColorCurvesEnabled(): boolean;
  29881. /**
  29882. * Sets wether the color curves effect is enabled.
  29883. */
  29884. set cameraColorCurvesEnabled(value: boolean);
  29885. /**
  29886. * Gets wether the color grading effect is enabled.
  29887. */
  29888. get cameraColorGradingEnabled(): boolean;
  29889. /**
  29890. * Gets wether the color grading effect is enabled.
  29891. */
  29892. set cameraColorGradingEnabled(value: boolean);
  29893. /**
  29894. * Gets wether tonemapping is enabled or not.
  29895. */
  29896. get cameraToneMappingEnabled(): boolean;
  29897. /**
  29898. * Sets wether tonemapping is enabled or not
  29899. */
  29900. set cameraToneMappingEnabled(value: boolean);
  29901. /**
  29902. * The camera exposure used on this material.
  29903. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29904. * This corresponds to a photographic exposure.
  29905. */
  29906. get cameraExposure(): number;
  29907. /**
  29908. * The camera exposure used on this material.
  29909. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  29910. * This corresponds to a photographic exposure.
  29911. */
  29912. set cameraExposure(value: number);
  29913. /**
  29914. * Gets The camera contrast used on this material.
  29915. */
  29916. get cameraContrast(): number;
  29917. /**
  29918. * Sets The camera contrast used on this material.
  29919. */
  29920. set cameraContrast(value: number);
  29921. /**
  29922. * Gets the Color Grading 2D Lookup Texture.
  29923. */
  29924. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  29925. /**
  29926. * Sets the Color Grading 2D Lookup Texture.
  29927. */
  29928. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  29929. /**
  29930. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29931. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29932. * 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;
  29933. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29934. */
  29935. get cameraColorCurves(): Nullable<ColorCurves>;
  29936. /**
  29937. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29938. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29939. * 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;
  29940. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29941. */
  29942. set cameraColorCurves(value: Nullable<ColorCurves>);
  29943. /**
  29944. * Should this material render to several textures at once
  29945. */
  29946. get shouldRenderToMRT(): boolean;
  29947. /**
  29948. * Defines the detail map parameters for the material.
  29949. */
  29950. readonly detailMap: DetailMapConfiguration;
  29951. protected _renderTargets: SmartArray<RenderTargetTexture>;
  29952. protected _worldViewProjectionMatrix: Matrix;
  29953. protected _globalAmbientColor: Color3;
  29954. protected _useLogarithmicDepth: boolean;
  29955. protected _rebuildInParallel: boolean;
  29956. /**
  29957. * Instantiates a new standard material.
  29958. * This is the default material used in Babylon. It is the best trade off between quality
  29959. * and performances.
  29960. * @see https://doc.babylonjs.com/babylon101/materials
  29961. * @param name Define the name of the material in the scene
  29962. * @param scene Define the scene the material belong to
  29963. */
  29964. constructor(name: string, scene: Scene);
  29965. /**
  29966. * Gets a boolean indicating that current material needs to register RTT
  29967. */
  29968. get hasRenderTargetTextures(): boolean;
  29969. /**
  29970. * Gets the current class name of the material e.g. "StandardMaterial"
  29971. * Mainly use in serialization.
  29972. * @returns the class name
  29973. */
  29974. getClassName(): string;
  29975. /**
  29976. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  29977. * You can try switching to logarithmic depth.
  29978. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  29979. */
  29980. get useLogarithmicDepth(): boolean;
  29981. set useLogarithmicDepth(value: boolean);
  29982. /**
  29983. * Specifies if the material will require alpha blending
  29984. * @returns a boolean specifying if alpha blending is needed
  29985. */
  29986. needAlphaBlending(): boolean;
  29987. /**
  29988. * Specifies if this material should be rendered in alpha test mode
  29989. * @returns a boolean specifying if an alpha test is needed.
  29990. */
  29991. needAlphaTesting(): boolean;
  29992. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  29993. /**
  29994. * Get the texture used for alpha test purpose.
  29995. * @returns the diffuse texture in case of the standard material.
  29996. */
  29997. getAlphaTestTexture(): Nullable<BaseTexture>;
  29998. /**
  29999. * Get if the submesh is ready to be used and all its information available.
  30000. * Child classes can use it to update shaders
  30001. * @param mesh defines the mesh to check
  30002. * @param subMesh defines which submesh to check
  30003. * @param useInstances specifies that instances should be used
  30004. * @returns a boolean indicating that the submesh is ready or not
  30005. */
  30006. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30007. /**
  30008. * Builds the material UBO layouts.
  30009. * Used internally during the effect preparation.
  30010. */
  30011. buildUniformLayout(): void;
  30012. /**
  30013. * Unbinds the material from the mesh
  30014. */
  30015. unbind(): void;
  30016. /**
  30017. * Binds the submesh to this material by preparing the effect and shader to draw
  30018. * @param world defines the world transformation matrix
  30019. * @param mesh defines the mesh containing the submesh
  30020. * @param subMesh defines the submesh to bind the material to
  30021. */
  30022. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30023. /**
  30024. * Get the list of animatables in the material.
  30025. * @returns the list of animatables object used in the material
  30026. */
  30027. getAnimatables(): IAnimatable[];
  30028. /**
  30029. * Gets the active textures from the material
  30030. * @returns an array of textures
  30031. */
  30032. getActiveTextures(): BaseTexture[];
  30033. /**
  30034. * Specifies if the material uses a texture
  30035. * @param texture defines the texture to check against the material
  30036. * @returns a boolean specifying if the material uses the texture
  30037. */
  30038. hasTexture(texture: BaseTexture): boolean;
  30039. /**
  30040. * Disposes the material
  30041. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30042. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30043. */
  30044. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30045. /**
  30046. * Makes a duplicate of the material, and gives it a new name
  30047. * @param name defines the new name for the duplicated material
  30048. * @returns the cloned material
  30049. */
  30050. clone(name: string): StandardMaterial;
  30051. /**
  30052. * Serializes this material in a JSON representation
  30053. * @returns the serialized material object
  30054. */
  30055. serialize(): any;
  30056. /**
  30057. * Creates a standard material from parsed material data
  30058. * @param source defines the JSON representation of the material
  30059. * @param scene defines the hosting scene
  30060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30061. * @returns a new standard material
  30062. */
  30063. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30064. /**
  30065. * Are diffuse textures enabled in the application.
  30066. */
  30067. static get DiffuseTextureEnabled(): boolean;
  30068. static set DiffuseTextureEnabled(value: boolean);
  30069. /**
  30070. * Are detail textures enabled in the application.
  30071. */
  30072. static get DetailTextureEnabled(): boolean;
  30073. static set DetailTextureEnabled(value: boolean);
  30074. /**
  30075. * Are ambient textures enabled in the application.
  30076. */
  30077. static get AmbientTextureEnabled(): boolean;
  30078. static set AmbientTextureEnabled(value: boolean);
  30079. /**
  30080. * Are opacity textures enabled in the application.
  30081. */
  30082. static get OpacityTextureEnabled(): boolean;
  30083. static set OpacityTextureEnabled(value: boolean);
  30084. /**
  30085. * Are reflection textures enabled in the application.
  30086. */
  30087. static get ReflectionTextureEnabled(): boolean;
  30088. static set ReflectionTextureEnabled(value: boolean);
  30089. /**
  30090. * Are emissive textures enabled in the application.
  30091. */
  30092. static get EmissiveTextureEnabled(): boolean;
  30093. static set EmissiveTextureEnabled(value: boolean);
  30094. /**
  30095. * Are specular textures enabled in the application.
  30096. */
  30097. static get SpecularTextureEnabled(): boolean;
  30098. static set SpecularTextureEnabled(value: boolean);
  30099. /**
  30100. * Are bump textures enabled in the application.
  30101. */
  30102. static get BumpTextureEnabled(): boolean;
  30103. static set BumpTextureEnabled(value: boolean);
  30104. /**
  30105. * Are lightmap textures enabled in the application.
  30106. */
  30107. static get LightmapTextureEnabled(): boolean;
  30108. static set LightmapTextureEnabled(value: boolean);
  30109. /**
  30110. * Are refraction textures enabled in the application.
  30111. */
  30112. static get RefractionTextureEnabled(): boolean;
  30113. static set RefractionTextureEnabled(value: boolean);
  30114. /**
  30115. * Are color grading textures enabled in the application.
  30116. */
  30117. static get ColorGradingTextureEnabled(): boolean;
  30118. static set ColorGradingTextureEnabled(value: boolean);
  30119. /**
  30120. * Are fresnels enabled in the application.
  30121. */
  30122. static get FresnelEnabled(): boolean;
  30123. static set FresnelEnabled(value: boolean);
  30124. }
  30125. }
  30126. declare module BABYLON {
  30127. /**
  30128. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30129. *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.
  30130. * The SPS is also a particle system. It provides some methods to manage the particles.
  30131. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30132. *
  30133. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30134. */
  30135. export class SolidParticleSystem implements IDisposable {
  30136. /**
  30137. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30138. * Example : var p = SPS.particles[i];
  30139. */
  30140. particles: SolidParticle[];
  30141. /**
  30142. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30143. */
  30144. nbParticles: number;
  30145. /**
  30146. * If the particles must ever face the camera (default false). Useful for planar particles.
  30147. */
  30148. billboard: boolean;
  30149. /**
  30150. * Recompute normals when adding a shape
  30151. */
  30152. recomputeNormals: boolean;
  30153. /**
  30154. * This a counter ofr your own usage. It's not set by any SPS functions.
  30155. */
  30156. counter: number;
  30157. /**
  30158. * The SPS name. This name is also given to the underlying mesh.
  30159. */
  30160. name: string;
  30161. /**
  30162. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30163. */
  30164. mesh: Mesh;
  30165. /**
  30166. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30167. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30168. */
  30169. vars: any;
  30170. /**
  30171. * This array is populated when the SPS is set as 'pickable'.
  30172. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30173. * Each element of this array is an object `{idx: int, faceId: int}`.
  30174. * `idx` is the picked particle index in the `SPS.particles` array
  30175. * `faceId` is the picked face index counted within this particle.
  30176. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30177. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30178. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30179. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30180. */
  30181. pickedParticles: {
  30182. idx: number;
  30183. faceId: number;
  30184. }[];
  30185. /**
  30186. * This array is populated when the SPS is set as 'pickable'
  30187. * Each key of this array is a submesh index.
  30188. * Each element of this array is a second array defined like this :
  30189. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30190. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30191. * `idx` is the picked particle index in the `SPS.particles` array
  30192. * `faceId` is the picked face index counted within this particle.
  30193. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30194. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30195. */
  30196. pickedBySubMesh: {
  30197. idx: number;
  30198. faceId: number;
  30199. }[][];
  30200. /**
  30201. * This array is populated when `enableDepthSort` is set to true.
  30202. * Each element of this array is an instance of the class DepthSortedParticle.
  30203. */
  30204. depthSortedParticles: DepthSortedParticle[];
  30205. /**
  30206. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30207. * @hidden
  30208. */
  30209. _bSphereOnly: boolean;
  30210. /**
  30211. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30212. * @hidden
  30213. */
  30214. _bSphereRadiusFactor: number;
  30215. private _scene;
  30216. private _positions;
  30217. private _indices;
  30218. private _normals;
  30219. private _colors;
  30220. private _uvs;
  30221. private _indices32;
  30222. private _positions32;
  30223. private _normals32;
  30224. private _fixedNormal32;
  30225. private _colors32;
  30226. private _uvs32;
  30227. private _index;
  30228. private _updatable;
  30229. private _pickable;
  30230. private _isVisibilityBoxLocked;
  30231. private _alwaysVisible;
  30232. private _depthSort;
  30233. private _expandable;
  30234. private _shapeCounter;
  30235. private _copy;
  30236. private _color;
  30237. private _computeParticleColor;
  30238. private _computeParticleTexture;
  30239. private _computeParticleRotation;
  30240. private _computeParticleVertex;
  30241. private _computeBoundingBox;
  30242. private _depthSortParticles;
  30243. private _camera;
  30244. private _mustUnrotateFixedNormals;
  30245. private _particlesIntersect;
  30246. private _needs32Bits;
  30247. private _isNotBuilt;
  30248. private _lastParticleId;
  30249. private _idxOfId;
  30250. private _multimaterialEnabled;
  30251. private _useModelMaterial;
  30252. private _indicesByMaterial;
  30253. private _materialIndexes;
  30254. private _depthSortFunction;
  30255. private _materialSortFunction;
  30256. private _materials;
  30257. private _multimaterial;
  30258. private _materialIndexesById;
  30259. private _defaultMaterial;
  30260. private _autoUpdateSubMeshes;
  30261. private _tmpVertex;
  30262. /**
  30263. * Creates a SPS (Solid Particle System) object.
  30264. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30265. * @param scene (Scene) is the scene in which the SPS is added.
  30266. * @param options defines the options of the sps e.g.
  30267. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30268. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30269. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30270. * * 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.
  30271. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30272. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30273. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30274. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30275. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30276. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30277. */
  30278. constructor(name: string, scene: Scene, options?: {
  30279. updatable?: boolean;
  30280. isPickable?: boolean;
  30281. enableDepthSort?: boolean;
  30282. particleIntersection?: boolean;
  30283. boundingSphereOnly?: boolean;
  30284. bSphereRadiusFactor?: number;
  30285. expandable?: boolean;
  30286. useModelMaterial?: boolean;
  30287. enableMultiMaterial?: boolean;
  30288. });
  30289. /**
  30290. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30291. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30292. * @returns the created mesh
  30293. */
  30294. buildMesh(): Mesh;
  30295. /**
  30296. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  30297. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  30298. * Thus the particles generated from `digest()` have their property `position` set yet.
  30299. * @param mesh ( Mesh ) is the mesh to be digested
  30300. * @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
  30301. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  30302. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  30303. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30304. * @returns the current SPS
  30305. */
  30306. digest(mesh: Mesh, options?: {
  30307. facetNb?: number;
  30308. number?: number;
  30309. delta?: number;
  30310. storage?: [];
  30311. }): SolidParticleSystem;
  30312. /**
  30313. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  30314. * @hidden
  30315. */
  30316. private _unrotateFixedNormals;
  30317. /**
  30318. * Resets the temporary working copy particle
  30319. * @hidden
  30320. */
  30321. private _resetCopy;
  30322. /**
  30323. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  30324. * @param p the current index in the positions array to be updated
  30325. * @param ind the current index in the indices array
  30326. * @param shape a Vector3 array, the shape geometry
  30327. * @param positions the positions array to be updated
  30328. * @param meshInd the shape indices array
  30329. * @param indices the indices array to be updated
  30330. * @param meshUV the shape uv array
  30331. * @param uvs the uv array to be updated
  30332. * @param meshCol the shape color array
  30333. * @param colors the color array to be updated
  30334. * @param meshNor the shape normals array
  30335. * @param normals the normals array to be updated
  30336. * @param idx the particle index
  30337. * @param idxInShape the particle index in its shape
  30338. * @param options the addShape() method passed options
  30339. * @model the particle model
  30340. * @hidden
  30341. */
  30342. private _meshBuilder;
  30343. /**
  30344. * Returns a shape Vector3 array from positions float array
  30345. * @param positions float array
  30346. * @returns a vector3 array
  30347. * @hidden
  30348. */
  30349. private _posToShape;
  30350. /**
  30351. * Returns a shapeUV array from a float uvs (array deep copy)
  30352. * @param uvs as a float array
  30353. * @returns a shapeUV array
  30354. * @hidden
  30355. */
  30356. private _uvsToShapeUV;
  30357. /**
  30358. * Adds a new particle object in the particles array
  30359. * @param idx particle index in particles array
  30360. * @param id particle id
  30361. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  30362. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  30363. * @param model particle ModelShape object
  30364. * @param shapeId model shape identifier
  30365. * @param idxInShape index of the particle in the current model
  30366. * @param bInfo model bounding info object
  30367. * @param storage target storage array, if any
  30368. * @hidden
  30369. */
  30370. private _addParticle;
  30371. /**
  30372. * Adds some particles to the SPS from the model shape. Returns the shape id.
  30373. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  30374. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  30375. * @param nb (positive integer) the number of particles to be created from this model
  30376. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  30377. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  30378. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  30379. * @returns the number of shapes in the system
  30380. */
  30381. addShape(mesh: Mesh, nb: number, options?: {
  30382. positionFunction?: any;
  30383. vertexFunction?: any;
  30384. storage?: [];
  30385. }): number;
  30386. /**
  30387. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  30388. * @hidden
  30389. */
  30390. private _rebuildParticle;
  30391. /**
  30392. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  30393. * @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.
  30394. * @returns the SPS.
  30395. */
  30396. rebuildMesh(reset?: boolean): SolidParticleSystem;
  30397. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  30398. * Returns an array with the removed particles.
  30399. * 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.
  30400. * The SPS can't be empty so at least one particle needs to remain in place.
  30401. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  30402. * @param start index of the first particle to remove
  30403. * @param end index of the last particle to remove (included)
  30404. * @returns an array populated with the removed particles
  30405. */
  30406. removeParticles(start: number, end: number): SolidParticle[];
  30407. /**
  30408. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  30409. * @param solidParticleArray an array populated with Solid Particles objects
  30410. * @returns the SPS
  30411. */
  30412. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  30413. /**
  30414. * Creates a new particle and modifies the SPS mesh geometry :
  30415. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  30416. * - calls _addParticle() to populate the particle array
  30417. * factorized code from addShape() and insertParticlesFromArray()
  30418. * @param idx particle index in the particles array
  30419. * @param i particle index in its shape
  30420. * @param modelShape particle ModelShape object
  30421. * @param shape shape vertex array
  30422. * @param meshInd shape indices array
  30423. * @param meshUV shape uv array
  30424. * @param meshCol shape color array
  30425. * @param meshNor shape normals array
  30426. * @param bbInfo shape bounding info
  30427. * @param storage target particle storage
  30428. * @options addShape() passed options
  30429. * @hidden
  30430. */
  30431. private _insertNewParticle;
  30432. /**
  30433. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  30434. * This method calls `updateParticle()` for each particle of the SPS.
  30435. * For an animated SPS, it is usually called within the render loop.
  30436. * 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.
  30437. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  30438. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  30439. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  30440. * @returns the SPS.
  30441. */
  30442. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  30443. /**
  30444. * Disposes the SPS.
  30445. */
  30446. dispose(): void;
  30447. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  30448. * idx is the particle index in the SPS
  30449. * faceId is the picked face index counted within this particle.
  30450. * Returns null if the pickInfo can't identify a picked particle.
  30451. * @param pickingInfo (PickingInfo object)
  30452. * @returns {idx: number, faceId: number} or null
  30453. */
  30454. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  30455. idx: number;
  30456. faceId: number;
  30457. }>;
  30458. /**
  30459. * Returns a SolidParticle object from its identifier : particle.id
  30460. * @param id (integer) the particle Id
  30461. * @returns the searched particle or null if not found in the SPS.
  30462. */
  30463. getParticleById(id: number): Nullable<SolidParticle>;
  30464. /**
  30465. * Returns a new array populated with the particles having the passed shapeId.
  30466. * @param shapeId (integer) the shape identifier
  30467. * @returns a new solid particle array
  30468. */
  30469. getParticlesByShapeId(shapeId: number): SolidParticle[];
  30470. /**
  30471. * Populates the passed array "ref" with the particles having the passed shapeId.
  30472. * @param shapeId the shape identifier
  30473. * @returns the SPS
  30474. * @param ref
  30475. */
  30476. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  30477. /**
  30478. * Computes the required SubMeshes according the materials assigned to the particles.
  30479. * @returns the solid particle system.
  30480. * Does nothing if called before the SPS mesh is built.
  30481. */
  30482. computeSubMeshes(): SolidParticleSystem;
  30483. /**
  30484. * Sorts the solid particles by material when MultiMaterial is enabled.
  30485. * Updates the indices32 array.
  30486. * Updates the indicesByMaterial array.
  30487. * Updates the mesh indices array.
  30488. * @returns the SPS
  30489. * @hidden
  30490. */
  30491. private _sortParticlesByMaterial;
  30492. /**
  30493. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  30494. * @hidden
  30495. */
  30496. private _setMaterialIndexesById;
  30497. /**
  30498. * Returns an array with unique values of Materials from the passed array
  30499. * @param array the material array to be checked and filtered
  30500. * @hidden
  30501. */
  30502. private _filterUniqueMaterialId;
  30503. /**
  30504. * Sets a new Standard Material as _defaultMaterial if not already set.
  30505. * @hidden
  30506. */
  30507. private _setDefaultMaterial;
  30508. /**
  30509. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  30510. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30511. * @returns the SPS.
  30512. */
  30513. refreshVisibleSize(): SolidParticleSystem;
  30514. /**
  30515. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  30516. * @param size the size (float) of the visibility box
  30517. * note : this doesn't lock the SPS mesh bounding box.
  30518. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30519. */
  30520. setVisibilityBox(size: number): void;
  30521. /**
  30522. * Gets whether the SPS as always visible or not
  30523. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30524. */
  30525. get isAlwaysVisible(): boolean;
  30526. /**
  30527. * Sets the SPS as always visible or not
  30528. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30529. */
  30530. set isAlwaysVisible(val: boolean);
  30531. /**
  30532. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30533. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30534. */
  30535. set isVisibilityBoxLocked(val: boolean);
  30536. /**
  30537. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  30538. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  30539. */
  30540. get isVisibilityBoxLocked(): boolean;
  30541. /**
  30542. * Tells to `setParticles()` to compute the particle rotations or not.
  30543. * Default value : true. The SPS is faster when it's set to false.
  30544. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30545. */
  30546. set computeParticleRotation(val: boolean);
  30547. /**
  30548. * Tells to `setParticles()` to compute the particle colors or not.
  30549. * Default value : true. The SPS is faster when it's set to false.
  30550. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30551. */
  30552. set computeParticleColor(val: boolean);
  30553. set computeParticleTexture(val: boolean);
  30554. /**
  30555. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  30556. * Default value : false. The SPS is faster when it's set to false.
  30557. * Note : the particle custom vertex positions aren't stored values.
  30558. */
  30559. set computeParticleVertex(val: boolean);
  30560. /**
  30561. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  30562. */
  30563. set computeBoundingBox(val: boolean);
  30564. /**
  30565. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  30566. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30567. * Default : `true`
  30568. */
  30569. set depthSortParticles(val: boolean);
  30570. /**
  30571. * Gets if `setParticles()` computes the particle rotations or not.
  30572. * Default value : true. The SPS is faster when it's set to false.
  30573. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  30574. */
  30575. get computeParticleRotation(): boolean;
  30576. /**
  30577. * Gets if `setParticles()` computes the particle colors or not.
  30578. * Default value : true. The SPS is faster when it's set to false.
  30579. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  30580. */
  30581. get computeParticleColor(): boolean;
  30582. /**
  30583. * Gets if `setParticles()` computes the particle textures or not.
  30584. * Default value : true. The SPS is faster when it's set to false.
  30585. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  30586. */
  30587. get computeParticleTexture(): boolean;
  30588. /**
  30589. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  30590. * Default value : false. The SPS is faster when it's set to false.
  30591. * Note : the particle custom vertex positions aren't stored values.
  30592. */
  30593. get computeParticleVertex(): boolean;
  30594. /**
  30595. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  30596. */
  30597. get computeBoundingBox(): boolean;
  30598. /**
  30599. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  30600. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  30601. * Default : `true`
  30602. */
  30603. get depthSortParticles(): boolean;
  30604. /**
  30605. * Gets if the SPS is created as expandable at construction time.
  30606. * Default : `false`
  30607. */
  30608. get expandable(): boolean;
  30609. /**
  30610. * Gets if the SPS supports the Multi Materials
  30611. */
  30612. get multimaterialEnabled(): boolean;
  30613. /**
  30614. * Gets if the SPS uses the model materials for its own multimaterial.
  30615. */
  30616. get useModelMaterial(): boolean;
  30617. /**
  30618. * The SPS used material array.
  30619. */
  30620. get materials(): Material[];
  30621. /**
  30622. * Sets the SPS MultiMaterial from the passed materials.
  30623. * Note : the passed array is internally copied and not used then by reference.
  30624. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  30625. */
  30626. setMultiMaterial(materials: Material[]): void;
  30627. /**
  30628. * The SPS computed multimaterial object
  30629. */
  30630. get multimaterial(): MultiMaterial;
  30631. set multimaterial(mm: MultiMaterial);
  30632. /**
  30633. * If the subMeshes must be updated on the next call to setParticles()
  30634. */
  30635. get autoUpdateSubMeshes(): boolean;
  30636. set autoUpdateSubMeshes(val: boolean);
  30637. /**
  30638. * This function does nothing. It may be overwritten to set all the particle first values.
  30639. * The SPS doesn't call this function, you may have to call it by your own.
  30640. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30641. */
  30642. initParticles(): void;
  30643. /**
  30644. * This function does nothing. It may be overwritten to recycle a particle.
  30645. * The SPS doesn't call this function, you may have to call it by your own.
  30646. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30647. * @param particle The particle to recycle
  30648. * @returns the recycled particle
  30649. */
  30650. recycleParticle(particle: SolidParticle): SolidParticle;
  30651. /**
  30652. * Updates a particle : this function should be overwritten by the user.
  30653. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  30654. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  30655. * @example : just set a particle position or velocity and recycle conditions
  30656. * @param particle The particle to update
  30657. * @returns the updated particle
  30658. */
  30659. updateParticle(particle: SolidParticle): SolidParticle;
  30660. /**
  30661. * Updates a vertex of a particle : it can be overwritten by the user.
  30662. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  30663. * @param particle the current particle
  30664. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  30665. * @param pt the index of the current vertex in the particle shape
  30666. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  30667. * @example : just set a vertex particle position or color
  30668. * @returns the sps
  30669. */
  30670. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  30671. /**
  30672. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  30673. * This does nothing and may be overwritten by the user.
  30674. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30675. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30676. * @param update the boolean update value actually passed to setParticles()
  30677. */
  30678. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30679. /**
  30680. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  30681. * This will be passed three parameters.
  30682. * This does nothing and may be overwritten by the user.
  30683. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30684. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  30685. * @param update the boolean update value actually passed to setParticles()
  30686. */
  30687. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  30688. }
  30689. }
  30690. declare module BABYLON {
  30691. /**
  30692. * Represents one particle of a solid particle system.
  30693. */
  30694. export class SolidParticle {
  30695. /**
  30696. * particle global index
  30697. */
  30698. idx: number;
  30699. /**
  30700. * particle identifier
  30701. */
  30702. id: number;
  30703. /**
  30704. * The color of the particle
  30705. */
  30706. color: Nullable<Color4>;
  30707. /**
  30708. * The world space position of the particle.
  30709. */
  30710. position: Vector3;
  30711. /**
  30712. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  30713. */
  30714. rotation: Vector3;
  30715. /**
  30716. * The world space rotation quaternion of the particle.
  30717. */
  30718. rotationQuaternion: Nullable<Quaternion>;
  30719. /**
  30720. * The scaling of the particle.
  30721. */
  30722. scaling: Vector3;
  30723. /**
  30724. * The uvs of the particle.
  30725. */
  30726. uvs: Vector4;
  30727. /**
  30728. * The current speed of the particle.
  30729. */
  30730. velocity: Vector3;
  30731. /**
  30732. * The pivot point in the particle local space.
  30733. */
  30734. pivot: Vector3;
  30735. /**
  30736. * Must the particle be translated from its pivot point in its local space ?
  30737. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  30738. * Default : false
  30739. */
  30740. translateFromPivot: boolean;
  30741. /**
  30742. * Is the particle active or not ?
  30743. */
  30744. alive: boolean;
  30745. /**
  30746. * Is the particle visible or not ?
  30747. */
  30748. isVisible: boolean;
  30749. /**
  30750. * Index of this particle in the global "positions" array (Internal use)
  30751. * @hidden
  30752. */
  30753. _pos: number;
  30754. /**
  30755. * @hidden Index of this particle in the global "indices" array (Internal use)
  30756. */
  30757. _ind: number;
  30758. /**
  30759. * @hidden ModelShape of this particle (Internal use)
  30760. */
  30761. _model: ModelShape;
  30762. /**
  30763. * ModelShape id of this particle
  30764. */
  30765. shapeId: number;
  30766. /**
  30767. * Index of the particle in its shape id
  30768. */
  30769. idxInShape: number;
  30770. /**
  30771. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  30772. */
  30773. _modelBoundingInfo: BoundingInfo;
  30774. /**
  30775. * @hidden Particle BoundingInfo object (Internal use)
  30776. */
  30777. _boundingInfo: BoundingInfo;
  30778. /**
  30779. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  30780. */
  30781. _sps: SolidParticleSystem;
  30782. /**
  30783. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  30784. */
  30785. _stillInvisible: boolean;
  30786. /**
  30787. * @hidden Last computed particle rotation matrix
  30788. */
  30789. _rotationMatrix: number[];
  30790. /**
  30791. * Parent particle Id, if any.
  30792. * Default null.
  30793. */
  30794. parentId: Nullable<number>;
  30795. /**
  30796. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  30797. */
  30798. materialIndex: Nullable<number>;
  30799. /**
  30800. * Custom object or properties.
  30801. */
  30802. props: Nullable<any>;
  30803. /**
  30804. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  30805. * The possible values are :
  30806. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  30807. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30808. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  30809. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  30810. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  30811. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  30812. * */
  30813. cullingStrategy: number;
  30814. /**
  30815. * @hidden Internal global position in the SPS.
  30816. */
  30817. _globalPosition: Vector3;
  30818. /**
  30819. * Creates a Solid Particle object.
  30820. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  30821. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  30822. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  30823. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  30824. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  30825. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  30826. * @param shapeId (integer) is the model shape identifier in the SPS.
  30827. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  30828. * @param sps defines the sps it is associated to
  30829. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  30830. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  30831. */
  30832. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  30833. /**
  30834. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  30835. * @param target the particle target
  30836. * @returns the current particle
  30837. */
  30838. copyToRef(target: SolidParticle): SolidParticle;
  30839. /**
  30840. * Legacy support, changed scale to scaling
  30841. */
  30842. get scale(): Vector3;
  30843. /**
  30844. * Legacy support, changed scale to scaling
  30845. */
  30846. set scale(scale: Vector3);
  30847. /**
  30848. * Legacy support, changed quaternion to rotationQuaternion
  30849. */
  30850. get quaternion(): Nullable<Quaternion>;
  30851. /**
  30852. * Legacy support, changed quaternion to rotationQuaternion
  30853. */
  30854. set quaternion(q: Nullable<Quaternion>);
  30855. /**
  30856. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  30857. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  30858. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  30859. * @returns true if it intersects
  30860. */
  30861. intersectsMesh(target: Mesh | SolidParticle): boolean;
  30862. /**
  30863. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  30864. * A particle is in the frustum if its bounding box intersects the frustum
  30865. * @param frustumPlanes defines the frustum to test
  30866. * @returns true if the particle is in the frustum planes
  30867. */
  30868. isInFrustum(frustumPlanes: Plane[]): boolean;
  30869. /**
  30870. * get the rotation matrix of the particle
  30871. * @hidden
  30872. */
  30873. getRotationMatrix(m: Matrix): void;
  30874. }
  30875. /**
  30876. * Represents the shape of the model used by one particle of a solid particle system.
  30877. * SPS internal tool, don't use it manually.
  30878. */
  30879. export class ModelShape {
  30880. /**
  30881. * The shape id
  30882. * @hidden
  30883. */
  30884. shapeID: number;
  30885. /**
  30886. * flat array of model positions (internal use)
  30887. * @hidden
  30888. */
  30889. _shape: Vector3[];
  30890. /**
  30891. * flat array of model UVs (internal use)
  30892. * @hidden
  30893. */
  30894. _shapeUV: number[];
  30895. /**
  30896. * color array of the model
  30897. * @hidden
  30898. */
  30899. _shapeColors: number[];
  30900. /**
  30901. * indices array of the model
  30902. * @hidden
  30903. */
  30904. _indices: number[];
  30905. /**
  30906. * normals array of the model
  30907. * @hidden
  30908. */
  30909. _normals: number[];
  30910. /**
  30911. * length of the shape in the model indices array (internal use)
  30912. * @hidden
  30913. */
  30914. _indicesLength: number;
  30915. /**
  30916. * Custom position function (internal use)
  30917. * @hidden
  30918. */
  30919. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  30920. /**
  30921. * Custom vertex function (internal use)
  30922. * @hidden
  30923. */
  30924. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  30925. /**
  30926. * Model material (internal use)
  30927. * @hidden
  30928. */
  30929. _material: Nullable<Material>;
  30930. /**
  30931. * 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.
  30932. * SPS internal tool, don't use it manually.
  30933. * @hidden
  30934. */
  30935. 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>);
  30936. }
  30937. /**
  30938. * Represents a Depth Sorted Particle in the solid particle system.
  30939. * @hidden
  30940. */
  30941. export class DepthSortedParticle {
  30942. /**
  30943. * Particle index
  30944. */
  30945. idx: number;
  30946. /**
  30947. * Index of the particle in the "indices" array
  30948. */
  30949. ind: number;
  30950. /**
  30951. * Length of the particle shape in the "indices" array
  30952. */
  30953. indicesLength: number;
  30954. /**
  30955. * Squared distance from the particle to the camera
  30956. */
  30957. sqDistance: number;
  30958. /**
  30959. * Material index when used with MultiMaterials
  30960. */
  30961. materialIndex: number;
  30962. /**
  30963. * Creates a new sorted particle
  30964. * @param materialIndex
  30965. */
  30966. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  30967. }
  30968. /**
  30969. * Represents a solid particle vertex
  30970. */
  30971. export class SolidParticleVertex {
  30972. /**
  30973. * Vertex position
  30974. */
  30975. position: Vector3;
  30976. /**
  30977. * Vertex color
  30978. */
  30979. color: Color4;
  30980. /**
  30981. * Vertex UV
  30982. */
  30983. uv: Vector2;
  30984. /**
  30985. * Creates a new solid particle vertex
  30986. */
  30987. constructor();
  30988. /** Vertex x coordinate */
  30989. get x(): number;
  30990. set x(val: number);
  30991. /** Vertex y coordinate */
  30992. get y(): number;
  30993. set y(val: number);
  30994. /** Vertex z coordinate */
  30995. get z(): number;
  30996. set z(val: number);
  30997. }
  30998. }
  30999. declare module BABYLON {
  31000. /**
  31001. * @hidden
  31002. */
  31003. export class _MeshCollisionData {
  31004. _checkCollisions: boolean;
  31005. _collisionMask: number;
  31006. _collisionGroup: number;
  31007. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31008. _collider: Nullable<Collider>;
  31009. _oldPositionForCollisions: Vector3;
  31010. _diffPositionForCollisions: Vector3;
  31011. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31012. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31013. }
  31014. }
  31015. declare module BABYLON {
  31016. /** @hidden */
  31017. class _FacetDataStorage {
  31018. facetPositions: Vector3[];
  31019. facetNormals: Vector3[];
  31020. facetPartitioning: number[][];
  31021. facetNb: number;
  31022. partitioningSubdivisions: number;
  31023. partitioningBBoxRatio: number;
  31024. facetDataEnabled: boolean;
  31025. facetParameters: any;
  31026. bbSize: Vector3;
  31027. subDiv: {
  31028. max: number;
  31029. X: number;
  31030. Y: number;
  31031. Z: number;
  31032. };
  31033. facetDepthSort: boolean;
  31034. facetDepthSortEnabled: boolean;
  31035. depthSortedIndices: IndicesArray;
  31036. depthSortedFacets: {
  31037. ind: number;
  31038. sqDistance: number;
  31039. }[];
  31040. facetDepthSortFunction: (f1: {
  31041. ind: number;
  31042. sqDistance: number;
  31043. }, f2: {
  31044. ind: number;
  31045. sqDistance: number;
  31046. }) => number;
  31047. facetDepthSortFrom: Vector3;
  31048. facetDepthSortOrigin: Vector3;
  31049. invertedMatrix: Matrix;
  31050. }
  31051. /**
  31052. * @hidden
  31053. **/
  31054. class _InternalAbstractMeshDataInfo {
  31055. _hasVertexAlpha: boolean;
  31056. _useVertexColors: boolean;
  31057. _numBoneInfluencers: number;
  31058. _applyFog: boolean;
  31059. _receiveShadows: boolean;
  31060. _facetData: _FacetDataStorage;
  31061. _visibility: number;
  31062. _skeleton: Nullable<Skeleton>;
  31063. _layerMask: number;
  31064. _computeBonesUsingShaders: boolean;
  31065. _isActive: boolean;
  31066. _onlyForInstances: boolean;
  31067. _isActiveIntermediate: boolean;
  31068. _onlyForInstancesIntermediate: boolean;
  31069. _actAsRegularMesh: boolean;
  31070. }
  31071. /**
  31072. * Class used to store all common mesh properties
  31073. */
  31074. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31075. /** No occlusion */
  31076. static OCCLUSION_TYPE_NONE: number;
  31077. /** Occlusion set to optimisitic */
  31078. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31079. /** Occlusion set to strict */
  31080. static OCCLUSION_TYPE_STRICT: number;
  31081. /** Use an accurante occlusion algorithm */
  31082. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31083. /** Use a conservative occlusion algorithm */
  31084. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31085. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31086. * Test order :
  31087. * Is the bounding sphere outside the frustum ?
  31088. * If not, are the bounding box vertices outside the frustum ?
  31089. * It not, then the cullable object is in the frustum.
  31090. */
  31091. static readonly CULLINGSTRATEGY_STANDARD: number;
  31092. /** Culling strategy : Bounding Sphere Only.
  31093. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31094. * It's also less accurate than the standard because some not visible objects can still be selected.
  31095. * Test : is the bounding sphere outside the frustum ?
  31096. * If not, then the cullable object is in the frustum.
  31097. */
  31098. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31099. /** Culling strategy : Optimistic Inclusion.
  31100. * This in an inclusion test first, then the standard exclusion test.
  31101. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31102. * 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.
  31103. * Anyway, it's as accurate as the standard strategy.
  31104. * Test :
  31105. * Is the cullable object bounding sphere center in the frustum ?
  31106. * If not, apply the default culling strategy.
  31107. */
  31108. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31109. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31110. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31111. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31112. * 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.
  31113. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31114. * Test :
  31115. * Is the cullable object bounding sphere center in the frustum ?
  31116. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31117. */
  31118. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31119. /**
  31120. * No billboard
  31121. */
  31122. static get BILLBOARDMODE_NONE(): number;
  31123. /** Billboard on X axis */
  31124. static get BILLBOARDMODE_X(): number;
  31125. /** Billboard on Y axis */
  31126. static get BILLBOARDMODE_Y(): number;
  31127. /** Billboard on Z axis */
  31128. static get BILLBOARDMODE_Z(): number;
  31129. /** Billboard on all axes */
  31130. static get BILLBOARDMODE_ALL(): number;
  31131. /** Billboard on using position instead of orientation */
  31132. static get BILLBOARDMODE_USE_POSITION(): number;
  31133. /** @hidden */
  31134. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31135. /**
  31136. * The culling strategy to use to check whether the mesh must be rendered or not.
  31137. * This value can be changed at any time and will be used on the next render mesh selection.
  31138. * The possible values are :
  31139. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31140. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31141. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31142. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31143. * Please read each static variable documentation to get details about the culling process.
  31144. * */
  31145. cullingStrategy: number;
  31146. /**
  31147. * Gets the number of facets in the mesh
  31148. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31149. */
  31150. get facetNb(): number;
  31151. /**
  31152. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31153. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31154. */
  31155. get partitioningSubdivisions(): number;
  31156. set partitioningSubdivisions(nb: number);
  31157. /**
  31158. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31159. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31160. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31161. */
  31162. get partitioningBBoxRatio(): number;
  31163. set partitioningBBoxRatio(ratio: number);
  31164. /**
  31165. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31166. * Works only for updatable meshes.
  31167. * Doesn't work with multi-materials
  31168. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31169. */
  31170. get mustDepthSortFacets(): boolean;
  31171. set mustDepthSortFacets(sort: boolean);
  31172. /**
  31173. * The location (Vector3) where the facet depth sort must be computed from.
  31174. * By default, the active camera position.
  31175. * Used only when facet depth sort is enabled
  31176. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31177. */
  31178. get facetDepthSortFrom(): Vector3;
  31179. set facetDepthSortFrom(location: Vector3);
  31180. /**
  31181. * gets a boolean indicating if facetData is enabled
  31182. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31183. */
  31184. get isFacetDataEnabled(): boolean;
  31185. /** @hidden */
  31186. _updateNonUniformScalingState(value: boolean): boolean;
  31187. /**
  31188. * An event triggered when this mesh collides with another one
  31189. */
  31190. onCollideObservable: Observable<AbstractMesh>;
  31191. /** Set a function to call when this mesh collides with another one */
  31192. set onCollide(callback: () => void);
  31193. /**
  31194. * An event triggered when the collision's position changes
  31195. */
  31196. onCollisionPositionChangeObservable: Observable<Vector3>;
  31197. /** Set a function to call when the collision's position changes */
  31198. set onCollisionPositionChange(callback: () => void);
  31199. /**
  31200. * An event triggered when material is changed
  31201. */
  31202. onMaterialChangedObservable: Observable<AbstractMesh>;
  31203. /**
  31204. * Gets or sets the orientation for POV movement & rotation
  31205. */
  31206. definedFacingForward: boolean;
  31207. /** @hidden */
  31208. _occlusionQuery: Nullable<WebGLQuery>;
  31209. /** @hidden */
  31210. _renderingGroup: Nullable<RenderingGroup>;
  31211. /**
  31212. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31213. */
  31214. get visibility(): number;
  31215. /**
  31216. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31217. */
  31218. set visibility(value: number);
  31219. /** Gets or sets the alpha index used to sort transparent meshes
  31220. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31221. */
  31222. alphaIndex: number;
  31223. /**
  31224. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31225. */
  31226. isVisible: boolean;
  31227. /**
  31228. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31229. */
  31230. isPickable: boolean;
  31231. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31232. showSubMeshesBoundingBox: boolean;
  31233. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31234. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31235. */
  31236. isBlocker: boolean;
  31237. /**
  31238. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31239. */
  31240. enablePointerMoveEvents: boolean;
  31241. /**
  31242. * Specifies the rendering group id for this mesh (0 by default)
  31243. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31244. */
  31245. renderingGroupId: number;
  31246. private _material;
  31247. /** Gets or sets current material */
  31248. get material(): Nullable<Material>;
  31249. set material(value: Nullable<Material>);
  31250. /**
  31251. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31252. * @see https://doc.babylonjs.com/babylon101/shadows
  31253. */
  31254. get receiveShadows(): boolean;
  31255. set receiveShadows(value: boolean);
  31256. /** Defines color to use when rendering outline */
  31257. outlineColor: Color3;
  31258. /** Define width to use when rendering outline */
  31259. outlineWidth: number;
  31260. /** Defines color to use when rendering overlay */
  31261. overlayColor: Color3;
  31262. /** Defines alpha to use when rendering overlay */
  31263. overlayAlpha: number;
  31264. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31265. get hasVertexAlpha(): boolean;
  31266. set hasVertexAlpha(value: boolean);
  31267. /** 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) */
  31268. get useVertexColors(): boolean;
  31269. set useVertexColors(value: boolean);
  31270. /**
  31271. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31272. */
  31273. get computeBonesUsingShaders(): boolean;
  31274. set computeBonesUsingShaders(value: boolean);
  31275. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31276. get numBoneInfluencers(): number;
  31277. set numBoneInfluencers(value: number);
  31278. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31279. get applyFog(): boolean;
  31280. set applyFog(value: boolean);
  31281. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31282. useOctreeForRenderingSelection: boolean;
  31283. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31284. useOctreeForPicking: boolean;
  31285. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31286. useOctreeForCollisions: boolean;
  31287. /**
  31288. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31289. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31290. */
  31291. get layerMask(): number;
  31292. set layerMask(value: number);
  31293. /**
  31294. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  31295. */
  31296. alwaysSelectAsActiveMesh: boolean;
  31297. /**
  31298. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  31299. */
  31300. doNotSyncBoundingInfo: boolean;
  31301. /**
  31302. * Gets or sets the current action manager
  31303. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31304. */
  31305. actionManager: Nullable<AbstractActionManager>;
  31306. private _meshCollisionData;
  31307. /**
  31308. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  31309. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31310. */
  31311. ellipsoid: Vector3;
  31312. /**
  31313. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  31314. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31315. */
  31316. ellipsoidOffset: Vector3;
  31317. /**
  31318. * Gets or sets a collision mask used to mask collisions (default is -1).
  31319. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31320. */
  31321. get collisionMask(): number;
  31322. set collisionMask(mask: number);
  31323. /**
  31324. * Gets or sets the current collision group mask (-1 by default).
  31325. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  31326. */
  31327. get collisionGroup(): number;
  31328. set collisionGroup(mask: number);
  31329. /**
  31330. * Gets or sets current surrounding meshes (null by default).
  31331. *
  31332. * By default collision detection is tested against every mesh in the scene.
  31333. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  31334. * meshes will be tested for the collision.
  31335. *
  31336. * Note: if set to an empty array no collision will happen when this mesh is moved.
  31337. */
  31338. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  31339. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  31340. /**
  31341. * Defines edge width used when edgesRenderer is enabled
  31342. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31343. */
  31344. edgesWidth: number;
  31345. /**
  31346. * Defines edge color used when edgesRenderer is enabled
  31347. * @see https://www.babylonjs-playground.com/#10OJSG#13
  31348. */
  31349. edgesColor: Color4;
  31350. /** @hidden */
  31351. _edgesRenderer: Nullable<IEdgesRenderer>;
  31352. /** @hidden */
  31353. _masterMesh: Nullable<AbstractMesh>;
  31354. /** @hidden */
  31355. _boundingInfo: Nullable<BoundingInfo>;
  31356. /** @hidden */
  31357. _renderId: number;
  31358. /**
  31359. * Gets or sets the list of subMeshes
  31360. * @see https://doc.babylonjs.com/how_to/multi_materials
  31361. */
  31362. subMeshes: SubMesh[];
  31363. /** @hidden */
  31364. _intersectionsInProgress: AbstractMesh[];
  31365. /** @hidden */
  31366. _unIndexed: boolean;
  31367. /** @hidden */
  31368. _lightSources: Light[];
  31369. /** Gets the list of lights affecting that mesh */
  31370. get lightSources(): Light[];
  31371. /** @hidden */
  31372. get _positions(): Nullable<Vector3[]>;
  31373. /** @hidden */
  31374. _waitingData: {
  31375. lods: Nullable<any>;
  31376. actions: Nullable<any>;
  31377. freezeWorldMatrix: Nullable<boolean>;
  31378. };
  31379. /** @hidden */
  31380. _bonesTransformMatrices: Nullable<Float32Array>;
  31381. /** @hidden */
  31382. _transformMatrixTexture: Nullable<RawTexture>;
  31383. /**
  31384. * Gets or sets a skeleton to apply skining transformations
  31385. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  31386. */
  31387. set skeleton(value: Nullable<Skeleton>);
  31388. get skeleton(): Nullable<Skeleton>;
  31389. /**
  31390. * An event triggered when the mesh is rebuilt.
  31391. */
  31392. onRebuildObservable: Observable<AbstractMesh>;
  31393. /**
  31394. * Creates a new AbstractMesh
  31395. * @param name defines the name of the mesh
  31396. * @param scene defines the hosting scene
  31397. */
  31398. constructor(name: string, scene?: Nullable<Scene>);
  31399. /**
  31400. * Returns the string "AbstractMesh"
  31401. * @returns "AbstractMesh"
  31402. */
  31403. getClassName(): string;
  31404. /**
  31405. * Gets a string representation of the current mesh
  31406. * @param fullDetails defines a boolean indicating if full details must be included
  31407. * @returns a string representation of the current mesh
  31408. */
  31409. toString(fullDetails?: boolean): string;
  31410. /**
  31411. * @hidden
  31412. */
  31413. protected _getEffectiveParent(): Nullable<Node>;
  31414. /** @hidden */
  31415. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  31416. /** @hidden */
  31417. _rebuild(): void;
  31418. /** @hidden */
  31419. _resyncLightSources(): void;
  31420. /** @hidden */
  31421. _resyncLightSource(light: Light): void;
  31422. /** @hidden */
  31423. _unBindEffect(): void;
  31424. /** @hidden */
  31425. _removeLightSource(light: Light, dispose: boolean): void;
  31426. private _markSubMeshesAsDirty;
  31427. /** @hidden */
  31428. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  31429. /** @hidden */
  31430. _markSubMeshesAsAttributesDirty(): void;
  31431. /** @hidden */
  31432. _markSubMeshesAsMiscDirty(): void;
  31433. /**
  31434. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  31435. */
  31436. get scaling(): Vector3;
  31437. set scaling(newScaling: Vector3);
  31438. /**
  31439. * Returns true if the mesh is blocked. Implemented by child classes
  31440. */
  31441. get isBlocked(): boolean;
  31442. /**
  31443. * Returns the mesh itself by default. Implemented by child classes
  31444. * @param camera defines the camera to use to pick the right LOD level
  31445. * @returns the currentAbstractMesh
  31446. */
  31447. getLOD(camera: Camera): Nullable<AbstractMesh>;
  31448. /**
  31449. * Returns 0 by default. Implemented by child classes
  31450. * @returns an integer
  31451. */
  31452. getTotalVertices(): number;
  31453. /**
  31454. * Returns a positive integer : the total number of indices in this mesh geometry.
  31455. * @returns the numner of indices or zero if the mesh has no geometry.
  31456. */
  31457. getTotalIndices(): number;
  31458. /**
  31459. * Returns null by default. Implemented by child classes
  31460. * @returns null
  31461. */
  31462. getIndices(): Nullable<IndicesArray>;
  31463. /**
  31464. * Returns the array of the requested vertex data kind. Implemented by child classes
  31465. * @param kind defines the vertex data kind to use
  31466. * @returns null
  31467. */
  31468. getVerticesData(kind: string): Nullable<FloatArray>;
  31469. /**
  31470. * Sets the vertex data of the mesh geometry for the requested `kind`.
  31471. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  31472. * Note that a new underlying VertexBuffer object is created each call.
  31473. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  31474. * @param kind defines vertex data kind:
  31475. * * VertexBuffer.PositionKind
  31476. * * VertexBuffer.UVKind
  31477. * * VertexBuffer.UV2Kind
  31478. * * VertexBuffer.UV3Kind
  31479. * * VertexBuffer.UV4Kind
  31480. * * VertexBuffer.UV5Kind
  31481. * * VertexBuffer.UV6Kind
  31482. * * VertexBuffer.ColorKind
  31483. * * VertexBuffer.MatricesIndicesKind
  31484. * * VertexBuffer.MatricesIndicesExtraKind
  31485. * * VertexBuffer.MatricesWeightsKind
  31486. * * VertexBuffer.MatricesWeightsExtraKind
  31487. * @param data defines the data source
  31488. * @param updatable defines if the data must be flagged as updatable (or static)
  31489. * @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
  31490. * @returns the current mesh
  31491. */
  31492. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  31493. /**
  31494. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  31495. * If the mesh has no geometry, it is simply returned as it is.
  31496. * @param kind defines vertex data kind:
  31497. * * VertexBuffer.PositionKind
  31498. * * VertexBuffer.UVKind
  31499. * * VertexBuffer.UV2Kind
  31500. * * VertexBuffer.UV3Kind
  31501. * * VertexBuffer.UV4Kind
  31502. * * VertexBuffer.UV5Kind
  31503. * * VertexBuffer.UV6Kind
  31504. * * VertexBuffer.ColorKind
  31505. * * VertexBuffer.MatricesIndicesKind
  31506. * * VertexBuffer.MatricesIndicesExtraKind
  31507. * * VertexBuffer.MatricesWeightsKind
  31508. * * VertexBuffer.MatricesWeightsExtraKind
  31509. * @param data defines the data source
  31510. * @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
  31511. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  31512. * @returns the current mesh
  31513. */
  31514. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  31515. /**
  31516. * Sets the mesh indices,
  31517. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  31518. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  31519. * @param totalVertices Defines the total number of vertices
  31520. * @returns the current mesh
  31521. */
  31522. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  31523. /**
  31524. * Gets a boolean indicating if specific vertex data is present
  31525. * @param kind defines the vertex data kind to use
  31526. * @returns true is data kind is present
  31527. */
  31528. isVerticesDataPresent(kind: string): boolean;
  31529. /**
  31530. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  31531. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  31532. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  31533. * @returns a BoundingInfo
  31534. */
  31535. getBoundingInfo(): BoundingInfo;
  31536. /**
  31537. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  31538. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  31539. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  31540. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  31541. * @returns the current mesh
  31542. */
  31543. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  31544. /**
  31545. * Overwrite the current bounding info
  31546. * @param boundingInfo defines the new bounding info
  31547. * @returns the current mesh
  31548. */
  31549. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  31550. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  31551. get useBones(): boolean;
  31552. /** @hidden */
  31553. _preActivate(): void;
  31554. /** @hidden */
  31555. _preActivateForIntermediateRendering(renderId: number): void;
  31556. /** @hidden */
  31557. _activate(renderId: number, intermediateRendering: boolean): boolean;
  31558. /** @hidden */
  31559. _postActivate(): void;
  31560. /** @hidden */
  31561. _freeze(): void;
  31562. /** @hidden */
  31563. _unFreeze(): void;
  31564. /**
  31565. * Gets the current world matrix
  31566. * @returns a Matrix
  31567. */
  31568. getWorldMatrix(): Matrix;
  31569. /** @hidden */
  31570. _getWorldMatrixDeterminant(): number;
  31571. /**
  31572. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  31573. */
  31574. get isAnInstance(): boolean;
  31575. /**
  31576. * Gets a boolean indicating if this mesh has instances
  31577. */
  31578. get hasInstances(): boolean;
  31579. /**
  31580. * Gets a boolean indicating if this mesh has thin instances
  31581. */
  31582. get hasThinInstances(): boolean;
  31583. /**
  31584. * Perform relative position change from the point of view of behind the front of the mesh.
  31585. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31586. * Supports definition of mesh facing forward or backward
  31587. * @param amountRight defines the distance on the right axis
  31588. * @param amountUp defines the distance on the up axis
  31589. * @param amountForward defines the distance on the forward axis
  31590. * @returns the current mesh
  31591. */
  31592. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  31593. /**
  31594. * Calculate relative position change from the point of view of behind the front of the mesh.
  31595. * This is performed taking into account the meshes current rotation, so you do not have to care.
  31596. * Supports definition of mesh facing forward or backward
  31597. * @param amountRight defines the distance on the right axis
  31598. * @param amountUp defines the distance on the up axis
  31599. * @param amountForward defines the distance on the forward axis
  31600. * @returns the new displacement vector
  31601. */
  31602. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  31603. /**
  31604. * Perform relative rotation change from the point of view of behind the front of the mesh.
  31605. * Supports definition of mesh facing forward or backward
  31606. * @param flipBack defines the flip
  31607. * @param twirlClockwise defines the twirl
  31608. * @param tiltRight defines the tilt
  31609. * @returns the current mesh
  31610. */
  31611. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  31612. /**
  31613. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  31614. * Supports definition of mesh facing forward or backward.
  31615. * @param flipBack defines the flip
  31616. * @param twirlClockwise defines the twirl
  31617. * @param tiltRight defines the tilt
  31618. * @returns the new rotation vector
  31619. */
  31620. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  31621. /**
  31622. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  31623. * This means the mesh underlying bounding box and sphere are recomputed.
  31624. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  31625. * @returns the current mesh
  31626. */
  31627. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  31628. /** @hidden */
  31629. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  31630. /** @hidden */
  31631. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  31632. /** @hidden */
  31633. _updateBoundingInfo(): AbstractMesh;
  31634. /** @hidden */
  31635. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  31636. /** @hidden */
  31637. protected _afterComputeWorldMatrix(): void;
  31638. /** @hidden */
  31639. get _effectiveMesh(): AbstractMesh;
  31640. /**
  31641. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  31642. * A mesh is in the frustum if its bounding box intersects the frustum
  31643. * @param frustumPlanes defines the frustum to test
  31644. * @returns true if the mesh is in the frustum planes
  31645. */
  31646. isInFrustum(frustumPlanes: Plane[]): boolean;
  31647. /**
  31648. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  31649. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  31650. * @param frustumPlanes defines the frustum to test
  31651. * @returns true if the mesh is completely in the frustum planes
  31652. */
  31653. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31654. /**
  31655. * True if the mesh intersects another mesh or a SolidParticle object
  31656. * @param mesh defines a target mesh or SolidParticle to test
  31657. * @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)
  31658. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  31659. * @returns true if there is an intersection
  31660. */
  31661. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  31662. /**
  31663. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  31664. * @param point defines the point to test
  31665. * @returns true if there is an intersection
  31666. */
  31667. intersectsPoint(point: Vector3): boolean;
  31668. /**
  31669. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  31670. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31671. */
  31672. get checkCollisions(): boolean;
  31673. set checkCollisions(collisionEnabled: boolean);
  31674. /**
  31675. * Gets Collider object used to compute collisions (not physics)
  31676. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31677. */
  31678. get collider(): Nullable<Collider>;
  31679. /**
  31680. * Move the mesh using collision engine
  31681. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31682. * @param displacement defines the requested displacement vector
  31683. * @returns the current mesh
  31684. */
  31685. moveWithCollisions(displacement: Vector3): AbstractMesh;
  31686. private _onCollisionPositionChange;
  31687. /** @hidden */
  31688. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  31689. /** @hidden */
  31690. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  31691. /** @hidden */
  31692. _checkCollision(collider: Collider): AbstractMesh;
  31693. /** @hidden */
  31694. _generatePointsArray(): boolean;
  31695. /**
  31696. * Checks if the passed Ray intersects with the mesh
  31697. * @param ray defines the ray to use
  31698. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  31699. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31700. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  31701. * @returns the picking info
  31702. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  31703. */
  31704. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  31705. /**
  31706. * Clones the current mesh
  31707. * @param name defines the mesh name
  31708. * @param newParent defines the new mesh parent
  31709. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  31710. * @returns the new mesh
  31711. */
  31712. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  31713. /**
  31714. * Disposes all the submeshes of the current meshnp
  31715. * @returns the current mesh
  31716. */
  31717. releaseSubMeshes(): AbstractMesh;
  31718. /**
  31719. * Releases resources associated with this abstract mesh.
  31720. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31721. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31722. */
  31723. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31724. /**
  31725. * Adds the passed mesh as a child to the current mesh
  31726. * @param mesh defines the child mesh
  31727. * @returns the current mesh
  31728. */
  31729. addChild(mesh: AbstractMesh): AbstractMesh;
  31730. /**
  31731. * Removes the passed mesh from the current mesh children list
  31732. * @param mesh defines the child mesh
  31733. * @returns the current mesh
  31734. */
  31735. removeChild(mesh: AbstractMesh): AbstractMesh;
  31736. /** @hidden */
  31737. private _initFacetData;
  31738. /**
  31739. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  31740. * This method can be called within the render loop.
  31741. * 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
  31742. * @returns the current mesh
  31743. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31744. */
  31745. updateFacetData(): AbstractMesh;
  31746. /**
  31747. * Returns the facetLocalNormals array.
  31748. * The normals are expressed in the mesh local spac
  31749. * @returns an array of Vector3
  31750. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31751. */
  31752. getFacetLocalNormals(): Vector3[];
  31753. /**
  31754. * Returns the facetLocalPositions array.
  31755. * The facet positions are expressed in the mesh local space
  31756. * @returns an array of Vector3
  31757. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31758. */
  31759. getFacetLocalPositions(): Vector3[];
  31760. /**
  31761. * Returns the facetLocalPartioning array
  31762. * @returns an array of array of numbers
  31763. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31764. */
  31765. getFacetLocalPartitioning(): number[][];
  31766. /**
  31767. * Returns the i-th facet position in the world system.
  31768. * This method allocates a new Vector3 per call
  31769. * @param i defines the facet index
  31770. * @returns a new Vector3
  31771. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31772. */
  31773. getFacetPosition(i: number): Vector3;
  31774. /**
  31775. * Sets the reference Vector3 with the i-th facet position in the world system
  31776. * @param i defines the facet index
  31777. * @param ref defines the target vector
  31778. * @returns the current mesh
  31779. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31780. */
  31781. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  31782. /**
  31783. * Returns the i-th facet normal in the world system.
  31784. * This method allocates a new Vector3 per call
  31785. * @param i defines the facet index
  31786. * @returns a new Vector3
  31787. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31788. */
  31789. getFacetNormal(i: number): Vector3;
  31790. /**
  31791. * Sets the reference Vector3 with the i-th facet normal in the world system
  31792. * @param i defines the facet index
  31793. * @param ref defines the target vector
  31794. * @returns the current mesh
  31795. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31796. */
  31797. getFacetNormalToRef(i: number, ref: Vector3): this;
  31798. /**
  31799. * 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)
  31800. * @param x defines x coordinate
  31801. * @param y defines y coordinate
  31802. * @param z defines z coordinate
  31803. * @returns the array of facet indexes
  31804. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31805. */
  31806. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  31807. /**
  31808. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  31809. * @param projected sets as the (x,y,z) world projection on the facet
  31810. * @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
  31811. * @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
  31812. * @param x defines x coordinate
  31813. * @param y defines y coordinate
  31814. * @param z defines z coordinate
  31815. * @returns the face index if found (or null instead)
  31816. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31817. */
  31818. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31819. /**
  31820. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  31821. * @param projected sets as the (x,y,z) local projection on the facet
  31822. * @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
  31823. * @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
  31824. * @param x defines x coordinate
  31825. * @param y defines y coordinate
  31826. * @param z defines z coordinate
  31827. * @returns the face index if found (or null instead)
  31828. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31829. */
  31830. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  31831. /**
  31832. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  31833. * @returns the parameters
  31834. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31835. */
  31836. getFacetDataParameters(): any;
  31837. /**
  31838. * Disables the feature FacetData and frees the related memory
  31839. * @returns the current mesh
  31840. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  31841. */
  31842. disableFacetData(): AbstractMesh;
  31843. /**
  31844. * Updates the AbstractMesh indices array
  31845. * @param indices defines the data source
  31846. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  31847. * @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)
  31848. * @returns the current mesh
  31849. */
  31850. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  31851. /**
  31852. * Creates new normals data for the mesh
  31853. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  31854. * @returns the current mesh
  31855. */
  31856. createNormals(updatable: boolean): AbstractMesh;
  31857. /**
  31858. * Align the mesh with a normal
  31859. * @param normal defines the normal to use
  31860. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  31861. * @returns the current mesh
  31862. */
  31863. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  31864. /** @hidden */
  31865. _checkOcclusionQuery(): boolean;
  31866. /**
  31867. * Disables the mesh edge rendering mode
  31868. * @returns the currentAbstractMesh
  31869. */
  31870. disableEdgesRendering(): AbstractMesh;
  31871. /**
  31872. * Enables the edge rendering mode on the mesh.
  31873. * This mode makes the mesh edges visible
  31874. * @param epsilon defines the maximal distance between two angles to detect a face
  31875. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  31876. * @returns the currentAbstractMesh
  31877. * @see https://www.babylonjs-playground.com/#19O9TU#0
  31878. */
  31879. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  31880. /**
  31881. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  31882. * @returns an array of particle systems in the scene that use the mesh as an emitter
  31883. */
  31884. getConnectedParticleSystems(): IParticleSystem[];
  31885. }
  31886. }
  31887. declare module BABYLON {
  31888. /**
  31889. * Interface used to define ActionEvent
  31890. */
  31891. export interface IActionEvent {
  31892. /** The mesh or sprite that triggered the action */
  31893. source: any;
  31894. /** The X mouse cursor position at the time of the event */
  31895. pointerX: number;
  31896. /** The Y mouse cursor position at the time of the event */
  31897. pointerY: number;
  31898. /** The mesh that is currently pointed at (can be null) */
  31899. meshUnderPointer: Nullable<AbstractMesh>;
  31900. /** the original (browser) event that triggered the ActionEvent */
  31901. sourceEvent?: any;
  31902. /** additional data for the event */
  31903. additionalData?: any;
  31904. }
  31905. /**
  31906. * ActionEvent is the event being sent when an action is triggered.
  31907. */
  31908. export class ActionEvent implements IActionEvent {
  31909. /** The mesh or sprite that triggered the action */
  31910. source: any;
  31911. /** The X mouse cursor position at the time of the event */
  31912. pointerX: number;
  31913. /** The Y mouse cursor position at the time of the event */
  31914. pointerY: number;
  31915. /** The mesh that is currently pointed at (can be null) */
  31916. meshUnderPointer: Nullable<AbstractMesh>;
  31917. /** the original (browser) event that triggered the ActionEvent */
  31918. sourceEvent?: any;
  31919. /** additional data for the event */
  31920. additionalData?: any;
  31921. /**
  31922. * Creates a new ActionEvent
  31923. * @param source The mesh or sprite that triggered the action
  31924. * @param pointerX The X mouse cursor position at the time of the event
  31925. * @param pointerY The Y mouse cursor position at the time of the event
  31926. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  31927. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  31928. * @param additionalData additional data for the event
  31929. */
  31930. constructor(
  31931. /** The mesh or sprite that triggered the action */
  31932. source: any,
  31933. /** The X mouse cursor position at the time of the event */
  31934. pointerX: number,
  31935. /** The Y mouse cursor position at the time of the event */
  31936. pointerY: number,
  31937. /** The mesh that is currently pointed at (can be null) */
  31938. meshUnderPointer: Nullable<AbstractMesh>,
  31939. /** the original (browser) event that triggered the ActionEvent */
  31940. sourceEvent?: any,
  31941. /** additional data for the event */
  31942. additionalData?: any);
  31943. /**
  31944. * Helper function to auto-create an ActionEvent from a source mesh.
  31945. * @param source The source mesh that triggered the event
  31946. * @param evt The original (browser) event
  31947. * @param additionalData additional data for the event
  31948. * @returns the new ActionEvent
  31949. */
  31950. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  31951. /**
  31952. * Helper function to auto-create an ActionEvent from a source sprite
  31953. * @param source The source sprite that triggered the event
  31954. * @param scene Scene associated with the sprite
  31955. * @param evt The original (browser) event
  31956. * @param additionalData additional data for the event
  31957. * @returns the new ActionEvent
  31958. */
  31959. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  31960. /**
  31961. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  31962. * @param scene the scene where the event occurred
  31963. * @param evt The original (browser) event
  31964. * @returns the new ActionEvent
  31965. */
  31966. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  31967. /**
  31968. * Helper function to auto-create an ActionEvent from a primitive
  31969. * @param prim defines the target primitive
  31970. * @param pointerPos defines the pointer position
  31971. * @param evt The original (browser) event
  31972. * @param additionalData additional data for the event
  31973. * @returns the new ActionEvent
  31974. */
  31975. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  31976. }
  31977. }
  31978. declare module BABYLON {
  31979. /**
  31980. * Abstract class used to decouple action Manager from scene and meshes.
  31981. * Do not instantiate.
  31982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  31983. */
  31984. export abstract class AbstractActionManager implements IDisposable {
  31985. /** Gets the list of active triggers */
  31986. static Triggers: {
  31987. [key: string]: number;
  31988. };
  31989. /** Gets the cursor to use when hovering items */
  31990. hoverCursor: string;
  31991. /** Gets the list of actions */
  31992. actions: IAction[];
  31993. /**
  31994. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  31995. */
  31996. isRecursive: boolean;
  31997. /**
  31998. * Releases all associated resources
  31999. */
  32000. abstract dispose(): void;
  32001. /**
  32002. * Does this action manager has pointer triggers
  32003. */
  32004. abstract get hasPointerTriggers(): boolean;
  32005. /**
  32006. * Does this action manager has pick triggers
  32007. */
  32008. abstract get hasPickTriggers(): boolean;
  32009. /**
  32010. * Process a specific trigger
  32011. * @param trigger defines the trigger to process
  32012. * @param evt defines the event details to be processed
  32013. */
  32014. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32015. /**
  32016. * Does this action manager handles actions of any of the given triggers
  32017. * @param triggers defines the triggers to be tested
  32018. * @return a boolean indicating whether one (or more) of the triggers is handled
  32019. */
  32020. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32021. /**
  32022. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32023. * speed.
  32024. * @param triggerA defines the trigger to be tested
  32025. * @param triggerB defines the trigger to be tested
  32026. * @return a boolean indicating whether one (or more) of the triggers is handled
  32027. */
  32028. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32029. /**
  32030. * Does this action manager handles actions of a given trigger
  32031. * @param trigger defines the trigger to be tested
  32032. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32033. * @return whether the trigger is handled
  32034. */
  32035. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32036. /**
  32037. * Serialize this manager to a JSON object
  32038. * @param name defines the property name to store this manager
  32039. * @returns a JSON representation of this manager
  32040. */
  32041. abstract serialize(name: string): any;
  32042. /**
  32043. * Registers an action to this action manager
  32044. * @param action defines the action to be registered
  32045. * @return the action amended (prepared) after registration
  32046. */
  32047. abstract registerAction(action: IAction): Nullable<IAction>;
  32048. /**
  32049. * Unregisters an action to this action manager
  32050. * @param action defines the action to be unregistered
  32051. * @return a boolean indicating whether the action has been unregistered
  32052. */
  32053. abstract unregisterAction(action: IAction): Boolean;
  32054. /**
  32055. * Does exist one action manager with at least one trigger
  32056. **/
  32057. static get HasTriggers(): boolean;
  32058. /**
  32059. * Does exist one action manager with at least one pick trigger
  32060. **/
  32061. static get HasPickTriggers(): boolean;
  32062. /**
  32063. * Does exist one action manager that handles actions of a given trigger
  32064. * @param trigger defines the trigger to be tested
  32065. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32066. **/
  32067. static HasSpecificTrigger(trigger: number): boolean;
  32068. }
  32069. }
  32070. declare module BABYLON {
  32071. /**
  32072. * Defines how a node can be built from a string name.
  32073. */
  32074. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32075. /**
  32076. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32077. */
  32078. export class Node implements IBehaviorAware<Node> {
  32079. /** @hidden */
  32080. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32081. private static _NodeConstructors;
  32082. /**
  32083. * Add a new node constructor
  32084. * @param type defines the type name of the node to construct
  32085. * @param constructorFunc defines the constructor function
  32086. */
  32087. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32088. /**
  32089. * Returns a node constructor based on type name
  32090. * @param type defines the type name
  32091. * @param name defines the new node name
  32092. * @param scene defines the hosting scene
  32093. * @param options defines optional options to transmit to constructors
  32094. * @returns the new constructor or null
  32095. */
  32096. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32097. /**
  32098. * Gets or sets the name of the node
  32099. */
  32100. name: string;
  32101. /**
  32102. * Gets or sets the id of the node
  32103. */
  32104. id: string;
  32105. /**
  32106. * Gets or sets the unique id of the node
  32107. */
  32108. uniqueId: number;
  32109. /**
  32110. * Gets or sets a string used to store user defined state for the node
  32111. */
  32112. state: string;
  32113. /**
  32114. * Gets or sets an object used to store user defined information for the node
  32115. */
  32116. metadata: any;
  32117. /**
  32118. * For internal use only. Please do not use.
  32119. */
  32120. reservedDataStore: any;
  32121. /**
  32122. * List of inspectable custom properties (used by the Inspector)
  32123. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32124. */
  32125. inspectableCustomProperties: IInspectable[];
  32126. private _doNotSerialize;
  32127. /**
  32128. * Gets or sets a boolean used to define if the node must be serialized
  32129. */
  32130. get doNotSerialize(): boolean;
  32131. set doNotSerialize(value: boolean);
  32132. /** @hidden */
  32133. _isDisposed: boolean;
  32134. /**
  32135. * Gets a list of Animations associated with the node
  32136. */
  32137. animations: Animation[];
  32138. protected _ranges: {
  32139. [name: string]: Nullable<AnimationRange>;
  32140. };
  32141. /**
  32142. * Callback raised when the node is ready to be used
  32143. */
  32144. onReady: Nullable<(node: Node) => void>;
  32145. private _isEnabled;
  32146. private _isParentEnabled;
  32147. private _isReady;
  32148. /** @hidden */
  32149. _currentRenderId: number;
  32150. private _parentUpdateId;
  32151. /** @hidden */
  32152. _childUpdateId: number;
  32153. /** @hidden */
  32154. _waitingParentId: Nullable<string>;
  32155. /** @hidden */
  32156. _scene: Scene;
  32157. /** @hidden */
  32158. _cache: any;
  32159. private _parentNode;
  32160. private _children;
  32161. /** @hidden */
  32162. _worldMatrix: Matrix;
  32163. /** @hidden */
  32164. _worldMatrixDeterminant: number;
  32165. /** @hidden */
  32166. _worldMatrixDeterminantIsDirty: boolean;
  32167. /** @hidden */
  32168. private _sceneRootNodesIndex;
  32169. /**
  32170. * Gets a boolean indicating if the node has been disposed
  32171. * @returns true if the node was disposed
  32172. */
  32173. isDisposed(): boolean;
  32174. /**
  32175. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32176. * @see https://doc.babylonjs.com/how_to/parenting
  32177. */
  32178. set parent(parent: Nullable<Node>);
  32179. get parent(): Nullable<Node>;
  32180. /** @hidden */
  32181. _addToSceneRootNodes(): void;
  32182. /** @hidden */
  32183. _removeFromSceneRootNodes(): void;
  32184. private _animationPropertiesOverride;
  32185. /**
  32186. * Gets or sets the animation properties override
  32187. */
  32188. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32189. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32190. /**
  32191. * Gets a string idenfifying the name of the class
  32192. * @returns "Node" string
  32193. */
  32194. getClassName(): string;
  32195. /** @hidden */
  32196. readonly _isNode: boolean;
  32197. /**
  32198. * An event triggered when the mesh is disposed
  32199. */
  32200. onDisposeObservable: Observable<Node>;
  32201. private _onDisposeObserver;
  32202. /**
  32203. * Sets a callback that will be raised when the node will be disposed
  32204. */
  32205. set onDispose(callback: () => void);
  32206. /**
  32207. * Creates a new Node
  32208. * @param name the name and id to be given to this node
  32209. * @param scene the scene this node will be added to
  32210. */
  32211. constructor(name: string, scene?: Nullable<Scene>);
  32212. /**
  32213. * Gets the scene of the node
  32214. * @returns a scene
  32215. */
  32216. getScene(): Scene;
  32217. /**
  32218. * Gets the engine of the node
  32219. * @returns a Engine
  32220. */
  32221. getEngine(): Engine;
  32222. private _behaviors;
  32223. /**
  32224. * Attach a behavior to the node
  32225. * @see https://doc.babylonjs.com/features/behaviour
  32226. * @param behavior defines the behavior to attach
  32227. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32228. * @returns the current Node
  32229. */
  32230. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32231. /**
  32232. * Remove an attached behavior
  32233. * @see https://doc.babylonjs.com/features/behaviour
  32234. * @param behavior defines the behavior to attach
  32235. * @returns the current Node
  32236. */
  32237. removeBehavior(behavior: Behavior<Node>): Node;
  32238. /**
  32239. * Gets the list of attached behaviors
  32240. * @see https://doc.babylonjs.com/features/behaviour
  32241. */
  32242. get behaviors(): Behavior<Node>[];
  32243. /**
  32244. * Gets an attached behavior by name
  32245. * @param name defines the name of the behavior to look for
  32246. * @see https://doc.babylonjs.com/features/behaviour
  32247. * @returns null if behavior was not found else the requested behavior
  32248. */
  32249. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32250. /**
  32251. * Returns the latest update of the World matrix
  32252. * @returns a Matrix
  32253. */
  32254. getWorldMatrix(): Matrix;
  32255. /** @hidden */
  32256. _getWorldMatrixDeterminant(): number;
  32257. /**
  32258. * Returns directly the latest state of the mesh World matrix.
  32259. * A Matrix is returned.
  32260. */
  32261. get worldMatrixFromCache(): Matrix;
  32262. /** @hidden */
  32263. _initCache(): void;
  32264. /** @hidden */
  32265. updateCache(force?: boolean): void;
  32266. /** @hidden */
  32267. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32268. /** @hidden */
  32269. _updateCache(ignoreParentClass?: boolean): void;
  32270. /** @hidden */
  32271. _isSynchronized(): boolean;
  32272. /** @hidden */
  32273. _markSyncedWithParent(): void;
  32274. /** @hidden */
  32275. isSynchronizedWithParent(): boolean;
  32276. /** @hidden */
  32277. isSynchronized(): boolean;
  32278. /**
  32279. * Is this node ready to be used/rendered
  32280. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32281. * @return true if the node is ready
  32282. */
  32283. isReady(completeCheck?: boolean): boolean;
  32284. /**
  32285. * Is this node enabled?
  32286. * 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
  32287. * @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
  32288. * @return whether this node (and its parent) is enabled
  32289. */
  32290. isEnabled(checkAncestors?: boolean): boolean;
  32291. /** @hidden */
  32292. protected _syncParentEnabledState(): void;
  32293. /**
  32294. * Set the enabled state of this node
  32295. * @param value defines the new enabled state
  32296. */
  32297. setEnabled(value: boolean): void;
  32298. /**
  32299. * Is this node a descendant of the given node?
  32300. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  32301. * @param ancestor defines the parent node to inspect
  32302. * @returns a boolean indicating if this node is a descendant of the given node
  32303. */
  32304. isDescendantOf(ancestor: Node): boolean;
  32305. /** @hidden */
  32306. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  32307. /**
  32308. * Will return all nodes that have this node as ascendant
  32309. * @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
  32310. * @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
  32311. * @return all children nodes of all types
  32312. */
  32313. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  32314. /**
  32315. * Get all child-meshes of this node
  32316. * @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)
  32317. * @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
  32318. * @returns an array of AbstractMesh
  32319. */
  32320. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  32321. /**
  32322. * Get all direct children of this node
  32323. * @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
  32324. * @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)
  32325. * @returns an array of Node
  32326. */
  32327. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  32328. /** @hidden */
  32329. _setReady(state: boolean): void;
  32330. /**
  32331. * Get an animation by name
  32332. * @param name defines the name of the animation to look for
  32333. * @returns null if not found else the requested animation
  32334. */
  32335. getAnimationByName(name: string): Nullable<Animation>;
  32336. /**
  32337. * Creates an animation range for this node
  32338. * @param name defines the name of the range
  32339. * @param from defines the starting key
  32340. * @param to defines the end key
  32341. */
  32342. createAnimationRange(name: string, from: number, to: number): void;
  32343. /**
  32344. * Delete a specific animation range
  32345. * @param name defines the name of the range to delete
  32346. * @param deleteFrames defines if animation frames from the range must be deleted as well
  32347. */
  32348. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  32349. /**
  32350. * Get an animation range by name
  32351. * @param name defines the name of the animation range to look for
  32352. * @returns null if not found else the requested animation range
  32353. */
  32354. getAnimationRange(name: string): Nullable<AnimationRange>;
  32355. /**
  32356. * Gets the list of all animation ranges defined on this node
  32357. * @returns an array
  32358. */
  32359. getAnimationRanges(): Nullable<AnimationRange>[];
  32360. /**
  32361. * Will start the animation sequence
  32362. * @param name defines the range frames for animation sequence
  32363. * @param loop defines if the animation should loop (false by default)
  32364. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  32365. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  32366. * @returns the object created for this animation. If range does not exist, it will return null
  32367. */
  32368. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  32369. /**
  32370. * Serialize animation ranges into a JSON compatible object
  32371. * @returns serialization object
  32372. */
  32373. serializeAnimationRanges(): any;
  32374. /**
  32375. * Computes the world matrix of the node
  32376. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  32377. * @returns the world matrix
  32378. */
  32379. computeWorldMatrix(force?: boolean): Matrix;
  32380. /**
  32381. * Releases resources associated with this node.
  32382. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32383. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32384. */
  32385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32386. /**
  32387. * Parse animation range data from a serialization object and store them into a given node
  32388. * @param node defines where to store the animation ranges
  32389. * @param parsedNode defines the serialization object to read data from
  32390. * @param scene defines the hosting scene
  32391. */
  32392. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  32393. /**
  32394. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  32395. * @param includeDescendants Include bounding info from descendants as well (true by default)
  32396. * @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
  32397. * @returns the new bounding vectors
  32398. */
  32399. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  32400. min: Vector3;
  32401. max: Vector3;
  32402. };
  32403. }
  32404. }
  32405. declare module BABYLON {
  32406. /**
  32407. * @hidden
  32408. */
  32409. export class _IAnimationState {
  32410. key: number;
  32411. repeatCount: number;
  32412. workValue?: any;
  32413. loopMode?: number;
  32414. offsetValue?: any;
  32415. highLimitValue?: any;
  32416. }
  32417. /**
  32418. * Class used to store any kind of animation
  32419. */
  32420. export class Animation {
  32421. /**Name of the animation */
  32422. name: string;
  32423. /**Property to animate */
  32424. targetProperty: string;
  32425. /**The frames per second of the animation */
  32426. framePerSecond: number;
  32427. /**The data type of the animation */
  32428. dataType: number;
  32429. /**The loop mode of the animation */
  32430. loopMode?: number | undefined;
  32431. /**Specifies if blending should be enabled */
  32432. enableBlending?: boolean | undefined;
  32433. /**
  32434. * Use matrix interpolation instead of using direct key value when animating matrices
  32435. */
  32436. static AllowMatricesInterpolation: boolean;
  32437. /**
  32438. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  32439. */
  32440. static AllowMatrixDecomposeForInterpolation: boolean;
  32441. /** Define the Url to load snippets */
  32442. static SnippetUrl: string;
  32443. /** Snippet ID if the animation was created from the snippet server */
  32444. snippetId: string;
  32445. /**
  32446. * Stores the key frames of the animation
  32447. */
  32448. private _keys;
  32449. /**
  32450. * Stores the easing function of the animation
  32451. */
  32452. private _easingFunction;
  32453. /**
  32454. * @hidden Internal use only
  32455. */
  32456. _runtimeAnimations: RuntimeAnimation[];
  32457. /**
  32458. * The set of event that will be linked to this animation
  32459. */
  32460. private _events;
  32461. /**
  32462. * Stores an array of target property paths
  32463. */
  32464. targetPropertyPath: string[];
  32465. /**
  32466. * Stores the blending speed of the animation
  32467. */
  32468. blendingSpeed: number;
  32469. /**
  32470. * Stores the animation ranges for the animation
  32471. */
  32472. private _ranges;
  32473. /**
  32474. * @hidden Internal use
  32475. */
  32476. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  32477. /**
  32478. * Sets up an animation
  32479. * @param property The property to animate
  32480. * @param animationType The animation type to apply
  32481. * @param framePerSecond The frames per second of the animation
  32482. * @param easingFunction The easing function used in the animation
  32483. * @returns The created animation
  32484. */
  32485. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  32486. /**
  32487. * Create and start an animation on a node
  32488. * @param name defines the name of the global animation that will be run on all nodes
  32489. * @param node defines the root node where the animation will take place
  32490. * @param targetProperty defines property to animate
  32491. * @param framePerSecond defines the number of frame per second yo use
  32492. * @param totalFrame defines the number of frames in total
  32493. * @param from defines the initial value
  32494. * @param to defines the final value
  32495. * @param loopMode defines which loop mode you want to use (off by default)
  32496. * @param easingFunction defines the easing function to use (linear by default)
  32497. * @param onAnimationEnd defines the callback to call when animation end
  32498. * @returns the animatable created for this animation
  32499. */
  32500. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32501. /**
  32502. * Create and start an animation on a node and its descendants
  32503. * @param name defines the name of the global animation that will be run on all nodes
  32504. * @param node defines the root node where the animation will take place
  32505. * @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
  32506. * @param targetProperty defines property to animate
  32507. * @param framePerSecond defines the number of frame per second to use
  32508. * @param totalFrame defines the number of frames in total
  32509. * @param from defines the initial value
  32510. * @param to defines the final value
  32511. * @param loopMode defines which loop mode you want to use (off by default)
  32512. * @param easingFunction defines the easing function to use (linear by default)
  32513. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  32514. * @returns the list of animatables created for all nodes
  32515. * @example https://www.babylonjs-playground.com/#MH0VLI
  32516. */
  32517. 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[]>;
  32518. /**
  32519. * Creates a new animation, merges it with the existing animations and starts it
  32520. * @param name Name of the animation
  32521. * @param node Node which contains the scene that begins the animations
  32522. * @param targetProperty Specifies which property to animate
  32523. * @param framePerSecond The frames per second of the animation
  32524. * @param totalFrame The total number of frames
  32525. * @param from The frame at the beginning of the animation
  32526. * @param to The frame at the end of the animation
  32527. * @param loopMode Specifies the loop mode of the animation
  32528. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  32529. * @param onAnimationEnd Callback to run once the animation is complete
  32530. * @returns Nullable animation
  32531. */
  32532. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  32533. /**
  32534. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  32535. * @param sourceAnimation defines the Animation containing keyframes to convert
  32536. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  32537. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  32538. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  32539. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  32540. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  32541. */
  32542. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  32543. /**
  32544. * Transition property of an host to the target Value
  32545. * @param property The property to transition
  32546. * @param targetValue The target Value of the property
  32547. * @param host The object where the property to animate belongs
  32548. * @param scene Scene used to run the animation
  32549. * @param frameRate Framerate (in frame/s) to use
  32550. * @param transition The transition type we want to use
  32551. * @param duration The duration of the animation, in milliseconds
  32552. * @param onAnimationEnd Callback trigger at the end of the animation
  32553. * @returns Nullable animation
  32554. */
  32555. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  32556. /**
  32557. * Return the array of runtime animations currently using this animation
  32558. */
  32559. get runtimeAnimations(): RuntimeAnimation[];
  32560. /**
  32561. * Specifies if any of the runtime animations are currently running
  32562. */
  32563. get hasRunningRuntimeAnimations(): boolean;
  32564. /**
  32565. * Initializes the animation
  32566. * @param name Name of the animation
  32567. * @param targetProperty Property to animate
  32568. * @param framePerSecond The frames per second of the animation
  32569. * @param dataType The data type of the animation
  32570. * @param loopMode The loop mode of the animation
  32571. * @param enableBlending Specifies if blending should be enabled
  32572. */
  32573. constructor(
  32574. /**Name of the animation */
  32575. name: string,
  32576. /**Property to animate */
  32577. targetProperty: string,
  32578. /**The frames per second of the animation */
  32579. framePerSecond: number,
  32580. /**The data type of the animation */
  32581. dataType: number,
  32582. /**The loop mode of the animation */
  32583. loopMode?: number | undefined,
  32584. /**Specifies if blending should be enabled */
  32585. enableBlending?: boolean | undefined);
  32586. /**
  32587. * Converts the animation to a string
  32588. * @param fullDetails support for multiple levels of logging within scene loading
  32589. * @returns String form of the animation
  32590. */
  32591. toString(fullDetails?: boolean): string;
  32592. /**
  32593. * Add an event to this animation
  32594. * @param event Event to add
  32595. */
  32596. addEvent(event: AnimationEvent): void;
  32597. /**
  32598. * Remove all events found at the given frame
  32599. * @param frame The frame to remove events from
  32600. */
  32601. removeEvents(frame: number): void;
  32602. /**
  32603. * Retrieves all the events from the animation
  32604. * @returns Events from the animation
  32605. */
  32606. getEvents(): AnimationEvent[];
  32607. /**
  32608. * Creates an animation range
  32609. * @param name Name of the animation range
  32610. * @param from Starting frame of the animation range
  32611. * @param to Ending frame of the animation
  32612. */
  32613. createRange(name: string, from: number, to: number): void;
  32614. /**
  32615. * Deletes an animation range by name
  32616. * @param name Name of the animation range to delete
  32617. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  32618. */
  32619. deleteRange(name: string, deleteFrames?: boolean): void;
  32620. /**
  32621. * Gets the animation range by name, or null if not defined
  32622. * @param name Name of the animation range
  32623. * @returns Nullable animation range
  32624. */
  32625. getRange(name: string): Nullable<AnimationRange>;
  32626. /**
  32627. * Gets the key frames from the animation
  32628. * @returns The key frames of the animation
  32629. */
  32630. getKeys(): Array<IAnimationKey>;
  32631. /**
  32632. * Gets the highest frame rate of the animation
  32633. * @returns Highest frame rate of the animation
  32634. */
  32635. getHighestFrame(): number;
  32636. /**
  32637. * Gets the easing function of the animation
  32638. * @returns Easing function of the animation
  32639. */
  32640. getEasingFunction(): IEasingFunction;
  32641. /**
  32642. * Sets the easing function of the animation
  32643. * @param easingFunction A custom mathematical formula for animation
  32644. */
  32645. setEasingFunction(easingFunction: EasingFunction): void;
  32646. /**
  32647. * Interpolates a scalar linearly
  32648. * @param startValue Start value of the animation curve
  32649. * @param endValue End value of the animation curve
  32650. * @param gradient Scalar amount to interpolate
  32651. * @returns Interpolated scalar value
  32652. */
  32653. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  32654. /**
  32655. * Interpolates a scalar cubically
  32656. * @param startValue Start value of the animation curve
  32657. * @param outTangent End tangent of the animation
  32658. * @param endValue End value of the animation curve
  32659. * @param inTangent Start tangent of the animation curve
  32660. * @param gradient Scalar amount to interpolate
  32661. * @returns Interpolated scalar value
  32662. */
  32663. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  32664. /**
  32665. * Interpolates a quaternion using a spherical linear interpolation
  32666. * @param startValue Start value of the animation curve
  32667. * @param endValue End value of the animation curve
  32668. * @param gradient Scalar amount to interpolate
  32669. * @returns Interpolated quaternion value
  32670. */
  32671. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  32672. /**
  32673. * Interpolates a quaternion cubically
  32674. * @param startValue Start value of the animation curve
  32675. * @param outTangent End tangent of the animation curve
  32676. * @param endValue End value of the animation curve
  32677. * @param inTangent Start tangent of the animation curve
  32678. * @param gradient Scalar amount to interpolate
  32679. * @returns Interpolated quaternion value
  32680. */
  32681. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  32682. /**
  32683. * Interpolates a Vector3 linearl
  32684. * @param startValue Start value of the animation curve
  32685. * @param endValue End value of the animation curve
  32686. * @param gradient Scalar amount to interpolate
  32687. * @returns Interpolated scalar value
  32688. */
  32689. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  32690. /**
  32691. * Interpolates a Vector3 cubically
  32692. * @param startValue Start value of the animation curve
  32693. * @param outTangent End tangent of the animation
  32694. * @param endValue End value of the animation curve
  32695. * @param inTangent Start tangent of the animation curve
  32696. * @param gradient Scalar amount to interpolate
  32697. * @returns InterpolatedVector3 value
  32698. */
  32699. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  32700. /**
  32701. * Interpolates a Vector2 linearly
  32702. * @param startValue Start value of the animation curve
  32703. * @param endValue End value of the animation curve
  32704. * @param gradient Scalar amount to interpolate
  32705. * @returns Interpolated Vector2 value
  32706. */
  32707. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  32708. /**
  32709. * Interpolates a Vector2 cubically
  32710. * @param startValue Start value of the animation curve
  32711. * @param outTangent End tangent of the animation
  32712. * @param endValue End value of the animation curve
  32713. * @param inTangent Start tangent of the animation curve
  32714. * @param gradient Scalar amount to interpolate
  32715. * @returns Interpolated Vector2 value
  32716. */
  32717. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  32718. /**
  32719. * Interpolates a size linearly
  32720. * @param startValue Start value of the animation curve
  32721. * @param endValue End value of the animation curve
  32722. * @param gradient Scalar amount to interpolate
  32723. * @returns Interpolated Size value
  32724. */
  32725. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  32726. /**
  32727. * Interpolates a Color3 linearly
  32728. * @param startValue Start value of the animation curve
  32729. * @param endValue End value of the animation curve
  32730. * @param gradient Scalar amount to interpolate
  32731. * @returns Interpolated Color3 value
  32732. */
  32733. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  32734. /**
  32735. * Interpolates a Color4 linearly
  32736. * @param startValue Start value of the animation curve
  32737. * @param endValue End value of the animation curve
  32738. * @param gradient Scalar amount to interpolate
  32739. * @returns Interpolated Color3 value
  32740. */
  32741. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  32742. /**
  32743. * @hidden Internal use only
  32744. */
  32745. _getKeyValue(value: any): any;
  32746. /**
  32747. * @hidden Internal use only
  32748. */
  32749. _interpolate(currentFrame: number, state: _IAnimationState): any;
  32750. /**
  32751. * Defines the function to use to interpolate matrices
  32752. * @param startValue defines the start matrix
  32753. * @param endValue defines the end matrix
  32754. * @param gradient defines the gradient between both matrices
  32755. * @param result defines an optional target matrix where to store the interpolation
  32756. * @returns the interpolated matrix
  32757. */
  32758. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  32759. /**
  32760. * Makes a copy of the animation
  32761. * @returns Cloned animation
  32762. */
  32763. clone(): Animation;
  32764. /**
  32765. * Sets the key frames of the animation
  32766. * @param values The animation key frames to set
  32767. */
  32768. setKeys(values: Array<IAnimationKey>): void;
  32769. /**
  32770. * Serializes the animation to an object
  32771. * @returns Serialized object
  32772. */
  32773. serialize(): any;
  32774. /**
  32775. * Float animation type
  32776. */
  32777. static readonly ANIMATIONTYPE_FLOAT: number;
  32778. /**
  32779. * Vector3 animation type
  32780. */
  32781. static readonly ANIMATIONTYPE_VECTOR3: number;
  32782. /**
  32783. * Quaternion animation type
  32784. */
  32785. static readonly ANIMATIONTYPE_QUATERNION: number;
  32786. /**
  32787. * Matrix animation type
  32788. */
  32789. static readonly ANIMATIONTYPE_MATRIX: number;
  32790. /**
  32791. * Color3 animation type
  32792. */
  32793. static readonly ANIMATIONTYPE_COLOR3: number;
  32794. /**
  32795. * Color3 animation type
  32796. */
  32797. static readonly ANIMATIONTYPE_COLOR4: number;
  32798. /**
  32799. * Vector2 animation type
  32800. */
  32801. static readonly ANIMATIONTYPE_VECTOR2: number;
  32802. /**
  32803. * Size animation type
  32804. */
  32805. static readonly ANIMATIONTYPE_SIZE: number;
  32806. /**
  32807. * Relative Loop Mode
  32808. */
  32809. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  32810. /**
  32811. * Cycle Loop Mode
  32812. */
  32813. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  32814. /**
  32815. * Constant Loop Mode
  32816. */
  32817. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  32818. /** @hidden */
  32819. static _UniversalLerp(left: any, right: any, amount: number): any;
  32820. /**
  32821. * Parses an animation object and creates an animation
  32822. * @param parsedAnimation Parsed animation object
  32823. * @returns Animation object
  32824. */
  32825. static Parse(parsedAnimation: any): Animation;
  32826. /**
  32827. * Appends the serialized animations from the source animations
  32828. * @param source Source containing the animations
  32829. * @param destination Target to store the animations
  32830. */
  32831. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32832. /**
  32833. * Creates a new animation or an array of animations from a snippet saved in a remote file
  32834. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  32835. * @param url defines the url to load from
  32836. * @returns a promise that will resolve to the new animation or an array of animations
  32837. */
  32838. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  32839. /**
  32840. * Creates an animation or an array of animations from a snippet saved by the Inspector
  32841. * @param snippetId defines the snippet to load
  32842. * @returns a promise that will resolve to the new animation or a new array of animations
  32843. */
  32844. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  32845. }
  32846. }
  32847. declare module BABYLON {
  32848. /**
  32849. * Interface containing an array of animations
  32850. */
  32851. export interface IAnimatable {
  32852. /**
  32853. * Array of animations
  32854. */
  32855. animations: Nullable<Array<Animation>>;
  32856. }
  32857. }
  32858. declare module BABYLON {
  32859. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  32860. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32861. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32862. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32863. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32864. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32865. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32866. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32867. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32868. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32869. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32870. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32871. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32872. /**
  32873. * Decorator used to define property that can be serialized as reference to a camera
  32874. * @param sourceName defines the name of the property to decorate
  32875. */
  32876. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  32877. /**
  32878. * Class used to help serialization objects
  32879. */
  32880. export class SerializationHelper {
  32881. /** @hidden */
  32882. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  32883. /** @hidden */
  32884. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  32885. /** @hidden */
  32886. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  32887. /** @hidden */
  32888. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  32889. /**
  32890. * Appends the serialized animations from the source animations
  32891. * @param source Source containing the animations
  32892. * @param destination Target to store the animations
  32893. */
  32894. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  32895. /**
  32896. * Static function used to serialized a specific entity
  32897. * @param entity defines the entity to serialize
  32898. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  32899. * @returns a JSON compatible object representing the serialization of the entity
  32900. */
  32901. static Serialize<T>(entity: T, serializationObject?: any): any;
  32902. /**
  32903. * Creates a new entity from a serialization data object
  32904. * @param creationFunction defines a function used to instanciated the new entity
  32905. * @param source defines the source serialization data
  32906. * @param scene defines the hosting scene
  32907. * @param rootUrl defines the root url for resources
  32908. * @returns a new entity
  32909. */
  32910. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  32911. /**
  32912. * Clones an object
  32913. * @param creationFunction defines the function used to instanciate the new object
  32914. * @param source defines the source object
  32915. * @returns the cloned object
  32916. */
  32917. static Clone<T>(creationFunction: () => T, source: T): T;
  32918. /**
  32919. * Instanciates a new object based on a source one (some data will be shared between both object)
  32920. * @param creationFunction defines the function used to instanciate the new object
  32921. * @param source defines the source object
  32922. * @returns the new object
  32923. */
  32924. static Instanciate<T>(creationFunction: () => T, source: T): T;
  32925. }
  32926. }
  32927. declare module BABYLON {
  32928. /**
  32929. * Base class of all the textures in babylon.
  32930. * It groups all the common properties the materials, post process, lights... might need
  32931. * in order to make a correct use of the texture.
  32932. */
  32933. export class BaseTexture implements IAnimatable {
  32934. /**
  32935. * Default anisotropic filtering level for the application.
  32936. * It is set to 4 as a good tradeoff between perf and quality.
  32937. */
  32938. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  32939. /**
  32940. * Gets or sets the unique id of the texture
  32941. */
  32942. uniqueId: number;
  32943. /**
  32944. * Define the name of the texture.
  32945. */
  32946. name: string;
  32947. /**
  32948. * Gets or sets an object used to store user defined information.
  32949. */
  32950. metadata: any;
  32951. /**
  32952. * For internal use only. Please do not use.
  32953. */
  32954. reservedDataStore: any;
  32955. private _hasAlpha;
  32956. /**
  32957. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  32958. */
  32959. set hasAlpha(value: boolean);
  32960. get hasAlpha(): boolean;
  32961. /**
  32962. * Defines if the alpha value should be determined via the rgb values.
  32963. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  32964. */
  32965. getAlphaFromRGB: boolean;
  32966. /**
  32967. * Intensity or strength of the texture.
  32968. * It is commonly used by materials to fine tune the intensity of the texture
  32969. */
  32970. level: number;
  32971. /**
  32972. * Define the UV chanel to use starting from 0 and defaulting to 0.
  32973. * This is part of the texture as textures usually maps to one uv set.
  32974. */
  32975. coordinatesIndex: number;
  32976. private _coordinatesMode;
  32977. /**
  32978. * How a texture is mapped.
  32979. *
  32980. * | Value | Type | Description |
  32981. * | ----- | ----------------------------------- | ----------- |
  32982. * | 0 | EXPLICIT_MODE | |
  32983. * | 1 | SPHERICAL_MODE | |
  32984. * | 2 | PLANAR_MODE | |
  32985. * | 3 | CUBIC_MODE | |
  32986. * | 4 | PROJECTION_MODE | |
  32987. * | 5 | SKYBOX_MODE | |
  32988. * | 6 | INVCUBIC_MODE | |
  32989. * | 7 | EQUIRECTANGULAR_MODE | |
  32990. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  32991. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  32992. */
  32993. set coordinatesMode(value: number);
  32994. get coordinatesMode(): number;
  32995. /**
  32996. * | Value | Type | Description |
  32997. * | ----- | ------------------ | ----------- |
  32998. * | 0 | CLAMP_ADDRESSMODE | |
  32999. * | 1 | WRAP_ADDRESSMODE | |
  33000. * | 2 | MIRROR_ADDRESSMODE | |
  33001. */
  33002. wrapU: number;
  33003. /**
  33004. * | Value | Type | Description |
  33005. * | ----- | ------------------ | ----------- |
  33006. * | 0 | CLAMP_ADDRESSMODE | |
  33007. * | 1 | WRAP_ADDRESSMODE | |
  33008. * | 2 | MIRROR_ADDRESSMODE | |
  33009. */
  33010. wrapV: number;
  33011. /**
  33012. * | Value | Type | Description |
  33013. * | ----- | ------------------ | ----------- |
  33014. * | 0 | CLAMP_ADDRESSMODE | |
  33015. * | 1 | WRAP_ADDRESSMODE | |
  33016. * | 2 | MIRROR_ADDRESSMODE | |
  33017. */
  33018. wrapR: number;
  33019. /**
  33020. * With compliant hardware and browser (supporting anisotropic filtering)
  33021. * this defines the level of anisotropic filtering in the texture.
  33022. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33023. */
  33024. anisotropicFilteringLevel: number;
  33025. /**
  33026. * Define if the texture is a cube texture or if false a 2d texture.
  33027. */
  33028. get isCube(): boolean;
  33029. set isCube(value: boolean);
  33030. /**
  33031. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33032. */
  33033. get is3D(): boolean;
  33034. set is3D(value: boolean);
  33035. /**
  33036. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33037. */
  33038. get is2DArray(): boolean;
  33039. set is2DArray(value: boolean);
  33040. /**
  33041. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33042. * HDR texture are usually stored in linear space.
  33043. * This only impacts the PBR and Background materials
  33044. */
  33045. gammaSpace: boolean;
  33046. /**
  33047. * Gets or sets whether or not the texture contains RGBD data.
  33048. */
  33049. get isRGBD(): boolean;
  33050. set isRGBD(value: boolean);
  33051. /**
  33052. * Is Z inverted in the texture (useful in a cube texture).
  33053. */
  33054. invertZ: boolean;
  33055. /**
  33056. * Are mip maps generated for this texture or not.
  33057. */
  33058. get noMipmap(): boolean;
  33059. /**
  33060. * @hidden
  33061. */
  33062. lodLevelInAlpha: boolean;
  33063. /**
  33064. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33065. */
  33066. get lodGenerationOffset(): number;
  33067. set lodGenerationOffset(value: number);
  33068. /**
  33069. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33070. */
  33071. get lodGenerationScale(): number;
  33072. set lodGenerationScale(value: number);
  33073. /**
  33074. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33075. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33076. * average roughness values.
  33077. */
  33078. get linearSpecularLOD(): boolean;
  33079. set linearSpecularLOD(value: boolean);
  33080. /**
  33081. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33082. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33083. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33084. */
  33085. get irradianceTexture(): Nullable<BaseTexture>;
  33086. set irradianceTexture(value: Nullable<BaseTexture>);
  33087. /**
  33088. * Define if the texture is a render target.
  33089. */
  33090. isRenderTarget: boolean;
  33091. /**
  33092. * Define the unique id of the texture in the scene.
  33093. */
  33094. get uid(): string;
  33095. /** @hidden */
  33096. _prefiltered: boolean;
  33097. /**
  33098. * Return a string representation of the texture.
  33099. * @returns the texture as a string
  33100. */
  33101. toString(): string;
  33102. /**
  33103. * Get the class name of the texture.
  33104. * @returns "BaseTexture"
  33105. */
  33106. getClassName(): string;
  33107. /**
  33108. * Define the list of animation attached to the texture.
  33109. */
  33110. animations: Animation[];
  33111. /**
  33112. * An event triggered when the texture is disposed.
  33113. */
  33114. onDisposeObservable: Observable<BaseTexture>;
  33115. private _onDisposeObserver;
  33116. /**
  33117. * Callback triggered when the texture has been disposed.
  33118. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33119. */
  33120. set onDispose(callback: () => void);
  33121. /**
  33122. * Define the current state of the loading sequence when in delayed load mode.
  33123. */
  33124. delayLoadState: number;
  33125. private _scene;
  33126. private _engine;
  33127. /** @hidden */
  33128. _texture: Nullable<InternalTexture>;
  33129. private _uid;
  33130. /**
  33131. * Define if the texture is preventinga material to render or not.
  33132. * If not and the texture is not ready, the engine will use a default black texture instead.
  33133. */
  33134. get isBlocking(): boolean;
  33135. /**
  33136. * Instantiates a new BaseTexture.
  33137. * Base class of all the textures in babylon.
  33138. * It groups all the common properties the materials, post process, lights... might need
  33139. * in order to make a correct use of the texture.
  33140. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33141. */
  33142. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33143. /**
  33144. * Get the scene the texture belongs to.
  33145. * @returns the scene or null if undefined
  33146. */
  33147. getScene(): Nullable<Scene>;
  33148. /** @hidden */
  33149. protected _getEngine(): Nullable<ThinEngine>;
  33150. /**
  33151. * Get the texture transform matrix used to offset tile the texture for istance.
  33152. * @returns the transformation matrix
  33153. */
  33154. getTextureMatrix(): Matrix;
  33155. /**
  33156. * Get the texture reflection matrix used to rotate/transform the reflection.
  33157. * @returns the reflection matrix
  33158. */
  33159. getReflectionTextureMatrix(): Matrix;
  33160. /**
  33161. * Get the underlying lower level texture from Babylon.
  33162. * @returns the insternal texture
  33163. */
  33164. getInternalTexture(): Nullable<InternalTexture>;
  33165. /**
  33166. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33167. * @returns true if ready or not blocking
  33168. */
  33169. isReadyOrNotBlocking(): boolean;
  33170. /**
  33171. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33172. * @returns true if fully ready
  33173. */
  33174. isReady(): boolean;
  33175. private _cachedSize;
  33176. /**
  33177. * Get the size of the texture.
  33178. * @returns the texture size.
  33179. */
  33180. getSize(): ISize;
  33181. /**
  33182. * Get the base size of the texture.
  33183. * It can be different from the size if the texture has been resized for POT for instance
  33184. * @returns the base size
  33185. */
  33186. getBaseSize(): ISize;
  33187. /**
  33188. * Update the sampling mode of the texture.
  33189. * Default is Trilinear mode.
  33190. *
  33191. * | Value | Type | Description |
  33192. * | ----- | ------------------ | ----------- |
  33193. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33194. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33195. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33196. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33197. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33198. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33199. * | 7 | NEAREST_LINEAR | |
  33200. * | 8 | NEAREST_NEAREST | |
  33201. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33202. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33203. * | 11 | LINEAR_LINEAR | |
  33204. * | 12 | LINEAR_NEAREST | |
  33205. *
  33206. * > _mag_: magnification filter (close to the viewer)
  33207. * > _min_: minification filter (far from the viewer)
  33208. * > _mip_: filter used between mip map levels
  33209. *@param samplingMode Define the new sampling mode of the texture
  33210. */
  33211. updateSamplingMode(samplingMode: number): void;
  33212. /**
  33213. * Scales the texture if is `canRescale()`
  33214. * @param ratio the resize factor we want to use to rescale
  33215. */
  33216. scale(ratio: number): void;
  33217. /**
  33218. * Get if the texture can rescale.
  33219. */
  33220. get canRescale(): boolean;
  33221. /** @hidden */
  33222. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33223. /** @hidden */
  33224. _rebuild(): void;
  33225. /**
  33226. * Triggers the load sequence in delayed load mode.
  33227. */
  33228. delayLoad(): void;
  33229. /**
  33230. * Clones the texture.
  33231. * @returns the cloned texture
  33232. */
  33233. clone(): Nullable<BaseTexture>;
  33234. /**
  33235. * Get the texture underlying type (INT, FLOAT...)
  33236. */
  33237. get textureType(): number;
  33238. /**
  33239. * Get the texture underlying format (RGB, RGBA...)
  33240. */
  33241. get textureFormat(): number;
  33242. /**
  33243. * Indicates that textures need to be re-calculated for all materials
  33244. */
  33245. protected _markAllSubMeshesAsTexturesDirty(): void;
  33246. /**
  33247. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33248. * This will returns an RGBA array buffer containing either in values (0-255) or
  33249. * float values (0-1) depending of the underlying buffer type.
  33250. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33251. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33252. * @param buffer defines a user defined buffer to fill with data (can be null)
  33253. * @returns The Array buffer containing the pixels data.
  33254. */
  33255. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33256. /**
  33257. * Release and destroy the underlying lower level texture aka internalTexture.
  33258. */
  33259. releaseInternalTexture(): void;
  33260. /** @hidden */
  33261. get _lodTextureHigh(): Nullable<BaseTexture>;
  33262. /** @hidden */
  33263. get _lodTextureMid(): Nullable<BaseTexture>;
  33264. /** @hidden */
  33265. get _lodTextureLow(): Nullable<BaseTexture>;
  33266. /**
  33267. * Dispose the texture and release its associated resources.
  33268. */
  33269. dispose(): void;
  33270. /**
  33271. * Serialize the texture into a JSON representation that can be parsed later on.
  33272. * @returns the JSON representation of the texture
  33273. */
  33274. serialize(): any;
  33275. /**
  33276. * Helper function to be called back once a list of texture contains only ready textures.
  33277. * @param textures Define the list of textures to wait for
  33278. * @param callback Define the callback triggered once the entire list will be ready
  33279. */
  33280. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33281. private static _isScene;
  33282. }
  33283. }
  33284. declare module BABYLON {
  33285. /**
  33286. * Options to be used when creating an effect.
  33287. */
  33288. export interface IEffectCreationOptions {
  33289. /**
  33290. * Atrributes that will be used in the shader.
  33291. */
  33292. attributes: string[];
  33293. /**
  33294. * Uniform varible names that will be set in the shader.
  33295. */
  33296. uniformsNames: string[];
  33297. /**
  33298. * Uniform buffer variable names that will be set in the shader.
  33299. */
  33300. uniformBuffersNames: string[];
  33301. /**
  33302. * Sampler texture variable names that will be set in the shader.
  33303. */
  33304. samplers: string[];
  33305. /**
  33306. * Define statements that will be set in the shader.
  33307. */
  33308. defines: any;
  33309. /**
  33310. * Possible fallbacks for this effect to improve performance when needed.
  33311. */
  33312. fallbacks: Nullable<IEffectFallbacks>;
  33313. /**
  33314. * Callback that will be called when the shader is compiled.
  33315. */
  33316. onCompiled: Nullable<(effect: Effect) => void>;
  33317. /**
  33318. * Callback that will be called if an error occurs during shader compilation.
  33319. */
  33320. onError: Nullable<(effect: Effect, errors: string) => void>;
  33321. /**
  33322. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33323. */
  33324. indexParameters?: any;
  33325. /**
  33326. * Max number of lights that can be used in the shader.
  33327. */
  33328. maxSimultaneousLights?: number;
  33329. /**
  33330. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  33331. */
  33332. transformFeedbackVaryings?: Nullable<string[]>;
  33333. /**
  33334. * 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
  33335. */
  33336. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  33337. /**
  33338. * Is this effect rendering to several color attachments ?
  33339. */
  33340. multiTarget?: boolean;
  33341. }
  33342. /**
  33343. * Effect containing vertex and fragment shader that can be executed on an object.
  33344. */
  33345. export class Effect implements IDisposable {
  33346. /**
  33347. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  33348. */
  33349. static ShadersRepository: string;
  33350. /**
  33351. * Enable logging of the shader code when a compilation error occurs
  33352. */
  33353. static LogShaderCodeOnCompilationError: boolean;
  33354. /**
  33355. * Name of the effect.
  33356. */
  33357. name: any;
  33358. /**
  33359. * String container all the define statements that should be set on the shader.
  33360. */
  33361. defines: string;
  33362. /**
  33363. * Callback that will be called when the shader is compiled.
  33364. */
  33365. onCompiled: Nullable<(effect: Effect) => void>;
  33366. /**
  33367. * Callback that will be called if an error occurs during shader compilation.
  33368. */
  33369. onError: Nullable<(effect: Effect, errors: string) => void>;
  33370. /**
  33371. * Callback that will be called when effect is bound.
  33372. */
  33373. onBind: Nullable<(effect: Effect) => void>;
  33374. /**
  33375. * Unique ID of the effect.
  33376. */
  33377. uniqueId: number;
  33378. /**
  33379. * Observable that will be called when the shader is compiled.
  33380. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  33381. */
  33382. onCompileObservable: Observable<Effect>;
  33383. /**
  33384. * Observable that will be called if an error occurs during shader compilation.
  33385. */
  33386. onErrorObservable: Observable<Effect>;
  33387. /** @hidden */
  33388. _onBindObservable: Nullable<Observable<Effect>>;
  33389. /**
  33390. * @hidden
  33391. * Specifies if the effect was previously ready
  33392. */
  33393. _wasPreviouslyReady: boolean;
  33394. /**
  33395. * Observable that will be called when effect is bound.
  33396. */
  33397. get onBindObservable(): Observable<Effect>;
  33398. /** @hidden */
  33399. _bonesComputationForcedToCPU: boolean;
  33400. /** @hidden */
  33401. _multiTarget: boolean;
  33402. private static _uniqueIdSeed;
  33403. private _engine;
  33404. private _uniformBuffersNames;
  33405. private _uniformBuffersNamesList;
  33406. private _uniformsNames;
  33407. private _samplerList;
  33408. private _samplers;
  33409. private _isReady;
  33410. private _compilationError;
  33411. private _allFallbacksProcessed;
  33412. private _attributesNames;
  33413. private _attributes;
  33414. private _attributeLocationByName;
  33415. private _uniforms;
  33416. /**
  33417. * Key for the effect.
  33418. * @hidden
  33419. */
  33420. _key: string;
  33421. private _indexParameters;
  33422. private _fallbacks;
  33423. private _vertexSourceCode;
  33424. private _fragmentSourceCode;
  33425. private _vertexSourceCodeOverride;
  33426. private _fragmentSourceCodeOverride;
  33427. private _transformFeedbackVaryings;
  33428. /**
  33429. * Compiled shader to webGL program.
  33430. * @hidden
  33431. */
  33432. _pipelineContext: Nullable<IPipelineContext>;
  33433. private _valueCache;
  33434. private static _baseCache;
  33435. /**
  33436. * Instantiates an effect.
  33437. * An effect can be used to create/manage/execute vertex and fragment shaders.
  33438. * @param baseName Name of the effect.
  33439. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  33440. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  33441. * @param samplers List of sampler variables that will be passed to the shader.
  33442. * @param engine Engine to be used to render the effect
  33443. * @param defines Define statements to be added to the shader.
  33444. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  33445. * @param onCompiled Callback that will be called when the shader is compiled.
  33446. * @param onError Callback that will be called if an error occurs during shader compilation.
  33447. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  33448. */
  33449. 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);
  33450. private _useFinalCode;
  33451. /**
  33452. * Unique key for this effect
  33453. */
  33454. get key(): string;
  33455. /**
  33456. * If the effect has been compiled and prepared.
  33457. * @returns if the effect is compiled and prepared.
  33458. */
  33459. isReady(): boolean;
  33460. private _isReadyInternal;
  33461. /**
  33462. * The engine the effect was initialized with.
  33463. * @returns the engine.
  33464. */
  33465. getEngine(): Engine;
  33466. /**
  33467. * The pipeline context for this effect
  33468. * @returns the associated pipeline context
  33469. */
  33470. getPipelineContext(): Nullable<IPipelineContext>;
  33471. /**
  33472. * The set of names of attribute variables for the shader.
  33473. * @returns An array of attribute names.
  33474. */
  33475. getAttributesNames(): string[];
  33476. /**
  33477. * Returns the attribute at the given index.
  33478. * @param index The index of the attribute.
  33479. * @returns The location of the attribute.
  33480. */
  33481. getAttributeLocation(index: number): number;
  33482. /**
  33483. * Returns the attribute based on the name of the variable.
  33484. * @param name of the attribute to look up.
  33485. * @returns the attribute location.
  33486. */
  33487. getAttributeLocationByName(name: string): number;
  33488. /**
  33489. * The number of attributes.
  33490. * @returns the numnber of attributes.
  33491. */
  33492. getAttributesCount(): number;
  33493. /**
  33494. * Gets the index of a uniform variable.
  33495. * @param uniformName of the uniform to look up.
  33496. * @returns the index.
  33497. */
  33498. getUniformIndex(uniformName: string): number;
  33499. /**
  33500. * Returns the attribute based on the name of the variable.
  33501. * @param uniformName of the uniform to look up.
  33502. * @returns the location of the uniform.
  33503. */
  33504. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  33505. /**
  33506. * Returns an array of sampler variable names
  33507. * @returns The array of sampler variable names.
  33508. */
  33509. getSamplers(): string[];
  33510. /**
  33511. * Returns an array of uniform variable names
  33512. * @returns The array of uniform variable names.
  33513. */
  33514. getUniformNames(): string[];
  33515. /**
  33516. * Returns an array of uniform buffer variable names
  33517. * @returns The array of uniform buffer variable names.
  33518. */
  33519. getUniformBuffersNames(): string[];
  33520. /**
  33521. * Returns the index parameters used to create the effect
  33522. * @returns The index parameters object
  33523. */
  33524. getIndexParameters(): any;
  33525. /**
  33526. * The error from the last compilation.
  33527. * @returns the error string.
  33528. */
  33529. getCompilationError(): string;
  33530. /**
  33531. * Gets a boolean indicating that all fallbacks were used during compilation
  33532. * @returns true if all fallbacks were used
  33533. */
  33534. allFallbacksProcessed(): boolean;
  33535. /**
  33536. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  33537. * @param func The callback to be used.
  33538. */
  33539. executeWhenCompiled(func: (effect: Effect) => void): void;
  33540. private _checkIsReady;
  33541. private _loadShader;
  33542. /**
  33543. * Gets the vertex shader source code of this effect
  33544. */
  33545. get vertexSourceCode(): string;
  33546. /**
  33547. * Gets the fragment shader source code of this effect
  33548. */
  33549. get fragmentSourceCode(): string;
  33550. /**
  33551. * Recompiles the webGL program
  33552. * @param vertexSourceCode The source code for the vertex shader.
  33553. * @param fragmentSourceCode The source code for the fragment shader.
  33554. * @param onCompiled Callback called when completed.
  33555. * @param onError Callback called on error.
  33556. * @hidden
  33557. */
  33558. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  33559. /**
  33560. * Prepares the effect
  33561. * @hidden
  33562. */
  33563. _prepareEffect(): void;
  33564. private _getShaderCodeAndErrorLine;
  33565. private _processCompilationErrors;
  33566. /**
  33567. * Checks if the effect is supported. (Must be called after compilation)
  33568. */
  33569. get isSupported(): boolean;
  33570. /**
  33571. * Binds a texture to the engine to be used as output of the shader.
  33572. * @param channel Name of the output variable.
  33573. * @param texture Texture to bind.
  33574. * @hidden
  33575. */
  33576. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  33577. /**
  33578. * Sets a texture on the engine to be used in the shader.
  33579. * @param channel Name of the sampler variable.
  33580. * @param texture Texture to set.
  33581. */
  33582. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  33583. /**
  33584. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  33585. * @param channel Name of the sampler variable.
  33586. * @param texture Texture to set.
  33587. */
  33588. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  33589. /**
  33590. * Sets an array of textures on the engine to be used in the shader.
  33591. * @param channel Name of the variable.
  33592. * @param textures Textures to set.
  33593. */
  33594. setTextureArray(channel: string, textures: BaseTexture[]): void;
  33595. /**
  33596. * 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)
  33597. * @param channel Name of the sampler variable.
  33598. * @param postProcess Post process to get the input texture from.
  33599. */
  33600. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  33601. /**
  33602. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  33603. * 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)
  33604. * @param channel Name of the sampler variable.
  33605. * @param postProcess Post process to get the output texture from.
  33606. */
  33607. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  33608. /** @hidden */
  33609. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  33610. /** @hidden */
  33611. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  33612. /** @hidden */
  33613. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  33614. /** @hidden */
  33615. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  33616. /**
  33617. * Binds a buffer to a uniform.
  33618. * @param buffer Buffer to bind.
  33619. * @param name Name of the uniform variable to bind to.
  33620. */
  33621. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  33622. /**
  33623. * Binds block to a uniform.
  33624. * @param blockName Name of the block to bind.
  33625. * @param index Index to bind.
  33626. */
  33627. bindUniformBlock(blockName: string, index: number): void;
  33628. /**
  33629. * Sets an interger value on a uniform variable.
  33630. * @param uniformName Name of the variable.
  33631. * @param value Value to be set.
  33632. * @returns this effect.
  33633. */
  33634. setInt(uniformName: string, value: number): Effect;
  33635. /**
  33636. * Sets an int array on a uniform variable.
  33637. * @param uniformName Name of the variable.
  33638. * @param array array to be set.
  33639. * @returns this effect.
  33640. */
  33641. setIntArray(uniformName: string, array: Int32Array): Effect;
  33642. /**
  33643. * 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)
  33644. * @param uniformName Name of the variable.
  33645. * @param array array to be set.
  33646. * @returns this effect.
  33647. */
  33648. setIntArray2(uniformName: string, array: Int32Array): Effect;
  33649. /**
  33650. * 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)
  33651. * @param uniformName Name of the variable.
  33652. * @param array array to be set.
  33653. * @returns this effect.
  33654. */
  33655. setIntArray3(uniformName: string, array: Int32Array): Effect;
  33656. /**
  33657. * 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)
  33658. * @param uniformName Name of the variable.
  33659. * @param array array to be set.
  33660. * @returns this effect.
  33661. */
  33662. setIntArray4(uniformName: string, array: Int32Array): Effect;
  33663. /**
  33664. * Sets an float array on a uniform variable.
  33665. * @param uniformName Name of the variable.
  33666. * @param array array to be set.
  33667. * @returns this effect.
  33668. */
  33669. setFloatArray(uniformName: string, array: Float32Array): Effect;
  33670. /**
  33671. * 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)
  33672. * @param uniformName Name of the variable.
  33673. * @param array array to be set.
  33674. * @returns this effect.
  33675. */
  33676. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  33677. /**
  33678. * 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)
  33679. * @param uniformName Name of the variable.
  33680. * @param array array to be set.
  33681. * @returns this effect.
  33682. */
  33683. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  33684. /**
  33685. * 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)
  33686. * @param uniformName Name of the variable.
  33687. * @param array array to be set.
  33688. * @returns this effect.
  33689. */
  33690. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  33691. /**
  33692. * Sets an array on a uniform variable.
  33693. * @param uniformName Name of the variable.
  33694. * @param array array to be set.
  33695. * @returns this effect.
  33696. */
  33697. setArray(uniformName: string, array: number[]): Effect;
  33698. /**
  33699. * 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)
  33700. * @param uniformName Name of the variable.
  33701. * @param array array to be set.
  33702. * @returns this effect.
  33703. */
  33704. setArray2(uniformName: string, array: number[]): Effect;
  33705. /**
  33706. * 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)
  33707. * @param uniformName Name of the variable.
  33708. * @param array array to be set.
  33709. * @returns this effect.
  33710. */
  33711. setArray3(uniformName: string, array: number[]): Effect;
  33712. /**
  33713. * 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)
  33714. * @param uniformName Name of the variable.
  33715. * @param array array to be set.
  33716. * @returns this effect.
  33717. */
  33718. setArray4(uniformName: string, array: number[]): Effect;
  33719. /**
  33720. * Sets matrices on a uniform variable.
  33721. * @param uniformName Name of the variable.
  33722. * @param matrices matrices to be set.
  33723. * @returns this effect.
  33724. */
  33725. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  33726. /**
  33727. * Sets matrix on a uniform variable.
  33728. * @param uniformName Name of the variable.
  33729. * @param matrix matrix to be set.
  33730. * @returns this effect.
  33731. */
  33732. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  33733. /**
  33734. * 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)
  33735. * @param uniformName Name of the variable.
  33736. * @param matrix matrix to be set.
  33737. * @returns this effect.
  33738. */
  33739. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  33740. /**
  33741. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  33742. * @param uniformName Name of the variable.
  33743. * @param matrix matrix to be set.
  33744. * @returns this effect.
  33745. */
  33746. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  33747. /**
  33748. * Sets a float on a uniform variable.
  33749. * @param uniformName Name of the variable.
  33750. * @param value value to be set.
  33751. * @returns this effect.
  33752. */
  33753. setFloat(uniformName: string, value: number): Effect;
  33754. /**
  33755. * Sets a boolean on a uniform variable.
  33756. * @param uniformName Name of the variable.
  33757. * @param bool value to be set.
  33758. * @returns this effect.
  33759. */
  33760. setBool(uniformName: string, bool: boolean): Effect;
  33761. /**
  33762. * Sets a Vector2 on a uniform variable.
  33763. * @param uniformName Name of the variable.
  33764. * @param vector2 vector2 to be set.
  33765. * @returns this effect.
  33766. */
  33767. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  33768. /**
  33769. * Sets a float2 on a uniform variable.
  33770. * @param uniformName Name of the variable.
  33771. * @param x First float in float2.
  33772. * @param y Second float in float2.
  33773. * @returns this effect.
  33774. */
  33775. setFloat2(uniformName: string, x: number, y: number): Effect;
  33776. /**
  33777. * Sets a Vector3 on a uniform variable.
  33778. * @param uniformName Name of the variable.
  33779. * @param vector3 Value to be set.
  33780. * @returns this effect.
  33781. */
  33782. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  33783. /**
  33784. * Sets a float3 on a uniform variable.
  33785. * @param uniformName Name of the variable.
  33786. * @param x First float in float3.
  33787. * @param y Second float in float3.
  33788. * @param z Third float in float3.
  33789. * @returns this effect.
  33790. */
  33791. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  33792. /**
  33793. * Sets a Vector4 on a uniform variable.
  33794. * @param uniformName Name of the variable.
  33795. * @param vector4 Value to be set.
  33796. * @returns this effect.
  33797. */
  33798. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  33799. /**
  33800. * Sets a float4 on a uniform variable.
  33801. * @param uniformName Name of the variable.
  33802. * @param x First float in float4.
  33803. * @param y Second float in float4.
  33804. * @param z Third float in float4.
  33805. * @param w Fourth float in float4.
  33806. * @returns this effect.
  33807. */
  33808. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  33809. /**
  33810. * Sets a Color3 on a uniform variable.
  33811. * @param uniformName Name of the variable.
  33812. * @param color3 Value to be set.
  33813. * @returns this effect.
  33814. */
  33815. setColor3(uniformName: string, color3: IColor3Like): Effect;
  33816. /**
  33817. * Sets a Color4 on a uniform variable.
  33818. * @param uniformName Name of the variable.
  33819. * @param color3 Value to be set.
  33820. * @param alpha Alpha value to be set.
  33821. * @returns this effect.
  33822. */
  33823. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  33824. /**
  33825. * Sets a Color4 on a uniform variable
  33826. * @param uniformName defines the name of the variable
  33827. * @param color4 defines the value to be set
  33828. * @returns this effect.
  33829. */
  33830. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  33831. /** Release all associated resources */
  33832. dispose(): void;
  33833. /**
  33834. * This function will add a new shader to the shader store
  33835. * @param name the name of the shader
  33836. * @param pixelShader optional pixel shader content
  33837. * @param vertexShader optional vertex shader content
  33838. */
  33839. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  33840. /**
  33841. * Store of each shader (The can be looked up using effect.key)
  33842. */
  33843. static ShadersStore: {
  33844. [key: string]: string;
  33845. };
  33846. /**
  33847. * Store of each included file for a shader (The can be looked up using effect.key)
  33848. */
  33849. static IncludesShadersStore: {
  33850. [key: string]: string;
  33851. };
  33852. /**
  33853. * Resets the cache of effects.
  33854. */
  33855. static ResetCache(): void;
  33856. }
  33857. }
  33858. declare module BABYLON {
  33859. /**
  33860. * Interface used to describe the capabilities of the engine relatively to the current browser
  33861. */
  33862. export interface EngineCapabilities {
  33863. /** Maximum textures units per fragment shader */
  33864. maxTexturesImageUnits: number;
  33865. /** Maximum texture units per vertex shader */
  33866. maxVertexTextureImageUnits: number;
  33867. /** Maximum textures units in the entire pipeline */
  33868. maxCombinedTexturesImageUnits: number;
  33869. /** Maximum texture size */
  33870. maxTextureSize: number;
  33871. /** Maximum texture samples */
  33872. maxSamples?: number;
  33873. /** Maximum cube texture size */
  33874. maxCubemapTextureSize: number;
  33875. /** Maximum render texture size */
  33876. maxRenderTextureSize: number;
  33877. /** Maximum number of vertex attributes */
  33878. maxVertexAttribs: number;
  33879. /** Maximum number of varyings */
  33880. maxVaryingVectors: number;
  33881. /** Maximum number of uniforms per vertex shader */
  33882. maxVertexUniformVectors: number;
  33883. /** Maximum number of uniforms per fragment shader */
  33884. maxFragmentUniformVectors: number;
  33885. /** Defines if standard derivates (dx/dy) are supported */
  33886. standardDerivatives: boolean;
  33887. /** Defines if s3tc texture compression is supported */
  33888. s3tc?: WEBGL_compressed_texture_s3tc;
  33889. /** Defines if pvrtc texture compression is supported */
  33890. pvrtc: any;
  33891. /** Defines if etc1 texture compression is supported */
  33892. etc1: any;
  33893. /** Defines if etc2 texture compression is supported */
  33894. etc2: any;
  33895. /** Defines if astc texture compression is supported */
  33896. astc: any;
  33897. /** Defines if float textures are supported */
  33898. textureFloat: boolean;
  33899. /** Defines if vertex array objects are supported */
  33900. vertexArrayObject: boolean;
  33901. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  33902. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  33903. /** Gets the maximum level of anisotropy supported */
  33904. maxAnisotropy: number;
  33905. /** Defines if instancing is supported */
  33906. instancedArrays: boolean;
  33907. /** Defines if 32 bits indices are supported */
  33908. uintIndices: boolean;
  33909. /** Defines if high precision shaders are supported */
  33910. highPrecisionShaderSupported: boolean;
  33911. /** Defines if depth reading in the fragment shader is supported */
  33912. fragmentDepthSupported: boolean;
  33913. /** Defines if float texture linear filtering is supported*/
  33914. textureFloatLinearFiltering: boolean;
  33915. /** Defines if rendering to float textures is supported */
  33916. textureFloatRender: boolean;
  33917. /** Defines if half float textures are supported*/
  33918. textureHalfFloat: boolean;
  33919. /** Defines if half float texture linear filtering is supported*/
  33920. textureHalfFloatLinearFiltering: boolean;
  33921. /** Defines if rendering to half float textures is supported */
  33922. textureHalfFloatRender: boolean;
  33923. /** Defines if textureLOD shader command is supported */
  33924. textureLOD: boolean;
  33925. /** Defines if draw buffers extension is supported */
  33926. drawBuffersExtension: boolean;
  33927. /** Defines if depth textures are supported */
  33928. depthTextureExtension: boolean;
  33929. /** Defines if float color buffer are supported */
  33930. colorBufferFloat: boolean;
  33931. /** Gets disjoint timer query extension (null if not supported) */
  33932. timerQuery?: EXT_disjoint_timer_query;
  33933. /** Defines if timestamp can be used with timer query */
  33934. canUseTimestampForTimerQuery: boolean;
  33935. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  33936. multiview?: any;
  33937. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  33938. oculusMultiview?: any;
  33939. /** Function used to let the system compiles shaders in background */
  33940. parallelShaderCompile?: {
  33941. COMPLETION_STATUS_KHR: number;
  33942. };
  33943. /** Max number of texture samples for MSAA */
  33944. maxMSAASamples: number;
  33945. /** Defines if the blend min max extension is supported */
  33946. blendMinMax: boolean;
  33947. }
  33948. }
  33949. declare module BABYLON {
  33950. /**
  33951. * @hidden
  33952. **/
  33953. export class DepthCullingState {
  33954. private _isDepthTestDirty;
  33955. private _isDepthMaskDirty;
  33956. private _isDepthFuncDirty;
  33957. private _isCullFaceDirty;
  33958. private _isCullDirty;
  33959. private _isZOffsetDirty;
  33960. private _isFrontFaceDirty;
  33961. private _depthTest;
  33962. private _depthMask;
  33963. private _depthFunc;
  33964. private _cull;
  33965. private _cullFace;
  33966. private _zOffset;
  33967. private _frontFace;
  33968. /**
  33969. * Initializes the state.
  33970. */
  33971. constructor();
  33972. get isDirty(): boolean;
  33973. get zOffset(): number;
  33974. set zOffset(value: number);
  33975. get cullFace(): Nullable<number>;
  33976. set cullFace(value: Nullable<number>);
  33977. get cull(): Nullable<boolean>;
  33978. set cull(value: Nullable<boolean>);
  33979. get depthFunc(): Nullable<number>;
  33980. set depthFunc(value: Nullable<number>);
  33981. get depthMask(): boolean;
  33982. set depthMask(value: boolean);
  33983. get depthTest(): boolean;
  33984. set depthTest(value: boolean);
  33985. get frontFace(): Nullable<number>;
  33986. set frontFace(value: Nullable<number>);
  33987. reset(): void;
  33988. apply(gl: WebGLRenderingContext): void;
  33989. }
  33990. }
  33991. declare module BABYLON {
  33992. /**
  33993. * @hidden
  33994. **/
  33995. export class StencilState {
  33996. /** 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 */
  33997. static readonly ALWAYS: number;
  33998. /** Passed to stencilOperation to specify that stencil value must be kept */
  33999. static readonly KEEP: number;
  34000. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34001. static readonly REPLACE: number;
  34002. private _isStencilTestDirty;
  34003. private _isStencilMaskDirty;
  34004. private _isStencilFuncDirty;
  34005. private _isStencilOpDirty;
  34006. private _stencilTest;
  34007. private _stencilMask;
  34008. private _stencilFunc;
  34009. private _stencilFuncRef;
  34010. private _stencilFuncMask;
  34011. private _stencilOpStencilFail;
  34012. private _stencilOpDepthFail;
  34013. private _stencilOpStencilDepthPass;
  34014. get isDirty(): boolean;
  34015. get stencilFunc(): number;
  34016. set stencilFunc(value: number);
  34017. get stencilFuncRef(): number;
  34018. set stencilFuncRef(value: number);
  34019. get stencilFuncMask(): number;
  34020. set stencilFuncMask(value: number);
  34021. get stencilOpStencilFail(): number;
  34022. set stencilOpStencilFail(value: number);
  34023. get stencilOpDepthFail(): number;
  34024. set stencilOpDepthFail(value: number);
  34025. get stencilOpStencilDepthPass(): number;
  34026. set stencilOpStencilDepthPass(value: number);
  34027. get stencilMask(): number;
  34028. set stencilMask(value: number);
  34029. get stencilTest(): boolean;
  34030. set stencilTest(value: boolean);
  34031. constructor();
  34032. reset(): void;
  34033. apply(gl: WebGLRenderingContext): void;
  34034. }
  34035. }
  34036. declare module BABYLON {
  34037. /**
  34038. * @hidden
  34039. **/
  34040. export class AlphaState {
  34041. private _isAlphaBlendDirty;
  34042. private _isBlendFunctionParametersDirty;
  34043. private _isBlendEquationParametersDirty;
  34044. private _isBlendConstantsDirty;
  34045. private _alphaBlend;
  34046. private _blendFunctionParameters;
  34047. private _blendEquationParameters;
  34048. private _blendConstants;
  34049. /**
  34050. * Initializes the state.
  34051. */
  34052. constructor();
  34053. get isDirty(): boolean;
  34054. get alphaBlend(): boolean;
  34055. set alphaBlend(value: boolean);
  34056. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34057. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34058. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34059. reset(): void;
  34060. apply(gl: WebGLRenderingContext): void;
  34061. }
  34062. }
  34063. declare module BABYLON {
  34064. /** @hidden */
  34065. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34066. attributeProcessor(attribute: string): string;
  34067. varyingProcessor(varying: string, isFragment: boolean): string;
  34068. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34069. }
  34070. }
  34071. declare module BABYLON {
  34072. /**
  34073. * Interface for attribute information associated with buffer instanciation
  34074. */
  34075. export interface InstancingAttributeInfo {
  34076. /**
  34077. * Name of the GLSL attribute
  34078. * if attribute index is not specified, this is used to retrieve the index from the effect
  34079. */
  34080. attributeName: string;
  34081. /**
  34082. * Index/offset of the attribute in the vertex shader
  34083. * if not specified, this will be computes from the name.
  34084. */
  34085. index?: number;
  34086. /**
  34087. * size of the attribute, 1, 2, 3 or 4
  34088. */
  34089. attributeSize: number;
  34090. /**
  34091. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34092. */
  34093. offset: number;
  34094. /**
  34095. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34096. * default to 1
  34097. */
  34098. divisor?: number;
  34099. /**
  34100. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34101. * default is FLOAT
  34102. */
  34103. attributeType?: number;
  34104. /**
  34105. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34106. */
  34107. normalized?: boolean;
  34108. }
  34109. }
  34110. declare module BABYLON {
  34111. interface ThinEngine {
  34112. /**
  34113. * Update a video texture
  34114. * @param texture defines the texture to update
  34115. * @param video defines the video element to use
  34116. * @param invertY defines if data must be stored with Y axis inverted
  34117. */
  34118. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34119. }
  34120. }
  34121. declare module BABYLON {
  34122. interface ThinEngine {
  34123. /**
  34124. * Creates a dynamic texture
  34125. * @param width defines the width of the texture
  34126. * @param height defines the height of the texture
  34127. * @param generateMipMaps defines if the engine should generate the mip levels
  34128. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34129. * @returns the dynamic texture inside an InternalTexture
  34130. */
  34131. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34132. /**
  34133. * Update the content of a dynamic texture
  34134. * @param texture defines the texture to update
  34135. * @param canvas defines the canvas containing the source
  34136. * @param invertY defines if data must be stored with Y axis inverted
  34137. * @param premulAlpha defines if alpha is stored as premultiplied
  34138. * @param format defines the format of the data
  34139. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34140. */
  34141. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34142. }
  34143. }
  34144. declare module BABYLON {
  34145. /**
  34146. * Settings for finer control over video usage
  34147. */
  34148. export interface VideoTextureSettings {
  34149. /**
  34150. * Applies `autoplay` to video, if specified
  34151. */
  34152. autoPlay?: boolean;
  34153. /**
  34154. * Applies `loop` to video, if specified
  34155. */
  34156. loop?: boolean;
  34157. /**
  34158. * Automatically updates internal texture from video at every frame in the render loop
  34159. */
  34160. autoUpdateTexture: boolean;
  34161. /**
  34162. * Image src displayed during the video loading or until the user interacts with the video.
  34163. */
  34164. poster?: string;
  34165. }
  34166. /**
  34167. * If you want to display a video in your scene, this is the special texture for that.
  34168. * This special texture works similar to other textures, with the exception of a few parameters.
  34169. * @see https://doc.babylonjs.com/how_to/video_texture
  34170. */
  34171. export class VideoTexture extends Texture {
  34172. /**
  34173. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34174. */
  34175. readonly autoUpdateTexture: boolean;
  34176. /**
  34177. * The video instance used by the texture internally
  34178. */
  34179. readonly video: HTMLVideoElement;
  34180. private _onUserActionRequestedObservable;
  34181. /**
  34182. * Event triggerd when a dom action is required by the user to play the video.
  34183. * This happens due to recent changes in browser policies preventing video to auto start.
  34184. */
  34185. get onUserActionRequestedObservable(): Observable<Texture>;
  34186. private _generateMipMaps;
  34187. private _stillImageCaptured;
  34188. private _displayingPosterTexture;
  34189. private _settings;
  34190. private _createInternalTextureOnEvent;
  34191. private _frameId;
  34192. private _currentSrc;
  34193. /**
  34194. * Creates a video texture.
  34195. * If you want to display a video in your scene, this is the special texture for that.
  34196. * This special texture works similar to other textures, with the exception of a few parameters.
  34197. * @see https://doc.babylonjs.com/how_to/video_texture
  34198. * @param name optional name, will detect from video source, if not defined
  34199. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34200. * @param scene is obviously the current scene.
  34201. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34202. * @param invertY is false by default but can be used to invert video on Y axis
  34203. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34204. * @param settings allows finer control over video usage
  34205. */
  34206. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34207. private _getName;
  34208. private _getVideo;
  34209. private _createInternalTexture;
  34210. private reset;
  34211. /**
  34212. * @hidden Internal method to initiate `update`.
  34213. */
  34214. _rebuild(): void;
  34215. /**
  34216. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34217. */
  34218. update(): void;
  34219. /**
  34220. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34221. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34222. */
  34223. updateTexture(isVisible: boolean): void;
  34224. protected _updateInternalTexture: () => void;
  34225. /**
  34226. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34227. * @param url New url.
  34228. */
  34229. updateURL(url: string): void;
  34230. /**
  34231. * Clones the texture.
  34232. * @returns the cloned texture
  34233. */
  34234. clone(): VideoTexture;
  34235. /**
  34236. * Dispose the texture and release its associated resources.
  34237. */
  34238. dispose(): void;
  34239. /**
  34240. * Creates a video texture straight from a stream.
  34241. * @param scene Define the scene the texture should be created in
  34242. * @param stream Define the stream the texture should be created from
  34243. * @returns The created video texture as a promise
  34244. */
  34245. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34246. /**
  34247. * Creates a video texture straight from your WebCam video feed.
  34248. * @param scene Define the scene the texture should be created in
  34249. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34250. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34251. * @returns The created video texture as a promise
  34252. */
  34253. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34254. minWidth: number;
  34255. maxWidth: number;
  34256. minHeight: number;
  34257. maxHeight: number;
  34258. deviceId: string;
  34259. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34260. /**
  34261. * Creates a video texture straight from your WebCam video feed.
  34262. * @param scene Define the scene the texture should be created in
  34263. * @param onReady Define a callback to triggered once the texture will be ready
  34264. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34265. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34266. */
  34267. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34268. minWidth: number;
  34269. maxWidth: number;
  34270. minHeight: number;
  34271. maxHeight: number;
  34272. deviceId: string;
  34273. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34274. }
  34275. }
  34276. declare module BABYLON {
  34277. /**
  34278. * Defines the interface used by objects working like Scene
  34279. * @hidden
  34280. */
  34281. export interface ISceneLike {
  34282. _addPendingData(data: any): void;
  34283. _removePendingData(data: any): void;
  34284. offlineProvider: IOfflineProvider;
  34285. }
  34286. /** Interface defining initialization parameters for Engine class */
  34287. export interface EngineOptions extends WebGLContextAttributes {
  34288. /**
  34289. * Defines if the engine should no exceed a specified device ratio
  34290. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34291. */
  34292. limitDeviceRatio?: number;
  34293. /**
  34294. * Defines if webvr should be enabled automatically
  34295. * @see https://doc.babylonjs.com/how_to/webvr_camera
  34296. */
  34297. autoEnableWebVR?: boolean;
  34298. /**
  34299. * Defines if webgl2 should be turned off even if supported
  34300. * @see https://doc.babylonjs.com/features/webgl2
  34301. */
  34302. disableWebGL2Support?: boolean;
  34303. /**
  34304. * Defines if webaudio should be initialized as well
  34305. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  34306. */
  34307. audioEngine?: boolean;
  34308. /**
  34309. * Defines if animations should run using a deterministic lock step
  34310. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34311. */
  34312. deterministicLockstep?: boolean;
  34313. /** Defines the maximum steps to use with deterministic lock step mode */
  34314. lockstepMaxSteps?: number;
  34315. /** Defines the seconds between each deterministic lock step */
  34316. timeStep?: number;
  34317. /**
  34318. * Defines that engine should ignore context lost events
  34319. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  34320. */
  34321. doNotHandleContextLost?: boolean;
  34322. /**
  34323. * Defines that engine should ignore modifying touch action attribute and style
  34324. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  34325. */
  34326. doNotHandleTouchAction?: boolean;
  34327. /**
  34328. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  34329. */
  34330. useHighPrecisionFloats?: boolean;
  34331. /**
  34332. * Make the canvas XR Compatible for XR sessions
  34333. */
  34334. xrCompatible?: boolean;
  34335. }
  34336. /**
  34337. * The base engine class (root of all engines)
  34338. */
  34339. export class ThinEngine {
  34340. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  34341. static ExceptionList: ({
  34342. key: string;
  34343. capture: string;
  34344. captureConstraint: number;
  34345. targets: string[];
  34346. } | {
  34347. key: string;
  34348. capture: null;
  34349. captureConstraint: null;
  34350. targets: string[];
  34351. })[];
  34352. /** @hidden */
  34353. static _TextureLoaders: IInternalTextureLoader[];
  34354. /**
  34355. * Returns the current npm package of the sdk
  34356. */
  34357. static get NpmPackage(): string;
  34358. /**
  34359. * Returns the current version of the framework
  34360. */
  34361. static get Version(): string;
  34362. /**
  34363. * Returns a string describing the current engine
  34364. */
  34365. get description(): string;
  34366. /**
  34367. * Gets or sets the epsilon value used by collision engine
  34368. */
  34369. static CollisionsEpsilon: number;
  34370. /**
  34371. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34372. */
  34373. static get ShadersRepository(): string;
  34374. static set ShadersRepository(value: string);
  34375. /** @hidden */
  34376. _shaderProcessor: IShaderProcessor;
  34377. /**
  34378. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  34379. */
  34380. forcePOTTextures: boolean;
  34381. /**
  34382. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  34383. */
  34384. isFullscreen: boolean;
  34385. /**
  34386. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  34387. */
  34388. cullBackFaces: boolean;
  34389. /**
  34390. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  34391. */
  34392. renderEvenInBackground: boolean;
  34393. /**
  34394. * Gets or sets a boolean indicating that cache can be kept between frames
  34395. */
  34396. preventCacheWipeBetweenFrames: boolean;
  34397. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  34398. validateShaderPrograms: boolean;
  34399. /**
  34400. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  34401. * This can provide greater z depth for distant objects.
  34402. */
  34403. useReverseDepthBuffer: boolean;
  34404. /**
  34405. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  34406. */
  34407. disableUniformBuffers: boolean;
  34408. /** @hidden */
  34409. _uniformBuffers: UniformBuffer[];
  34410. /**
  34411. * Gets a boolean indicating that the engine supports uniform buffers
  34412. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  34413. */
  34414. get supportsUniformBuffers(): boolean;
  34415. /** @hidden */
  34416. _gl: WebGLRenderingContext;
  34417. /** @hidden */
  34418. _webGLVersion: number;
  34419. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  34420. protected _windowIsBackground: boolean;
  34421. protected _creationOptions: EngineOptions;
  34422. protected _highPrecisionShadersAllowed: boolean;
  34423. /** @hidden */
  34424. get _shouldUseHighPrecisionShader(): boolean;
  34425. /**
  34426. * Gets a boolean indicating that only power of 2 textures are supported
  34427. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  34428. */
  34429. get needPOTTextures(): boolean;
  34430. /** @hidden */
  34431. _badOS: boolean;
  34432. /** @hidden */
  34433. _badDesktopOS: boolean;
  34434. private _hardwareScalingLevel;
  34435. /** @hidden */
  34436. _caps: EngineCapabilities;
  34437. private _isStencilEnable;
  34438. private _glVersion;
  34439. private _glRenderer;
  34440. private _glVendor;
  34441. /** @hidden */
  34442. _videoTextureSupported: boolean;
  34443. protected _renderingQueueLaunched: boolean;
  34444. protected _activeRenderLoops: (() => void)[];
  34445. /**
  34446. * Observable signaled when a context lost event is raised
  34447. */
  34448. onContextLostObservable: Observable<ThinEngine>;
  34449. /**
  34450. * Observable signaled when a context restored event is raised
  34451. */
  34452. onContextRestoredObservable: Observable<ThinEngine>;
  34453. private _onContextLost;
  34454. private _onContextRestored;
  34455. protected _contextWasLost: boolean;
  34456. /** @hidden */
  34457. _doNotHandleContextLost: boolean;
  34458. /**
  34459. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  34460. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  34461. */
  34462. get doNotHandleContextLost(): boolean;
  34463. set doNotHandleContextLost(value: boolean);
  34464. /**
  34465. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  34466. */
  34467. disableVertexArrayObjects: boolean;
  34468. /** @hidden */
  34469. protected _colorWrite: boolean;
  34470. /** @hidden */
  34471. protected _colorWriteChanged: boolean;
  34472. /** @hidden */
  34473. protected _depthCullingState: DepthCullingState;
  34474. /** @hidden */
  34475. protected _stencilState: StencilState;
  34476. /** @hidden */
  34477. _alphaState: AlphaState;
  34478. /** @hidden */
  34479. _alphaMode: number;
  34480. /** @hidden */
  34481. _alphaEquation: number;
  34482. /** @hidden */
  34483. _internalTexturesCache: InternalTexture[];
  34484. /** @hidden */
  34485. protected _activeChannel: number;
  34486. private _currentTextureChannel;
  34487. /** @hidden */
  34488. protected _boundTexturesCache: {
  34489. [key: string]: Nullable<InternalTexture>;
  34490. };
  34491. /** @hidden */
  34492. protected _currentEffect: Nullable<Effect>;
  34493. /** @hidden */
  34494. protected _currentProgram: Nullable<WebGLProgram>;
  34495. private _compiledEffects;
  34496. private _vertexAttribArraysEnabled;
  34497. /** @hidden */
  34498. protected _cachedViewport: Nullable<IViewportLike>;
  34499. private _cachedVertexArrayObject;
  34500. /** @hidden */
  34501. protected _cachedVertexBuffers: any;
  34502. /** @hidden */
  34503. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  34504. /** @hidden */
  34505. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  34506. /** @hidden */
  34507. _currentRenderTarget: Nullable<InternalTexture>;
  34508. private _uintIndicesCurrentlySet;
  34509. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  34510. /** @hidden */
  34511. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  34512. /** @hidden */
  34513. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  34514. private _currentBufferPointers;
  34515. private _currentInstanceLocations;
  34516. private _currentInstanceBuffers;
  34517. private _textureUnits;
  34518. /** @hidden */
  34519. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  34520. /** @hidden */
  34521. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  34522. /** @hidden */
  34523. _boundRenderFunction: any;
  34524. private _vaoRecordInProgress;
  34525. private _mustWipeVertexAttributes;
  34526. private _emptyTexture;
  34527. private _emptyCubeTexture;
  34528. private _emptyTexture3D;
  34529. private _emptyTexture2DArray;
  34530. /** @hidden */
  34531. _frameHandler: number;
  34532. private _nextFreeTextureSlots;
  34533. private _maxSimultaneousTextures;
  34534. private _activeRequests;
  34535. /** @hidden */
  34536. _transformTextureUrl: Nullable<(url: string) => string>;
  34537. protected get _supportsHardwareTextureRescaling(): boolean;
  34538. private _framebufferDimensionsObject;
  34539. /**
  34540. * sets the object from which width and height will be taken from when getting render width and height
  34541. * Will fallback to the gl object
  34542. * @param dimensions the framebuffer width and height that will be used.
  34543. */
  34544. set framebufferDimensionsObject(dimensions: Nullable<{
  34545. framebufferWidth: number;
  34546. framebufferHeight: number;
  34547. }>);
  34548. /**
  34549. * Gets the current viewport
  34550. */
  34551. get currentViewport(): Nullable<IViewportLike>;
  34552. /**
  34553. * Gets the default empty texture
  34554. */
  34555. get emptyTexture(): InternalTexture;
  34556. /**
  34557. * Gets the default empty 3D texture
  34558. */
  34559. get emptyTexture3D(): InternalTexture;
  34560. /**
  34561. * Gets the default empty 2D array texture
  34562. */
  34563. get emptyTexture2DArray(): InternalTexture;
  34564. /**
  34565. * Gets the default empty cube texture
  34566. */
  34567. get emptyCubeTexture(): InternalTexture;
  34568. /**
  34569. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  34570. */
  34571. readonly premultipliedAlpha: boolean;
  34572. /**
  34573. * Observable event triggered before each texture is initialized
  34574. */
  34575. onBeforeTextureInitObservable: Observable<Texture>;
  34576. /**
  34577. * Creates a new engine
  34578. * @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
  34579. * @param antialias defines enable antialiasing (default: false)
  34580. * @param options defines further options to be sent to the getContext() function
  34581. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34582. */
  34583. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34584. private _rebuildInternalTextures;
  34585. private _rebuildEffects;
  34586. /**
  34587. * Gets a boolean indicating if all created effects are ready
  34588. * @returns true if all effects are ready
  34589. */
  34590. areAllEffectsReady(): boolean;
  34591. protected _rebuildBuffers(): void;
  34592. protected _initGLContext(): void;
  34593. /**
  34594. * Gets version of the current webGL context
  34595. */
  34596. get webGLVersion(): number;
  34597. /**
  34598. * Gets a string idenfifying the name of the class
  34599. * @returns "Engine" string
  34600. */
  34601. getClassName(): string;
  34602. /**
  34603. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  34604. */
  34605. get isStencilEnable(): boolean;
  34606. /** @hidden */
  34607. _prepareWorkingCanvas(): void;
  34608. /**
  34609. * Reset the texture cache to empty state
  34610. */
  34611. resetTextureCache(): void;
  34612. /**
  34613. * Gets an object containing information about the current webGL context
  34614. * @returns an object containing the vender, the renderer and the version of the current webGL context
  34615. */
  34616. getGlInfo(): {
  34617. vendor: string;
  34618. renderer: string;
  34619. version: string;
  34620. };
  34621. /**
  34622. * Defines the hardware scaling level.
  34623. * By default the hardware scaling level is computed from the window device ratio.
  34624. * 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.
  34625. * @param level defines the level to use
  34626. */
  34627. setHardwareScalingLevel(level: number): void;
  34628. /**
  34629. * Gets the current hardware scaling level.
  34630. * By default the hardware scaling level is computed from the window device ratio.
  34631. * 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.
  34632. * @returns a number indicating the current hardware scaling level
  34633. */
  34634. getHardwareScalingLevel(): number;
  34635. /**
  34636. * Gets the list of loaded textures
  34637. * @returns an array containing all loaded textures
  34638. */
  34639. getLoadedTexturesCache(): InternalTexture[];
  34640. /**
  34641. * Gets the object containing all engine capabilities
  34642. * @returns the EngineCapabilities object
  34643. */
  34644. getCaps(): EngineCapabilities;
  34645. /**
  34646. * stop executing a render loop function and remove it from the execution array
  34647. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  34648. */
  34649. stopRenderLoop(renderFunction?: () => void): void;
  34650. /** @hidden */
  34651. _renderLoop(): void;
  34652. /**
  34653. * Gets the HTML canvas attached with the current webGL context
  34654. * @returns a HTML canvas
  34655. */
  34656. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  34657. /**
  34658. * Gets host window
  34659. * @returns the host window object
  34660. */
  34661. getHostWindow(): Nullable<Window>;
  34662. /**
  34663. * Gets the current render width
  34664. * @param useScreen defines if screen size must be used (or the current render target if any)
  34665. * @returns a number defining the current render width
  34666. */
  34667. getRenderWidth(useScreen?: boolean): number;
  34668. /**
  34669. * Gets the current render height
  34670. * @param useScreen defines if screen size must be used (or the current render target if any)
  34671. * @returns a number defining the current render height
  34672. */
  34673. getRenderHeight(useScreen?: boolean): number;
  34674. /**
  34675. * Can be used to override the current requestAnimationFrame requester.
  34676. * @hidden
  34677. */
  34678. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  34679. /**
  34680. * Register and execute a render loop. The engine can have more than one render function
  34681. * @param renderFunction defines the function to continuously execute
  34682. */
  34683. runRenderLoop(renderFunction: () => void): void;
  34684. /**
  34685. * Clear the current render buffer or the current render target (if any is set up)
  34686. * @param color defines the color to use
  34687. * @param backBuffer defines if the back buffer must be cleared
  34688. * @param depth defines if the depth buffer must be cleared
  34689. * @param stencil defines if the stencil buffer must be cleared
  34690. */
  34691. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  34692. private _viewportCached;
  34693. /** @hidden */
  34694. _viewport(x: number, y: number, width: number, height: number): void;
  34695. /**
  34696. * Set the WebGL's viewport
  34697. * @param viewport defines the viewport element to be used
  34698. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  34699. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  34700. */
  34701. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  34702. /**
  34703. * Begin a new frame
  34704. */
  34705. beginFrame(): void;
  34706. /**
  34707. * Enf the current frame
  34708. */
  34709. endFrame(): void;
  34710. /**
  34711. * Resize the view according to the canvas' size
  34712. */
  34713. resize(): void;
  34714. /**
  34715. * Force a specific size of the canvas
  34716. * @param width defines the new canvas' width
  34717. * @param height defines the new canvas' height
  34718. * @returns true if the size was changed
  34719. */
  34720. setSize(width: number, height: number): boolean;
  34721. /**
  34722. * Binds the frame buffer to the specified texture.
  34723. * @param texture The texture to render to or null for the default canvas
  34724. * @param faceIndex The face of the texture to render to in case of cube texture
  34725. * @param requiredWidth The width of the target to render to
  34726. * @param requiredHeight The height of the target to render to
  34727. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  34728. * @param lodLevel defines the lod level to bind to the frame buffer
  34729. * @param layer defines the 2d array index to bind to frame buffer to
  34730. */
  34731. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  34732. /** @hidden */
  34733. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  34734. /**
  34735. * Unbind the current render target texture from the webGL context
  34736. * @param texture defines the render target texture to unbind
  34737. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  34738. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  34739. */
  34740. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  34741. /**
  34742. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  34743. */
  34744. flushFramebuffer(): void;
  34745. /**
  34746. * Unbind the current render target and bind the default framebuffer
  34747. */
  34748. restoreDefaultFramebuffer(): void;
  34749. /** @hidden */
  34750. protected _resetVertexBufferBinding(): void;
  34751. /**
  34752. * Creates a vertex buffer
  34753. * @param data the data for the vertex buffer
  34754. * @returns the new WebGL static buffer
  34755. */
  34756. createVertexBuffer(data: DataArray): DataBuffer;
  34757. private _createVertexBuffer;
  34758. /**
  34759. * Creates a dynamic vertex buffer
  34760. * @param data the data for the dynamic vertex buffer
  34761. * @returns the new WebGL dynamic buffer
  34762. */
  34763. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  34764. protected _resetIndexBufferBinding(): void;
  34765. /**
  34766. * Creates a new index buffer
  34767. * @param indices defines the content of the index buffer
  34768. * @param updatable defines if the index buffer must be updatable
  34769. * @returns a new webGL buffer
  34770. */
  34771. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  34772. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  34773. /**
  34774. * Bind a webGL buffer to the webGL context
  34775. * @param buffer defines the buffer to bind
  34776. */
  34777. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  34778. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  34779. private bindBuffer;
  34780. /**
  34781. * update the bound buffer with the given data
  34782. * @param data defines the data to update
  34783. */
  34784. updateArrayBuffer(data: Float32Array): void;
  34785. private _vertexAttribPointer;
  34786. /** @hidden */
  34787. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  34788. private _bindVertexBuffersAttributes;
  34789. /**
  34790. * Records a vertex array object
  34791. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34792. * @param vertexBuffers defines the list of vertex buffers to store
  34793. * @param indexBuffer defines the index buffer to store
  34794. * @param effect defines the effect to store
  34795. * @returns the new vertex array object
  34796. */
  34797. recordVertexArrayObject(vertexBuffers: {
  34798. [key: string]: VertexBuffer;
  34799. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  34800. /**
  34801. * Bind a specific vertex array object
  34802. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  34803. * @param vertexArrayObject defines the vertex array object to bind
  34804. * @param indexBuffer defines the index buffer to bind
  34805. */
  34806. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  34807. /**
  34808. * Bind webGl buffers directly to the webGL context
  34809. * @param vertexBuffer defines the vertex buffer to bind
  34810. * @param indexBuffer defines the index buffer to bind
  34811. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  34812. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  34813. * @param effect defines the effect associated with the vertex buffer
  34814. */
  34815. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  34816. private _unbindVertexArrayObject;
  34817. /**
  34818. * Bind a list of vertex buffers to the webGL context
  34819. * @param vertexBuffers defines the list of vertex buffers to bind
  34820. * @param indexBuffer defines the index buffer to bind
  34821. * @param effect defines the effect associated with the vertex buffers
  34822. */
  34823. bindBuffers(vertexBuffers: {
  34824. [key: string]: Nullable<VertexBuffer>;
  34825. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  34826. /**
  34827. * Unbind all instance attributes
  34828. */
  34829. unbindInstanceAttributes(): void;
  34830. /**
  34831. * Release and free the memory of a vertex array object
  34832. * @param vao defines the vertex array object to delete
  34833. */
  34834. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  34835. /** @hidden */
  34836. _releaseBuffer(buffer: DataBuffer): boolean;
  34837. protected _deleteBuffer(buffer: DataBuffer): void;
  34838. /**
  34839. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  34840. * @param instancesBuffer defines the webGL buffer to update and bind
  34841. * @param data defines the data to store in the buffer
  34842. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  34843. */
  34844. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  34845. /**
  34846. * Bind the content of a webGL buffer used with instantiation
  34847. * @param instancesBuffer defines the webGL buffer to bind
  34848. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  34849. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  34850. */
  34851. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  34852. /**
  34853. * Disable the instance attribute corresponding to the name in parameter
  34854. * @param name defines the name of the attribute to disable
  34855. */
  34856. disableInstanceAttributeByName(name: string): void;
  34857. /**
  34858. * Disable the instance attribute corresponding to the location in parameter
  34859. * @param attributeLocation defines the attribute location of the attribute to disable
  34860. */
  34861. disableInstanceAttribute(attributeLocation: number): void;
  34862. /**
  34863. * Disable the attribute corresponding to the location in parameter
  34864. * @param attributeLocation defines the attribute location of the attribute to disable
  34865. */
  34866. disableAttributeByIndex(attributeLocation: number): void;
  34867. /**
  34868. * Send a draw order
  34869. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34870. * @param indexStart defines the starting index
  34871. * @param indexCount defines the number of index to draw
  34872. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34873. */
  34874. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  34875. /**
  34876. * Draw a list of points
  34877. * @param verticesStart defines the index of first vertex to draw
  34878. * @param verticesCount defines the count of vertices to draw
  34879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34880. */
  34881. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34882. /**
  34883. * Draw a list of unindexed primitives
  34884. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  34885. * @param verticesStart defines the index of first vertex to draw
  34886. * @param verticesCount defines the count of vertices to draw
  34887. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34888. */
  34889. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34890. /**
  34891. * Draw a list of indexed primitives
  34892. * @param fillMode defines the primitive to use
  34893. * @param indexStart defines the starting index
  34894. * @param indexCount defines the number of index to draw
  34895. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34896. */
  34897. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  34898. /**
  34899. * Draw a list of unindexed primitives
  34900. * @param fillMode defines the primitive to use
  34901. * @param verticesStart defines the index of first vertex to draw
  34902. * @param verticesCount defines the count of vertices to draw
  34903. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  34904. */
  34905. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  34906. private _drawMode;
  34907. /** @hidden */
  34908. protected _reportDrawCall(): void;
  34909. /** @hidden */
  34910. _releaseEffect(effect: Effect): void;
  34911. /** @hidden */
  34912. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34913. /**
  34914. * Create a new effect (used to store vertex/fragment shaders)
  34915. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  34916. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  34917. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  34918. * @param samplers defines an array of string used to represent textures
  34919. * @param defines defines the string containing the defines to use to compile the shaders
  34920. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  34921. * @param onCompiled defines a function to call when the effect creation is successful
  34922. * @param onError defines a function to call when the effect creation has failed
  34923. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  34924. * @returns the new Effect
  34925. */
  34926. 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;
  34927. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  34928. private _compileShader;
  34929. private _compileRawShader;
  34930. /** @hidden */
  34931. _getShaderSource(shader: WebGLShader): Nullable<string>;
  34932. /**
  34933. * Directly creates a webGL program
  34934. * @param pipelineContext defines the pipeline context to attach to
  34935. * @param vertexCode defines the vertex shader code to use
  34936. * @param fragmentCode defines the fragment shader code to use
  34937. * @param context defines the webGL context to use (if not set, the current one will be used)
  34938. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34939. * @returns the new webGL program
  34940. */
  34941. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34942. /**
  34943. * Creates a webGL program
  34944. * @param pipelineContext defines the pipeline context to attach to
  34945. * @param vertexCode defines the vertex shader code to use
  34946. * @param fragmentCode defines the fragment shader code to use
  34947. * @param defines defines the string containing the defines to use to compile the shaders
  34948. * @param context defines the webGL context to use (if not set, the current one will be used)
  34949. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  34950. * @returns the new webGL program
  34951. */
  34952. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34953. /**
  34954. * Creates a new pipeline context
  34955. * @returns the new pipeline
  34956. */
  34957. createPipelineContext(): IPipelineContext;
  34958. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34959. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  34960. /** @hidden */
  34961. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  34962. /** @hidden */
  34963. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  34964. /** @hidden */
  34965. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  34966. /**
  34967. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  34968. * @param pipelineContext defines the pipeline context to use
  34969. * @param uniformsNames defines the list of uniform names
  34970. * @returns an array of webGL uniform locations
  34971. */
  34972. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  34973. /**
  34974. * Gets the lsit of active attributes for a given webGL program
  34975. * @param pipelineContext defines the pipeline context to use
  34976. * @param attributesNames defines the list of attribute names to get
  34977. * @returns an array of indices indicating the offset of each attribute
  34978. */
  34979. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  34980. /**
  34981. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  34982. * @param effect defines the effect to activate
  34983. */
  34984. enableEffect(effect: Nullable<Effect>): void;
  34985. /**
  34986. * Set the value of an uniform to a number (int)
  34987. * @param uniform defines the webGL uniform location where to store the value
  34988. * @param value defines the int number to store
  34989. */
  34990. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  34991. /**
  34992. * Set the value of an uniform to an array of int32
  34993. * @param uniform defines the webGL uniform location where to store the value
  34994. * @param array defines the array of int32 to store
  34995. */
  34996. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  34997. /**
  34998. * Set the value of an uniform to an array of int32 (stored as vec2)
  34999. * @param uniform defines the webGL uniform location where to store the value
  35000. * @param array defines the array of int32 to store
  35001. */
  35002. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35003. /**
  35004. * Set the value of an uniform to an array of int32 (stored as vec3)
  35005. * @param uniform defines the webGL uniform location where to store the value
  35006. * @param array defines the array of int32 to store
  35007. */
  35008. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35009. /**
  35010. * Set the value of an uniform to an array of int32 (stored as vec4)
  35011. * @param uniform defines the webGL uniform location where to store the value
  35012. * @param array defines the array of int32 to store
  35013. */
  35014. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35015. /**
  35016. * Set the value of an uniform to an array of number
  35017. * @param uniform defines the webGL uniform location where to store the value
  35018. * @param array defines the array of number to store
  35019. */
  35020. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35021. /**
  35022. * Set the value of an uniform to an array of number (stored as vec2)
  35023. * @param uniform defines the webGL uniform location where to store the value
  35024. * @param array defines the array of number to store
  35025. */
  35026. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35027. /**
  35028. * Set the value of an uniform to an array of number (stored as vec3)
  35029. * @param uniform defines the webGL uniform location where to store the value
  35030. * @param array defines the array of number to store
  35031. */
  35032. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35033. /**
  35034. * Set the value of an uniform to an array of number (stored as vec4)
  35035. * @param uniform defines the webGL uniform location where to store the value
  35036. * @param array defines the array of number to store
  35037. */
  35038. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35039. /**
  35040. * Set the value of an uniform to an array of float32 (stored as matrices)
  35041. * @param uniform defines the webGL uniform location where to store the value
  35042. * @param matrices defines the array of float32 to store
  35043. */
  35044. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35045. /**
  35046. * Set the value of an uniform to a matrix (3x3)
  35047. * @param uniform defines the webGL uniform location where to store the value
  35048. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35049. */
  35050. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35051. /**
  35052. * Set the value of an uniform to a matrix (2x2)
  35053. * @param uniform defines the webGL uniform location where to store the value
  35054. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35055. */
  35056. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35057. /**
  35058. * Set the value of an uniform to a number (float)
  35059. * @param uniform defines the webGL uniform location where to store the value
  35060. * @param value defines the float number to store
  35061. */
  35062. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35063. /**
  35064. * Set the value of an uniform to a vec2
  35065. * @param uniform defines the webGL uniform location where to store the value
  35066. * @param x defines the 1st component of the value
  35067. * @param y defines the 2nd component of the value
  35068. */
  35069. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35070. /**
  35071. * Set the value of an uniform to a vec3
  35072. * @param uniform defines the webGL uniform location where to store the value
  35073. * @param x defines the 1st component of the value
  35074. * @param y defines the 2nd component of the value
  35075. * @param z defines the 3rd component of the value
  35076. */
  35077. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35078. /**
  35079. * Set the value of an uniform to a vec4
  35080. * @param uniform defines the webGL uniform location where to store the value
  35081. * @param x defines the 1st component of the value
  35082. * @param y defines the 2nd component of the value
  35083. * @param z defines the 3rd component of the value
  35084. * @param w defines the 4th component of the value
  35085. */
  35086. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35087. /**
  35088. * Apply all cached states (depth, culling, stencil and alpha)
  35089. */
  35090. applyStates(): void;
  35091. /**
  35092. * Enable or disable color writing
  35093. * @param enable defines the state to set
  35094. */
  35095. setColorWrite(enable: boolean): void;
  35096. /**
  35097. * Gets a boolean indicating if color writing is enabled
  35098. * @returns the current color writing state
  35099. */
  35100. getColorWrite(): boolean;
  35101. /**
  35102. * Gets the depth culling state manager
  35103. */
  35104. get depthCullingState(): DepthCullingState;
  35105. /**
  35106. * Gets the alpha state manager
  35107. */
  35108. get alphaState(): AlphaState;
  35109. /**
  35110. * Gets the stencil state manager
  35111. */
  35112. get stencilState(): StencilState;
  35113. /**
  35114. * Clears the list of texture accessible through engine.
  35115. * This can help preventing texture load conflict due to name collision.
  35116. */
  35117. clearInternalTexturesCache(): void;
  35118. /**
  35119. * Force the entire cache to be cleared
  35120. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35121. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35122. */
  35123. wipeCaches(bruteForce?: boolean): void;
  35124. /** @hidden */
  35125. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35126. min: number;
  35127. mag: number;
  35128. };
  35129. /** @hidden */
  35130. _createTexture(): WebGLTexture;
  35131. /**
  35132. * Usually called from Texture.ts.
  35133. * Passed information to create a WebGLTexture
  35134. * @param url defines a value which contains one of the following:
  35135. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35136. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35137. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35138. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35139. * @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)
  35140. * @param scene needed for loading to the correct scene
  35141. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35142. * @param onLoad optional callback to be called upon successful completion
  35143. * @param onError optional callback to be called upon failure
  35144. * @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
  35145. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35146. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35147. * @param forcedExtension defines the extension to use to pick the right loader
  35148. * @param mimeType defines an optional mime type
  35149. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35150. */
  35151. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  35152. /**
  35153. * Loads an image as an HTMLImageElement.
  35154. * @param input url string, ArrayBuffer, or Blob to load
  35155. * @param onLoad callback called when the image successfully loads
  35156. * @param onError callback called when the image fails to load
  35157. * @param offlineProvider offline provider for caching
  35158. * @param mimeType optional mime type
  35159. * @returns the HTMLImageElement of the loaded image
  35160. * @hidden
  35161. */
  35162. 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>;
  35163. /**
  35164. * @hidden
  35165. */
  35166. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35167. private _unpackFlipYCached;
  35168. /**
  35169. * In case you are sharing the context with other applications, it might
  35170. * be interested to not cache the unpack flip y state to ensure a consistent
  35171. * value would be set.
  35172. */
  35173. enableUnpackFlipYCached: boolean;
  35174. /** @hidden */
  35175. _unpackFlipY(value: boolean): void;
  35176. /** @hidden */
  35177. _getUnpackAlignement(): number;
  35178. private _getTextureTarget;
  35179. /**
  35180. * Update the sampling mode of a given texture
  35181. * @param samplingMode defines the required sampling mode
  35182. * @param texture defines the texture to update
  35183. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35184. */
  35185. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35186. /**
  35187. * Update the sampling mode of a given texture
  35188. * @param texture defines the texture to update
  35189. * @param wrapU defines the texture wrap mode of the u coordinates
  35190. * @param wrapV defines the texture wrap mode of the v coordinates
  35191. * @param wrapR defines the texture wrap mode of the r coordinates
  35192. */
  35193. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35194. /** @hidden */
  35195. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35196. width: number;
  35197. height: number;
  35198. layers?: number;
  35199. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35200. /** @hidden */
  35201. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35202. /** @hidden */
  35203. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35204. /**
  35205. * Update a portion of an internal texture
  35206. * @param texture defines the texture to update
  35207. * @param imageData defines the data to store into the texture
  35208. * @param xOffset defines the x coordinates of the update rectangle
  35209. * @param yOffset defines the y coordinates of the update rectangle
  35210. * @param width defines the width of the update rectangle
  35211. * @param height defines the height of the update rectangle
  35212. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35213. * @param lod defines the lod level to update (0 by default)
  35214. */
  35215. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35216. /** @hidden */
  35217. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35218. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35219. private _prepareWebGLTexture;
  35220. /** @hidden */
  35221. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35222. private _getDepthStencilBuffer;
  35223. /** @hidden */
  35224. _releaseFramebufferObjects(texture: InternalTexture): void;
  35225. /** @hidden */
  35226. _releaseTexture(texture: InternalTexture): void;
  35227. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35228. protected _setProgram(program: WebGLProgram): void;
  35229. protected _boundUniforms: {
  35230. [key: number]: WebGLUniformLocation;
  35231. };
  35232. /**
  35233. * Binds an effect to the webGL context
  35234. * @param effect defines the effect to bind
  35235. */
  35236. bindSamplers(effect: Effect): void;
  35237. private _activateCurrentTexture;
  35238. /** @hidden */
  35239. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35240. /** @hidden */
  35241. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35242. /**
  35243. * Unbind all textures from the webGL context
  35244. */
  35245. unbindAllTextures(): void;
  35246. /**
  35247. * Sets a texture to the according uniform.
  35248. * @param channel The texture channel
  35249. * @param uniform The uniform to set
  35250. * @param texture The texture to apply
  35251. */
  35252. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35253. private _bindSamplerUniformToChannel;
  35254. private _getTextureWrapMode;
  35255. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35256. /**
  35257. * Sets an array of texture to the webGL context
  35258. * @param channel defines the channel where the texture array must be set
  35259. * @param uniform defines the associated uniform location
  35260. * @param textures defines the array of textures to bind
  35261. */
  35262. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35263. /** @hidden */
  35264. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35265. private _setTextureParameterFloat;
  35266. private _setTextureParameterInteger;
  35267. /**
  35268. * Unbind all vertex attributes from the webGL context
  35269. */
  35270. unbindAllAttributes(): void;
  35271. /**
  35272. * 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
  35273. */
  35274. releaseEffects(): void;
  35275. /**
  35276. * Dispose and release all associated resources
  35277. */
  35278. dispose(): void;
  35279. /**
  35280. * Attach a new callback raised when context lost event is fired
  35281. * @param callback defines the callback to call
  35282. */
  35283. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35284. /**
  35285. * Attach a new callback raised when context restored event is fired
  35286. * @param callback defines the callback to call
  35287. */
  35288. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35289. /**
  35290. * Get the current error code of the webGL context
  35291. * @returns the error code
  35292. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  35293. */
  35294. getError(): number;
  35295. private _canRenderToFloatFramebuffer;
  35296. private _canRenderToHalfFloatFramebuffer;
  35297. private _canRenderToFramebuffer;
  35298. /** @hidden */
  35299. _getWebGLTextureType(type: number): number;
  35300. /** @hidden */
  35301. _getInternalFormat(format: number): number;
  35302. /** @hidden */
  35303. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  35304. /** @hidden */
  35305. _getRGBAMultiSampleBufferFormat(type: number): number;
  35306. /** @hidden */
  35307. _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;
  35308. /**
  35309. * Loads a file from a url
  35310. * @param url url to load
  35311. * @param onSuccess callback called when the file successfully loads
  35312. * @param onProgress callback called while file is loading (if the server supports this mode)
  35313. * @param offlineProvider defines the offline provider for caching
  35314. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35315. * @param onError callback called when the file fails to load
  35316. * @returns a file request object
  35317. * @hidden
  35318. */
  35319. 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;
  35320. /**
  35321. * Reads pixels from the current frame buffer. Please note that this function can be slow
  35322. * @param x defines the x coordinate of the rectangle where pixels must be read
  35323. * @param y defines the y coordinate of the rectangle where pixels must be read
  35324. * @param width defines the width of the rectangle where pixels must be read
  35325. * @param height defines the height of the rectangle where pixels must be read
  35326. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  35327. * @returns a Uint8Array containing RGBA colors
  35328. */
  35329. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  35330. private static _isSupported;
  35331. /**
  35332. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  35333. * @returns true if the engine can be created
  35334. * @ignorenaming
  35335. */
  35336. static isSupported(): boolean;
  35337. /**
  35338. * Find the next highest power of two.
  35339. * @param x Number to start search from.
  35340. * @return Next highest power of two.
  35341. */
  35342. static CeilingPOT(x: number): number;
  35343. /**
  35344. * Find the next lowest power of two.
  35345. * @param x Number to start search from.
  35346. * @return Next lowest power of two.
  35347. */
  35348. static FloorPOT(x: number): number;
  35349. /**
  35350. * Find the nearest power of two.
  35351. * @param x Number to start search from.
  35352. * @return Next nearest power of two.
  35353. */
  35354. static NearestPOT(x: number): number;
  35355. /**
  35356. * Get the closest exponent of two
  35357. * @param value defines the value to approximate
  35358. * @param max defines the maximum value to return
  35359. * @param mode defines how to define the closest value
  35360. * @returns closest exponent of two of the given value
  35361. */
  35362. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  35363. /**
  35364. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  35365. * @param func - the function to be called
  35366. * @param requester - the object that will request the next frame. Falls back to window.
  35367. * @returns frame number
  35368. */
  35369. static QueueNewFrame(func: () => void, requester?: any): number;
  35370. /**
  35371. * Gets host document
  35372. * @returns the host document object
  35373. */
  35374. getHostDocument(): Nullable<Document>;
  35375. }
  35376. }
  35377. declare module BABYLON {
  35378. /**
  35379. * Class representing spherical harmonics coefficients to the 3rd degree
  35380. */
  35381. export class SphericalHarmonics {
  35382. /**
  35383. * Defines whether or not the harmonics have been prescaled for rendering.
  35384. */
  35385. preScaled: boolean;
  35386. /**
  35387. * The l0,0 coefficients of the spherical harmonics
  35388. */
  35389. l00: Vector3;
  35390. /**
  35391. * The l1,-1 coefficients of the spherical harmonics
  35392. */
  35393. l1_1: Vector3;
  35394. /**
  35395. * The l1,0 coefficients of the spherical harmonics
  35396. */
  35397. l10: Vector3;
  35398. /**
  35399. * The l1,1 coefficients of the spherical harmonics
  35400. */
  35401. l11: Vector3;
  35402. /**
  35403. * The l2,-2 coefficients of the spherical harmonics
  35404. */
  35405. l2_2: Vector3;
  35406. /**
  35407. * The l2,-1 coefficients of the spherical harmonics
  35408. */
  35409. l2_1: Vector3;
  35410. /**
  35411. * The l2,0 coefficients of the spherical harmonics
  35412. */
  35413. l20: Vector3;
  35414. /**
  35415. * The l2,1 coefficients of the spherical harmonics
  35416. */
  35417. l21: Vector3;
  35418. /**
  35419. * The l2,2 coefficients of the spherical harmonics
  35420. */
  35421. l22: Vector3;
  35422. /**
  35423. * Adds a light to the spherical harmonics
  35424. * @param direction the direction of the light
  35425. * @param color the color of the light
  35426. * @param deltaSolidAngle the delta solid angle of the light
  35427. */
  35428. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  35429. /**
  35430. * Scales the spherical harmonics by the given amount
  35431. * @param scale the amount to scale
  35432. */
  35433. scaleInPlace(scale: number): void;
  35434. /**
  35435. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  35436. *
  35437. * ```
  35438. * E_lm = A_l * L_lm
  35439. * ```
  35440. *
  35441. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  35442. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  35443. * the scaling factors are given in equation 9.
  35444. */
  35445. convertIncidentRadianceToIrradiance(): void;
  35446. /**
  35447. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  35448. *
  35449. * ```
  35450. * L = (1/pi) * E * rho
  35451. * ```
  35452. *
  35453. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  35454. */
  35455. convertIrradianceToLambertianRadiance(): void;
  35456. /**
  35457. * Integrates the reconstruction coefficients directly in to the SH preventing further
  35458. * required operations at run time.
  35459. *
  35460. * This is simply done by scaling back the SH with Ylm constants parameter.
  35461. * The trigonometric part being applied by the shader at run time.
  35462. */
  35463. preScaleForRendering(): void;
  35464. /**
  35465. * Constructs a spherical harmonics from an array.
  35466. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  35467. * @returns the spherical harmonics
  35468. */
  35469. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  35470. /**
  35471. * Gets the spherical harmonics from polynomial
  35472. * @param polynomial the spherical polynomial
  35473. * @returns the spherical harmonics
  35474. */
  35475. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  35476. }
  35477. /**
  35478. * Class representing spherical polynomial coefficients to the 3rd degree
  35479. */
  35480. export class SphericalPolynomial {
  35481. private _harmonics;
  35482. /**
  35483. * The spherical harmonics used to create the polynomials.
  35484. */
  35485. get preScaledHarmonics(): SphericalHarmonics;
  35486. /**
  35487. * The x coefficients of the spherical polynomial
  35488. */
  35489. x: Vector3;
  35490. /**
  35491. * The y coefficients of the spherical polynomial
  35492. */
  35493. y: Vector3;
  35494. /**
  35495. * The z coefficients of the spherical polynomial
  35496. */
  35497. z: Vector3;
  35498. /**
  35499. * The xx coefficients of the spherical polynomial
  35500. */
  35501. xx: Vector3;
  35502. /**
  35503. * The yy coefficients of the spherical polynomial
  35504. */
  35505. yy: Vector3;
  35506. /**
  35507. * The zz coefficients of the spherical polynomial
  35508. */
  35509. zz: Vector3;
  35510. /**
  35511. * The xy coefficients of the spherical polynomial
  35512. */
  35513. xy: Vector3;
  35514. /**
  35515. * The yz coefficients of the spherical polynomial
  35516. */
  35517. yz: Vector3;
  35518. /**
  35519. * The zx coefficients of the spherical polynomial
  35520. */
  35521. zx: Vector3;
  35522. /**
  35523. * Adds an ambient color to the spherical polynomial
  35524. * @param color the color to add
  35525. */
  35526. addAmbient(color: Color3): void;
  35527. /**
  35528. * Scales the spherical polynomial by the given amount
  35529. * @param scale the amount to scale
  35530. */
  35531. scaleInPlace(scale: number): void;
  35532. /**
  35533. * Gets the spherical polynomial from harmonics
  35534. * @param harmonics the spherical harmonics
  35535. * @returns the spherical polynomial
  35536. */
  35537. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  35538. /**
  35539. * Constructs a spherical polynomial from an array.
  35540. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  35541. * @returns the spherical polynomial
  35542. */
  35543. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  35544. }
  35545. }
  35546. declare module BABYLON {
  35547. /**
  35548. * Defines the source of the internal texture
  35549. */
  35550. export enum InternalTextureSource {
  35551. /**
  35552. * The source of the texture data is unknown
  35553. */
  35554. Unknown = 0,
  35555. /**
  35556. * Texture data comes from an URL
  35557. */
  35558. Url = 1,
  35559. /**
  35560. * Texture data is only used for temporary storage
  35561. */
  35562. Temp = 2,
  35563. /**
  35564. * Texture data comes from raw data (ArrayBuffer)
  35565. */
  35566. Raw = 3,
  35567. /**
  35568. * Texture content is dynamic (video or dynamic texture)
  35569. */
  35570. Dynamic = 4,
  35571. /**
  35572. * Texture content is generated by rendering to it
  35573. */
  35574. RenderTarget = 5,
  35575. /**
  35576. * Texture content is part of a multi render target process
  35577. */
  35578. MultiRenderTarget = 6,
  35579. /**
  35580. * Texture data comes from a cube data file
  35581. */
  35582. Cube = 7,
  35583. /**
  35584. * Texture data comes from a raw cube data
  35585. */
  35586. CubeRaw = 8,
  35587. /**
  35588. * Texture data come from a prefiltered cube data file
  35589. */
  35590. CubePrefiltered = 9,
  35591. /**
  35592. * Texture content is raw 3D data
  35593. */
  35594. Raw3D = 10,
  35595. /**
  35596. * Texture content is raw 2D array data
  35597. */
  35598. Raw2DArray = 11,
  35599. /**
  35600. * Texture content is a depth texture
  35601. */
  35602. Depth = 12,
  35603. /**
  35604. * Texture data comes from a raw cube data encoded with RGBD
  35605. */
  35606. CubeRawRGBD = 13
  35607. }
  35608. /**
  35609. * Class used to store data associated with WebGL texture data for the engine
  35610. * This class should not be used directly
  35611. */
  35612. export class InternalTexture {
  35613. /** @hidden */
  35614. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  35615. /**
  35616. * Defines if the texture is ready
  35617. */
  35618. isReady: boolean;
  35619. /**
  35620. * Defines if the texture is a cube texture
  35621. */
  35622. isCube: boolean;
  35623. /**
  35624. * Defines if the texture contains 3D data
  35625. */
  35626. is3D: boolean;
  35627. /**
  35628. * Defines if the texture contains 2D array data
  35629. */
  35630. is2DArray: boolean;
  35631. /**
  35632. * Defines if the texture contains multiview data
  35633. */
  35634. isMultiview: boolean;
  35635. /**
  35636. * Gets the URL used to load this texture
  35637. */
  35638. url: string;
  35639. /**
  35640. * Gets the sampling mode of the texture
  35641. */
  35642. samplingMode: number;
  35643. /**
  35644. * Gets a boolean indicating if the texture needs mipmaps generation
  35645. */
  35646. generateMipMaps: boolean;
  35647. /**
  35648. * Gets the number of samples used by the texture (WebGL2+ only)
  35649. */
  35650. samples: number;
  35651. /**
  35652. * Gets the type of the texture (int, float...)
  35653. */
  35654. type: number;
  35655. /**
  35656. * Gets the format of the texture (RGB, RGBA...)
  35657. */
  35658. format: number;
  35659. /**
  35660. * Observable called when the texture is loaded
  35661. */
  35662. onLoadedObservable: Observable<InternalTexture>;
  35663. /**
  35664. * Gets the width of the texture
  35665. */
  35666. width: number;
  35667. /**
  35668. * Gets the height of the texture
  35669. */
  35670. height: number;
  35671. /**
  35672. * Gets the depth of the texture
  35673. */
  35674. depth: number;
  35675. /**
  35676. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  35677. */
  35678. baseWidth: number;
  35679. /**
  35680. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  35681. */
  35682. baseHeight: number;
  35683. /**
  35684. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  35685. */
  35686. baseDepth: number;
  35687. /**
  35688. * Gets a boolean indicating if the texture is inverted on Y axis
  35689. */
  35690. invertY: boolean;
  35691. /** @hidden */
  35692. _invertVScale: boolean;
  35693. /** @hidden */
  35694. _associatedChannel: number;
  35695. /** @hidden */
  35696. _source: InternalTextureSource;
  35697. /** @hidden */
  35698. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  35699. /** @hidden */
  35700. _bufferView: Nullable<ArrayBufferView>;
  35701. /** @hidden */
  35702. _bufferViewArray: Nullable<ArrayBufferView[]>;
  35703. /** @hidden */
  35704. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  35705. /** @hidden */
  35706. _size: number;
  35707. /** @hidden */
  35708. _extension: string;
  35709. /** @hidden */
  35710. _files: Nullable<string[]>;
  35711. /** @hidden */
  35712. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35713. /** @hidden */
  35714. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35715. /** @hidden */
  35716. _framebuffer: Nullable<WebGLFramebuffer>;
  35717. /** @hidden */
  35718. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  35719. /** @hidden */
  35720. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  35721. /** @hidden */
  35722. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  35723. /** @hidden */
  35724. _attachments: Nullable<number[]>;
  35725. /** @hidden */
  35726. _textureArray: Nullable<InternalTexture[]>;
  35727. /** @hidden */
  35728. _cachedCoordinatesMode: Nullable<number>;
  35729. /** @hidden */
  35730. _cachedWrapU: Nullable<number>;
  35731. /** @hidden */
  35732. _cachedWrapV: Nullable<number>;
  35733. /** @hidden */
  35734. _cachedWrapR: Nullable<number>;
  35735. /** @hidden */
  35736. _cachedAnisotropicFilteringLevel: Nullable<number>;
  35737. /** @hidden */
  35738. _isDisabled: boolean;
  35739. /** @hidden */
  35740. _compression: Nullable<string>;
  35741. /** @hidden */
  35742. _generateStencilBuffer: boolean;
  35743. /** @hidden */
  35744. _generateDepthBuffer: boolean;
  35745. /** @hidden */
  35746. _comparisonFunction: number;
  35747. /** @hidden */
  35748. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  35749. /** @hidden */
  35750. _lodGenerationScale: number;
  35751. /** @hidden */
  35752. _lodGenerationOffset: number;
  35753. /** @hidden */
  35754. _depthStencilTexture: Nullable<InternalTexture>;
  35755. /** @hidden */
  35756. _colorTextureArray: Nullable<WebGLTexture>;
  35757. /** @hidden */
  35758. _depthStencilTextureArray: Nullable<WebGLTexture>;
  35759. /** @hidden */
  35760. _lodTextureHigh: Nullable<BaseTexture>;
  35761. /** @hidden */
  35762. _lodTextureMid: Nullable<BaseTexture>;
  35763. /** @hidden */
  35764. _lodTextureLow: Nullable<BaseTexture>;
  35765. /** @hidden */
  35766. _isRGBD: boolean;
  35767. /** @hidden */
  35768. _linearSpecularLOD: boolean;
  35769. /** @hidden */
  35770. _irradianceTexture: Nullable<BaseTexture>;
  35771. /** @hidden */
  35772. _webGLTexture: Nullable<WebGLTexture>;
  35773. /** @hidden */
  35774. _references: number;
  35775. private _engine;
  35776. /**
  35777. * Gets the Engine the texture belongs to.
  35778. * @returns The babylon engine
  35779. */
  35780. getEngine(): ThinEngine;
  35781. /**
  35782. * Gets the data source type of the texture
  35783. */
  35784. get source(): InternalTextureSource;
  35785. /**
  35786. * Creates a new InternalTexture
  35787. * @param engine defines the engine to use
  35788. * @param source defines the type of data that will be used
  35789. * @param delayAllocation if the texture allocation should be delayed (default: false)
  35790. */
  35791. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  35792. /**
  35793. * Increments the number of references (ie. the number of Texture that point to it)
  35794. */
  35795. incrementReferences(): void;
  35796. /**
  35797. * Change the size of the texture (not the size of the content)
  35798. * @param width defines the new width
  35799. * @param height defines the new height
  35800. * @param depth defines the new depth (1 by default)
  35801. */
  35802. updateSize(width: int, height: int, depth?: int): void;
  35803. /** @hidden */
  35804. _rebuild(): void;
  35805. /** @hidden */
  35806. _swapAndDie(target: InternalTexture): void;
  35807. /**
  35808. * Dispose the current allocated resources
  35809. */
  35810. dispose(): void;
  35811. }
  35812. }
  35813. declare module BABYLON {
  35814. /**
  35815. * Class used to work with sound analyzer using fast fourier transform (FFT)
  35816. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35817. */
  35818. export class Analyser {
  35819. /**
  35820. * Gets or sets the smoothing
  35821. * @ignorenaming
  35822. */
  35823. SMOOTHING: number;
  35824. /**
  35825. * Gets or sets the FFT table size
  35826. * @ignorenaming
  35827. */
  35828. FFT_SIZE: number;
  35829. /**
  35830. * Gets or sets the bar graph amplitude
  35831. * @ignorenaming
  35832. */
  35833. BARGRAPHAMPLITUDE: number;
  35834. /**
  35835. * Gets or sets the position of the debug canvas
  35836. * @ignorenaming
  35837. */
  35838. DEBUGCANVASPOS: {
  35839. x: number;
  35840. y: number;
  35841. };
  35842. /**
  35843. * Gets or sets the debug canvas size
  35844. * @ignorenaming
  35845. */
  35846. DEBUGCANVASSIZE: {
  35847. width: number;
  35848. height: number;
  35849. };
  35850. private _byteFreqs;
  35851. private _byteTime;
  35852. private _floatFreqs;
  35853. private _webAudioAnalyser;
  35854. private _debugCanvas;
  35855. private _debugCanvasContext;
  35856. private _scene;
  35857. private _registerFunc;
  35858. private _audioEngine;
  35859. /**
  35860. * Creates a new analyser
  35861. * @param scene defines hosting scene
  35862. */
  35863. constructor(scene: Scene);
  35864. /**
  35865. * Get the number of data values you will have to play with for the visualization
  35866. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  35867. * @returns a number
  35868. */
  35869. getFrequencyBinCount(): number;
  35870. /**
  35871. * Gets the current frequency data as a byte array
  35872. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35873. * @returns a Uint8Array
  35874. */
  35875. getByteFrequencyData(): Uint8Array;
  35876. /**
  35877. * Gets the current waveform as a byte array
  35878. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  35879. * @returns a Uint8Array
  35880. */
  35881. getByteTimeDomainData(): Uint8Array;
  35882. /**
  35883. * Gets the current frequency data as a float array
  35884. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  35885. * @returns a Float32Array
  35886. */
  35887. getFloatFrequencyData(): Float32Array;
  35888. /**
  35889. * Renders the debug canvas
  35890. */
  35891. drawDebugCanvas(): void;
  35892. /**
  35893. * Stops rendering the debug canvas and removes it
  35894. */
  35895. stopDebugCanvas(): void;
  35896. /**
  35897. * Connects two audio nodes
  35898. * @param inputAudioNode defines first node to connect
  35899. * @param outputAudioNode defines second node to connect
  35900. */
  35901. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  35902. /**
  35903. * Releases all associated resources
  35904. */
  35905. dispose(): void;
  35906. }
  35907. }
  35908. declare module BABYLON {
  35909. /**
  35910. * This represents an audio engine and it is responsible
  35911. * to play, synchronize and analyse sounds throughout the application.
  35912. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35913. */
  35914. export interface IAudioEngine extends IDisposable {
  35915. /**
  35916. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35917. */
  35918. readonly canUseWebAudio: boolean;
  35919. /**
  35920. * Gets the current AudioContext if available.
  35921. */
  35922. readonly audioContext: Nullable<AudioContext>;
  35923. /**
  35924. * The master gain node defines the global audio volume of your audio engine.
  35925. */
  35926. readonly masterGain: GainNode;
  35927. /**
  35928. * Gets whether or not mp3 are supported by your browser.
  35929. */
  35930. readonly isMP3supported: boolean;
  35931. /**
  35932. * Gets whether or not ogg are supported by your browser.
  35933. */
  35934. readonly isOGGsupported: boolean;
  35935. /**
  35936. * Defines if Babylon should emit a warning if WebAudio is not supported.
  35937. * @ignoreNaming
  35938. */
  35939. WarnedWebAudioUnsupported: boolean;
  35940. /**
  35941. * Defines if the audio engine relies on a custom unlocked button.
  35942. * In this case, the embedded button will not be displayed.
  35943. */
  35944. useCustomUnlockedButton: boolean;
  35945. /**
  35946. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  35947. */
  35948. readonly unlocked: boolean;
  35949. /**
  35950. * Event raised when audio has been unlocked on the browser.
  35951. */
  35952. onAudioUnlockedObservable: Observable<AudioEngine>;
  35953. /**
  35954. * Event raised when audio has been locked on the browser.
  35955. */
  35956. onAudioLockedObservable: Observable<AudioEngine>;
  35957. /**
  35958. * Flags the audio engine in Locked state.
  35959. * This happens due to new browser policies preventing audio to autoplay.
  35960. */
  35961. lock(): void;
  35962. /**
  35963. * Unlocks the audio engine once a user action has been done on the dom.
  35964. * This is helpful to resume play once browser policies have been satisfied.
  35965. */
  35966. unlock(): void;
  35967. /**
  35968. * Gets the global volume sets on the master gain.
  35969. * @returns the global volume if set or -1 otherwise
  35970. */
  35971. getGlobalVolume(): number;
  35972. /**
  35973. * Sets the global volume of your experience (sets on the master gain).
  35974. * @param newVolume Defines the new global volume of the application
  35975. */
  35976. setGlobalVolume(newVolume: number): void;
  35977. /**
  35978. * Connect the audio engine to an audio analyser allowing some amazing
  35979. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35980. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35981. * @param analyser The analyser to connect to the engine
  35982. */
  35983. connectToAnalyser(analyser: Analyser): void;
  35984. }
  35985. /**
  35986. * This represents the default audio engine used in babylon.
  35987. * It is responsible to play, synchronize and analyse sounds throughout the application.
  35988. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35989. */
  35990. export class AudioEngine implements IAudioEngine {
  35991. private _audioContext;
  35992. private _audioContextInitialized;
  35993. private _muteButton;
  35994. private _hostElement;
  35995. /**
  35996. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  35997. */
  35998. canUseWebAudio: boolean;
  35999. /**
  36000. * The master gain node defines the global audio volume of your audio engine.
  36001. */
  36002. masterGain: GainNode;
  36003. /**
  36004. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36005. * @ignoreNaming
  36006. */
  36007. WarnedWebAudioUnsupported: boolean;
  36008. /**
  36009. * Gets whether or not mp3 are supported by your browser.
  36010. */
  36011. isMP3supported: boolean;
  36012. /**
  36013. * Gets whether or not ogg are supported by your browser.
  36014. */
  36015. isOGGsupported: boolean;
  36016. /**
  36017. * Gets whether audio has been unlocked on the device.
  36018. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36019. * a user interaction has happened.
  36020. */
  36021. unlocked: boolean;
  36022. /**
  36023. * Defines if the audio engine relies on a custom unlocked button.
  36024. * In this case, the embedded button will not be displayed.
  36025. */
  36026. useCustomUnlockedButton: boolean;
  36027. /**
  36028. * Event raised when audio has been unlocked on the browser.
  36029. */
  36030. onAudioUnlockedObservable: Observable<AudioEngine>;
  36031. /**
  36032. * Event raised when audio has been locked on the browser.
  36033. */
  36034. onAudioLockedObservable: Observable<AudioEngine>;
  36035. /**
  36036. * Gets the current AudioContext if available.
  36037. */
  36038. get audioContext(): Nullable<AudioContext>;
  36039. private _connectedAnalyser;
  36040. /**
  36041. * Instantiates a new audio engine.
  36042. *
  36043. * There should be only one per page as some browsers restrict the number
  36044. * of audio contexts you can create.
  36045. * @param hostElement defines the host element where to display the mute icon if necessary
  36046. */
  36047. constructor(hostElement?: Nullable<HTMLElement>);
  36048. /**
  36049. * Flags the audio engine in Locked state.
  36050. * This happens due to new browser policies preventing audio to autoplay.
  36051. */
  36052. lock(): void;
  36053. /**
  36054. * Unlocks the audio engine once a user action has been done on the dom.
  36055. * This is helpful to resume play once browser policies have been satisfied.
  36056. */
  36057. unlock(): void;
  36058. private _resumeAudioContext;
  36059. private _initializeAudioContext;
  36060. private _tryToRun;
  36061. private _triggerRunningState;
  36062. private _triggerSuspendedState;
  36063. private _displayMuteButton;
  36064. private _moveButtonToTopLeft;
  36065. private _onResize;
  36066. private _hideMuteButton;
  36067. /**
  36068. * Destroy and release the resources associated with the audio ccontext.
  36069. */
  36070. dispose(): void;
  36071. /**
  36072. * Gets the global volume sets on the master gain.
  36073. * @returns the global volume if set or -1 otherwise
  36074. */
  36075. getGlobalVolume(): number;
  36076. /**
  36077. * Sets the global volume of your experience (sets on the master gain).
  36078. * @param newVolume Defines the new global volume of the application
  36079. */
  36080. setGlobalVolume(newVolume: number): void;
  36081. /**
  36082. * Connect the audio engine to an audio analyser allowing some amazing
  36083. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36084. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36085. * @param analyser The analyser to connect to the engine
  36086. */
  36087. connectToAnalyser(analyser: Analyser): void;
  36088. }
  36089. }
  36090. declare module BABYLON {
  36091. /**
  36092. * Interface used to present a loading screen while loading a scene
  36093. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36094. */
  36095. export interface ILoadingScreen {
  36096. /**
  36097. * Function called to display the loading screen
  36098. */
  36099. displayLoadingUI: () => void;
  36100. /**
  36101. * Function called to hide the loading screen
  36102. */
  36103. hideLoadingUI: () => void;
  36104. /**
  36105. * Gets or sets the color to use for the background
  36106. */
  36107. loadingUIBackgroundColor: string;
  36108. /**
  36109. * Gets or sets the text to display while loading
  36110. */
  36111. loadingUIText: string;
  36112. }
  36113. /**
  36114. * Class used for the default loading screen
  36115. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36116. */
  36117. export class DefaultLoadingScreen implements ILoadingScreen {
  36118. private _renderingCanvas;
  36119. private _loadingText;
  36120. private _loadingDivBackgroundColor;
  36121. private _loadingDiv;
  36122. private _loadingTextDiv;
  36123. /** Gets or sets the logo url to use for the default loading screen */
  36124. static DefaultLogoUrl: string;
  36125. /** Gets or sets the spinner url to use for the default loading screen */
  36126. static DefaultSpinnerUrl: string;
  36127. /**
  36128. * Creates a new default loading screen
  36129. * @param _renderingCanvas defines the canvas used to render the scene
  36130. * @param _loadingText defines the default text to display
  36131. * @param _loadingDivBackgroundColor defines the default background color
  36132. */
  36133. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36134. /**
  36135. * Function called to display the loading screen
  36136. */
  36137. displayLoadingUI(): void;
  36138. /**
  36139. * Function called to hide the loading screen
  36140. */
  36141. hideLoadingUI(): void;
  36142. /**
  36143. * Gets or sets the text to display while loading
  36144. */
  36145. set loadingUIText(text: string);
  36146. get loadingUIText(): string;
  36147. /**
  36148. * Gets or sets the color to use for the background
  36149. */
  36150. get loadingUIBackgroundColor(): string;
  36151. set loadingUIBackgroundColor(color: string);
  36152. private _resizeLoadingUI;
  36153. }
  36154. }
  36155. declare module BABYLON {
  36156. /**
  36157. * Interface for any object that can request an animation frame
  36158. */
  36159. export interface ICustomAnimationFrameRequester {
  36160. /**
  36161. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36162. */
  36163. renderFunction?: Function;
  36164. /**
  36165. * Called to request the next frame to render to
  36166. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36167. */
  36168. requestAnimationFrame: Function;
  36169. /**
  36170. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36171. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36172. */
  36173. requestID?: number;
  36174. }
  36175. }
  36176. declare module BABYLON {
  36177. /**
  36178. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36179. */
  36180. export class PerformanceMonitor {
  36181. private _enabled;
  36182. private _rollingFrameTime;
  36183. private _lastFrameTimeMs;
  36184. /**
  36185. * constructor
  36186. * @param frameSampleSize The number of samples required to saturate the sliding window
  36187. */
  36188. constructor(frameSampleSize?: number);
  36189. /**
  36190. * Samples current frame
  36191. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36192. */
  36193. sampleFrame(timeMs?: number): void;
  36194. /**
  36195. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36196. */
  36197. get averageFrameTime(): number;
  36198. /**
  36199. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36200. */
  36201. get averageFrameTimeVariance(): number;
  36202. /**
  36203. * Returns the frame time of the most recent frame
  36204. */
  36205. get instantaneousFrameTime(): number;
  36206. /**
  36207. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36208. */
  36209. get averageFPS(): number;
  36210. /**
  36211. * Returns the average framerate in frames per second using the most recent frame time
  36212. */
  36213. get instantaneousFPS(): number;
  36214. /**
  36215. * Returns true if enough samples have been taken to completely fill the sliding window
  36216. */
  36217. get isSaturated(): boolean;
  36218. /**
  36219. * Enables contributions to the sliding window sample set
  36220. */
  36221. enable(): void;
  36222. /**
  36223. * Disables contributions to the sliding window sample set
  36224. * Samples will not be interpolated over the disabled period
  36225. */
  36226. disable(): void;
  36227. /**
  36228. * Returns true if sampling is enabled
  36229. */
  36230. get isEnabled(): boolean;
  36231. /**
  36232. * Resets performance monitor
  36233. */
  36234. reset(): void;
  36235. }
  36236. /**
  36237. * RollingAverage
  36238. *
  36239. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36240. */
  36241. export class RollingAverage {
  36242. /**
  36243. * Current average
  36244. */
  36245. average: number;
  36246. /**
  36247. * Current variance
  36248. */
  36249. variance: number;
  36250. protected _samples: Array<number>;
  36251. protected _sampleCount: number;
  36252. protected _pos: number;
  36253. protected _m2: number;
  36254. /**
  36255. * constructor
  36256. * @param length The number of samples required to saturate the sliding window
  36257. */
  36258. constructor(length: number);
  36259. /**
  36260. * Adds a sample to the sample set
  36261. * @param v The sample value
  36262. */
  36263. add(v: number): void;
  36264. /**
  36265. * Returns previously added values or null if outside of history or outside the sliding window domain
  36266. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36267. * @return Value previously recorded with add() or null if outside of range
  36268. */
  36269. history(i: number): number;
  36270. /**
  36271. * Returns true if enough samples have been taken to completely fill the sliding window
  36272. * @return true if sample-set saturated
  36273. */
  36274. isSaturated(): boolean;
  36275. /**
  36276. * Resets the rolling average (equivalent to 0 samples taken so far)
  36277. */
  36278. reset(): void;
  36279. /**
  36280. * Wraps a value around the sample range boundaries
  36281. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36282. * @return Wrapped position in sample range
  36283. */
  36284. protected _wrapPosition(i: number): number;
  36285. }
  36286. }
  36287. declare module BABYLON {
  36288. /**
  36289. * This class is used to track a performance counter which is number based.
  36290. * The user has access to many properties which give statistics of different nature.
  36291. *
  36292. * The implementer can track two kinds of Performance Counter: time and count.
  36293. * 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.
  36294. * 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.
  36295. */
  36296. export class PerfCounter {
  36297. /**
  36298. * Gets or sets a global boolean to turn on and off all the counters
  36299. */
  36300. static Enabled: boolean;
  36301. /**
  36302. * Returns the smallest value ever
  36303. */
  36304. get min(): number;
  36305. /**
  36306. * Returns the biggest value ever
  36307. */
  36308. get max(): number;
  36309. /**
  36310. * Returns the average value since the performance counter is running
  36311. */
  36312. get average(): number;
  36313. /**
  36314. * Returns the average value of the last second the counter was monitored
  36315. */
  36316. get lastSecAverage(): number;
  36317. /**
  36318. * Returns the current value
  36319. */
  36320. get current(): number;
  36321. /**
  36322. * Gets the accumulated total
  36323. */
  36324. get total(): number;
  36325. /**
  36326. * Gets the total value count
  36327. */
  36328. get count(): number;
  36329. /**
  36330. * Creates a new counter
  36331. */
  36332. constructor();
  36333. /**
  36334. * Call this method to start monitoring a new frame.
  36335. * 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.
  36336. */
  36337. fetchNewFrame(): void;
  36338. /**
  36339. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  36340. * @param newCount the count value to add to the monitored count
  36341. * @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.
  36342. */
  36343. addCount(newCount: number, fetchResult: boolean): void;
  36344. /**
  36345. * Start monitoring this performance counter
  36346. */
  36347. beginMonitoring(): void;
  36348. /**
  36349. * Compute the time lapsed since the previous beginMonitoring() call.
  36350. * @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
  36351. */
  36352. endMonitoring(newFrame?: boolean): void;
  36353. private _fetchResult;
  36354. private _startMonitoringTime;
  36355. private _min;
  36356. private _max;
  36357. private _average;
  36358. private _current;
  36359. private _totalValueCount;
  36360. private _totalAccumulated;
  36361. private _lastSecAverage;
  36362. private _lastSecAccumulated;
  36363. private _lastSecTime;
  36364. private _lastSecValueCount;
  36365. }
  36366. }
  36367. declare module BABYLON {
  36368. interface ThinEngine {
  36369. /**
  36370. * Sets alpha constants used by some alpha blending modes
  36371. * @param r defines the red component
  36372. * @param g defines the green component
  36373. * @param b defines the blue component
  36374. * @param a defines the alpha component
  36375. */
  36376. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  36377. /**
  36378. * Sets the current alpha mode
  36379. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  36380. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  36381. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36382. */
  36383. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  36384. /**
  36385. * Gets the current alpha mode
  36386. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  36387. * @returns the current alpha mode
  36388. */
  36389. getAlphaMode(): number;
  36390. /**
  36391. * Sets the current alpha equation
  36392. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  36393. */
  36394. setAlphaEquation(equation: number): void;
  36395. /**
  36396. * Gets the current alpha equation.
  36397. * @returns the current alpha equation
  36398. */
  36399. getAlphaEquation(): number;
  36400. }
  36401. }
  36402. declare module BABYLON {
  36403. interface ThinEngine {
  36404. /** @hidden */
  36405. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  36406. }
  36407. }
  36408. declare module BABYLON {
  36409. /**
  36410. * Defines the interface used by display changed events
  36411. */
  36412. export interface IDisplayChangedEventArgs {
  36413. /** Gets the vrDisplay object (if any) */
  36414. vrDisplay: Nullable<any>;
  36415. /** Gets a boolean indicating if webVR is supported */
  36416. vrSupported: boolean;
  36417. }
  36418. /**
  36419. * Defines the interface used by objects containing a viewport (like a camera)
  36420. */
  36421. interface IViewportOwnerLike {
  36422. /**
  36423. * Gets or sets the viewport
  36424. */
  36425. viewport: IViewportLike;
  36426. }
  36427. /**
  36428. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  36429. */
  36430. export class Engine extends ThinEngine {
  36431. /** Defines that alpha blending is disabled */
  36432. static readonly ALPHA_DISABLE: number;
  36433. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  36434. static readonly ALPHA_ADD: number;
  36435. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  36436. static readonly ALPHA_COMBINE: number;
  36437. /** Defines that alpha blending to DEST - SRC * DEST */
  36438. static readonly ALPHA_SUBTRACT: number;
  36439. /** Defines that alpha blending to SRC * DEST */
  36440. static readonly ALPHA_MULTIPLY: number;
  36441. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  36442. static readonly ALPHA_MAXIMIZED: number;
  36443. /** Defines that alpha blending to SRC + DEST */
  36444. static readonly ALPHA_ONEONE: number;
  36445. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  36446. static readonly ALPHA_PREMULTIPLIED: number;
  36447. /**
  36448. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  36449. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  36450. */
  36451. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  36452. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  36453. static readonly ALPHA_INTERPOLATE: number;
  36454. /**
  36455. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  36456. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  36457. */
  36458. static readonly ALPHA_SCREENMODE: number;
  36459. /** Defines that the ressource is not delayed*/
  36460. static readonly DELAYLOADSTATE_NONE: number;
  36461. /** Defines that the ressource was successfully delay loaded */
  36462. static readonly DELAYLOADSTATE_LOADED: number;
  36463. /** Defines that the ressource is currently delay loading */
  36464. static readonly DELAYLOADSTATE_LOADING: number;
  36465. /** Defines that the ressource is delayed and has not started loading */
  36466. static readonly DELAYLOADSTATE_NOTLOADED: number;
  36467. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  36468. static readonly NEVER: number;
  36469. /** 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 */
  36470. static readonly ALWAYS: number;
  36471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  36472. static readonly LESS: number;
  36473. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  36474. static readonly EQUAL: number;
  36475. /** 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 */
  36476. static readonly LEQUAL: number;
  36477. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  36478. static readonly GREATER: number;
  36479. /** 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 */
  36480. static readonly GEQUAL: number;
  36481. /** 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 */
  36482. static readonly NOTEQUAL: number;
  36483. /** Passed to stencilOperation to specify that stencil value must be kept */
  36484. static readonly KEEP: number;
  36485. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36486. static readonly REPLACE: number;
  36487. /** Passed to stencilOperation to specify that stencil value must be incremented */
  36488. static readonly INCR: number;
  36489. /** Passed to stencilOperation to specify that stencil value must be decremented */
  36490. static readonly DECR: number;
  36491. /** Passed to stencilOperation to specify that stencil value must be inverted */
  36492. static readonly INVERT: number;
  36493. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  36494. static readonly INCR_WRAP: number;
  36495. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  36496. static readonly DECR_WRAP: number;
  36497. /** Texture is not repeating outside of 0..1 UVs */
  36498. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  36499. /** Texture is repeating outside of 0..1 UVs */
  36500. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  36501. /** Texture is repeating and mirrored */
  36502. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  36503. /** ALPHA */
  36504. static readonly TEXTUREFORMAT_ALPHA: number;
  36505. /** LUMINANCE */
  36506. static readonly TEXTUREFORMAT_LUMINANCE: number;
  36507. /** LUMINANCE_ALPHA */
  36508. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  36509. /** RGB */
  36510. static readonly TEXTUREFORMAT_RGB: number;
  36511. /** RGBA */
  36512. static readonly TEXTUREFORMAT_RGBA: number;
  36513. /** RED */
  36514. static readonly TEXTUREFORMAT_RED: number;
  36515. /** RED (2nd reference) */
  36516. static readonly TEXTUREFORMAT_R: number;
  36517. /** RG */
  36518. static readonly TEXTUREFORMAT_RG: number;
  36519. /** RED_INTEGER */
  36520. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  36521. /** RED_INTEGER (2nd reference) */
  36522. static readonly TEXTUREFORMAT_R_INTEGER: number;
  36523. /** RG_INTEGER */
  36524. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  36525. /** RGB_INTEGER */
  36526. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  36527. /** RGBA_INTEGER */
  36528. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  36529. /** UNSIGNED_BYTE */
  36530. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  36531. /** UNSIGNED_BYTE (2nd reference) */
  36532. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  36533. /** FLOAT */
  36534. static readonly TEXTURETYPE_FLOAT: number;
  36535. /** HALF_FLOAT */
  36536. static readonly TEXTURETYPE_HALF_FLOAT: number;
  36537. /** BYTE */
  36538. static readonly TEXTURETYPE_BYTE: number;
  36539. /** SHORT */
  36540. static readonly TEXTURETYPE_SHORT: number;
  36541. /** UNSIGNED_SHORT */
  36542. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  36543. /** INT */
  36544. static readonly TEXTURETYPE_INT: number;
  36545. /** UNSIGNED_INT */
  36546. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  36547. /** UNSIGNED_SHORT_4_4_4_4 */
  36548. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  36549. /** UNSIGNED_SHORT_5_5_5_1 */
  36550. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  36551. /** UNSIGNED_SHORT_5_6_5 */
  36552. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  36553. /** UNSIGNED_INT_2_10_10_10_REV */
  36554. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  36555. /** UNSIGNED_INT_24_8 */
  36556. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  36557. /** UNSIGNED_INT_10F_11F_11F_REV */
  36558. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  36559. /** UNSIGNED_INT_5_9_9_9_REV */
  36560. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  36561. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  36562. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  36563. /** nearest is mag = nearest and min = nearest and mip = linear */
  36564. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  36565. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36566. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  36567. /** Trilinear is mag = linear and min = linear and mip = linear */
  36568. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  36569. /** nearest is mag = nearest and min = nearest and mip = linear */
  36570. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  36571. /** Bilinear is mag = linear and min = linear and mip = nearest */
  36572. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  36573. /** Trilinear is mag = linear and min = linear and mip = linear */
  36574. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  36575. /** mag = nearest and min = nearest and mip = nearest */
  36576. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  36577. /** mag = nearest and min = linear and mip = nearest */
  36578. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  36579. /** mag = nearest and min = linear and mip = linear */
  36580. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  36581. /** mag = nearest and min = linear and mip = none */
  36582. static readonly TEXTURE_NEAREST_LINEAR: number;
  36583. /** mag = nearest and min = nearest and mip = none */
  36584. static readonly TEXTURE_NEAREST_NEAREST: number;
  36585. /** mag = linear and min = nearest and mip = nearest */
  36586. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  36587. /** mag = linear and min = nearest and mip = linear */
  36588. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  36589. /** mag = linear and min = linear and mip = none */
  36590. static readonly TEXTURE_LINEAR_LINEAR: number;
  36591. /** mag = linear and min = nearest and mip = none */
  36592. static readonly TEXTURE_LINEAR_NEAREST: number;
  36593. /** Explicit coordinates mode */
  36594. static readonly TEXTURE_EXPLICIT_MODE: number;
  36595. /** Spherical coordinates mode */
  36596. static readonly TEXTURE_SPHERICAL_MODE: number;
  36597. /** Planar coordinates mode */
  36598. static readonly TEXTURE_PLANAR_MODE: number;
  36599. /** Cubic coordinates mode */
  36600. static readonly TEXTURE_CUBIC_MODE: number;
  36601. /** Projection coordinates mode */
  36602. static readonly TEXTURE_PROJECTION_MODE: number;
  36603. /** Skybox coordinates mode */
  36604. static readonly TEXTURE_SKYBOX_MODE: number;
  36605. /** Inverse Cubic coordinates mode */
  36606. static readonly TEXTURE_INVCUBIC_MODE: number;
  36607. /** Equirectangular coordinates mode */
  36608. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  36609. /** Equirectangular Fixed coordinates mode */
  36610. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  36611. /** Equirectangular Fixed Mirrored coordinates mode */
  36612. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  36613. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  36614. static readonly SCALEMODE_FLOOR: number;
  36615. /** Defines that texture rescaling will look for the nearest power of 2 size */
  36616. static readonly SCALEMODE_NEAREST: number;
  36617. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  36618. static readonly SCALEMODE_CEILING: number;
  36619. /**
  36620. * Returns the current npm package of the sdk
  36621. */
  36622. static get NpmPackage(): string;
  36623. /**
  36624. * Returns the current version of the framework
  36625. */
  36626. static get Version(): string;
  36627. /** Gets the list of created engines */
  36628. static get Instances(): Engine[];
  36629. /**
  36630. * Gets the latest created engine
  36631. */
  36632. static get LastCreatedEngine(): Nullable<Engine>;
  36633. /**
  36634. * Gets the latest created scene
  36635. */
  36636. static get LastCreatedScene(): Nullable<Scene>;
  36637. /**
  36638. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  36639. * @param flag defines which part of the materials must be marked as dirty
  36640. * @param predicate defines a predicate used to filter which materials should be affected
  36641. */
  36642. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36643. /**
  36644. * Method called to create the default loading screen.
  36645. * This can be overriden in your own app.
  36646. * @param canvas The rendering canvas element
  36647. * @returns The loading screen
  36648. */
  36649. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  36650. /**
  36651. * Method called to create the default rescale post process on each engine.
  36652. */
  36653. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  36654. /**
  36655. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  36656. **/
  36657. enableOfflineSupport: boolean;
  36658. /**
  36659. * 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)
  36660. **/
  36661. disableManifestCheck: boolean;
  36662. /**
  36663. * Gets the list of created scenes
  36664. */
  36665. scenes: Scene[];
  36666. /**
  36667. * Event raised when a new scene is created
  36668. */
  36669. onNewSceneAddedObservable: Observable<Scene>;
  36670. /**
  36671. * Gets the list of created postprocesses
  36672. */
  36673. postProcesses: PostProcess[];
  36674. /**
  36675. * Gets a boolean indicating if the pointer is currently locked
  36676. */
  36677. isPointerLock: boolean;
  36678. /**
  36679. * Observable event triggered each time the rendering canvas is resized
  36680. */
  36681. onResizeObservable: Observable<Engine>;
  36682. /**
  36683. * Observable event triggered each time the canvas loses focus
  36684. */
  36685. onCanvasBlurObservable: Observable<Engine>;
  36686. /**
  36687. * Observable event triggered each time the canvas gains focus
  36688. */
  36689. onCanvasFocusObservable: Observable<Engine>;
  36690. /**
  36691. * Observable event triggered each time the canvas receives pointerout event
  36692. */
  36693. onCanvasPointerOutObservable: Observable<PointerEvent>;
  36694. /**
  36695. * Observable raised when the engine begins a new frame
  36696. */
  36697. onBeginFrameObservable: Observable<Engine>;
  36698. /**
  36699. * If set, will be used to request the next animation frame for the render loop
  36700. */
  36701. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  36702. /**
  36703. * Observable raised when the engine ends the current frame
  36704. */
  36705. onEndFrameObservable: Observable<Engine>;
  36706. /**
  36707. * Observable raised when the engine is about to compile a shader
  36708. */
  36709. onBeforeShaderCompilationObservable: Observable<Engine>;
  36710. /**
  36711. * Observable raised when the engine has jsut compiled a shader
  36712. */
  36713. onAfterShaderCompilationObservable: Observable<Engine>;
  36714. /**
  36715. * Gets the audio engine
  36716. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36717. * @ignorenaming
  36718. */
  36719. static audioEngine: IAudioEngine;
  36720. /**
  36721. * Default AudioEngine factory responsible of creating the Audio Engine.
  36722. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  36723. */
  36724. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  36725. /**
  36726. * Default offline support factory responsible of creating a tool used to store data locally.
  36727. * By default, this will create a Database object if the workload has been embedded.
  36728. */
  36729. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  36730. private _loadingScreen;
  36731. private _pointerLockRequested;
  36732. private _rescalePostProcess;
  36733. private _deterministicLockstep;
  36734. private _lockstepMaxSteps;
  36735. private _timeStep;
  36736. protected get _supportsHardwareTextureRescaling(): boolean;
  36737. private _fps;
  36738. private _deltaTime;
  36739. /** @hidden */
  36740. _drawCalls: PerfCounter;
  36741. /** 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 */
  36742. canvasTabIndex: number;
  36743. /**
  36744. * Turn this value on if you want to pause FPS computation when in background
  36745. */
  36746. disablePerformanceMonitorInBackground: boolean;
  36747. private _performanceMonitor;
  36748. /**
  36749. * Gets the performance monitor attached to this engine
  36750. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  36751. */
  36752. get performanceMonitor(): PerformanceMonitor;
  36753. private _onFocus;
  36754. private _onBlur;
  36755. private _onCanvasPointerOut;
  36756. private _onCanvasBlur;
  36757. private _onCanvasFocus;
  36758. private _onFullscreenChange;
  36759. private _onPointerLockChange;
  36760. /**
  36761. * Gets the HTML element used to attach event listeners
  36762. * @returns a HTML element
  36763. */
  36764. getInputElement(): Nullable<HTMLElement>;
  36765. /**
  36766. * Creates a new engine
  36767. * @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
  36768. * @param antialias defines enable antialiasing (default: false)
  36769. * @param options defines further options to be sent to the getContext() function
  36770. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36771. */
  36772. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36773. /**
  36774. * Gets current aspect ratio
  36775. * @param viewportOwner defines the camera to use to get the aspect ratio
  36776. * @param useScreen defines if screen size must be used (or the current render target if any)
  36777. * @returns a number defining the aspect ratio
  36778. */
  36779. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  36780. /**
  36781. * Gets current screen aspect ratio
  36782. * @returns a number defining the aspect ratio
  36783. */
  36784. getScreenAspectRatio(): number;
  36785. /**
  36786. * Gets the client rect of the HTML canvas attached with the current webGL context
  36787. * @returns a client rectanglee
  36788. */
  36789. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  36790. /**
  36791. * Gets the client rect of the HTML element used for events
  36792. * @returns a client rectanglee
  36793. */
  36794. getInputElementClientRect(): Nullable<ClientRect>;
  36795. /**
  36796. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  36797. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36798. * @returns true if engine is in deterministic lock step mode
  36799. */
  36800. isDeterministicLockStep(): boolean;
  36801. /**
  36802. * Gets the max steps when engine is running in deterministic lock step
  36803. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36804. * @returns the max steps
  36805. */
  36806. getLockstepMaxSteps(): number;
  36807. /**
  36808. * Returns the time in ms between steps when using deterministic lock step.
  36809. * @returns time step in (ms)
  36810. */
  36811. getTimeStep(): number;
  36812. /**
  36813. * Force the mipmap generation for the given render target texture
  36814. * @param texture defines the render target texture to use
  36815. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  36816. */
  36817. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  36818. /** States */
  36819. /**
  36820. * Set various states to the webGL context
  36821. * @param culling defines backface culling state
  36822. * @param zOffset defines the value to apply to zOffset (0 by default)
  36823. * @param force defines if states must be applied even if cache is up to date
  36824. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  36825. */
  36826. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  36827. /**
  36828. * Set the z offset to apply to current rendering
  36829. * @param value defines the offset to apply
  36830. */
  36831. setZOffset(value: number): void;
  36832. /**
  36833. * Gets the current value of the zOffset
  36834. * @returns the current zOffset state
  36835. */
  36836. getZOffset(): number;
  36837. /**
  36838. * Enable or disable depth buffering
  36839. * @param enable defines the state to set
  36840. */
  36841. setDepthBuffer(enable: boolean): void;
  36842. /**
  36843. * Gets a boolean indicating if depth writing is enabled
  36844. * @returns the current depth writing state
  36845. */
  36846. getDepthWrite(): boolean;
  36847. /**
  36848. * Enable or disable depth writing
  36849. * @param enable defines the state to set
  36850. */
  36851. setDepthWrite(enable: boolean): void;
  36852. /**
  36853. * Gets a boolean indicating if stencil buffer is enabled
  36854. * @returns the current stencil buffer state
  36855. */
  36856. getStencilBuffer(): boolean;
  36857. /**
  36858. * Enable or disable the stencil buffer
  36859. * @param enable defines if the stencil buffer must be enabled or disabled
  36860. */
  36861. setStencilBuffer(enable: boolean): void;
  36862. /**
  36863. * Gets the current stencil mask
  36864. * @returns a number defining the new stencil mask to use
  36865. */
  36866. getStencilMask(): number;
  36867. /**
  36868. * Sets the current stencil mask
  36869. * @param mask defines the new stencil mask to use
  36870. */
  36871. setStencilMask(mask: number): void;
  36872. /**
  36873. * Gets the current stencil function
  36874. * @returns a number defining the stencil function to use
  36875. */
  36876. getStencilFunction(): number;
  36877. /**
  36878. * Gets the current stencil reference value
  36879. * @returns a number defining the stencil reference value to use
  36880. */
  36881. getStencilFunctionReference(): number;
  36882. /**
  36883. * Gets the current stencil mask
  36884. * @returns a number defining the stencil mask to use
  36885. */
  36886. getStencilFunctionMask(): number;
  36887. /**
  36888. * Sets the current stencil function
  36889. * @param stencilFunc defines the new stencil function to use
  36890. */
  36891. setStencilFunction(stencilFunc: number): void;
  36892. /**
  36893. * Sets the current stencil reference
  36894. * @param reference defines the new stencil reference to use
  36895. */
  36896. setStencilFunctionReference(reference: number): void;
  36897. /**
  36898. * Sets the current stencil mask
  36899. * @param mask defines the new stencil mask to use
  36900. */
  36901. setStencilFunctionMask(mask: number): void;
  36902. /**
  36903. * Gets the current stencil operation when stencil fails
  36904. * @returns a number defining stencil operation to use when stencil fails
  36905. */
  36906. getStencilOperationFail(): number;
  36907. /**
  36908. * Gets the current stencil operation when depth fails
  36909. * @returns a number defining stencil operation to use when depth fails
  36910. */
  36911. getStencilOperationDepthFail(): number;
  36912. /**
  36913. * Gets the current stencil operation when stencil passes
  36914. * @returns a number defining stencil operation to use when stencil passes
  36915. */
  36916. getStencilOperationPass(): number;
  36917. /**
  36918. * Sets the stencil operation to use when stencil fails
  36919. * @param operation defines the stencil operation to use when stencil fails
  36920. */
  36921. setStencilOperationFail(operation: number): void;
  36922. /**
  36923. * Sets the stencil operation to use when depth fails
  36924. * @param operation defines the stencil operation to use when depth fails
  36925. */
  36926. setStencilOperationDepthFail(operation: number): void;
  36927. /**
  36928. * Sets the stencil operation to use when stencil passes
  36929. * @param operation defines the stencil operation to use when stencil passes
  36930. */
  36931. setStencilOperationPass(operation: number): void;
  36932. /**
  36933. * Sets a boolean indicating if the dithering state is enabled or disabled
  36934. * @param value defines the dithering state
  36935. */
  36936. setDitheringState(value: boolean): void;
  36937. /**
  36938. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  36939. * @param value defines the rasterizer state
  36940. */
  36941. setRasterizerState(value: boolean): void;
  36942. /**
  36943. * Gets the current depth function
  36944. * @returns a number defining the depth function
  36945. */
  36946. getDepthFunction(): Nullable<number>;
  36947. /**
  36948. * Sets the current depth function
  36949. * @param depthFunc defines the function to use
  36950. */
  36951. setDepthFunction(depthFunc: number): void;
  36952. /**
  36953. * Sets the current depth function to GREATER
  36954. */
  36955. setDepthFunctionToGreater(): void;
  36956. /**
  36957. * Sets the current depth function to GEQUAL
  36958. */
  36959. setDepthFunctionToGreaterOrEqual(): void;
  36960. /**
  36961. * Sets the current depth function to LESS
  36962. */
  36963. setDepthFunctionToLess(): void;
  36964. /**
  36965. * Sets the current depth function to LEQUAL
  36966. */
  36967. setDepthFunctionToLessOrEqual(): void;
  36968. private _cachedStencilBuffer;
  36969. private _cachedStencilFunction;
  36970. private _cachedStencilMask;
  36971. private _cachedStencilOperationPass;
  36972. private _cachedStencilOperationFail;
  36973. private _cachedStencilOperationDepthFail;
  36974. private _cachedStencilReference;
  36975. /**
  36976. * Caches the the state of the stencil buffer
  36977. */
  36978. cacheStencilState(): void;
  36979. /**
  36980. * Restores the state of the stencil buffer
  36981. */
  36982. restoreStencilState(): void;
  36983. /**
  36984. * Directly set the WebGL Viewport
  36985. * @param x defines the x coordinate of the viewport (in screen space)
  36986. * @param y defines the y coordinate of the viewport (in screen space)
  36987. * @param width defines the width of the viewport (in screen space)
  36988. * @param height defines the height of the viewport (in screen space)
  36989. * @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
  36990. */
  36991. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  36992. /**
  36993. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  36994. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  36995. * @param y defines the y-coordinate of the corner of the clear rectangle
  36996. * @param width defines the width of the clear rectangle
  36997. * @param height defines the height of the clear rectangle
  36998. * @param clearColor defines the clear color
  36999. */
  37000. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37001. /**
  37002. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37003. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37004. * @param y defines the y-coordinate of the corner of the clear rectangle
  37005. * @param width defines the width of the clear rectangle
  37006. * @param height defines the height of the clear rectangle
  37007. */
  37008. enableScissor(x: number, y: number, width: number, height: number): void;
  37009. /**
  37010. * Disable previously set scissor test rectangle
  37011. */
  37012. disableScissor(): void;
  37013. protected _reportDrawCall(): void;
  37014. /**
  37015. * Initializes a webVR display and starts listening to display change events
  37016. * The onVRDisplayChangedObservable will be notified upon these changes
  37017. * @returns The onVRDisplayChangedObservable
  37018. */
  37019. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37020. /** @hidden */
  37021. _prepareVRComponent(): void;
  37022. /** @hidden */
  37023. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37024. /** @hidden */
  37025. _submitVRFrame(): void;
  37026. /**
  37027. * Call this function to leave webVR mode
  37028. * Will do nothing if webVR is not supported or if there is no webVR device
  37029. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37030. */
  37031. disableVR(): void;
  37032. /**
  37033. * Gets a boolean indicating that the system is in VR mode and is presenting
  37034. * @returns true if VR mode is engaged
  37035. */
  37036. isVRPresenting(): boolean;
  37037. /** @hidden */
  37038. _requestVRFrame(): void;
  37039. /** @hidden */
  37040. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37041. /**
  37042. * Gets the source code of the vertex shader associated with a specific webGL program
  37043. * @param program defines the program to use
  37044. * @returns a string containing the source code of the vertex shader associated with the program
  37045. */
  37046. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37047. /**
  37048. * Gets the source code of the fragment shader associated with a specific webGL program
  37049. * @param program defines the program to use
  37050. * @returns a string containing the source code of the fragment shader associated with the program
  37051. */
  37052. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37053. /**
  37054. * Sets a depth stencil texture from a render target to the according uniform.
  37055. * @param channel The texture channel
  37056. * @param uniform The uniform to set
  37057. * @param texture The render target texture containing the depth stencil texture to apply
  37058. */
  37059. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37060. /**
  37061. * Sets a texture to the webGL context from a postprocess
  37062. * @param channel defines the channel to use
  37063. * @param postProcess defines the source postprocess
  37064. */
  37065. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37066. /**
  37067. * Binds the output of the passed in post process to the texture channel specified
  37068. * @param channel The channel the texture should be bound to
  37069. * @param postProcess The post process which's output should be bound
  37070. */
  37071. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37072. protected _rebuildBuffers(): void;
  37073. /** @hidden */
  37074. _renderFrame(): void;
  37075. _renderLoop(): void;
  37076. /** @hidden */
  37077. _renderViews(): boolean;
  37078. /**
  37079. * Toggle full screen mode
  37080. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37081. */
  37082. switchFullscreen(requestPointerLock: boolean): void;
  37083. /**
  37084. * Enters full screen mode
  37085. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37086. */
  37087. enterFullscreen(requestPointerLock: boolean): void;
  37088. /**
  37089. * Exits full screen mode
  37090. */
  37091. exitFullscreen(): void;
  37092. /**
  37093. * Enters Pointerlock mode
  37094. */
  37095. enterPointerlock(): void;
  37096. /**
  37097. * Exits Pointerlock mode
  37098. */
  37099. exitPointerlock(): void;
  37100. /**
  37101. * Begin a new frame
  37102. */
  37103. beginFrame(): void;
  37104. /**
  37105. * Enf the current frame
  37106. */
  37107. endFrame(): void;
  37108. resize(): void;
  37109. /**
  37110. * Force a specific size of the canvas
  37111. * @param width defines the new canvas' width
  37112. * @param height defines the new canvas' height
  37113. * @returns true if the size was changed
  37114. */
  37115. setSize(width: number, height: number): boolean;
  37116. /**
  37117. * Updates a dynamic vertex buffer.
  37118. * @param vertexBuffer the vertex buffer to update
  37119. * @param data the data used to update the vertex buffer
  37120. * @param byteOffset the byte offset of the data
  37121. * @param byteLength the byte length of the data
  37122. */
  37123. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37124. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37125. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37126. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37127. _releaseTexture(texture: InternalTexture): void;
  37128. /**
  37129. * @hidden
  37130. * Rescales a texture
  37131. * @param source input texutre
  37132. * @param destination destination texture
  37133. * @param scene scene to use to render the resize
  37134. * @param internalFormat format to use when resizing
  37135. * @param onComplete callback to be called when resize has completed
  37136. */
  37137. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37138. /**
  37139. * Gets the current framerate
  37140. * @returns a number representing the framerate
  37141. */
  37142. getFps(): number;
  37143. /**
  37144. * Gets the time spent between current and previous frame
  37145. * @returns a number representing the delta time in ms
  37146. */
  37147. getDeltaTime(): number;
  37148. private _measureFps;
  37149. /** @hidden */
  37150. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37151. /**
  37152. * Update a dynamic index buffer
  37153. * @param indexBuffer defines the target index buffer
  37154. * @param indices defines the data to update
  37155. * @param offset defines the offset in the target index buffer where update should start
  37156. */
  37157. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37158. /**
  37159. * Updates the sample count of a render target texture
  37160. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37161. * @param texture defines the texture to update
  37162. * @param samples defines the sample count to set
  37163. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37164. */
  37165. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37166. /**
  37167. * Updates a depth texture Comparison Mode and Function.
  37168. * If the comparison Function is equal to 0, the mode will be set to none.
  37169. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37170. * @param texture The texture to set the comparison function for
  37171. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37172. */
  37173. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37174. /**
  37175. * Creates a webGL buffer to use with instanciation
  37176. * @param capacity defines the size of the buffer
  37177. * @returns the webGL buffer
  37178. */
  37179. createInstancesBuffer(capacity: number): DataBuffer;
  37180. /**
  37181. * Delete a webGL buffer used with instanciation
  37182. * @param buffer defines the webGL buffer to delete
  37183. */
  37184. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37185. private _clientWaitAsync;
  37186. /** @hidden */
  37187. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37188. dispose(): void;
  37189. private _disableTouchAction;
  37190. /**
  37191. * Display the loading screen
  37192. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37193. */
  37194. displayLoadingUI(): void;
  37195. /**
  37196. * Hide the loading screen
  37197. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37198. */
  37199. hideLoadingUI(): void;
  37200. /**
  37201. * Gets the current loading screen object
  37202. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37203. */
  37204. get loadingScreen(): ILoadingScreen;
  37205. /**
  37206. * Sets the current loading screen object
  37207. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37208. */
  37209. set loadingScreen(loadingScreen: ILoadingScreen);
  37210. /**
  37211. * Sets the current loading screen text
  37212. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37213. */
  37214. set loadingUIText(text: string);
  37215. /**
  37216. * Sets the current loading screen background color
  37217. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37218. */
  37219. set loadingUIBackgroundColor(color: string);
  37220. /** Pointerlock and fullscreen */
  37221. /**
  37222. * Ask the browser to promote the current element to pointerlock mode
  37223. * @param element defines the DOM element to promote
  37224. */
  37225. static _RequestPointerlock(element: HTMLElement): void;
  37226. /**
  37227. * Asks the browser to exit pointerlock mode
  37228. */
  37229. static _ExitPointerlock(): void;
  37230. /**
  37231. * Ask the browser to promote the current element to fullscreen rendering mode
  37232. * @param element defines the DOM element to promote
  37233. */
  37234. static _RequestFullscreen(element: HTMLElement): void;
  37235. /**
  37236. * Asks the browser to exit fullscreen mode
  37237. */
  37238. static _ExitFullscreen(): void;
  37239. }
  37240. }
  37241. declare module BABYLON {
  37242. /**
  37243. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37244. * during the life time of the application.
  37245. */
  37246. export class EngineStore {
  37247. /** Gets the list of created engines */
  37248. static Instances: Engine[];
  37249. /** @hidden */
  37250. static _LastCreatedScene: Nullable<Scene>;
  37251. /**
  37252. * Gets the latest created engine
  37253. */
  37254. static get LastCreatedEngine(): Nullable<Engine>;
  37255. /**
  37256. * Gets the latest created scene
  37257. */
  37258. static get LastCreatedScene(): Nullable<Scene>;
  37259. /**
  37260. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37261. * @ignorenaming
  37262. */
  37263. static UseFallbackTexture: boolean;
  37264. /**
  37265. * Texture content used if a texture cannot loaded
  37266. * @ignorenaming
  37267. */
  37268. static FallbackTexture: string;
  37269. }
  37270. }
  37271. declare module BABYLON {
  37272. /**
  37273. * Helper class that provides a small promise polyfill
  37274. */
  37275. export class PromisePolyfill {
  37276. /**
  37277. * Static function used to check if the polyfill is required
  37278. * If this is the case then the function will inject the polyfill to window.Promise
  37279. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37280. */
  37281. static Apply(force?: boolean): void;
  37282. }
  37283. }
  37284. declare module BABYLON {
  37285. /**
  37286. * Interface for screenshot methods with describe argument called `size` as object with options
  37287. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37288. */
  37289. export interface IScreenshotSize {
  37290. /**
  37291. * number in pixels for canvas height
  37292. */
  37293. height?: number;
  37294. /**
  37295. * multiplier allowing render at a higher or lower resolution
  37296. * If value is defined then height and width will be ignored and taken from camera
  37297. */
  37298. precision?: number;
  37299. /**
  37300. * number in pixels for canvas width
  37301. */
  37302. width?: number;
  37303. }
  37304. }
  37305. declare module BABYLON {
  37306. interface IColor4Like {
  37307. r: float;
  37308. g: float;
  37309. b: float;
  37310. a: float;
  37311. }
  37312. /**
  37313. * Class containing a set of static utilities functions
  37314. */
  37315. export class Tools {
  37316. /**
  37317. * Gets or sets the base URL to use to load assets
  37318. */
  37319. static get BaseUrl(): string;
  37320. static set BaseUrl(value: string);
  37321. /**
  37322. * Enable/Disable Custom HTTP Request Headers globally.
  37323. * default = false
  37324. * @see CustomRequestHeaders
  37325. */
  37326. static UseCustomRequestHeaders: boolean;
  37327. /**
  37328. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  37329. * i.e. when loading files, where the server/service expects an Authorization header
  37330. */
  37331. static CustomRequestHeaders: {
  37332. [key: string]: string;
  37333. };
  37334. /**
  37335. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  37336. */
  37337. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  37338. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  37339. /**
  37340. * Default behaviour for cors in the application.
  37341. * It can be a string if the expected behavior is identical in the entire app.
  37342. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  37343. */
  37344. static get CorsBehavior(): string | ((url: string | string[]) => string);
  37345. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  37346. /**
  37347. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37348. * @ignorenaming
  37349. */
  37350. static get UseFallbackTexture(): boolean;
  37351. static set UseFallbackTexture(value: boolean);
  37352. /**
  37353. * Use this object to register external classes like custom textures or material
  37354. * to allow the laoders to instantiate them
  37355. */
  37356. static get RegisteredExternalClasses(): {
  37357. [key: string]: Object;
  37358. };
  37359. static set RegisteredExternalClasses(classes: {
  37360. [key: string]: Object;
  37361. });
  37362. /**
  37363. * Texture content used if a texture cannot loaded
  37364. * @ignorenaming
  37365. */
  37366. static get fallbackTexture(): string;
  37367. static set fallbackTexture(value: string);
  37368. /**
  37369. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  37370. * @param u defines the coordinate on X axis
  37371. * @param v defines the coordinate on Y axis
  37372. * @param width defines the width of the source data
  37373. * @param height defines the height of the source data
  37374. * @param pixels defines the source byte array
  37375. * @param color defines the output color
  37376. */
  37377. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  37378. /**
  37379. * Interpolates between a and b via alpha
  37380. * @param a The lower value (returned when alpha = 0)
  37381. * @param b The upper value (returned when alpha = 1)
  37382. * @param alpha The interpolation-factor
  37383. * @return The mixed value
  37384. */
  37385. static Mix(a: number, b: number, alpha: number): number;
  37386. /**
  37387. * Tries to instantiate a new object from a given class name
  37388. * @param className defines the class name to instantiate
  37389. * @returns the new object or null if the system was not able to do the instantiation
  37390. */
  37391. static Instantiate(className: string): any;
  37392. /**
  37393. * Provides a slice function that will work even on IE
  37394. * @param data defines the array to slice
  37395. * @param start defines the start of the data (optional)
  37396. * @param end defines the end of the data (optional)
  37397. * @returns the new sliced array
  37398. */
  37399. static Slice<T>(data: T, start?: number, end?: number): T;
  37400. /**
  37401. * Polyfill for setImmediate
  37402. * @param action defines the action to execute after the current execution block
  37403. */
  37404. static SetImmediate(action: () => void): void;
  37405. /**
  37406. * Function indicating if a number is an exponent of 2
  37407. * @param value defines the value to test
  37408. * @returns true if the value is an exponent of 2
  37409. */
  37410. static IsExponentOfTwo(value: number): boolean;
  37411. private static _tmpFloatArray;
  37412. /**
  37413. * Returns the nearest 32-bit single precision float representation of a Number
  37414. * @param value A Number. If the parameter is of a different type, it will get converted
  37415. * to a number or to NaN if it cannot be converted
  37416. * @returns number
  37417. */
  37418. static FloatRound(value: number): number;
  37419. /**
  37420. * Extracts the filename from a path
  37421. * @param path defines the path to use
  37422. * @returns the filename
  37423. */
  37424. static GetFilename(path: string): string;
  37425. /**
  37426. * Extracts the "folder" part of a path (everything before the filename).
  37427. * @param uri The URI to extract the info from
  37428. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  37429. * @returns The "folder" part of the path
  37430. */
  37431. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  37432. /**
  37433. * Extracts text content from a DOM element hierarchy
  37434. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  37435. */
  37436. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  37437. /**
  37438. * Convert an angle in radians to degrees
  37439. * @param angle defines the angle to convert
  37440. * @returns the angle in degrees
  37441. */
  37442. static ToDegrees(angle: number): number;
  37443. /**
  37444. * Convert an angle in degrees to radians
  37445. * @param angle defines the angle to convert
  37446. * @returns the angle in radians
  37447. */
  37448. static ToRadians(angle: number): number;
  37449. /**
  37450. * Returns an array if obj is not an array
  37451. * @param obj defines the object to evaluate as an array
  37452. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  37453. * @returns either obj directly if obj is an array or a new array containing obj
  37454. */
  37455. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  37456. /**
  37457. * Gets the pointer prefix to use
  37458. * @param engine defines the engine we are finding the prefix for
  37459. * @returns "pointer" if touch is enabled. Else returns "mouse"
  37460. */
  37461. static GetPointerPrefix(engine: Engine): string;
  37462. /**
  37463. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  37464. * @param url define the url we are trying
  37465. * @param element define the dom element where to configure the cors policy
  37466. */
  37467. static SetCorsBehavior(url: string | string[], element: {
  37468. crossOrigin: string | null;
  37469. }): void;
  37470. /**
  37471. * Removes unwanted characters from an url
  37472. * @param url defines the url to clean
  37473. * @returns the cleaned url
  37474. */
  37475. static CleanUrl(url: string): string;
  37476. /**
  37477. * Gets or sets a function used to pre-process url before using them to load assets
  37478. */
  37479. static get PreprocessUrl(): (url: string) => string;
  37480. static set PreprocessUrl(processor: (url: string) => string);
  37481. /**
  37482. * Loads an image as an HTMLImageElement.
  37483. * @param input url string, ArrayBuffer, or Blob to load
  37484. * @param onLoad callback called when the image successfully loads
  37485. * @param onError callback called when the image fails to load
  37486. * @param offlineProvider offline provider for caching
  37487. * @param mimeType optional mime type
  37488. * @returns the HTMLImageElement of the loaded image
  37489. */
  37490. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  37491. /**
  37492. * Loads a file from a url
  37493. * @param url url string, ArrayBuffer, or Blob to load
  37494. * @param onSuccess callback called when the file successfully loads
  37495. * @param onProgress callback called while file is loading (if the server supports this mode)
  37496. * @param offlineProvider defines the offline provider for caching
  37497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37498. * @param onError callback called when the file fails to load
  37499. * @returns a file request object
  37500. */
  37501. 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;
  37502. /**
  37503. * Loads a file from a url
  37504. * @param url the file url to load
  37505. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37506. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  37507. */
  37508. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  37509. /**
  37510. * Load a script (identified by an url). When the url returns, the
  37511. * content of this file is added into a new script element, attached to the DOM (body element)
  37512. * @param scriptUrl defines the url of the script to laod
  37513. * @param onSuccess defines the callback called when the script is loaded
  37514. * @param onError defines the callback to call if an error occurs
  37515. * @param scriptId defines the id of the script element
  37516. */
  37517. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  37518. /**
  37519. * Load an asynchronous script (identified by an url). When the url returns, the
  37520. * content of this file is added into a new script element, attached to the DOM (body element)
  37521. * @param scriptUrl defines the url of the script to laod
  37522. * @param scriptId defines the id of the script element
  37523. * @returns a promise request object
  37524. */
  37525. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  37526. /**
  37527. * Loads a file from a blob
  37528. * @param fileToLoad defines the blob to use
  37529. * @param callback defines the callback to call when data is loaded
  37530. * @param progressCallback defines the callback to call during loading process
  37531. * @returns a file request object
  37532. */
  37533. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  37534. /**
  37535. * Reads a file from a File object
  37536. * @param file defines the file to load
  37537. * @param onSuccess defines the callback to call when data is loaded
  37538. * @param onProgress defines the callback to call during loading process
  37539. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  37540. * @param onError defines the callback to call when an error occurs
  37541. * @returns a file request object
  37542. */
  37543. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37544. /**
  37545. * Creates a data url from a given string content
  37546. * @param content defines the content to convert
  37547. * @returns the new data url link
  37548. */
  37549. static FileAsURL(content: string): string;
  37550. /**
  37551. * Format the given number to a specific decimal format
  37552. * @param value defines the number to format
  37553. * @param decimals defines the number of decimals to use
  37554. * @returns the formatted string
  37555. */
  37556. static Format(value: number, decimals?: number): string;
  37557. /**
  37558. * Tries to copy an object by duplicating every property
  37559. * @param source defines the source object
  37560. * @param destination defines the target object
  37561. * @param doNotCopyList defines a list of properties to avoid
  37562. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  37563. */
  37564. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  37565. /**
  37566. * Gets a boolean indicating if the given object has no own property
  37567. * @param obj defines the object to test
  37568. * @returns true if object has no own property
  37569. */
  37570. static IsEmpty(obj: any): boolean;
  37571. /**
  37572. * Function used to register events at window level
  37573. * @param windowElement defines the Window object to use
  37574. * @param events defines the events to register
  37575. */
  37576. static RegisterTopRootEvents(windowElement: Window, events: {
  37577. name: string;
  37578. handler: Nullable<(e: FocusEvent) => any>;
  37579. }[]): void;
  37580. /**
  37581. * Function used to unregister events from window level
  37582. * @param windowElement defines the Window object to use
  37583. * @param events defines the events to unregister
  37584. */
  37585. static UnregisterTopRootEvents(windowElement: Window, events: {
  37586. name: string;
  37587. handler: Nullable<(e: FocusEvent) => any>;
  37588. }[]): void;
  37589. /**
  37590. * @ignore
  37591. */
  37592. static _ScreenshotCanvas: HTMLCanvasElement;
  37593. /**
  37594. * Dumps the current bound framebuffer
  37595. * @param width defines the rendering width
  37596. * @param height defines the rendering height
  37597. * @param engine defines the hosting engine
  37598. * @param successCallback defines the callback triggered once the data are available
  37599. * @param mimeType defines the mime type of the result
  37600. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  37601. */
  37602. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37603. /**
  37604. * Converts the canvas data to blob.
  37605. * This acts as a polyfill for browsers not supporting the to blob function.
  37606. * @param canvas Defines the canvas to extract the data from
  37607. * @param successCallback Defines the callback triggered once the data are available
  37608. * @param mimeType Defines the mime type of the result
  37609. */
  37610. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  37611. /**
  37612. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  37613. * @param successCallback defines the callback triggered once the data are available
  37614. * @param mimeType defines the mime type of the result
  37615. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  37616. */
  37617. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  37618. /**
  37619. * Downloads a blob in the browser
  37620. * @param blob defines the blob to download
  37621. * @param fileName defines the name of the downloaded file
  37622. */
  37623. static Download(blob: Blob, fileName: string): void;
  37624. /**
  37625. * Captures a screenshot of the current rendering
  37626. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37627. * @param engine defines the rendering engine
  37628. * @param camera defines the source camera
  37629. * @param size This parameter can be set to a single number or to an object with the
  37630. * following (optional) properties: precision, width, height. If a single number is passed,
  37631. * it will be used for both width and height. If an object is passed, the screenshot size
  37632. * will be derived from the parameters. The precision property is a multiplier allowing
  37633. * rendering at a higher or lower resolution
  37634. * @param successCallback defines the callback receives a single parameter which contains the
  37635. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37636. * src parameter of an <img> to display it
  37637. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37638. * Check your browser for supported MIME types
  37639. */
  37640. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  37641. /**
  37642. * Captures a screenshot of the current rendering
  37643. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37644. * @param engine defines the rendering engine
  37645. * @param camera defines the source camera
  37646. * @param size This parameter can be set to a single number or to an object with the
  37647. * following (optional) properties: precision, width, height. If a single number is passed,
  37648. * it will be used for both width and height. If an object is passed, the screenshot size
  37649. * will be derived from the parameters. The precision property is a multiplier allowing
  37650. * rendering at a higher or lower resolution
  37651. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  37652. * Check your browser for supported MIME types
  37653. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37654. * to the src parameter of an <img> to display it
  37655. */
  37656. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  37657. /**
  37658. * Generates an image screenshot from the specified camera.
  37659. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37660. * @param engine The engine to use for rendering
  37661. * @param camera The camera to use for rendering
  37662. * @param size This parameter can be set to a single number or to an object with the
  37663. * following (optional) properties: precision, width, height. If a single number is passed,
  37664. * it will be used for both width and height. If an object is passed, the screenshot size
  37665. * will be derived from the parameters. The precision property is a multiplier allowing
  37666. * rendering at a higher or lower resolution
  37667. * @param successCallback The callback receives a single parameter which contains the
  37668. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  37669. * src parameter of an <img> to display it
  37670. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37671. * Check your browser for supported MIME types
  37672. * @param samples Texture samples (default: 1)
  37673. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37674. * @param fileName A name for for the downloaded file.
  37675. */
  37676. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  37677. /**
  37678. * Generates an image screenshot from the specified camera.
  37679. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  37680. * @param engine The engine to use for rendering
  37681. * @param camera The camera to use for rendering
  37682. * @param size This parameter can be set to a single number or to an object with the
  37683. * following (optional) properties: precision, width, height. If a single number is passed,
  37684. * it will be used for both width and height. If an object is passed, the screenshot size
  37685. * will be derived from the parameters. The precision property is a multiplier allowing
  37686. * rendering at a higher or lower resolution
  37687. * @param mimeType The MIME type of the screenshot image (default: image/png).
  37688. * Check your browser for supported MIME types
  37689. * @param samples Texture samples (default: 1)
  37690. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  37691. * @param fileName A name for for the downloaded file.
  37692. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  37693. * to the src parameter of an <img> to display it
  37694. */
  37695. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  37696. /**
  37697. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  37698. * Be aware Math.random() could cause collisions, but:
  37699. * "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"
  37700. * @returns a pseudo random id
  37701. */
  37702. static RandomId(): string;
  37703. /**
  37704. * Test if the given uri is a base64 string
  37705. * @param uri The uri to test
  37706. * @return True if the uri is a base64 string or false otherwise
  37707. */
  37708. static IsBase64(uri: string): boolean;
  37709. /**
  37710. * Decode the given base64 uri.
  37711. * @param uri The uri to decode
  37712. * @return The decoded base64 data.
  37713. */
  37714. static DecodeBase64(uri: string): ArrayBuffer;
  37715. /**
  37716. * Gets the absolute url.
  37717. * @param url the input url
  37718. * @return the absolute url
  37719. */
  37720. static GetAbsoluteUrl(url: string): string;
  37721. /**
  37722. * No log
  37723. */
  37724. static readonly NoneLogLevel: number;
  37725. /**
  37726. * Only message logs
  37727. */
  37728. static readonly MessageLogLevel: number;
  37729. /**
  37730. * Only warning logs
  37731. */
  37732. static readonly WarningLogLevel: number;
  37733. /**
  37734. * Only error logs
  37735. */
  37736. static readonly ErrorLogLevel: number;
  37737. /**
  37738. * All logs
  37739. */
  37740. static readonly AllLogLevel: number;
  37741. /**
  37742. * Gets a value indicating the number of loading errors
  37743. * @ignorenaming
  37744. */
  37745. static get errorsCount(): number;
  37746. /**
  37747. * Callback called when a new log is added
  37748. */
  37749. static OnNewCacheEntry: (entry: string) => void;
  37750. /**
  37751. * Log a message to the console
  37752. * @param message defines the message to log
  37753. */
  37754. static Log(message: string): void;
  37755. /**
  37756. * Write a warning message to the console
  37757. * @param message defines the message to log
  37758. */
  37759. static Warn(message: string): void;
  37760. /**
  37761. * Write an error message to the console
  37762. * @param message defines the message to log
  37763. */
  37764. static Error(message: string): void;
  37765. /**
  37766. * Gets current log cache (list of logs)
  37767. */
  37768. static get LogCache(): string;
  37769. /**
  37770. * Clears the log cache
  37771. */
  37772. static ClearLogCache(): void;
  37773. /**
  37774. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  37775. */
  37776. static set LogLevels(level: number);
  37777. /**
  37778. * Checks if the window object exists
  37779. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  37780. */
  37781. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  37782. /**
  37783. * No performance log
  37784. */
  37785. static readonly PerformanceNoneLogLevel: number;
  37786. /**
  37787. * Use user marks to log performance
  37788. */
  37789. static readonly PerformanceUserMarkLogLevel: number;
  37790. /**
  37791. * Log performance to the console
  37792. */
  37793. static readonly PerformanceConsoleLogLevel: number;
  37794. private static _performance;
  37795. /**
  37796. * Sets the current performance log level
  37797. */
  37798. static set PerformanceLogLevel(level: number);
  37799. private static _StartPerformanceCounterDisabled;
  37800. private static _EndPerformanceCounterDisabled;
  37801. private static _StartUserMark;
  37802. private static _EndUserMark;
  37803. private static _StartPerformanceConsole;
  37804. private static _EndPerformanceConsole;
  37805. /**
  37806. * Starts a performance counter
  37807. */
  37808. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37809. /**
  37810. * Ends a specific performance coutner
  37811. */
  37812. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  37813. /**
  37814. * Gets either window.performance.now() if supported or Date.now() else
  37815. */
  37816. static get Now(): number;
  37817. /**
  37818. * This method will return the name of the class used to create the instance of the given object.
  37819. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  37820. * @param object the object to get the class name from
  37821. * @param isType defines if the object is actually a type
  37822. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  37823. */
  37824. static GetClassName(object: any, isType?: boolean): string;
  37825. /**
  37826. * Gets the first element of an array satisfying a given predicate
  37827. * @param array defines the array to browse
  37828. * @param predicate defines the predicate to use
  37829. * @returns null if not found or the element
  37830. */
  37831. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  37832. /**
  37833. * This method will return the name of the full name of the class, including its owning module (if any).
  37834. * 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).
  37835. * @param object the object to get the class name from
  37836. * @param isType defines if the object is actually a type
  37837. * @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.
  37838. * @ignorenaming
  37839. */
  37840. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  37841. /**
  37842. * Returns a promise that resolves after the given amount of time.
  37843. * @param delay Number of milliseconds to delay
  37844. * @returns Promise that resolves after the given amount of time
  37845. */
  37846. static DelayAsync(delay: number): Promise<void>;
  37847. /**
  37848. * Utility function to detect if the current user agent is Safari
  37849. * @returns whether or not the current user agent is safari
  37850. */
  37851. static IsSafari(): boolean;
  37852. }
  37853. /**
  37854. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  37855. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  37856. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  37857. * @param name The name of the class, case should be preserved
  37858. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  37859. */
  37860. export function className(name: string, module?: string): (target: Object) => void;
  37861. /**
  37862. * An implementation of a loop for asynchronous functions.
  37863. */
  37864. export class AsyncLoop {
  37865. /**
  37866. * Defines the number of iterations for the loop
  37867. */
  37868. iterations: number;
  37869. /**
  37870. * Defines the current index of the loop.
  37871. */
  37872. index: number;
  37873. private _done;
  37874. private _fn;
  37875. private _successCallback;
  37876. /**
  37877. * Constructor.
  37878. * @param iterations the number of iterations.
  37879. * @param func the function to run each iteration
  37880. * @param successCallback the callback that will be called upon succesful execution
  37881. * @param offset starting offset.
  37882. */
  37883. constructor(
  37884. /**
  37885. * Defines the number of iterations for the loop
  37886. */
  37887. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  37888. /**
  37889. * Execute the next iteration. Must be called after the last iteration was finished.
  37890. */
  37891. executeNext(): void;
  37892. /**
  37893. * Break the loop and run the success callback.
  37894. */
  37895. breakLoop(): void;
  37896. /**
  37897. * Create and run an async loop.
  37898. * @param iterations the number of iterations.
  37899. * @param fn the function to run each iteration
  37900. * @param successCallback the callback that will be called upon succesful execution
  37901. * @param offset starting offset.
  37902. * @returns the created async loop object
  37903. */
  37904. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  37905. /**
  37906. * A for-loop that will run a given number of iterations synchronous and the rest async.
  37907. * @param iterations total number of iterations
  37908. * @param syncedIterations number of synchronous iterations in each async iteration.
  37909. * @param fn the function to call each iteration.
  37910. * @param callback a success call back that will be called when iterating stops.
  37911. * @param breakFunction a break condition (optional)
  37912. * @param timeout timeout settings for the setTimeout function. default - 0.
  37913. * @returns the created async loop object
  37914. */
  37915. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  37916. }
  37917. }
  37918. declare module BABYLON {
  37919. /**
  37920. * This class implement a typical dictionary using a string as key and the generic type T as value.
  37921. * The underlying implementation relies on an associative array to ensure the best performances.
  37922. * The value can be anything including 'null' but except 'undefined'
  37923. */
  37924. export class StringDictionary<T> {
  37925. /**
  37926. * This will clear this dictionary and copy the content from the 'source' one.
  37927. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  37928. * @param source the dictionary to take the content from and copy to this dictionary
  37929. */
  37930. copyFrom(source: StringDictionary<T>): void;
  37931. /**
  37932. * Get a value based from its key
  37933. * @param key the given key to get the matching value from
  37934. * @return the value if found, otherwise undefined is returned
  37935. */
  37936. get(key: string): T | undefined;
  37937. /**
  37938. * Get a value from its key or add it if it doesn't exist.
  37939. * This method will ensure you that a given key/data will be present in the dictionary.
  37940. * @param key the given key to get the matching value from
  37941. * @param factory the factory that will create the value if the key is not present in the dictionary.
  37942. * The factory will only be invoked if there's no data for the given key.
  37943. * @return the value corresponding to the key.
  37944. */
  37945. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  37946. /**
  37947. * Get a value from its key if present in the dictionary otherwise add it
  37948. * @param key the key to get the value from
  37949. * @param val if there's no such key/value pair in the dictionary add it with this value
  37950. * @return the value corresponding to the key
  37951. */
  37952. getOrAdd(key: string, val: T): T;
  37953. /**
  37954. * Check if there's a given key in the dictionary
  37955. * @param key the key to check for
  37956. * @return true if the key is present, false otherwise
  37957. */
  37958. contains(key: string): boolean;
  37959. /**
  37960. * Add a new key and its corresponding value
  37961. * @param key the key to add
  37962. * @param value the value corresponding to the key
  37963. * @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
  37964. */
  37965. add(key: string, value: T): boolean;
  37966. /**
  37967. * Update a specific value associated to a key
  37968. * @param key defines the key to use
  37969. * @param value defines the value to store
  37970. * @returns true if the value was updated (or false if the key was not found)
  37971. */
  37972. set(key: string, value: T): boolean;
  37973. /**
  37974. * Get the element of the given key and remove it from the dictionary
  37975. * @param key defines the key to search
  37976. * @returns the value associated with the key or null if not found
  37977. */
  37978. getAndRemove(key: string): Nullable<T>;
  37979. /**
  37980. * Remove a key/value from the dictionary.
  37981. * @param key the key to remove
  37982. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  37983. */
  37984. remove(key: string): boolean;
  37985. /**
  37986. * Clear the whole content of the dictionary
  37987. */
  37988. clear(): void;
  37989. /**
  37990. * Gets the current count
  37991. */
  37992. get count(): number;
  37993. /**
  37994. * Execute a callback on each key/val of the dictionary.
  37995. * Note that you can remove any element in this dictionary in the callback implementation
  37996. * @param callback the callback to execute on a given key/value pair
  37997. */
  37998. forEach(callback: (key: string, val: T) => void): void;
  37999. /**
  38000. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38001. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38002. * Note that you can remove any element in this dictionary in the callback implementation
  38003. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38004. * @returns the first item
  38005. */
  38006. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38007. private _count;
  38008. private _data;
  38009. }
  38010. }
  38011. declare module BABYLON {
  38012. /** @hidden */
  38013. export interface ICollisionCoordinator {
  38014. createCollider(): Collider;
  38015. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38016. init(scene: Scene): void;
  38017. }
  38018. /** @hidden */
  38019. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38020. private _scene;
  38021. private _scaledPosition;
  38022. private _scaledVelocity;
  38023. private _finalPosition;
  38024. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38025. createCollider(): Collider;
  38026. init(scene: Scene): void;
  38027. private _collideWithWorld;
  38028. }
  38029. }
  38030. declare module BABYLON {
  38031. /**
  38032. * Class used to manage all inputs for the scene.
  38033. */
  38034. export class InputManager {
  38035. /** The distance in pixel that you have to move to prevent some events */
  38036. static DragMovementThreshold: number;
  38037. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38038. static LongPressDelay: number;
  38039. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38040. static DoubleClickDelay: number;
  38041. /** If you need to check double click without raising a single click at first click, enable this flag */
  38042. static ExclusiveDoubleClickMode: boolean;
  38043. private _wheelEventName;
  38044. private _onPointerMove;
  38045. private _onPointerDown;
  38046. private _onPointerUp;
  38047. private _initClickEvent;
  38048. private _initActionManager;
  38049. private _delayedSimpleClick;
  38050. private _delayedSimpleClickTimeout;
  38051. private _previousDelayedSimpleClickTimeout;
  38052. private _meshPickProceed;
  38053. private _previousButtonPressed;
  38054. private _currentPickResult;
  38055. private _previousPickResult;
  38056. private _totalPointersPressed;
  38057. private _doubleClickOccured;
  38058. private _pointerOverMesh;
  38059. private _pickedDownMesh;
  38060. private _pickedUpMesh;
  38061. private _pointerX;
  38062. private _pointerY;
  38063. private _unTranslatedPointerX;
  38064. private _unTranslatedPointerY;
  38065. private _startingPointerPosition;
  38066. private _previousStartingPointerPosition;
  38067. private _startingPointerTime;
  38068. private _previousStartingPointerTime;
  38069. private _pointerCaptures;
  38070. private _onKeyDown;
  38071. private _onKeyUp;
  38072. private _onCanvasFocusObserver;
  38073. private _onCanvasBlurObserver;
  38074. private _scene;
  38075. /**
  38076. * Creates a new InputManager
  38077. * @param scene defines the hosting scene
  38078. */
  38079. constructor(scene: Scene);
  38080. /**
  38081. * Gets the mesh that is currently under the pointer
  38082. */
  38083. get meshUnderPointer(): Nullable<AbstractMesh>;
  38084. /**
  38085. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38086. */
  38087. get unTranslatedPointer(): Vector2;
  38088. /**
  38089. * Gets or sets the current on-screen X position of the pointer
  38090. */
  38091. get pointerX(): number;
  38092. set pointerX(value: number);
  38093. /**
  38094. * Gets or sets the current on-screen Y position of the pointer
  38095. */
  38096. get pointerY(): number;
  38097. set pointerY(value: number);
  38098. private _updatePointerPosition;
  38099. private _processPointerMove;
  38100. private _setRayOnPointerInfo;
  38101. private _checkPrePointerObservable;
  38102. /**
  38103. * Use this method to simulate a pointer move on a mesh
  38104. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38105. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38106. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38107. */
  38108. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38109. /**
  38110. * Use this method to simulate a pointer down on a mesh
  38111. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38112. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38113. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38114. */
  38115. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38116. private _processPointerDown;
  38117. /** @hidden */
  38118. _isPointerSwiping(): boolean;
  38119. /**
  38120. * Use this method to simulate a pointer up on a mesh
  38121. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38122. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38123. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38124. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38125. */
  38126. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38127. private _processPointerUp;
  38128. /**
  38129. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38130. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38131. * @returns true if the pointer was captured
  38132. */
  38133. isPointerCaptured(pointerId?: number): boolean;
  38134. /**
  38135. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38136. * @param attachUp defines if you want to attach events to pointerup
  38137. * @param attachDown defines if you want to attach events to pointerdown
  38138. * @param attachMove defines if you want to attach events to pointermove
  38139. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38140. */
  38141. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38142. /**
  38143. * Detaches all event handlers
  38144. */
  38145. detachControl(): void;
  38146. /**
  38147. * Force the value of meshUnderPointer
  38148. * @param mesh defines the mesh to use
  38149. */
  38150. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38151. /**
  38152. * Gets the mesh under the pointer
  38153. * @returns a Mesh or null if no mesh is under the pointer
  38154. */
  38155. getPointerOverMesh(): Nullable<AbstractMesh>;
  38156. }
  38157. }
  38158. declare module BABYLON {
  38159. /**
  38160. * This class defines the direct association between an animation and a target
  38161. */
  38162. export class TargetedAnimation {
  38163. /**
  38164. * Animation to perform
  38165. */
  38166. animation: Animation;
  38167. /**
  38168. * Target to animate
  38169. */
  38170. target: any;
  38171. /**
  38172. * Returns the string "TargetedAnimation"
  38173. * @returns "TargetedAnimation"
  38174. */
  38175. getClassName(): string;
  38176. /**
  38177. * Serialize the object
  38178. * @returns the JSON object representing the current entity
  38179. */
  38180. serialize(): any;
  38181. }
  38182. /**
  38183. * Use this class to create coordinated animations on multiple targets
  38184. */
  38185. export class AnimationGroup implements IDisposable {
  38186. /** The name of the animation group */
  38187. name: string;
  38188. private _scene;
  38189. private _targetedAnimations;
  38190. private _animatables;
  38191. private _from;
  38192. private _to;
  38193. private _isStarted;
  38194. private _isPaused;
  38195. private _speedRatio;
  38196. private _loopAnimation;
  38197. private _isAdditive;
  38198. /**
  38199. * Gets or sets the unique id of the node
  38200. */
  38201. uniqueId: number;
  38202. /**
  38203. * This observable will notify when one animation have ended
  38204. */
  38205. onAnimationEndObservable: Observable<TargetedAnimation>;
  38206. /**
  38207. * Observer raised when one animation loops
  38208. */
  38209. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38210. /**
  38211. * Observer raised when all animations have looped
  38212. */
  38213. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38214. /**
  38215. * This observable will notify when all animations have ended.
  38216. */
  38217. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38218. /**
  38219. * This observable will notify when all animations have paused.
  38220. */
  38221. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38222. /**
  38223. * This observable will notify when all animations are playing.
  38224. */
  38225. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38226. /**
  38227. * Gets the first frame
  38228. */
  38229. get from(): number;
  38230. /**
  38231. * Gets the last frame
  38232. */
  38233. get to(): number;
  38234. /**
  38235. * Define if the animations are started
  38236. */
  38237. get isStarted(): boolean;
  38238. /**
  38239. * Gets a value indicating that the current group is playing
  38240. */
  38241. get isPlaying(): boolean;
  38242. /**
  38243. * Gets or sets the speed ratio to use for all animations
  38244. */
  38245. get speedRatio(): number;
  38246. /**
  38247. * Gets or sets the speed ratio to use for all animations
  38248. */
  38249. set speedRatio(value: number);
  38250. /**
  38251. * Gets or sets if all animations should loop or not
  38252. */
  38253. get loopAnimation(): boolean;
  38254. set loopAnimation(value: boolean);
  38255. /**
  38256. * Gets or sets if all animations should be evaluated additively
  38257. */
  38258. get isAdditive(): boolean;
  38259. set isAdditive(value: boolean);
  38260. /**
  38261. * Gets the targeted animations for this animation group
  38262. */
  38263. get targetedAnimations(): Array<TargetedAnimation>;
  38264. /**
  38265. * returning the list of animatables controlled by this animation group.
  38266. */
  38267. get animatables(): Array<Animatable>;
  38268. /**
  38269. * Gets the list of target animations
  38270. */
  38271. get children(): TargetedAnimation[];
  38272. /**
  38273. * Instantiates a new Animation Group.
  38274. * This helps managing several animations at once.
  38275. * @see https://doc.babylonjs.com/how_to/group
  38276. * @param name Defines the name of the group
  38277. * @param scene Defines the scene the group belongs to
  38278. */
  38279. constructor(
  38280. /** The name of the animation group */
  38281. name: string, scene?: Nullable<Scene>);
  38282. /**
  38283. * Add an animation (with its target) in the group
  38284. * @param animation defines the animation we want to add
  38285. * @param target defines the target of the animation
  38286. * @returns the TargetedAnimation object
  38287. */
  38288. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  38289. /**
  38290. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  38291. * It can add constant keys at begin or end
  38292. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  38293. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  38294. * @returns the animation group
  38295. */
  38296. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  38297. private _animationLoopCount;
  38298. private _animationLoopFlags;
  38299. private _processLoop;
  38300. /**
  38301. * Start all animations on given targets
  38302. * @param loop defines if animations must loop
  38303. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  38304. * @param from defines the from key (optional)
  38305. * @param to defines the to key (optional)
  38306. * @param isAdditive defines the additive state for the resulting animatables (optional)
  38307. * @returns the current animation group
  38308. */
  38309. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  38310. /**
  38311. * Pause all animations
  38312. * @returns the animation group
  38313. */
  38314. pause(): AnimationGroup;
  38315. /**
  38316. * Play all animations to initial state
  38317. * This function will start() the animations if they were not started or will restart() them if they were paused
  38318. * @param loop defines if animations must loop
  38319. * @returns the animation group
  38320. */
  38321. play(loop?: boolean): AnimationGroup;
  38322. /**
  38323. * Reset all animations to initial state
  38324. * @returns the animation group
  38325. */
  38326. reset(): AnimationGroup;
  38327. /**
  38328. * Restart animations from key 0
  38329. * @returns the animation group
  38330. */
  38331. restart(): AnimationGroup;
  38332. /**
  38333. * Stop all animations
  38334. * @returns the animation group
  38335. */
  38336. stop(): AnimationGroup;
  38337. /**
  38338. * Set animation weight for all animatables
  38339. * @param weight defines the weight to use
  38340. * @return the animationGroup
  38341. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38342. */
  38343. setWeightForAllAnimatables(weight: number): AnimationGroup;
  38344. /**
  38345. * Synchronize and normalize all animatables with a source animatable
  38346. * @param root defines the root animatable to synchronize with
  38347. * @return the animationGroup
  38348. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  38349. */
  38350. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  38351. /**
  38352. * Goes to a specific frame in this animation group
  38353. * @param frame the frame number to go to
  38354. * @return the animationGroup
  38355. */
  38356. goToFrame(frame: number): AnimationGroup;
  38357. /**
  38358. * Dispose all associated resources
  38359. */
  38360. dispose(): void;
  38361. private _checkAnimationGroupEnded;
  38362. /**
  38363. * Clone the current animation group and returns a copy
  38364. * @param newName defines the name of the new group
  38365. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  38366. * @returns the new aniamtion group
  38367. */
  38368. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  38369. /**
  38370. * Serializes the animationGroup to an object
  38371. * @returns Serialized object
  38372. */
  38373. serialize(): any;
  38374. /**
  38375. * Returns a new AnimationGroup object parsed from the source provided.
  38376. * @param parsedAnimationGroup defines the source
  38377. * @param scene defines the scene that will receive the animationGroup
  38378. * @returns a new AnimationGroup
  38379. */
  38380. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  38381. /**
  38382. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38383. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  38384. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38385. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  38386. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  38387. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  38388. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  38389. */
  38390. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  38391. /**
  38392. * Returns the string "AnimationGroup"
  38393. * @returns "AnimationGroup"
  38394. */
  38395. getClassName(): string;
  38396. /**
  38397. * Creates a detailled string about the object
  38398. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  38399. * @returns a string representing the object
  38400. */
  38401. toString(fullDetails?: boolean): string;
  38402. }
  38403. }
  38404. declare module BABYLON {
  38405. /**
  38406. * Define an interface for all classes that will hold resources
  38407. */
  38408. export interface IDisposable {
  38409. /**
  38410. * Releases all held resources
  38411. */
  38412. dispose(): void;
  38413. }
  38414. /** Interface defining initialization parameters for Scene class */
  38415. export interface SceneOptions {
  38416. /**
  38417. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  38418. * It will improve performance when the number of geometries becomes important.
  38419. */
  38420. useGeometryUniqueIdsMap?: boolean;
  38421. /**
  38422. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  38423. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38424. */
  38425. useMaterialMeshMap?: boolean;
  38426. /**
  38427. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  38428. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  38429. */
  38430. useClonedMeshMap?: boolean;
  38431. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  38432. virtual?: boolean;
  38433. }
  38434. /**
  38435. * Represents a scene to be rendered by the engine.
  38436. * @see https://doc.babylonjs.com/features/scene
  38437. */
  38438. export class Scene extends AbstractScene implements IAnimatable {
  38439. /** The fog is deactivated */
  38440. static readonly FOGMODE_NONE: number;
  38441. /** The fog density is following an exponential function */
  38442. static readonly FOGMODE_EXP: number;
  38443. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  38444. static readonly FOGMODE_EXP2: number;
  38445. /** The fog density is following a linear function. */
  38446. static readonly FOGMODE_LINEAR: number;
  38447. /**
  38448. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  38449. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38450. */
  38451. static MinDeltaTime: number;
  38452. /**
  38453. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  38454. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38455. */
  38456. static MaxDeltaTime: number;
  38457. /**
  38458. * Factory used to create the default material.
  38459. * @param name The name of the material to create
  38460. * @param scene The scene to create the material for
  38461. * @returns The default material
  38462. */
  38463. static DefaultMaterialFactory(scene: Scene): Material;
  38464. /**
  38465. * Factory used to create the a collision coordinator.
  38466. * @returns The collision coordinator
  38467. */
  38468. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  38469. /** @hidden */
  38470. _inputManager: InputManager;
  38471. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  38472. cameraToUseForPointers: Nullable<Camera>;
  38473. /** @hidden */
  38474. readonly _isScene: boolean;
  38475. /** @hidden */
  38476. _blockEntityCollection: boolean;
  38477. /**
  38478. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  38479. */
  38480. autoClear: boolean;
  38481. /**
  38482. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  38483. */
  38484. autoClearDepthAndStencil: boolean;
  38485. /**
  38486. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  38487. */
  38488. clearColor: Color4;
  38489. /**
  38490. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  38491. */
  38492. ambientColor: Color3;
  38493. /**
  38494. * This is use to store the default BRDF lookup for PBR materials in your scene.
  38495. * It should only be one of the following (if not the default embedded one):
  38496. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  38497. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  38498. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  38499. * The material properties need to be setup according to the type of texture in use.
  38500. */
  38501. environmentBRDFTexture: BaseTexture;
  38502. /** @hidden */
  38503. protected _environmentTexture: Nullable<BaseTexture>;
  38504. /**
  38505. * Texture used in all pbr material as the reflection texture.
  38506. * As in the majority of the scene they are the same (exception for multi room and so on),
  38507. * this is easier to reference from here than from all the materials.
  38508. */
  38509. get environmentTexture(): Nullable<BaseTexture>;
  38510. /**
  38511. * Texture used in all pbr material as the reflection texture.
  38512. * As in the majority of the scene they are the same (exception for multi room and so on),
  38513. * this is easier to set here than in all the materials.
  38514. */
  38515. set environmentTexture(value: Nullable<BaseTexture>);
  38516. /** @hidden */
  38517. protected _environmentIntensity: number;
  38518. /**
  38519. * Intensity of the environment in all pbr material.
  38520. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38521. * As in the majority of the scene they are the same (exception for multi room and so on),
  38522. * this is easier to reference from here than from all the materials.
  38523. */
  38524. get environmentIntensity(): number;
  38525. /**
  38526. * Intensity of the environment in all pbr material.
  38527. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  38528. * As in the majority of the scene they are the same (exception for multi room and so on),
  38529. * this is easier to set here than in all the materials.
  38530. */
  38531. set environmentIntensity(value: number);
  38532. /** @hidden */
  38533. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38534. /**
  38535. * Default image processing configuration used either in the rendering
  38536. * Forward main pass or through the imageProcessingPostProcess if present.
  38537. * As in the majority of the scene they are the same (exception for multi camera),
  38538. * this is easier to reference from here than from all the materials and post process.
  38539. *
  38540. * No setter as we it is a shared configuration, you can set the values instead.
  38541. */
  38542. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  38543. private _forceWireframe;
  38544. /**
  38545. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  38546. */
  38547. set forceWireframe(value: boolean);
  38548. get forceWireframe(): boolean;
  38549. private _skipFrustumClipping;
  38550. /**
  38551. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  38552. */
  38553. set skipFrustumClipping(value: boolean);
  38554. get skipFrustumClipping(): boolean;
  38555. private _forcePointsCloud;
  38556. /**
  38557. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  38558. */
  38559. set forcePointsCloud(value: boolean);
  38560. get forcePointsCloud(): boolean;
  38561. /**
  38562. * Gets or sets the active clipplane 1
  38563. */
  38564. clipPlane: Nullable<Plane>;
  38565. /**
  38566. * Gets or sets the active clipplane 2
  38567. */
  38568. clipPlane2: Nullable<Plane>;
  38569. /**
  38570. * Gets or sets the active clipplane 3
  38571. */
  38572. clipPlane3: Nullable<Plane>;
  38573. /**
  38574. * Gets or sets the active clipplane 4
  38575. */
  38576. clipPlane4: Nullable<Plane>;
  38577. /**
  38578. * Gets or sets the active clipplane 5
  38579. */
  38580. clipPlane5: Nullable<Plane>;
  38581. /**
  38582. * Gets or sets the active clipplane 6
  38583. */
  38584. clipPlane6: Nullable<Plane>;
  38585. /**
  38586. * Gets or sets a boolean indicating if animations are enabled
  38587. */
  38588. animationsEnabled: boolean;
  38589. private _animationPropertiesOverride;
  38590. /**
  38591. * Gets or sets the animation properties override
  38592. */
  38593. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  38594. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  38595. /**
  38596. * Gets or sets a boolean indicating if a constant deltatime has to be used
  38597. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  38598. */
  38599. useConstantAnimationDeltaTime: boolean;
  38600. /**
  38601. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  38602. * Please note that it requires to run a ray cast through the scene on every frame
  38603. */
  38604. constantlyUpdateMeshUnderPointer: boolean;
  38605. /**
  38606. * Defines the HTML cursor to use when hovering over interactive elements
  38607. */
  38608. hoverCursor: string;
  38609. /**
  38610. * Defines the HTML default cursor to use (empty by default)
  38611. */
  38612. defaultCursor: string;
  38613. /**
  38614. * Defines whether cursors are handled by the scene.
  38615. */
  38616. doNotHandleCursors: boolean;
  38617. /**
  38618. * This is used to call preventDefault() on pointer down
  38619. * in order to block unwanted artifacts like system double clicks
  38620. */
  38621. preventDefaultOnPointerDown: boolean;
  38622. /**
  38623. * This is used to call preventDefault() on pointer up
  38624. * in order to block unwanted artifacts like system double clicks
  38625. */
  38626. preventDefaultOnPointerUp: boolean;
  38627. /**
  38628. * Gets or sets user defined metadata
  38629. */
  38630. metadata: any;
  38631. /**
  38632. * For internal use only. Please do not use.
  38633. */
  38634. reservedDataStore: any;
  38635. /**
  38636. * Gets the name of the plugin used to load this scene (null by default)
  38637. */
  38638. loadingPluginName: string;
  38639. /**
  38640. * Use this array to add regular expressions used to disable offline support for specific urls
  38641. */
  38642. disableOfflineSupportExceptionRules: RegExp[];
  38643. /**
  38644. * An event triggered when the scene is disposed.
  38645. */
  38646. onDisposeObservable: Observable<Scene>;
  38647. private _onDisposeObserver;
  38648. /** Sets a function to be executed when this scene is disposed. */
  38649. set onDispose(callback: () => void);
  38650. /**
  38651. * An event triggered before rendering the scene (right after animations and physics)
  38652. */
  38653. onBeforeRenderObservable: Observable<Scene>;
  38654. private _onBeforeRenderObserver;
  38655. /** Sets a function to be executed before rendering this scene */
  38656. set beforeRender(callback: Nullable<() => void>);
  38657. /**
  38658. * An event triggered after rendering the scene
  38659. */
  38660. onAfterRenderObservable: Observable<Scene>;
  38661. /**
  38662. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  38663. */
  38664. onAfterRenderCameraObservable: Observable<Camera>;
  38665. private _onAfterRenderObserver;
  38666. /** Sets a function to be executed after rendering this scene */
  38667. set afterRender(callback: Nullable<() => void>);
  38668. /**
  38669. * An event triggered before animating the scene
  38670. */
  38671. onBeforeAnimationsObservable: Observable<Scene>;
  38672. /**
  38673. * An event triggered after animations processing
  38674. */
  38675. onAfterAnimationsObservable: Observable<Scene>;
  38676. /**
  38677. * An event triggered before draw calls are ready to be sent
  38678. */
  38679. onBeforeDrawPhaseObservable: Observable<Scene>;
  38680. /**
  38681. * An event triggered after draw calls have been sent
  38682. */
  38683. onAfterDrawPhaseObservable: Observable<Scene>;
  38684. /**
  38685. * An event triggered when the scene is ready
  38686. */
  38687. onReadyObservable: Observable<Scene>;
  38688. /**
  38689. * An event triggered before rendering a camera
  38690. */
  38691. onBeforeCameraRenderObservable: Observable<Camera>;
  38692. private _onBeforeCameraRenderObserver;
  38693. /** Sets a function to be executed before rendering a camera*/
  38694. set beforeCameraRender(callback: () => void);
  38695. /**
  38696. * An event triggered after rendering a camera
  38697. */
  38698. onAfterCameraRenderObservable: Observable<Camera>;
  38699. private _onAfterCameraRenderObserver;
  38700. /** Sets a function to be executed after rendering a camera*/
  38701. set afterCameraRender(callback: () => void);
  38702. /**
  38703. * An event triggered when active meshes evaluation is about to start
  38704. */
  38705. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  38706. /**
  38707. * An event triggered when active meshes evaluation is done
  38708. */
  38709. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  38710. /**
  38711. * An event triggered when particles rendering is about to start
  38712. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38713. */
  38714. onBeforeParticlesRenderingObservable: Observable<Scene>;
  38715. /**
  38716. * An event triggered when particles rendering is done
  38717. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  38718. */
  38719. onAfterParticlesRenderingObservable: Observable<Scene>;
  38720. /**
  38721. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  38722. */
  38723. onDataLoadedObservable: Observable<Scene>;
  38724. /**
  38725. * An event triggered when a camera is created
  38726. */
  38727. onNewCameraAddedObservable: Observable<Camera>;
  38728. /**
  38729. * An event triggered when a camera is removed
  38730. */
  38731. onCameraRemovedObservable: Observable<Camera>;
  38732. /**
  38733. * An event triggered when a light is created
  38734. */
  38735. onNewLightAddedObservable: Observable<Light>;
  38736. /**
  38737. * An event triggered when a light is removed
  38738. */
  38739. onLightRemovedObservable: Observable<Light>;
  38740. /**
  38741. * An event triggered when a geometry is created
  38742. */
  38743. onNewGeometryAddedObservable: Observable<Geometry>;
  38744. /**
  38745. * An event triggered when a geometry is removed
  38746. */
  38747. onGeometryRemovedObservable: Observable<Geometry>;
  38748. /**
  38749. * An event triggered when a transform node is created
  38750. */
  38751. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  38752. /**
  38753. * An event triggered when a transform node is removed
  38754. */
  38755. onTransformNodeRemovedObservable: Observable<TransformNode>;
  38756. /**
  38757. * An event triggered when a mesh is created
  38758. */
  38759. onNewMeshAddedObservable: Observable<AbstractMesh>;
  38760. /**
  38761. * An event triggered when a mesh is removed
  38762. */
  38763. onMeshRemovedObservable: Observable<AbstractMesh>;
  38764. /**
  38765. * An event triggered when a skeleton is created
  38766. */
  38767. onNewSkeletonAddedObservable: Observable<Skeleton>;
  38768. /**
  38769. * An event triggered when a skeleton is removed
  38770. */
  38771. onSkeletonRemovedObservable: Observable<Skeleton>;
  38772. /**
  38773. * An event triggered when a material is created
  38774. */
  38775. onNewMaterialAddedObservable: Observable<Material>;
  38776. /**
  38777. * An event triggered when a material is removed
  38778. */
  38779. onMaterialRemovedObservable: Observable<Material>;
  38780. /**
  38781. * An event triggered when a texture is created
  38782. */
  38783. onNewTextureAddedObservable: Observable<BaseTexture>;
  38784. /**
  38785. * An event triggered when a texture is removed
  38786. */
  38787. onTextureRemovedObservable: Observable<BaseTexture>;
  38788. /**
  38789. * An event triggered when render targets are about to be rendered
  38790. * Can happen multiple times per frame.
  38791. */
  38792. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  38793. /**
  38794. * An event triggered when render targets were rendered.
  38795. * Can happen multiple times per frame.
  38796. */
  38797. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  38798. /**
  38799. * An event triggered before calculating deterministic simulation step
  38800. */
  38801. onBeforeStepObservable: Observable<Scene>;
  38802. /**
  38803. * An event triggered after calculating deterministic simulation step
  38804. */
  38805. onAfterStepObservable: Observable<Scene>;
  38806. /**
  38807. * An event triggered when the activeCamera property is updated
  38808. */
  38809. onActiveCameraChanged: Observable<Scene>;
  38810. /**
  38811. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  38812. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38813. * 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)
  38814. */
  38815. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38816. /**
  38817. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  38818. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  38819. * 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)
  38820. */
  38821. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  38822. /**
  38823. * This Observable will when a mesh has been imported into the scene.
  38824. */
  38825. onMeshImportedObservable: Observable<AbstractMesh>;
  38826. /**
  38827. * This Observable will when an animation file has been imported into the scene.
  38828. */
  38829. onAnimationFileImportedObservable: Observable<Scene>;
  38830. /**
  38831. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  38832. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  38833. */
  38834. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  38835. /** @hidden */
  38836. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  38837. /**
  38838. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  38839. */
  38840. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  38841. /**
  38842. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  38843. */
  38844. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  38845. /**
  38846. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  38847. */
  38848. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  38849. /** Callback called when a pointer move is detected */
  38850. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38851. /** Callback called when a pointer down is detected */
  38852. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  38853. /** Callback called when a pointer up is detected */
  38854. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  38855. /** Callback called when a pointer pick is detected */
  38856. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  38857. /**
  38858. * 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).
  38859. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  38860. */
  38861. onPrePointerObservable: Observable<PointerInfoPre>;
  38862. /**
  38863. * Observable event triggered each time an input event is received from the rendering canvas
  38864. */
  38865. onPointerObservable: Observable<PointerInfo>;
  38866. /**
  38867. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  38868. */
  38869. get unTranslatedPointer(): Vector2;
  38870. /**
  38871. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  38872. */
  38873. static get DragMovementThreshold(): number;
  38874. static set DragMovementThreshold(value: number);
  38875. /**
  38876. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  38877. */
  38878. static get LongPressDelay(): number;
  38879. static set LongPressDelay(value: number);
  38880. /**
  38881. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  38882. */
  38883. static get DoubleClickDelay(): number;
  38884. static set DoubleClickDelay(value: number);
  38885. /** If you need to check double click without raising a single click at first click, enable this flag */
  38886. static get ExclusiveDoubleClickMode(): boolean;
  38887. static set ExclusiveDoubleClickMode(value: boolean);
  38888. /** @hidden */
  38889. _mirroredCameraPosition: Nullable<Vector3>;
  38890. /**
  38891. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  38892. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  38893. */
  38894. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  38895. /**
  38896. * Observable event triggered each time an keyboard event is received from the hosting window
  38897. */
  38898. onKeyboardObservable: Observable<KeyboardInfo>;
  38899. private _useRightHandedSystem;
  38900. /**
  38901. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  38902. */
  38903. set useRightHandedSystem(value: boolean);
  38904. get useRightHandedSystem(): boolean;
  38905. private _timeAccumulator;
  38906. private _currentStepId;
  38907. private _currentInternalStep;
  38908. /**
  38909. * Sets the step Id used by deterministic lock step
  38910. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38911. * @param newStepId defines the step Id
  38912. */
  38913. setStepId(newStepId: number): void;
  38914. /**
  38915. * Gets the step Id used by deterministic lock step
  38916. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38917. * @returns the step Id
  38918. */
  38919. getStepId(): number;
  38920. /**
  38921. * Gets the internal step used by deterministic lock step
  38922. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38923. * @returns the internal step
  38924. */
  38925. getInternalStep(): number;
  38926. private _fogEnabled;
  38927. /**
  38928. * Gets or sets a boolean indicating if fog is enabled on this scene
  38929. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38930. * (Default is true)
  38931. */
  38932. set fogEnabled(value: boolean);
  38933. get fogEnabled(): boolean;
  38934. private _fogMode;
  38935. /**
  38936. * Gets or sets the fog mode to use
  38937. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38938. * | mode | value |
  38939. * | --- | --- |
  38940. * | FOGMODE_NONE | 0 |
  38941. * | FOGMODE_EXP | 1 |
  38942. * | FOGMODE_EXP2 | 2 |
  38943. * | FOGMODE_LINEAR | 3 |
  38944. */
  38945. set fogMode(value: number);
  38946. get fogMode(): number;
  38947. /**
  38948. * Gets or sets the fog color to use
  38949. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38950. * (Default is Color3(0.2, 0.2, 0.3))
  38951. */
  38952. fogColor: Color3;
  38953. /**
  38954. * Gets or sets the fog density to use
  38955. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38956. * (Default is 0.1)
  38957. */
  38958. fogDensity: number;
  38959. /**
  38960. * Gets or sets the fog start distance to use
  38961. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38962. * (Default is 0)
  38963. */
  38964. fogStart: number;
  38965. /**
  38966. * Gets or sets the fog end distance to use
  38967. * @see https://doc.babylonjs.com/babylon101/environment#fog
  38968. * (Default is 1000)
  38969. */
  38970. fogEnd: number;
  38971. /**
  38972. * Flag indicating that the frame buffer binding is handled by another component
  38973. */
  38974. prePass: boolean;
  38975. private _shadowsEnabled;
  38976. /**
  38977. * Gets or sets a boolean indicating if shadows are enabled on this scene
  38978. */
  38979. set shadowsEnabled(value: boolean);
  38980. get shadowsEnabled(): boolean;
  38981. private _lightsEnabled;
  38982. /**
  38983. * Gets or sets a boolean indicating if lights are enabled on this scene
  38984. */
  38985. set lightsEnabled(value: boolean);
  38986. get lightsEnabled(): boolean;
  38987. /** All of the active cameras added to this scene. */
  38988. activeCameras: Camera[];
  38989. /** @hidden */
  38990. _activeCamera: Nullable<Camera>;
  38991. /** Gets or sets the current active camera */
  38992. get activeCamera(): Nullable<Camera>;
  38993. set activeCamera(value: Nullable<Camera>);
  38994. private _defaultMaterial;
  38995. /** The default material used on meshes when no material is affected */
  38996. get defaultMaterial(): Material;
  38997. /** The default material used on meshes when no material is affected */
  38998. set defaultMaterial(value: Material);
  38999. private _texturesEnabled;
  39000. /**
  39001. * Gets or sets a boolean indicating if textures are enabled on this scene
  39002. */
  39003. set texturesEnabled(value: boolean);
  39004. get texturesEnabled(): boolean;
  39005. /**
  39006. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39007. */
  39008. physicsEnabled: boolean;
  39009. /**
  39010. * Gets or sets a boolean indicating if particles are enabled on this scene
  39011. */
  39012. particlesEnabled: boolean;
  39013. /**
  39014. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39015. */
  39016. spritesEnabled: boolean;
  39017. private _skeletonsEnabled;
  39018. /**
  39019. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39020. */
  39021. set skeletonsEnabled(value: boolean);
  39022. get skeletonsEnabled(): boolean;
  39023. /**
  39024. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39025. */
  39026. lensFlaresEnabled: boolean;
  39027. /**
  39028. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39029. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39030. */
  39031. collisionsEnabled: boolean;
  39032. private _collisionCoordinator;
  39033. /** @hidden */
  39034. get collisionCoordinator(): ICollisionCoordinator;
  39035. /**
  39036. * Defines the gravity applied to this scene (used only for collisions)
  39037. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39038. */
  39039. gravity: Vector3;
  39040. /**
  39041. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39042. */
  39043. postProcessesEnabled: boolean;
  39044. /**
  39045. * The list of postprocesses added to the scene
  39046. */
  39047. postProcesses: PostProcess[];
  39048. /**
  39049. * Gets the current postprocess manager
  39050. */
  39051. postProcessManager: PostProcessManager;
  39052. /**
  39053. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39054. */
  39055. renderTargetsEnabled: boolean;
  39056. /**
  39057. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39058. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39059. */
  39060. dumpNextRenderTargets: boolean;
  39061. /**
  39062. * The list of user defined render targets added to the scene
  39063. */
  39064. customRenderTargets: RenderTargetTexture[];
  39065. /**
  39066. * Defines if texture loading must be delayed
  39067. * If true, textures will only be loaded when they need to be rendered
  39068. */
  39069. useDelayedTextureLoading: boolean;
  39070. /**
  39071. * Gets the list of meshes imported to the scene through SceneLoader
  39072. */
  39073. importedMeshesFiles: String[];
  39074. /**
  39075. * Gets or sets a boolean indicating if probes are enabled on this scene
  39076. */
  39077. probesEnabled: boolean;
  39078. /**
  39079. * Gets or sets the current offline provider to use to store scene data
  39080. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39081. */
  39082. offlineProvider: IOfflineProvider;
  39083. /**
  39084. * Gets or sets the action manager associated with the scene
  39085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39086. */
  39087. actionManager: AbstractActionManager;
  39088. private _meshesForIntersections;
  39089. /**
  39090. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39091. */
  39092. proceduralTexturesEnabled: boolean;
  39093. private _engine;
  39094. private _totalVertices;
  39095. /** @hidden */
  39096. _activeIndices: PerfCounter;
  39097. /** @hidden */
  39098. _activeParticles: PerfCounter;
  39099. /** @hidden */
  39100. _activeBones: PerfCounter;
  39101. private _animationRatio;
  39102. /** @hidden */
  39103. _animationTimeLast: number;
  39104. /** @hidden */
  39105. _animationTime: number;
  39106. /**
  39107. * Gets or sets a general scale for animation speed
  39108. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39109. */
  39110. animationTimeScale: number;
  39111. /** @hidden */
  39112. _cachedMaterial: Nullable<Material>;
  39113. /** @hidden */
  39114. _cachedEffect: Nullable<Effect>;
  39115. /** @hidden */
  39116. _cachedVisibility: Nullable<number>;
  39117. private _renderId;
  39118. private _frameId;
  39119. private _executeWhenReadyTimeoutId;
  39120. private _intermediateRendering;
  39121. private _viewUpdateFlag;
  39122. private _projectionUpdateFlag;
  39123. /** @hidden */
  39124. _toBeDisposed: Nullable<IDisposable>[];
  39125. private _activeRequests;
  39126. /** @hidden */
  39127. _pendingData: any[];
  39128. private _isDisposed;
  39129. /**
  39130. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39131. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39132. */
  39133. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39134. private _activeMeshes;
  39135. private _processedMaterials;
  39136. private _renderTargets;
  39137. /** @hidden */
  39138. _activeParticleSystems: SmartArray<IParticleSystem>;
  39139. private _activeSkeletons;
  39140. private _softwareSkinnedMeshes;
  39141. private _renderingManager;
  39142. /** @hidden */
  39143. _activeAnimatables: Animatable[];
  39144. private _transformMatrix;
  39145. private _sceneUbo;
  39146. /** @hidden */
  39147. _viewMatrix: Matrix;
  39148. private _projectionMatrix;
  39149. /** @hidden */
  39150. _forcedViewPosition: Nullable<Vector3>;
  39151. /** @hidden */
  39152. _frustumPlanes: Plane[];
  39153. /**
  39154. * Gets the list of frustum planes (built from the active camera)
  39155. */
  39156. get frustumPlanes(): Plane[];
  39157. /**
  39158. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39159. * This is useful if there are more lights that the maximum simulteanous authorized
  39160. */
  39161. requireLightSorting: boolean;
  39162. /** @hidden */
  39163. readonly useMaterialMeshMap: boolean;
  39164. /** @hidden */
  39165. readonly useClonedMeshMap: boolean;
  39166. private _externalData;
  39167. private _uid;
  39168. /**
  39169. * @hidden
  39170. * Backing store of defined scene components.
  39171. */
  39172. _components: ISceneComponent[];
  39173. /**
  39174. * @hidden
  39175. * Backing store of defined scene components.
  39176. */
  39177. _serializableComponents: ISceneSerializableComponent[];
  39178. /**
  39179. * List of components to register on the next registration step.
  39180. */
  39181. private _transientComponents;
  39182. /**
  39183. * Registers the transient components if needed.
  39184. */
  39185. private _registerTransientComponents;
  39186. /**
  39187. * @hidden
  39188. * Add a component to the scene.
  39189. * Note that the ccomponent could be registered on th next frame if this is called after
  39190. * the register component stage.
  39191. * @param component Defines the component to add to the scene
  39192. */
  39193. _addComponent(component: ISceneComponent): void;
  39194. /**
  39195. * @hidden
  39196. * Gets a component from the scene.
  39197. * @param name defines the name of the component to retrieve
  39198. * @returns the component or null if not present
  39199. */
  39200. _getComponent(name: string): Nullable<ISceneComponent>;
  39201. /**
  39202. * @hidden
  39203. * Defines the actions happening before camera updates.
  39204. */
  39205. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39206. /**
  39207. * @hidden
  39208. * Defines the actions happening before clear the canvas.
  39209. */
  39210. _beforeClearStage: Stage<SimpleStageAction>;
  39211. /**
  39212. * @hidden
  39213. * Defines the actions when collecting render targets for the frame.
  39214. */
  39215. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39216. /**
  39217. * @hidden
  39218. * Defines the actions happening for one camera in the frame.
  39219. */
  39220. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39221. /**
  39222. * @hidden
  39223. * Defines the actions happening during the per mesh ready checks.
  39224. */
  39225. _isReadyForMeshStage: Stage<MeshStageAction>;
  39226. /**
  39227. * @hidden
  39228. * Defines the actions happening before evaluate active mesh checks.
  39229. */
  39230. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39231. /**
  39232. * @hidden
  39233. * Defines the actions happening during the evaluate sub mesh checks.
  39234. */
  39235. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39236. /**
  39237. * @hidden
  39238. * Defines the actions happening during the active mesh stage.
  39239. */
  39240. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39241. /**
  39242. * @hidden
  39243. * Defines the actions happening during the per camera render target step.
  39244. */
  39245. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39246. /**
  39247. * @hidden
  39248. * Defines the actions happening just before the active camera is drawing.
  39249. */
  39250. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39251. /**
  39252. * @hidden
  39253. * Defines the actions happening just before a render target is drawing.
  39254. */
  39255. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39256. /**
  39257. * @hidden
  39258. * Defines the actions happening just before a rendering group is drawing.
  39259. */
  39260. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39261. /**
  39262. * @hidden
  39263. * Defines the actions happening just before a mesh is drawing.
  39264. */
  39265. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39266. /**
  39267. * @hidden
  39268. * Defines the actions happening just after a mesh has been drawn.
  39269. */
  39270. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39271. /**
  39272. * @hidden
  39273. * Defines the actions happening just after a rendering group has been drawn.
  39274. */
  39275. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39276. /**
  39277. * @hidden
  39278. * Defines the actions happening just after the active camera has been drawn.
  39279. */
  39280. _afterCameraDrawStage: Stage<CameraStageAction>;
  39281. /**
  39282. * @hidden
  39283. * Defines the actions happening just after a render target has been drawn.
  39284. */
  39285. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39286. /**
  39287. * @hidden
  39288. * Defines the actions happening just after rendering all cameras and computing intersections.
  39289. */
  39290. _afterRenderStage: Stage<SimpleStageAction>;
  39291. /**
  39292. * @hidden
  39293. * Defines the actions happening when a pointer move event happens.
  39294. */
  39295. _pointerMoveStage: Stage<PointerMoveStageAction>;
  39296. /**
  39297. * @hidden
  39298. * Defines the actions happening when a pointer down event happens.
  39299. */
  39300. _pointerDownStage: Stage<PointerUpDownStageAction>;
  39301. /**
  39302. * @hidden
  39303. * Defines the actions happening when a pointer up event happens.
  39304. */
  39305. _pointerUpStage: Stage<PointerUpDownStageAction>;
  39306. /**
  39307. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  39308. */
  39309. private geometriesByUniqueId;
  39310. /**
  39311. * Creates a new Scene
  39312. * @param engine defines the engine to use to render this scene
  39313. * @param options defines the scene options
  39314. */
  39315. constructor(engine: Engine, options?: SceneOptions);
  39316. /**
  39317. * Gets a string idenfifying the name of the class
  39318. * @returns "Scene" string
  39319. */
  39320. getClassName(): string;
  39321. private _defaultMeshCandidates;
  39322. /**
  39323. * @hidden
  39324. */
  39325. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39326. private _defaultSubMeshCandidates;
  39327. /**
  39328. * @hidden
  39329. */
  39330. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39331. /**
  39332. * Sets the default candidate providers for the scene.
  39333. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  39334. * and getCollidingSubMeshCandidates to their default function
  39335. */
  39336. setDefaultCandidateProviders(): void;
  39337. /**
  39338. * Gets the mesh that is currently under the pointer
  39339. */
  39340. get meshUnderPointer(): Nullable<AbstractMesh>;
  39341. /**
  39342. * Gets or sets the current on-screen X position of the pointer
  39343. */
  39344. get pointerX(): number;
  39345. set pointerX(value: number);
  39346. /**
  39347. * Gets or sets the current on-screen Y position of the pointer
  39348. */
  39349. get pointerY(): number;
  39350. set pointerY(value: number);
  39351. /**
  39352. * Gets the cached material (ie. the latest rendered one)
  39353. * @returns the cached material
  39354. */
  39355. getCachedMaterial(): Nullable<Material>;
  39356. /**
  39357. * Gets the cached effect (ie. the latest rendered one)
  39358. * @returns the cached effect
  39359. */
  39360. getCachedEffect(): Nullable<Effect>;
  39361. /**
  39362. * Gets the cached visibility state (ie. the latest rendered one)
  39363. * @returns the cached visibility state
  39364. */
  39365. getCachedVisibility(): Nullable<number>;
  39366. /**
  39367. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  39368. * @param material defines the current material
  39369. * @param effect defines the current effect
  39370. * @param visibility defines the current visibility state
  39371. * @returns true if one parameter is not cached
  39372. */
  39373. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  39374. /**
  39375. * Gets the engine associated with the scene
  39376. * @returns an Engine
  39377. */
  39378. getEngine(): Engine;
  39379. /**
  39380. * Gets the total number of vertices rendered per frame
  39381. * @returns the total number of vertices rendered per frame
  39382. */
  39383. getTotalVertices(): number;
  39384. /**
  39385. * Gets the performance counter for total vertices
  39386. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39387. */
  39388. get totalVerticesPerfCounter(): PerfCounter;
  39389. /**
  39390. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  39391. * @returns the total number of active indices rendered per frame
  39392. */
  39393. getActiveIndices(): number;
  39394. /**
  39395. * Gets the performance counter for active indices
  39396. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39397. */
  39398. get totalActiveIndicesPerfCounter(): PerfCounter;
  39399. /**
  39400. * Gets the total number of active particles rendered per frame
  39401. * @returns the total number of active particles rendered per frame
  39402. */
  39403. getActiveParticles(): number;
  39404. /**
  39405. * Gets the performance counter for active particles
  39406. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39407. */
  39408. get activeParticlesPerfCounter(): PerfCounter;
  39409. /**
  39410. * Gets the total number of active bones rendered per frame
  39411. * @returns the total number of active bones rendered per frame
  39412. */
  39413. getActiveBones(): number;
  39414. /**
  39415. * Gets the performance counter for active bones
  39416. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  39417. */
  39418. get activeBonesPerfCounter(): PerfCounter;
  39419. /**
  39420. * Gets the array of active meshes
  39421. * @returns an array of AbstractMesh
  39422. */
  39423. getActiveMeshes(): SmartArray<AbstractMesh>;
  39424. /**
  39425. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  39426. * @returns a number
  39427. */
  39428. getAnimationRatio(): number;
  39429. /**
  39430. * Gets an unique Id for the current render phase
  39431. * @returns a number
  39432. */
  39433. getRenderId(): number;
  39434. /**
  39435. * Gets an unique Id for the current frame
  39436. * @returns a number
  39437. */
  39438. getFrameId(): number;
  39439. /** Call this function if you want to manually increment the render Id*/
  39440. incrementRenderId(): void;
  39441. private _createUbo;
  39442. /**
  39443. * Use this method to simulate a pointer move on a mesh
  39444. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39445. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39446. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39447. * @returns the current scene
  39448. */
  39449. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39450. /**
  39451. * Use this method to simulate a pointer down on a mesh
  39452. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39453. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39454. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39455. * @returns the current scene
  39456. */
  39457. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  39458. /**
  39459. * Use this method to simulate a pointer up on a mesh
  39460. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39461. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39462. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39463. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39464. * @returns the current scene
  39465. */
  39466. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  39467. /**
  39468. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39469. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39470. * @returns true if the pointer was captured
  39471. */
  39472. isPointerCaptured(pointerId?: number): boolean;
  39473. /**
  39474. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39475. * @param attachUp defines if you want to attach events to pointerup
  39476. * @param attachDown defines if you want to attach events to pointerdown
  39477. * @param attachMove defines if you want to attach events to pointermove
  39478. */
  39479. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  39480. /** Detaches all event handlers*/
  39481. detachControl(): void;
  39482. /**
  39483. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  39484. * Delay loaded resources are not taking in account
  39485. * @return true if all required resources are ready
  39486. */
  39487. isReady(): boolean;
  39488. /** Resets all cached information relative to material (including effect and visibility) */
  39489. resetCachedMaterial(): void;
  39490. /**
  39491. * Registers a function to be called before every frame render
  39492. * @param func defines the function to register
  39493. */
  39494. registerBeforeRender(func: () => void): void;
  39495. /**
  39496. * Unregisters a function called before every frame render
  39497. * @param func defines the function to unregister
  39498. */
  39499. unregisterBeforeRender(func: () => void): void;
  39500. /**
  39501. * Registers a function to be called after every frame render
  39502. * @param func defines the function to register
  39503. */
  39504. registerAfterRender(func: () => void): void;
  39505. /**
  39506. * Unregisters a function called after every frame render
  39507. * @param func defines the function to unregister
  39508. */
  39509. unregisterAfterRender(func: () => void): void;
  39510. private _executeOnceBeforeRender;
  39511. /**
  39512. * The provided function will run before render once and will be disposed afterwards.
  39513. * A timeout delay can be provided so that the function will be executed in N ms.
  39514. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  39515. * @param func The function to be executed.
  39516. * @param timeout optional delay in ms
  39517. */
  39518. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  39519. /** @hidden */
  39520. _addPendingData(data: any): void;
  39521. /** @hidden */
  39522. _removePendingData(data: any): void;
  39523. /**
  39524. * Returns the number of items waiting to be loaded
  39525. * @returns the number of items waiting to be loaded
  39526. */
  39527. getWaitingItemsCount(): number;
  39528. /**
  39529. * Returns a boolean indicating if the scene is still loading data
  39530. */
  39531. get isLoading(): boolean;
  39532. /**
  39533. * Registers a function to be executed when the scene is ready
  39534. * @param {Function} func - the function to be executed
  39535. */
  39536. executeWhenReady(func: () => void): void;
  39537. /**
  39538. * Returns a promise that resolves when the scene is ready
  39539. * @returns A promise that resolves when the scene is ready
  39540. */
  39541. whenReadyAsync(): Promise<void>;
  39542. /** @hidden */
  39543. _checkIsReady(): void;
  39544. /**
  39545. * Gets all animatable attached to the scene
  39546. */
  39547. get animatables(): Animatable[];
  39548. /**
  39549. * Resets the last animation time frame.
  39550. * Useful to override when animations start running when loading a scene for the first time.
  39551. */
  39552. resetLastAnimationTimeFrame(): void;
  39553. /**
  39554. * Gets the current view matrix
  39555. * @returns a Matrix
  39556. */
  39557. getViewMatrix(): Matrix;
  39558. /**
  39559. * Gets the current projection matrix
  39560. * @returns a Matrix
  39561. */
  39562. getProjectionMatrix(): Matrix;
  39563. /**
  39564. * Gets the current transform matrix
  39565. * @returns a Matrix made of View * Projection
  39566. */
  39567. getTransformMatrix(): Matrix;
  39568. /**
  39569. * Sets the current transform matrix
  39570. * @param viewL defines the View matrix to use
  39571. * @param projectionL defines the Projection matrix to use
  39572. * @param viewR defines the right View matrix to use (if provided)
  39573. * @param projectionR defines the right Projection matrix to use (if provided)
  39574. */
  39575. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  39576. /**
  39577. * Gets the uniform buffer used to store scene data
  39578. * @returns a UniformBuffer
  39579. */
  39580. getSceneUniformBuffer(): UniformBuffer;
  39581. /**
  39582. * Gets an unique (relatively to the current scene) Id
  39583. * @returns an unique number for the scene
  39584. */
  39585. getUniqueId(): number;
  39586. /**
  39587. * Add a mesh to the list of scene's meshes
  39588. * @param newMesh defines the mesh to add
  39589. * @param recursive if all child meshes should also be added to the scene
  39590. */
  39591. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  39592. /**
  39593. * Remove a mesh for the list of scene's meshes
  39594. * @param toRemove defines the mesh to remove
  39595. * @param recursive if all child meshes should also be removed from the scene
  39596. * @returns the index where the mesh was in the mesh list
  39597. */
  39598. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  39599. /**
  39600. * Add a transform node to the list of scene's transform nodes
  39601. * @param newTransformNode defines the transform node to add
  39602. */
  39603. addTransformNode(newTransformNode: TransformNode): void;
  39604. /**
  39605. * Remove a transform node for the list of scene's transform nodes
  39606. * @param toRemove defines the transform node to remove
  39607. * @returns the index where the transform node was in the transform node list
  39608. */
  39609. removeTransformNode(toRemove: TransformNode): number;
  39610. /**
  39611. * Remove a skeleton for the list of scene's skeletons
  39612. * @param toRemove defines the skeleton to remove
  39613. * @returns the index where the skeleton was in the skeleton list
  39614. */
  39615. removeSkeleton(toRemove: Skeleton): number;
  39616. /**
  39617. * Remove a morph target for the list of scene's morph targets
  39618. * @param toRemove defines the morph target to remove
  39619. * @returns the index where the morph target was in the morph target list
  39620. */
  39621. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  39622. /**
  39623. * Remove a light for the list of scene's lights
  39624. * @param toRemove defines the light to remove
  39625. * @returns the index where the light was in the light list
  39626. */
  39627. removeLight(toRemove: Light): number;
  39628. /**
  39629. * Remove a camera for the list of scene's cameras
  39630. * @param toRemove defines the camera to remove
  39631. * @returns the index where the camera was in the camera list
  39632. */
  39633. removeCamera(toRemove: Camera): number;
  39634. /**
  39635. * Remove a particle system for the list of scene's particle systems
  39636. * @param toRemove defines the particle system to remove
  39637. * @returns the index where the particle system was in the particle system list
  39638. */
  39639. removeParticleSystem(toRemove: IParticleSystem): number;
  39640. /**
  39641. * Remove a animation for the list of scene's animations
  39642. * @param toRemove defines the animation to remove
  39643. * @returns the index where the animation was in the animation list
  39644. */
  39645. removeAnimation(toRemove: Animation): number;
  39646. /**
  39647. * Will stop the animation of the given target
  39648. * @param target - the target
  39649. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  39650. * @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)
  39651. */
  39652. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  39653. /**
  39654. * Removes the given animation group from this scene.
  39655. * @param toRemove The animation group to remove
  39656. * @returns The index of the removed animation group
  39657. */
  39658. removeAnimationGroup(toRemove: AnimationGroup): number;
  39659. /**
  39660. * Removes the given multi-material from this scene.
  39661. * @param toRemove The multi-material to remove
  39662. * @returns The index of the removed multi-material
  39663. */
  39664. removeMultiMaterial(toRemove: MultiMaterial): number;
  39665. /**
  39666. * Removes the given material from this scene.
  39667. * @param toRemove The material to remove
  39668. * @returns The index of the removed material
  39669. */
  39670. removeMaterial(toRemove: Material): number;
  39671. /**
  39672. * Removes the given action manager from this scene.
  39673. * @param toRemove The action manager to remove
  39674. * @returns The index of the removed action manager
  39675. */
  39676. removeActionManager(toRemove: AbstractActionManager): number;
  39677. /**
  39678. * Removes the given texture from this scene.
  39679. * @param toRemove The texture to remove
  39680. * @returns The index of the removed texture
  39681. */
  39682. removeTexture(toRemove: BaseTexture): number;
  39683. /**
  39684. * Adds the given light to this scene
  39685. * @param newLight The light to add
  39686. */
  39687. addLight(newLight: Light): void;
  39688. /**
  39689. * Sorts the list list based on light priorities
  39690. */
  39691. sortLightsByPriority(): void;
  39692. /**
  39693. * Adds the given camera to this scene
  39694. * @param newCamera The camera to add
  39695. */
  39696. addCamera(newCamera: Camera): void;
  39697. /**
  39698. * Adds the given skeleton to this scene
  39699. * @param newSkeleton The skeleton to add
  39700. */
  39701. addSkeleton(newSkeleton: Skeleton): void;
  39702. /**
  39703. * Adds the given particle system to this scene
  39704. * @param newParticleSystem The particle system to add
  39705. */
  39706. addParticleSystem(newParticleSystem: IParticleSystem): void;
  39707. /**
  39708. * Adds the given animation to this scene
  39709. * @param newAnimation The animation to add
  39710. */
  39711. addAnimation(newAnimation: Animation): void;
  39712. /**
  39713. * Adds the given animation group to this scene.
  39714. * @param newAnimationGroup The animation group to add
  39715. */
  39716. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  39717. /**
  39718. * Adds the given multi-material to this scene
  39719. * @param newMultiMaterial The multi-material to add
  39720. */
  39721. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  39722. /**
  39723. * Adds the given material to this scene
  39724. * @param newMaterial The material to add
  39725. */
  39726. addMaterial(newMaterial: Material): void;
  39727. /**
  39728. * Adds the given morph target to this scene
  39729. * @param newMorphTargetManager The morph target to add
  39730. */
  39731. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  39732. /**
  39733. * Adds the given geometry to this scene
  39734. * @param newGeometry The geometry to add
  39735. */
  39736. addGeometry(newGeometry: Geometry): void;
  39737. /**
  39738. * Adds the given action manager to this scene
  39739. * @param newActionManager The action manager to add
  39740. */
  39741. addActionManager(newActionManager: AbstractActionManager): void;
  39742. /**
  39743. * Adds the given texture to this scene.
  39744. * @param newTexture The texture to add
  39745. */
  39746. addTexture(newTexture: BaseTexture): void;
  39747. /**
  39748. * Switch active camera
  39749. * @param newCamera defines the new active camera
  39750. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  39751. */
  39752. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  39753. /**
  39754. * sets the active camera of the scene using its ID
  39755. * @param id defines the camera's ID
  39756. * @return the new active camera or null if none found.
  39757. */
  39758. setActiveCameraByID(id: string): Nullable<Camera>;
  39759. /**
  39760. * sets the active camera of the scene using its name
  39761. * @param name defines the camera's name
  39762. * @returns the new active camera or null if none found.
  39763. */
  39764. setActiveCameraByName(name: string): Nullable<Camera>;
  39765. /**
  39766. * get an animation group using its name
  39767. * @param name defines the material's name
  39768. * @return the animation group or null if none found.
  39769. */
  39770. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  39771. /**
  39772. * Get a material using its unique id
  39773. * @param uniqueId defines the material's unique id
  39774. * @return the material or null if none found.
  39775. */
  39776. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  39777. /**
  39778. * get a material using its id
  39779. * @param id defines the material's ID
  39780. * @return the material or null if none found.
  39781. */
  39782. getMaterialByID(id: string): Nullable<Material>;
  39783. /**
  39784. * Gets a the last added material using a given id
  39785. * @param id defines the material's ID
  39786. * @return the last material with the given id or null if none found.
  39787. */
  39788. getLastMaterialByID(id: string): Nullable<Material>;
  39789. /**
  39790. * Gets a material using its name
  39791. * @param name defines the material's name
  39792. * @return the material or null if none found.
  39793. */
  39794. getMaterialByName(name: string): Nullable<Material>;
  39795. /**
  39796. * Get a texture using its unique id
  39797. * @param uniqueId defines the texture's unique id
  39798. * @return the texture or null if none found.
  39799. */
  39800. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  39801. /**
  39802. * Gets a camera using its id
  39803. * @param id defines the id to look for
  39804. * @returns the camera or null if not found
  39805. */
  39806. getCameraByID(id: string): Nullable<Camera>;
  39807. /**
  39808. * Gets a camera using its unique id
  39809. * @param uniqueId defines the unique id to look for
  39810. * @returns the camera or null if not found
  39811. */
  39812. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  39813. /**
  39814. * Gets a camera using its name
  39815. * @param name defines the camera's name
  39816. * @return the camera or null if none found.
  39817. */
  39818. getCameraByName(name: string): Nullable<Camera>;
  39819. /**
  39820. * Gets a bone using its id
  39821. * @param id defines the bone's id
  39822. * @return the bone or null if not found
  39823. */
  39824. getBoneByID(id: string): Nullable<Bone>;
  39825. /**
  39826. * Gets a bone using its id
  39827. * @param name defines the bone's name
  39828. * @return the bone or null if not found
  39829. */
  39830. getBoneByName(name: string): Nullable<Bone>;
  39831. /**
  39832. * Gets a light node using its name
  39833. * @param name defines the the light's name
  39834. * @return the light or null if none found.
  39835. */
  39836. getLightByName(name: string): Nullable<Light>;
  39837. /**
  39838. * Gets a light node using its id
  39839. * @param id defines the light's id
  39840. * @return the light or null if none found.
  39841. */
  39842. getLightByID(id: string): Nullable<Light>;
  39843. /**
  39844. * Gets a light node using its scene-generated unique ID
  39845. * @param uniqueId defines the light's unique id
  39846. * @return the light or null if none found.
  39847. */
  39848. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  39849. /**
  39850. * Gets a particle system by id
  39851. * @param id defines the particle system id
  39852. * @return the corresponding system or null if none found
  39853. */
  39854. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  39855. /**
  39856. * Gets a geometry using its ID
  39857. * @param id defines the geometry's id
  39858. * @return the geometry or null if none found.
  39859. */
  39860. getGeometryByID(id: string): Nullable<Geometry>;
  39861. private _getGeometryByUniqueID;
  39862. /**
  39863. * Add a new geometry to this scene
  39864. * @param geometry defines the geometry to be added to the scene.
  39865. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  39866. * @return a boolean defining if the geometry was added or not
  39867. */
  39868. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  39869. /**
  39870. * Removes an existing geometry
  39871. * @param geometry defines the geometry to be removed from the scene
  39872. * @return a boolean defining if the geometry was removed or not
  39873. */
  39874. removeGeometry(geometry: Geometry): boolean;
  39875. /**
  39876. * Gets the list of geometries attached to the scene
  39877. * @returns an array of Geometry
  39878. */
  39879. getGeometries(): Geometry[];
  39880. /**
  39881. * Gets the first added mesh found of a given ID
  39882. * @param id defines the id to search for
  39883. * @return the mesh found or null if not found at all
  39884. */
  39885. getMeshByID(id: string): Nullable<AbstractMesh>;
  39886. /**
  39887. * Gets a list of meshes using their id
  39888. * @param id defines the id to search for
  39889. * @returns a list of meshes
  39890. */
  39891. getMeshesByID(id: string): Array<AbstractMesh>;
  39892. /**
  39893. * Gets the first added transform node found of a given ID
  39894. * @param id defines the id to search for
  39895. * @return the found transform node or null if not found at all.
  39896. */
  39897. getTransformNodeByID(id: string): Nullable<TransformNode>;
  39898. /**
  39899. * Gets a transform node with its auto-generated unique id
  39900. * @param uniqueId efines the unique id to search for
  39901. * @return the found transform node or null if not found at all.
  39902. */
  39903. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  39904. /**
  39905. * Gets a list of transform nodes using their id
  39906. * @param id defines the id to search for
  39907. * @returns a list of transform nodes
  39908. */
  39909. getTransformNodesByID(id: string): Array<TransformNode>;
  39910. /**
  39911. * Gets a mesh with its auto-generated unique id
  39912. * @param uniqueId defines the unique id to search for
  39913. * @return the found mesh or null if not found at all.
  39914. */
  39915. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  39916. /**
  39917. * Gets a the last added mesh using a given id
  39918. * @param id defines the id to search for
  39919. * @return the found mesh or null if not found at all.
  39920. */
  39921. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  39922. /**
  39923. * Gets a the last added node (Mesh, Camera, Light) using a given id
  39924. * @param id defines the id to search for
  39925. * @return the found node or null if not found at all
  39926. */
  39927. getLastEntryByID(id: string): Nullable<Node>;
  39928. /**
  39929. * Gets a node (Mesh, Camera, Light) using a given id
  39930. * @param id defines the id to search for
  39931. * @return the found node or null if not found at all
  39932. */
  39933. getNodeByID(id: string): Nullable<Node>;
  39934. /**
  39935. * Gets a node (Mesh, Camera, Light) using a given name
  39936. * @param name defines the name to search for
  39937. * @return the found node or null if not found at all.
  39938. */
  39939. getNodeByName(name: string): Nullable<Node>;
  39940. /**
  39941. * Gets a mesh using a given name
  39942. * @param name defines the name to search for
  39943. * @return the found mesh or null if not found at all.
  39944. */
  39945. getMeshByName(name: string): Nullable<AbstractMesh>;
  39946. /**
  39947. * Gets a transform node using a given name
  39948. * @param name defines the name to search for
  39949. * @return the found transform node or null if not found at all.
  39950. */
  39951. getTransformNodeByName(name: string): Nullable<TransformNode>;
  39952. /**
  39953. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  39954. * @param id defines the id to search for
  39955. * @return the found skeleton or null if not found at all.
  39956. */
  39957. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  39958. /**
  39959. * Gets a skeleton using a given auto generated unique id
  39960. * @param uniqueId defines the unique id to search for
  39961. * @return the found skeleton or null if not found at all.
  39962. */
  39963. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  39964. /**
  39965. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  39966. * @param id defines the id to search for
  39967. * @return the found skeleton or null if not found at all.
  39968. */
  39969. getSkeletonById(id: string): Nullable<Skeleton>;
  39970. /**
  39971. * Gets a skeleton using a given name
  39972. * @param name defines the name to search for
  39973. * @return the found skeleton or null if not found at all.
  39974. */
  39975. getSkeletonByName(name: string): Nullable<Skeleton>;
  39976. /**
  39977. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  39978. * @param id defines the id to search for
  39979. * @return the found morph target manager or null if not found at all.
  39980. */
  39981. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  39982. /**
  39983. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  39984. * @param id defines the id to search for
  39985. * @return the found morph target or null if not found at all.
  39986. */
  39987. getMorphTargetById(id: string): Nullable<MorphTarget>;
  39988. /**
  39989. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  39990. * @param name defines the name to search for
  39991. * @return the found morph target or null if not found at all.
  39992. */
  39993. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  39994. /**
  39995. * Gets a boolean indicating if the given mesh is active
  39996. * @param mesh defines the mesh to look for
  39997. * @returns true if the mesh is in the active list
  39998. */
  39999. isActiveMesh(mesh: AbstractMesh): boolean;
  40000. /**
  40001. * Return a unique id as a string which can serve as an identifier for the scene
  40002. */
  40003. get uid(): string;
  40004. /**
  40005. * Add an externaly attached data from its key.
  40006. * This method call will fail and return false, if such key already exists.
  40007. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40008. * @param key the unique key that identifies the data
  40009. * @param data the data object to associate to the key for this Engine instance
  40010. * @return true if no such key were already present and the data was added successfully, false otherwise
  40011. */
  40012. addExternalData<T>(key: string, data: T): boolean;
  40013. /**
  40014. * Get an externaly attached data from its key
  40015. * @param key the unique key that identifies the data
  40016. * @return the associated data, if present (can be null), or undefined if not present
  40017. */
  40018. getExternalData<T>(key: string): Nullable<T>;
  40019. /**
  40020. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40021. * @param key the unique key that identifies the data
  40022. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40023. * @return the associated data, can be null if the factory returned null.
  40024. */
  40025. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40026. /**
  40027. * Remove an externaly attached data from the Engine instance
  40028. * @param key the unique key that identifies the data
  40029. * @return true if the data was successfully removed, false if it doesn't exist
  40030. */
  40031. removeExternalData(key: string): boolean;
  40032. private _evaluateSubMesh;
  40033. /**
  40034. * Clear the processed materials smart array preventing retention point in material dispose.
  40035. */
  40036. freeProcessedMaterials(): void;
  40037. private _preventFreeActiveMeshesAndRenderingGroups;
  40038. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40039. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40040. * when disposing several meshes in a row or a hierarchy of meshes.
  40041. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40042. */
  40043. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40044. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40045. /**
  40046. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40047. */
  40048. freeActiveMeshes(): void;
  40049. /**
  40050. * Clear the info related to rendering groups preventing retention points during dispose.
  40051. */
  40052. freeRenderingGroups(): void;
  40053. /** @hidden */
  40054. _isInIntermediateRendering(): boolean;
  40055. /**
  40056. * Lambda returning the list of potentially active meshes.
  40057. */
  40058. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40059. /**
  40060. * Lambda returning the list of potentially active sub meshes.
  40061. */
  40062. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40063. /**
  40064. * Lambda returning the list of potentially intersecting sub meshes.
  40065. */
  40066. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40067. /**
  40068. * Lambda returning the list of potentially colliding sub meshes.
  40069. */
  40070. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40071. private _activeMeshesFrozen;
  40072. private _skipEvaluateActiveMeshesCompletely;
  40073. /**
  40074. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40075. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40076. * @returns the current scene
  40077. */
  40078. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40079. /**
  40080. * Use this function to restart evaluating active meshes on every frame
  40081. * @returns the current scene
  40082. */
  40083. unfreezeActiveMeshes(): Scene;
  40084. private _evaluateActiveMeshes;
  40085. private _activeMesh;
  40086. /**
  40087. * Update the transform matrix to update from the current active camera
  40088. * @param force defines a boolean used to force the update even if cache is up to date
  40089. */
  40090. updateTransformMatrix(force?: boolean): void;
  40091. private _bindFrameBuffer;
  40092. /** @hidden */
  40093. _allowPostProcessClearColor: boolean;
  40094. /** @hidden */
  40095. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40096. private _processSubCameras;
  40097. private _checkIntersections;
  40098. /** @hidden */
  40099. _advancePhysicsEngineStep(step: number): void;
  40100. /**
  40101. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40102. */
  40103. getDeterministicFrameTime: () => number;
  40104. /** @hidden */
  40105. _animate(): void;
  40106. /** Execute all animations (for a frame) */
  40107. animate(): void;
  40108. /**
  40109. * Render the scene
  40110. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40111. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40112. */
  40113. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40114. /**
  40115. * Freeze all materials
  40116. * A frozen material will not be updatable but should be faster to render
  40117. */
  40118. freezeMaterials(): void;
  40119. /**
  40120. * Unfreeze all materials
  40121. * A frozen material will not be updatable but should be faster to render
  40122. */
  40123. unfreezeMaterials(): void;
  40124. /**
  40125. * Releases all held ressources
  40126. */
  40127. dispose(): void;
  40128. /**
  40129. * Gets if the scene is already disposed
  40130. */
  40131. get isDisposed(): boolean;
  40132. /**
  40133. * Call this function to reduce memory footprint of the scene.
  40134. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40135. */
  40136. clearCachedVertexData(): void;
  40137. /**
  40138. * This function will remove the local cached buffer data from texture.
  40139. * It will save memory but will prevent the texture from being rebuilt
  40140. */
  40141. cleanCachedTextureBuffer(): void;
  40142. /**
  40143. * Get the world extend vectors with an optional filter
  40144. *
  40145. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40146. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40147. */
  40148. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40149. min: Vector3;
  40150. max: Vector3;
  40151. };
  40152. /**
  40153. * Creates a ray that can be used to pick in the scene
  40154. * @param x defines the x coordinate of the origin (on-screen)
  40155. * @param y defines the y coordinate of the origin (on-screen)
  40156. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40157. * @param camera defines the camera to use for the picking
  40158. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40159. * @returns a Ray
  40160. */
  40161. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40162. /**
  40163. * Creates a ray that can be used to pick in the scene
  40164. * @param x defines the x coordinate of the origin (on-screen)
  40165. * @param y defines the y coordinate of the origin (on-screen)
  40166. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40167. * @param result defines the ray where to store the picking ray
  40168. * @param camera defines the camera to use for the picking
  40169. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40170. * @returns the current scene
  40171. */
  40172. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40173. /**
  40174. * Creates a ray that can be used to pick in the scene
  40175. * @param x defines the x coordinate of the origin (on-screen)
  40176. * @param y defines the y coordinate of the origin (on-screen)
  40177. * @param camera defines the camera to use for the picking
  40178. * @returns a Ray
  40179. */
  40180. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40181. /**
  40182. * Creates a ray that can be used to pick in the scene
  40183. * @param x defines the x coordinate of the origin (on-screen)
  40184. * @param y defines the y coordinate of the origin (on-screen)
  40185. * @param result defines the ray where to store the picking ray
  40186. * @param camera defines the camera to use for the picking
  40187. * @returns the current scene
  40188. */
  40189. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40190. /** Launch a ray to try to pick a mesh in the scene
  40191. * @param x position on screen
  40192. * @param y position on screen
  40193. * @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
  40194. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40195. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40196. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40197. * @returns a PickingInfo
  40198. */
  40199. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40200. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40201. * @param x position on screen
  40202. * @param y position on screen
  40203. * @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
  40204. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40205. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40206. * @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)
  40207. */
  40208. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40209. /** Use the given ray to pick a mesh in the scene
  40210. * @param ray The ray to use to pick meshes
  40211. * @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
  40212. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40213. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40214. * @returns a PickingInfo
  40215. */
  40216. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40217. /**
  40218. * Launch a ray to try to pick a mesh in the scene
  40219. * @param x X position on screen
  40220. * @param y Y position on screen
  40221. * @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
  40222. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40223. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40224. * @returns an array of PickingInfo
  40225. */
  40226. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40227. /**
  40228. * Launch a ray to try to pick a mesh in the scene
  40229. * @param ray Ray to use
  40230. * @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
  40231. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40232. * @returns an array of PickingInfo
  40233. */
  40234. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40235. /**
  40236. * Force the value of meshUnderPointer
  40237. * @param mesh defines the mesh to use
  40238. */
  40239. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40240. /**
  40241. * Gets the mesh under the pointer
  40242. * @returns a Mesh or null if no mesh is under the pointer
  40243. */
  40244. getPointerOverMesh(): Nullable<AbstractMesh>;
  40245. /** @hidden */
  40246. _rebuildGeometries(): void;
  40247. /** @hidden */
  40248. _rebuildTextures(): void;
  40249. private _getByTags;
  40250. /**
  40251. * Get a list of meshes by tags
  40252. * @param tagsQuery defines the tags query to use
  40253. * @param forEach defines a predicate used to filter results
  40254. * @returns an array of Mesh
  40255. */
  40256. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40257. /**
  40258. * Get a list of cameras by tags
  40259. * @param tagsQuery defines the tags query to use
  40260. * @param forEach defines a predicate used to filter results
  40261. * @returns an array of Camera
  40262. */
  40263. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40264. /**
  40265. * Get a list of lights by tags
  40266. * @param tagsQuery defines the tags query to use
  40267. * @param forEach defines a predicate used to filter results
  40268. * @returns an array of Light
  40269. */
  40270. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40271. /**
  40272. * Get a list of materials by tags
  40273. * @param tagsQuery defines the tags query to use
  40274. * @param forEach defines a predicate used to filter results
  40275. * @returns an array of Material
  40276. */
  40277. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40278. /**
  40279. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40280. * This allowed control for front to back rendering or reversly depending of the special needs.
  40281. *
  40282. * @param renderingGroupId The rendering group id corresponding to its index
  40283. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40284. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40285. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40286. */
  40287. 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;
  40288. /**
  40289. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  40290. *
  40291. * @param renderingGroupId The rendering group id corresponding to its index
  40292. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  40293. * @param depth Automatically clears depth between groups if true and autoClear is true.
  40294. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  40295. */
  40296. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  40297. /**
  40298. * Gets the current auto clear configuration for one rendering group of the rendering
  40299. * manager.
  40300. * @param index the rendering group index to get the information for
  40301. * @returns The auto clear setup for the requested rendering group
  40302. */
  40303. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  40304. private _blockMaterialDirtyMechanism;
  40305. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  40306. get blockMaterialDirtyMechanism(): boolean;
  40307. set blockMaterialDirtyMechanism(value: boolean);
  40308. /**
  40309. * Will flag all materials as dirty to trigger new shader compilation
  40310. * @param flag defines the flag used to specify which material part must be marked as dirty
  40311. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  40312. */
  40313. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40314. /** @hidden */
  40315. _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;
  40316. /** @hidden */
  40317. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40318. /** @hidden */
  40319. _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;
  40320. /** @hidden */
  40321. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  40322. /** @hidden */
  40323. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  40324. /** @hidden */
  40325. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40326. }
  40327. }
  40328. declare module BABYLON {
  40329. /**
  40330. * Set of assets to keep when moving a scene into an asset container.
  40331. */
  40332. export class KeepAssets extends AbstractScene {
  40333. }
  40334. /**
  40335. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  40336. */
  40337. export class InstantiatedEntries {
  40338. /**
  40339. * List of new root nodes (eg. nodes with no parent)
  40340. */
  40341. rootNodes: TransformNode[];
  40342. /**
  40343. * List of new skeletons
  40344. */
  40345. skeletons: Skeleton[];
  40346. /**
  40347. * List of new animation groups
  40348. */
  40349. animationGroups: AnimationGroup[];
  40350. }
  40351. /**
  40352. * Container with a set of assets that can be added or removed from a scene.
  40353. */
  40354. export class AssetContainer extends AbstractScene {
  40355. private _wasAddedToScene;
  40356. /**
  40357. * The scene the AssetContainer belongs to.
  40358. */
  40359. scene: Scene;
  40360. /**
  40361. * Instantiates an AssetContainer.
  40362. * @param scene The scene the AssetContainer belongs to.
  40363. */
  40364. constructor(scene: Scene);
  40365. /**
  40366. * Instantiate or clone all meshes and add the new ones to the scene.
  40367. * Skeletons and animation groups will all be cloned
  40368. * @param nameFunction defines an optional function used to get new names for clones
  40369. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  40370. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  40371. */
  40372. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  40373. /**
  40374. * Adds all the assets from the container to the scene.
  40375. */
  40376. addAllToScene(): void;
  40377. /**
  40378. * Removes all the assets in the container from the scene
  40379. */
  40380. removeAllFromScene(): void;
  40381. /**
  40382. * Disposes all the assets in the container
  40383. */
  40384. dispose(): void;
  40385. private _moveAssets;
  40386. /**
  40387. * Removes all the assets contained in the scene and adds them to the container.
  40388. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  40389. */
  40390. moveAllFromScene(keepAssets?: KeepAssets): void;
  40391. /**
  40392. * 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.
  40393. * @returns the root mesh
  40394. */
  40395. createRootMesh(): Mesh;
  40396. /**
  40397. * Merge animations (direct and animation groups) from this asset container into a scene
  40398. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  40399. * @param animatables set of animatables to retarget to a node from the scene
  40400. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  40401. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  40402. */
  40403. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  40404. }
  40405. }
  40406. declare module BABYLON {
  40407. /**
  40408. * Defines how the parser contract is defined.
  40409. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  40410. */
  40411. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  40412. /**
  40413. * Defines how the individual parser contract is defined.
  40414. * These parser can parse an individual asset
  40415. */
  40416. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  40417. /**
  40418. * Base class of the scene acting as a container for the different elements composing a scene.
  40419. * This class is dynamically extended by the different components of the scene increasing
  40420. * flexibility and reducing coupling
  40421. */
  40422. export abstract class AbstractScene {
  40423. /**
  40424. * Stores the list of available parsers in the application.
  40425. */
  40426. private static _BabylonFileParsers;
  40427. /**
  40428. * Stores the list of available individual parsers in the application.
  40429. */
  40430. private static _IndividualBabylonFileParsers;
  40431. /**
  40432. * Adds a parser in the list of available ones
  40433. * @param name Defines the name of the parser
  40434. * @param parser Defines the parser to add
  40435. */
  40436. static AddParser(name: string, parser: BabylonFileParser): void;
  40437. /**
  40438. * Gets a general parser from the list of avaialble ones
  40439. * @param name Defines the name of the parser
  40440. * @returns the requested parser or null
  40441. */
  40442. static GetParser(name: string): Nullable<BabylonFileParser>;
  40443. /**
  40444. * Adds n individual parser in the list of available ones
  40445. * @param name Defines the name of the parser
  40446. * @param parser Defines the parser to add
  40447. */
  40448. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  40449. /**
  40450. * Gets an individual parser from the list of avaialble ones
  40451. * @param name Defines the name of the parser
  40452. * @returns the requested parser or null
  40453. */
  40454. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  40455. /**
  40456. * Parser json data and populate both a scene and its associated container object
  40457. * @param jsonData Defines the data to parse
  40458. * @param scene Defines the scene to parse the data for
  40459. * @param container Defines the container attached to the parsing sequence
  40460. * @param rootUrl Defines the root url of the data
  40461. */
  40462. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  40463. /**
  40464. * Gets the list of root nodes (ie. nodes with no parent)
  40465. */
  40466. rootNodes: Node[];
  40467. /** All of the cameras added to this scene
  40468. * @see https://doc.babylonjs.com/babylon101/cameras
  40469. */
  40470. cameras: Camera[];
  40471. /**
  40472. * All of the lights added to this scene
  40473. * @see https://doc.babylonjs.com/babylon101/lights
  40474. */
  40475. lights: Light[];
  40476. /**
  40477. * All of the (abstract) meshes added to this scene
  40478. */
  40479. meshes: AbstractMesh[];
  40480. /**
  40481. * The list of skeletons added to the scene
  40482. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  40483. */
  40484. skeletons: Skeleton[];
  40485. /**
  40486. * All of the particle systems added to this scene
  40487. * @see https://doc.babylonjs.com/babylon101/particles
  40488. */
  40489. particleSystems: IParticleSystem[];
  40490. /**
  40491. * Gets a list of Animations associated with the scene
  40492. */
  40493. animations: Animation[];
  40494. /**
  40495. * All of the animation groups added to this scene
  40496. * @see https://doc.babylonjs.com/how_to/group
  40497. */
  40498. animationGroups: AnimationGroup[];
  40499. /**
  40500. * All of the multi-materials added to this scene
  40501. * @see https://doc.babylonjs.com/how_to/multi_materials
  40502. */
  40503. multiMaterials: MultiMaterial[];
  40504. /**
  40505. * All of the materials added to this scene
  40506. * In the context of a Scene, it is not supposed to be modified manually.
  40507. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  40508. * Note also that the order of the Material within the array is not significant and might change.
  40509. * @see https://doc.babylonjs.com/babylon101/materials
  40510. */
  40511. materials: Material[];
  40512. /**
  40513. * The list of morph target managers added to the scene
  40514. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  40515. */
  40516. morphTargetManagers: MorphTargetManager[];
  40517. /**
  40518. * The list of geometries used in the scene.
  40519. */
  40520. geometries: Geometry[];
  40521. /**
  40522. * All of the tranform nodes added to this scene
  40523. * In the context of a Scene, it is not supposed to be modified manually.
  40524. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  40525. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  40526. * @see https://doc.babylonjs.com/how_to/transformnode
  40527. */
  40528. transformNodes: TransformNode[];
  40529. /**
  40530. * ActionManagers available on the scene.
  40531. */
  40532. actionManagers: AbstractActionManager[];
  40533. /**
  40534. * Textures to keep.
  40535. */
  40536. textures: BaseTexture[];
  40537. /**
  40538. * Environment texture for the scene
  40539. */
  40540. environmentTexture: Nullable<BaseTexture>;
  40541. /**
  40542. * @returns all meshes, lights, cameras, transformNodes and bones
  40543. */
  40544. getNodes(): Array<Node>;
  40545. }
  40546. }
  40547. declare module BABYLON {
  40548. /**
  40549. * Interface used to define options for Sound class
  40550. */
  40551. export interface ISoundOptions {
  40552. /**
  40553. * Does the sound autoplay once loaded.
  40554. */
  40555. autoplay?: boolean;
  40556. /**
  40557. * Does the sound loop after it finishes playing once.
  40558. */
  40559. loop?: boolean;
  40560. /**
  40561. * Sound's volume
  40562. */
  40563. volume?: number;
  40564. /**
  40565. * Is it a spatial sound?
  40566. */
  40567. spatialSound?: boolean;
  40568. /**
  40569. * Maximum distance to hear that sound
  40570. */
  40571. maxDistance?: number;
  40572. /**
  40573. * Uses user defined attenuation function
  40574. */
  40575. useCustomAttenuation?: boolean;
  40576. /**
  40577. * Define the roll off factor of spatial sounds.
  40578. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40579. */
  40580. rolloffFactor?: number;
  40581. /**
  40582. * Define the reference distance the sound should be heard perfectly.
  40583. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40584. */
  40585. refDistance?: number;
  40586. /**
  40587. * Define the distance attenuation model the sound will follow.
  40588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40589. */
  40590. distanceModel?: string;
  40591. /**
  40592. * Defines the playback speed (1 by default)
  40593. */
  40594. playbackRate?: number;
  40595. /**
  40596. * Defines if the sound is from a streaming source
  40597. */
  40598. streaming?: boolean;
  40599. /**
  40600. * Defines an optional length (in seconds) inside the sound file
  40601. */
  40602. length?: number;
  40603. /**
  40604. * Defines an optional offset (in seconds) inside the sound file
  40605. */
  40606. offset?: number;
  40607. /**
  40608. * If true, URLs will not be required to state the audio file codec to use.
  40609. */
  40610. skipCodecCheck?: boolean;
  40611. }
  40612. /**
  40613. * Defines a sound that can be played in the application.
  40614. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  40615. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40616. */
  40617. export class Sound {
  40618. /**
  40619. * The name of the sound in the scene.
  40620. */
  40621. name: string;
  40622. /**
  40623. * Does the sound autoplay once loaded.
  40624. */
  40625. autoplay: boolean;
  40626. /**
  40627. * Does the sound loop after it finishes playing once.
  40628. */
  40629. loop: boolean;
  40630. /**
  40631. * Does the sound use a custom attenuation curve to simulate the falloff
  40632. * happening when the source gets further away from the camera.
  40633. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40634. */
  40635. useCustomAttenuation: boolean;
  40636. /**
  40637. * The sound track id this sound belongs to.
  40638. */
  40639. soundTrackId: number;
  40640. /**
  40641. * Is this sound currently played.
  40642. */
  40643. isPlaying: boolean;
  40644. /**
  40645. * Is this sound currently paused.
  40646. */
  40647. isPaused: boolean;
  40648. /**
  40649. * Does this sound enables spatial sound.
  40650. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40651. */
  40652. spatialSound: boolean;
  40653. /**
  40654. * Define the reference distance the sound should be heard perfectly.
  40655. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40656. */
  40657. refDistance: number;
  40658. /**
  40659. * Define the roll off factor of spatial sounds.
  40660. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40661. */
  40662. rolloffFactor: number;
  40663. /**
  40664. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  40665. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40666. */
  40667. maxDistance: number;
  40668. /**
  40669. * Define the distance attenuation model the sound will follow.
  40670. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40671. */
  40672. distanceModel: string;
  40673. /**
  40674. * @hidden
  40675. * Back Compat
  40676. **/
  40677. onended: () => any;
  40678. /**
  40679. * Gets or sets an object used to store user defined information for the sound.
  40680. */
  40681. metadata: any;
  40682. /**
  40683. * Observable event when the current playing sound finishes.
  40684. */
  40685. onEndedObservable: Observable<Sound>;
  40686. private _panningModel;
  40687. private _playbackRate;
  40688. private _streaming;
  40689. private _startTime;
  40690. private _startOffset;
  40691. private _position;
  40692. /** @hidden */
  40693. _positionInEmitterSpace: boolean;
  40694. private _localDirection;
  40695. private _volume;
  40696. private _isReadyToPlay;
  40697. private _isDirectional;
  40698. private _readyToPlayCallback;
  40699. private _audioBuffer;
  40700. private _soundSource;
  40701. private _streamingSource;
  40702. private _soundPanner;
  40703. private _soundGain;
  40704. private _inputAudioNode;
  40705. private _outputAudioNode;
  40706. private _coneInnerAngle;
  40707. private _coneOuterAngle;
  40708. private _coneOuterGain;
  40709. private _scene;
  40710. private _connectedTransformNode;
  40711. private _customAttenuationFunction;
  40712. private _registerFunc;
  40713. private _isOutputConnected;
  40714. private _htmlAudioElement;
  40715. private _urlType;
  40716. private _length?;
  40717. private _offset?;
  40718. /** @hidden */
  40719. static _SceneComponentInitialization: (scene: Scene) => void;
  40720. /**
  40721. * Create a sound and attach it to a scene
  40722. * @param name Name of your sound
  40723. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  40724. * @param scene defines the scene the sound belongs to
  40725. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  40726. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  40727. */
  40728. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  40729. /**
  40730. * Release the sound and its associated resources
  40731. */
  40732. dispose(): void;
  40733. /**
  40734. * Gets if the sounds is ready to be played or not.
  40735. * @returns true if ready, otherwise false
  40736. */
  40737. isReady(): boolean;
  40738. private _soundLoaded;
  40739. /**
  40740. * Sets the data of the sound from an audiobuffer
  40741. * @param audioBuffer The audioBuffer containing the data
  40742. */
  40743. setAudioBuffer(audioBuffer: AudioBuffer): void;
  40744. /**
  40745. * Updates the current sounds options such as maxdistance, loop...
  40746. * @param options A JSON object containing values named as the object properties
  40747. */
  40748. updateOptions(options: ISoundOptions): void;
  40749. private _createSpatialParameters;
  40750. private _updateSpatialParameters;
  40751. /**
  40752. * Switch the panning model to HRTF:
  40753. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  40754. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40755. */
  40756. switchPanningModelToHRTF(): void;
  40757. /**
  40758. * Switch the panning model to Equal Power:
  40759. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  40760. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  40761. */
  40762. switchPanningModelToEqualPower(): void;
  40763. private _switchPanningModel;
  40764. /**
  40765. * Connect this sound to a sound track audio node like gain...
  40766. * @param soundTrackAudioNode the sound track audio node to connect to
  40767. */
  40768. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  40769. /**
  40770. * Transform this sound into a directional source
  40771. * @param coneInnerAngle Size of the inner cone in degree
  40772. * @param coneOuterAngle Size of the outer cone in degree
  40773. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  40774. */
  40775. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  40776. /**
  40777. * Gets or sets the inner angle for the directional cone.
  40778. */
  40779. get directionalConeInnerAngle(): number;
  40780. /**
  40781. * Gets or sets the inner angle for the directional cone.
  40782. */
  40783. set directionalConeInnerAngle(value: number);
  40784. /**
  40785. * Gets or sets the outer angle for the directional cone.
  40786. */
  40787. get directionalConeOuterAngle(): number;
  40788. /**
  40789. * Gets or sets the outer angle for the directional cone.
  40790. */
  40791. set directionalConeOuterAngle(value: number);
  40792. /**
  40793. * Sets the position of the emitter if spatial sound is enabled
  40794. * @param newPosition Defines the new posisiton
  40795. */
  40796. setPosition(newPosition: Vector3): void;
  40797. /**
  40798. * Sets the local direction of the emitter if spatial sound is enabled
  40799. * @param newLocalDirection Defines the new local direction
  40800. */
  40801. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  40802. private _updateDirection;
  40803. /** @hidden */
  40804. updateDistanceFromListener(): void;
  40805. /**
  40806. * Sets a new custom attenuation function for the sound.
  40807. * @param callback Defines the function used for the attenuation
  40808. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  40809. */
  40810. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  40811. /**
  40812. * Play the sound
  40813. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  40814. * @param offset (optional) Start the sound at a specific time in seconds
  40815. * @param length (optional) Sound duration (in seconds)
  40816. */
  40817. play(time?: number, offset?: number, length?: number): void;
  40818. private _onended;
  40819. /**
  40820. * Stop the sound
  40821. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  40822. */
  40823. stop(time?: number): void;
  40824. /**
  40825. * Put the sound in pause
  40826. */
  40827. pause(): void;
  40828. /**
  40829. * Sets a dedicated volume for this sounds
  40830. * @param newVolume Define the new volume of the sound
  40831. * @param time Define time for gradual change to new volume
  40832. */
  40833. setVolume(newVolume: number, time?: number): void;
  40834. /**
  40835. * Set the sound play back rate
  40836. * @param newPlaybackRate Define the playback rate the sound should be played at
  40837. */
  40838. setPlaybackRate(newPlaybackRate: number): void;
  40839. /**
  40840. * Gets the volume of the sound.
  40841. * @returns the volume of the sound
  40842. */
  40843. getVolume(): number;
  40844. /**
  40845. * Attach the sound to a dedicated mesh
  40846. * @param transformNode The transform node to connect the sound with
  40847. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40848. */
  40849. attachToMesh(transformNode: TransformNode): void;
  40850. /**
  40851. * Detach the sound from the previously attached mesh
  40852. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  40853. */
  40854. detachFromMesh(): void;
  40855. private _onRegisterAfterWorldMatrixUpdate;
  40856. /**
  40857. * Clone the current sound in the scene.
  40858. * @returns the new sound clone
  40859. */
  40860. clone(): Nullable<Sound>;
  40861. /**
  40862. * Gets the current underlying audio buffer containing the data
  40863. * @returns the audio buffer
  40864. */
  40865. getAudioBuffer(): Nullable<AudioBuffer>;
  40866. /**
  40867. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  40868. * @returns the source node
  40869. */
  40870. getSoundSource(): Nullable<AudioBufferSourceNode>;
  40871. /**
  40872. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  40873. * @returns the gain node
  40874. */
  40875. getSoundGain(): Nullable<GainNode>;
  40876. /**
  40877. * Serializes the Sound in a JSON representation
  40878. * @returns the JSON representation of the sound
  40879. */
  40880. serialize(): any;
  40881. /**
  40882. * Parse a JSON representation of a sound to innstantiate in a given scene
  40883. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  40884. * @param scene Define the scene the new parsed sound should be created in
  40885. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  40886. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  40887. * @returns the newly parsed sound
  40888. */
  40889. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  40890. }
  40891. }
  40892. declare module BABYLON {
  40893. /**
  40894. * This defines an action helpful to play a defined sound on a triggered action.
  40895. */
  40896. export class PlaySoundAction extends Action {
  40897. private _sound;
  40898. /**
  40899. * Instantiate the action
  40900. * @param triggerOptions defines the trigger options
  40901. * @param sound defines the sound to play
  40902. * @param condition defines the trigger related conditions
  40903. */
  40904. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40905. /** @hidden */
  40906. _prepare(): void;
  40907. /**
  40908. * Execute the action and play the sound.
  40909. */
  40910. execute(): void;
  40911. /**
  40912. * Serializes the actions and its related information.
  40913. * @param parent defines the object to serialize in
  40914. * @returns the serialized object
  40915. */
  40916. serialize(parent: any): any;
  40917. }
  40918. /**
  40919. * This defines an action helpful to stop a defined sound on a triggered action.
  40920. */
  40921. export class StopSoundAction extends Action {
  40922. private _sound;
  40923. /**
  40924. * Instantiate the action
  40925. * @param triggerOptions defines the trigger options
  40926. * @param sound defines the sound to stop
  40927. * @param condition defines the trigger related conditions
  40928. */
  40929. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  40930. /** @hidden */
  40931. _prepare(): void;
  40932. /**
  40933. * Execute the action and stop the sound.
  40934. */
  40935. execute(): void;
  40936. /**
  40937. * Serializes the actions and its related information.
  40938. * @param parent defines the object to serialize in
  40939. * @returns the serialized object
  40940. */
  40941. serialize(parent: any): any;
  40942. }
  40943. }
  40944. declare module BABYLON {
  40945. /**
  40946. * This defines an action responsible to change the value of a property
  40947. * by interpolating between its current value and the newly set one once triggered.
  40948. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40949. */
  40950. export class InterpolateValueAction extends Action {
  40951. /**
  40952. * Defines the path of the property where the value should be interpolated
  40953. */
  40954. propertyPath: string;
  40955. /**
  40956. * Defines the target value at the end of the interpolation.
  40957. */
  40958. value: any;
  40959. /**
  40960. * Defines the time it will take for the property to interpolate to the value.
  40961. */
  40962. duration: number;
  40963. /**
  40964. * Defines if the other scene animations should be stopped when the action has been triggered
  40965. */
  40966. stopOtherAnimations?: boolean;
  40967. /**
  40968. * Defines a callback raised once the interpolation animation has been done.
  40969. */
  40970. onInterpolationDone?: () => void;
  40971. /**
  40972. * Observable triggered once the interpolation animation has been done.
  40973. */
  40974. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  40975. private _target;
  40976. private _effectiveTarget;
  40977. private _property;
  40978. /**
  40979. * Instantiate the action
  40980. * @param triggerOptions defines the trigger options
  40981. * @param target defines the object containing the value to interpolate
  40982. * @param propertyPath defines the path to the property in the target object
  40983. * @param value defines the target value at the end of the interpolation
  40984. * @param duration deines the time it will take for the property to interpolate to the value.
  40985. * @param condition defines the trigger related conditions
  40986. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  40987. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  40988. */
  40989. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  40990. /** @hidden */
  40991. _prepare(): void;
  40992. /**
  40993. * Execute the action starts the value interpolation.
  40994. */
  40995. execute(): void;
  40996. /**
  40997. * Serializes the actions and its related information.
  40998. * @param parent defines the object to serialize in
  40999. * @returns the serialized object
  41000. */
  41001. serialize(parent: any): any;
  41002. }
  41003. }
  41004. declare module BABYLON {
  41005. /**
  41006. * Options allowed during the creation of a sound track.
  41007. */
  41008. export interface ISoundTrackOptions {
  41009. /**
  41010. * The volume the sound track should take during creation
  41011. */
  41012. volume?: number;
  41013. /**
  41014. * Define if the sound track is the main sound track of the scene
  41015. */
  41016. mainTrack?: boolean;
  41017. }
  41018. /**
  41019. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41020. * It will be also used in a future release to apply effects on a specific track.
  41021. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41022. */
  41023. export class SoundTrack {
  41024. /**
  41025. * The unique identifier of the sound track in the scene.
  41026. */
  41027. id: number;
  41028. /**
  41029. * The list of sounds included in the sound track.
  41030. */
  41031. soundCollection: Array<Sound>;
  41032. private _outputAudioNode;
  41033. private _scene;
  41034. private _connectedAnalyser;
  41035. private _options;
  41036. private _isInitialized;
  41037. /**
  41038. * Creates a new sound track.
  41039. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41040. * @param scene Define the scene the sound track belongs to
  41041. * @param options
  41042. */
  41043. constructor(scene: Scene, options?: ISoundTrackOptions);
  41044. private _initializeSoundTrackAudioGraph;
  41045. /**
  41046. * Release the sound track and its associated resources
  41047. */
  41048. dispose(): void;
  41049. /**
  41050. * Adds a sound to this sound track
  41051. * @param sound define the cound to add
  41052. * @ignoreNaming
  41053. */
  41054. AddSound(sound: Sound): void;
  41055. /**
  41056. * Removes a sound to this sound track
  41057. * @param sound define the cound to remove
  41058. * @ignoreNaming
  41059. */
  41060. RemoveSound(sound: Sound): void;
  41061. /**
  41062. * Set a global volume for the full sound track.
  41063. * @param newVolume Define the new volume of the sound track
  41064. */
  41065. setVolume(newVolume: number): void;
  41066. /**
  41067. * Switch the panning model to HRTF:
  41068. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41069. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41070. */
  41071. switchPanningModelToHRTF(): void;
  41072. /**
  41073. * Switch the panning model to Equal Power:
  41074. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41075. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41076. */
  41077. switchPanningModelToEqualPower(): void;
  41078. /**
  41079. * Connect the sound track to an audio analyser allowing some amazing
  41080. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41081. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41082. * @param analyser The analyser to connect to the engine
  41083. */
  41084. connectToAnalyser(analyser: Analyser): void;
  41085. }
  41086. }
  41087. declare module BABYLON {
  41088. interface AbstractScene {
  41089. /**
  41090. * The list of sounds used in the scene.
  41091. */
  41092. sounds: Nullable<Array<Sound>>;
  41093. }
  41094. interface Scene {
  41095. /**
  41096. * @hidden
  41097. * Backing field
  41098. */
  41099. _mainSoundTrack: SoundTrack;
  41100. /**
  41101. * The main sound track played by the scene.
  41102. * It cotains your primary collection of sounds.
  41103. */
  41104. mainSoundTrack: SoundTrack;
  41105. /**
  41106. * The list of sound tracks added to the scene
  41107. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41108. */
  41109. soundTracks: Nullable<Array<SoundTrack>>;
  41110. /**
  41111. * Gets a sound using a given name
  41112. * @param name defines the name to search for
  41113. * @return the found sound or null if not found at all.
  41114. */
  41115. getSoundByName(name: string): Nullable<Sound>;
  41116. /**
  41117. * Gets or sets if audio support is enabled
  41118. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41119. */
  41120. audioEnabled: boolean;
  41121. /**
  41122. * Gets or sets if audio will be output to headphones
  41123. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41124. */
  41125. headphone: boolean;
  41126. /**
  41127. * Gets or sets custom audio listener position provider
  41128. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41129. */
  41130. audioListenerPositionProvider: Nullable<() => Vector3>;
  41131. /**
  41132. * Gets or sets a refresh rate when using 3D audio positioning
  41133. */
  41134. audioPositioningRefreshRate: number;
  41135. }
  41136. /**
  41137. * Defines the sound scene component responsible to manage any sounds
  41138. * in a given scene.
  41139. */
  41140. export class AudioSceneComponent implements ISceneSerializableComponent {
  41141. /**
  41142. * The component name helpfull to identify the component in the list of scene components.
  41143. */
  41144. readonly name: string;
  41145. /**
  41146. * The scene the component belongs to.
  41147. */
  41148. scene: Scene;
  41149. private _audioEnabled;
  41150. /**
  41151. * Gets whether audio is enabled or not.
  41152. * Please use related enable/disable method to switch state.
  41153. */
  41154. get audioEnabled(): boolean;
  41155. private _headphone;
  41156. /**
  41157. * Gets whether audio is outputing to headphone or not.
  41158. * Please use the according Switch methods to change output.
  41159. */
  41160. get headphone(): boolean;
  41161. /**
  41162. * Gets or sets a refresh rate when using 3D audio positioning
  41163. */
  41164. audioPositioningRefreshRate: number;
  41165. private _audioListenerPositionProvider;
  41166. /**
  41167. * Gets the current audio listener position provider
  41168. */
  41169. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41170. /**
  41171. * Sets a custom listener position for all sounds in the scene
  41172. * By default, this is the position of the first active camera
  41173. */
  41174. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41175. /**
  41176. * Creates a new instance of the component for the given scene
  41177. * @param scene Defines the scene to register the component in
  41178. */
  41179. constructor(scene: Scene);
  41180. /**
  41181. * Registers the component in a given scene
  41182. */
  41183. register(): void;
  41184. /**
  41185. * Rebuilds the elements related to this component in case of
  41186. * context lost for instance.
  41187. */
  41188. rebuild(): void;
  41189. /**
  41190. * Serializes the component data to the specified json object
  41191. * @param serializationObject The object to serialize to
  41192. */
  41193. serialize(serializationObject: any): void;
  41194. /**
  41195. * Adds all the elements from the container to the scene
  41196. * @param container the container holding the elements
  41197. */
  41198. addFromContainer(container: AbstractScene): void;
  41199. /**
  41200. * Removes all the elements in the container from the scene
  41201. * @param container contains the elements to remove
  41202. * @param dispose if the removed element should be disposed (default: false)
  41203. */
  41204. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41205. /**
  41206. * Disposes the component and the associated ressources.
  41207. */
  41208. dispose(): void;
  41209. /**
  41210. * Disables audio in the associated scene.
  41211. */
  41212. disableAudio(): void;
  41213. /**
  41214. * Enables audio in the associated scene.
  41215. */
  41216. enableAudio(): void;
  41217. /**
  41218. * Switch audio to headphone output.
  41219. */
  41220. switchAudioModeForHeadphones(): void;
  41221. /**
  41222. * Switch audio to normal speakers.
  41223. */
  41224. switchAudioModeForNormalSpeakers(): void;
  41225. private _cachedCameraDirection;
  41226. private _cachedCameraPosition;
  41227. private _lastCheck;
  41228. private _afterRender;
  41229. }
  41230. }
  41231. declare module BABYLON {
  41232. /**
  41233. * Wraps one or more Sound objects and selects one with random weight for playback.
  41234. */
  41235. export class WeightedSound {
  41236. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41237. loop: boolean;
  41238. private _coneInnerAngle;
  41239. private _coneOuterAngle;
  41240. private _volume;
  41241. /** A Sound is currently playing. */
  41242. isPlaying: boolean;
  41243. /** A Sound is currently paused. */
  41244. isPaused: boolean;
  41245. private _sounds;
  41246. private _weights;
  41247. private _currentIndex?;
  41248. /**
  41249. * Creates a new WeightedSound from the list of sounds given.
  41250. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41251. * @param sounds Array of Sounds that will be selected from.
  41252. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41253. */
  41254. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41255. /**
  41256. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41257. */
  41258. get directionalConeInnerAngle(): number;
  41259. /**
  41260. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41261. */
  41262. set directionalConeInnerAngle(value: number);
  41263. /**
  41264. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41265. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41266. */
  41267. get directionalConeOuterAngle(): number;
  41268. /**
  41269. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41270. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41271. */
  41272. set directionalConeOuterAngle(value: number);
  41273. /**
  41274. * Playback volume.
  41275. */
  41276. get volume(): number;
  41277. /**
  41278. * Playback volume.
  41279. */
  41280. set volume(value: number);
  41281. private _onended;
  41282. /**
  41283. * Suspend playback
  41284. */
  41285. pause(): void;
  41286. /**
  41287. * Stop playback
  41288. */
  41289. stop(): void;
  41290. /**
  41291. * Start playback.
  41292. * @param startOffset Position the clip head at a specific time in seconds.
  41293. */
  41294. play(startOffset?: number): void;
  41295. }
  41296. }
  41297. declare module BABYLON {
  41298. /**
  41299. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  41300. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  41301. */
  41302. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  41303. /**
  41304. * Gets the name of the behavior.
  41305. */
  41306. get name(): string;
  41307. /**
  41308. * The easing function used by animations
  41309. */
  41310. static EasingFunction: BackEase;
  41311. /**
  41312. * The easing mode used by animations
  41313. */
  41314. static EasingMode: number;
  41315. /**
  41316. * The duration of the animation, in milliseconds
  41317. */
  41318. transitionDuration: number;
  41319. /**
  41320. * Length of the distance animated by the transition when lower radius is reached
  41321. */
  41322. lowerRadiusTransitionRange: number;
  41323. /**
  41324. * Length of the distance animated by the transition when upper radius is reached
  41325. */
  41326. upperRadiusTransitionRange: number;
  41327. private _autoTransitionRange;
  41328. /**
  41329. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41330. */
  41331. get autoTransitionRange(): boolean;
  41332. /**
  41333. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  41334. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  41335. */
  41336. set autoTransitionRange(value: boolean);
  41337. private _attachedCamera;
  41338. private _onAfterCheckInputsObserver;
  41339. private _onMeshTargetChangedObserver;
  41340. /**
  41341. * Initializes the behavior.
  41342. */
  41343. init(): void;
  41344. /**
  41345. * Attaches the behavior to its arc rotate camera.
  41346. * @param camera Defines the camera to attach the behavior to
  41347. */
  41348. attach(camera: ArcRotateCamera): void;
  41349. /**
  41350. * Detaches the behavior from its current arc rotate camera.
  41351. */
  41352. detach(): void;
  41353. private _radiusIsAnimating;
  41354. private _radiusBounceTransition;
  41355. private _animatables;
  41356. private _cachedWheelPrecision;
  41357. /**
  41358. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  41359. * @param radiusLimit The limit to check against.
  41360. * @return Bool to indicate if at limit.
  41361. */
  41362. private _isRadiusAtLimit;
  41363. /**
  41364. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  41365. * @param radiusDelta The delta by which to animate to. Can be negative.
  41366. */
  41367. private _applyBoundRadiusAnimation;
  41368. /**
  41369. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  41370. */
  41371. protected _clearAnimationLocks(): void;
  41372. /**
  41373. * Stops and removes all animations that have been applied to the camera
  41374. */
  41375. stopAllAnimations(): void;
  41376. }
  41377. }
  41378. declare module BABYLON {
  41379. /**
  41380. * 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.
  41381. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  41382. */
  41383. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  41384. /**
  41385. * Gets the name of the behavior.
  41386. */
  41387. get name(): string;
  41388. private _mode;
  41389. private _radiusScale;
  41390. private _positionScale;
  41391. private _defaultElevation;
  41392. private _elevationReturnTime;
  41393. private _elevationReturnWaitTime;
  41394. private _zoomStopsAnimation;
  41395. private _framingTime;
  41396. /**
  41397. * The easing function used by animations
  41398. */
  41399. static EasingFunction: ExponentialEase;
  41400. /**
  41401. * The easing mode used by animations
  41402. */
  41403. static EasingMode: number;
  41404. /**
  41405. * Sets the current mode used by the behavior
  41406. */
  41407. set mode(mode: number);
  41408. /**
  41409. * Gets current mode used by the behavior.
  41410. */
  41411. get mode(): number;
  41412. /**
  41413. * Sets the scale applied to the radius (1 by default)
  41414. */
  41415. set radiusScale(radius: number);
  41416. /**
  41417. * Gets the scale applied to the radius
  41418. */
  41419. get radiusScale(): number;
  41420. /**
  41421. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41422. */
  41423. set positionScale(scale: number);
  41424. /**
  41425. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  41426. */
  41427. get positionScale(): number;
  41428. /**
  41429. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41430. * behaviour is triggered, in radians.
  41431. */
  41432. set defaultElevation(elevation: number);
  41433. /**
  41434. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  41435. * behaviour is triggered, in radians.
  41436. */
  41437. get defaultElevation(): number;
  41438. /**
  41439. * Sets the time (in milliseconds) taken to return to the default beta position.
  41440. * Negative value indicates camera should not return to default.
  41441. */
  41442. set elevationReturnTime(speed: number);
  41443. /**
  41444. * Gets the time (in milliseconds) taken to return to the default beta position.
  41445. * Negative value indicates camera should not return to default.
  41446. */
  41447. get elevationReturnTime(): number;
  41448. /**
  41449. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41450. */
  41451. set elevationReturnWaitTime(time: number);
  41452. /**
  41453. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  41454. */
  41455. get elevationReturnWaitTime(): number;
  41456. /**
  41457. * Sets the flag that indicates if user zooming should stop animation.
  41458. */
  41459. set zoomStopsAnimation(flag: boolean);
  41460. /**
  41461. * Gets the flag that indicates if user zooming should stop animation.
  41462. */
  41463. get zoomStopsAnimation(): boolean;
  41464. /**
  41465. * Sets the transition time when framing the mesh, in milliseconds
  41466. */
  41467. set framingTime(time: number);
  41468. /**
  41469. * Gets the transition time when framing the mesh, in milliseconds
  41470. */
  41471. get framingTime(): number;
  41472. /**
  41473. * Define if the behavior should automatically change the configured
  41474. * camera limits and sensibilities.
  41475. */
  41476. autoCorrectCameraLimitsAndSensibility: boolean;
  41477. private _onPrePointerObservableObserver;
  41478. private _onAfterCheckInputsObserver;
  41479. private _onMeshTargetChangedObserver;
  41480. private _attachedCamera;
  41481. private _isPointerDown;
  41482. private _lastInteractionTime;
  41483. /**
  41484. * Initializes the behavior.
  41485. */
  41486. init(): void;
  41487. /**
  41488. * Attaches the behavior to its arc rotate camera.
  41489. * @param camera Defines the camera to attach the behavior to
  41490. */
  41491. attach(camera: ArcRotateCamera): void;
  41492. /**
  41493. * Detaches the behavior from its current arc rotate camera.
  41494. */
  41495. detach(): void;
  41496. private _animatables;
  41497. private _betaIsAnimating;
  41498. private _betaTransition;
  41499. private _radiusTransition;
  41500. private _vectorTransition;
  41501. /**
  41502. * Targets the given mesh and updates zoom level accordingly.
  41503. * @param mesh The mesh to target.
  41504. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41505. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41506. */
  41507. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41508. /**
  41509. * Targets the given mesh with its children and updates zoom level accordingly.
  41510. * @param mesh The mesh to target.
  41511. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41512. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41513. */
  41514. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41515. /**
  41516. * Targets the given meshes with their children and updates zoom level accordingly.
  41517. * @param meshes The mesh to target.
  41518. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41519. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41520. */
  41521. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41522. /**
  41523. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  41524. * @param minimumWorld Determines the smaller position of the bounding box extend
  41525. * @param maximumWorld Determines the bigger position of the bounding box extend
  41526. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  41527. * @param onAnimationEnd Callback triggered at the end of the framing animation
  41528. */
  41529. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  41530. /**
  41531. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  41532. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  41533. * frustum width.
  41534. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  41535. * to fully enclose the mesh in the viewing frustum.
  41536. */
  41537. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  41538. /**
  41539. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  41540. * is automatically returned to its default position (expected to be above ground plane).
  41541. */
  41542. private _maintainCameraAboveGround;
  41543. /**
  41544. * Returns the frustum slope based on the canvas ratio and camera FOV
  41545. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  41546. */
  41547. private _getFrustumSlope;
  41548. /**
  41549. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  41550. */
  41551. private _clearAnimationLocks;
  41552. /**
  41553. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  41554. */
  41555. private _applyUserInteraction;
  41556. /**
  41557. * Stops and removes all animations that have been applied to the camera
  41558. */
  41559. stopAllAnimations(): void;
  41560. /**
  41561. * Gets a value indicating if the user is moving the camera
  41562. */
  41563. get isUserIsMoving(): boolean;
  41564. /**
  41565. * The camera can move all the way towards the mesh.
  41566. */
  41567. static IgnoreBoundsSizeMode: number;
  41568. /**
  41569. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  41570. */
  41571. static FitFrustumSidesMode: number;
  41572. }
  41573. }
  41574. declare module BABYLON {
  41575. /**
  41576. * Base class for Camera Pointer Inputs.
  41577. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  41578. * for example usage.
  41579. */
  41580. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  41581. /**
  41582. * Defines the camera the input is attached to.
  41583. */
  41584. abstract camera: Camera;
  41585. /**
  41586. * Whether keyboard modifier keys are pressed at time of last mouse event.
  41587. */
  41588. protected _altKey: boolean;
  41589. protected _ctrlKey: boolean;
  41590. protected _metaKey: boolean;
  41591. protected _shiftKey: boolean;
  41592. /**
  41593. * Which mouse buttons were pressed at time of last mouse event.
  41594. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  41595. */
  41596. protected _buttonsPressed: number;
  41597. /**
  41598. * Defines the buttons associated with the input to handle camera move.
  41599. */
  41600. buttons: number[];
  41601. /**
  41602. * Attach the input controls to a specific dom element to get the input from.
  41603. * @param element Defines the element the controls should be listened from
  41604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41605. */
  41606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41607. /**
  41608. * Detach the current controls from the specified dom element.
  41609. * @param element Defines the element to stop listening the inputs from
  41610. */
  41611. detachControl(element: Nullable<HTMLElement>): void;
  41612. /**
  41613. * Gets the class name of the current input.
  41614. * @returns the class name
  41615. */
  41616. getClassName(): string;
  41617. /**
  41618. * Get the friendly name associated with the input class.
  41619. * @returns the input friendly name
  41620. */
  41621. getSimpleName(): string;
  41622. /**
  41623. * Called on pointer POINTERDOUBLETAP event.
  41624. * Override this method to provide functionality on POINTERDOUBLETAP event.
  41625. */
  41626. protected onDoubleTap(type: string): void;
  41627. /**
  41628. * Called on pointer POINTERMOVE event if only a single touch is active.
  41629. * Override this method to provide functionality.
  41630. */
  41631. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41632. /**
  41633. * Called on pointer POINTERMOVE event if multiple touches are active.
  41634. * Override this method to provide functionality.
  41635. */
  41636. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41637. /**
  41638. * Called on JS contextmenu event.
  41639. * Override this method to provide functionality.
  41640. */
  41641. protected onContextMenu(evt: PointerEvent): void;
  41642. /**
  41643. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41644. * press.
  41645. * Override this method to provide functionality.
  41646. */
  41647. protected onButtonDown(evt: PointerEvent): void;
  41648. /**
  41649. * Called each time a new POINTERUP event occurs. Ie, for each button
  41650. * release.
  41651. * Override this method to provide functionality.
  41652. */
  41653. protected onButtonUp(evt: PointerEvent): void;
  41654. /**
  41655. * Called when window becomes inactive.
  41656. * Override this method to provide functionality.
  41657. */
  41658. protected onLostFocus(): void;
  41659. private _pointerInput;
  41660. private _observer;
  41661. private _onLostFocus;
  41662. private pointA;
  41663. private pointB;
  41664. }
  41665. }
  41666. declare module BABYLON {
  41667. /**
  41668. * Manage the pointers inputs to control an arc rotate camera.
  41669. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41670. */
  41671. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  41672. /**
  41673. * Defines the camera the input is attached to.
  41674. */
  41675. camera: ArcRotateCamera;
  41676. /**
  41677. * Gets the class name of the current input.
  41678. * @returns the class name
  41679. */
  41680. getClassName(): string;
  41681. /**
  41682. * Defines the buttons associated with the input to handle camera move.
  41683. */
  41684. buttons: number[];
  41685. /**
  41686. * Defines the pointer angular sensibility along the X axis or how fast is
  41687. * the camera rotating.
  41688. */
  41689. angularSensibilityX: number;
  41690. /**
  41691. * Defines the pointer angular sensibility along the Y axis or how fast is
  41692. * the camera rotating.
  41693. */
  41694. angularSensibilityY: number;
  41695. /**
  41696. * Defines the pointer pinch precision or how fast is the camera zooming.
  41697. */
  41698. pinchPrecision: number;
  41699. /**
  41700. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41701. * from 0.
  41702. * It defines the percentage of current camera.radius to use as delta when
  41703. * pinch zoom is used.
  41704. */
  41705. pinchDeltaPercentage: number;
  41706. /**
  41707. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  41708. * that any object in the plane at the camera's target point will scale
  41709. * perfectly with finger motion.
  41710. * Overrides pinchDeltaPercentage and pinchPrecision.
  41711. */
  41712. useNaturalPinchZoom: boolean;
  41713. /**
  41714. * Defines the pointer panning sensibility or how fast is the camera moving.
  41715. */
  41716. panningSensibility: number;
  41717. /**
  41718. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  41719. */
  41720. multiTouchPanning: boolean;
  41721. /**
  41722. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  41723. * zoom (pinch) through multitouch.
  41724. */
  41725. multiTouchPanAndZoom: boolean;
  41726. /**
  41727. * Revers pinch action direction.
  41728. */
  41729. pinchInwards: boolean;
  41730. private _isPanClick;
  41731. private _twoFingerActivityCount;
  41732. private _isPinching;
  41733. /**
  41734. * Called on pointer POINTERMOVE event if only a single touch is active.
  41735. */
  41736. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41737. /**
  41738. * Called on pointer POINTERDOUBLETAP event.
  41739. */
  41740. protected onDoubleTap(type: string): void;
  41741. /**
  41742. * Called on pointer POINTERMOVE event if multiple touches are active.
  41743. */
  41744. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41745. /**
  41746. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  41747. * press.
  41748. */
  41749. protected onButtonDown(evt: PointerEvent): void;
  41750. /**
  41751. * Called each time a new POINTERUP event occurs. Ie, for each button
  41752. * release.
  41753. */
  41754. protected onButtonUp(evt: PointerEvent): void;
  41755. /**
  41756. * Called when window becomes inactive.
  41757. */
  41758. protected onLostFocus(): void;
  41759. }
  41760. }
  41761. declare module BABYLON {
  41762. /**
  41763. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  41764. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41765. */
  41766. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  41767. /**
  41768. * Defines the camera the input is attached to.
  41769. */
  41770. camera: ArcRotateCamera;
  41771. /**
  41772. * Defines the list of key codes associated with the up action (increase alpha)
  41773. */
  41774. keysUp: number[];
  41775. /**
  41776. * Defines the list of key codes associated with the down action (decrease alpha)
  41777. */
  41778. keysDown: number[];
  41779. /**
  41780. * Defines the list of key codes associated with the left action (increase beta)
  41781. */
  41782. keysLeft: number[];
  41783. /**
  41784. * Defines the list of key codes associated with the right action (decrease beta)
  41785. */
  41786. keysRight: number[];
  41787. /**
  41788. * Defines the list of key codes associated with the reset action.
  41789. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  41790. */
  41791. keysReset: number[];
  41792. /**
  41793. * Defines the panning sensibility of the inputs.
  41794. * (How fast is the camera panning)
  41795. */
  41796. panningSensibility: number;
  41797. /**
  41798. * Defines the zooming sensibility of the inputs.
  41799. * (How fast is the camera zooming)
  41800. */
  41801. zoomingSensibility: number;
  41802. /**
  41803. * Defines whether maintaining the alt key down switch the movement mode from
  41804. * orientation to zoom.
  41805. */
  41806. useAltToZoom: boolean;
  41807. /**
  41808. * Rotation speed of the camera
  41809. */
  41810. angularSpeed: number;
  41811. private _keys;
  41812. private _ctrlPressed;
  41813. private _altPressed;
  41814. private _onCanvasBlurObserver;
  41815. private _onKeyboardObserver;
  41816. private _engine;
  41817. private _scene;
  41818. /**
  41819. * Attach the input controls to a specific dom element to get the input from.
  41820. * @param element Defines the element the controls should be listened from
  41821. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41822. */
  41823. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41824. /**
  41825. * Detach the current controls from the specified dom element.
  41826. * @param element Defines the element to stop listening the inputs from
  41827. */
  41828. detachControl(element: Nullable<HTMLElement>): void;
  41829. /**
  41830. * Update the current camera state depending on the inputs that have been used this frame.
  41831. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41832. */
  41833. checkInputs(): void;
  41834. /**
  41835. * Gets the class name of the current intput.
  41836. * @returns the class name
  41837. */
  41838. getClassName(): string;
  41839. /**
  41840. * Get the friendly name associated with the input class.
  41841. * @returns the input friendly name
  41842. */
  41843. getSimpleName(): string;
  41844. }
  41845. }
  41846. declare module BABYLON {
  41847. /**
  41848. * Manage the mouse wheel inputs to control an arc rotate camera.
  41849. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41850. */
  41851. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  41852. /**
  41853. * Defines the camera the input is attached to.
  41854. */
  41855. camera: ArcRotateCamera;
  41856. /**
  41857. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  41858. */
  41859. wheelPrecision: number;
  41860. /**
  41861. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41862. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41863. */
  41864. wheelDeltaPercentage: number;
  41865. private _wheel;
  41866. private _observer;
  41867. private computeDeltaFromMouseWheelLegacyEvent;
  41868. /**
  41869. * Attach the input controls to a specific dom element to get the input from.
  41870. * @param element Defines the element the controls should be listened from
  41871. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41872. */
  41873. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41874. /**
  41875. * Detach the current controls from the specified dom element.
  41876. * @param element Defines the element to stop listening the inputs from
  41877. */
  41878. detachControl(element: Nullable<HTMLElement>): void;
  41879. /**
  41880. * Gets the class name of the current intput.
  41881. * @returns the class name
  41882. */
  41883. getClassName(): string;
  41884. /**
  41885. * Get the friendly name associated with the input class.
  41886. * @returns the input friendly name
  41887. */
  41888. getSimpleName(): string;
  41889. }
  41890. }
  41891. declare module BABYLON {
  41892. /**
  41893. * Default Inputs manager for the ArcRotateCamera.
  41894. * It groups all the default supported inputs for ease of use.
  41895. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  41896. */
  41897. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  41898. /**
  41899. * Instantiates a new ArcRotateCameraInputsManager.
  41900. * @param camera Defines the camera the inputs belong to
  41901. */
  41902. constructor(camera: ArcRotateCamera);
  41903. /**
  41904. * Add mouse wheel input support to the input manager.
  41905. * @returns the current input manager
  41906. */
  41907. addMouseWheel(): ArcRotateCameraInputsManager;
  41908. /**
  41909. * Add pointers input support to the input manager.
  41910. * @returns the current input manager
  41911. */
  41912. addPointers(): ArcRotateCameraInputsManager;
  41913. /**
  41914. * Add keyboard input support to the input manager.
  41915. * @returns the current input manager
  41916. */
  41917. addKeyboard(): ArcRotateCameraInputsManager;
  41918. }
  41919. }
  41920. declare module BABYLON {
  41921. /**
  41922. * This represents an orbital type of camera.
  41923. *
  41924. * 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.
  41925. * 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.
  41926. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  41927. */
  41928. export class ArcRotateCamera extends TargetCamera {
  41929. /**
  41930. * Defines the rotation angle of the camera along the longitudinal axis.
  41931. */
  41932. alpha: number;
  41933. /**
  41934. * Defines the rotation angle of the camera along the latitudinal axis.
  41935. */
  41936. beta: number;
  41937. /**
  41938. * Defines the radius of the camera from it s target point.
  41939. */
  41940. radius: number;
  41941. protected _target: Vector3;
  41942. protected _targetHost: Nullable<AbstractMesh>;
  41943. /**
  41944. * Defines the target point of the camera.
  41945. * The camera looks towards it form the radius distance.
  41946. */
  41947. get target(): Vector3;
  41948. set target(value: Vector3);
  41949. /**
  41950. * Define the current local position of the camera in the scene
  41951. */
  41952. get position(): Vector3;
  41953. set position(newPosition: Vector3);
  41954. protected _upVector: Vector3;
  41955. protected _upToYMatrix: Matrix;
  41956. protected _YToUpMatrix: Matrix;
  41957. /**
  41958. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  41959. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  41960. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  41961. */
  41962. set upVector(vec: Vector3);
  41963. get upVector(): Vector3;
  41964. /**
  41965. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  41966. */
  41967. setMatUp(): void;
  41968. /**
  41969. * Current inertia value on the longitudinal axis.
  41970. * The bigger this number the longer it will take for the camera to stop.
  41971. */
  41972. inertialAlphaOffset: number;
  41973. /**
  41974. * Current inertia value on the latitudinal axis.
  41975. * The bigger this number the longer it will take for the camera to stop.
  41976. */
  41977. inertialBetaOffset: number;
  41978. /**
  41979. * Current inertia value on the radius axis.
  41980. * The bigger this number the longer it will take for the camera to stop.
  41981. */
  41982. inertialRadiusOffset: number;
  41983. /**
  41984. * Minimum allowed angle on the longitudinal axis.
  41985. * This can help limiting how the Camera is able to move in the scene.
  41986. */
  41987. lowerAlphaLimit: Nullable<number>;
  41988. /**
  41989. * Maximum allowed angle on the longitudinal axis.
  41990. * This can help limiting how the Camera is able to move in the scene.
  41991. */
  41992. upperAlphaLimit: Nullable<number>;
  41993. /**
  41994. * Minimum allowed angle on the latitudinal axis.
  41995. * This can help limiting how the Camera is able to move in the scene.
  41996. */
  41997. lowerBetaLimit: number;
  41998. /**
  41999. * Maximum allowed angle on the latitudinal axis.
  42000. * This can help limiting how the Camera is able to move in the scene.
  42001. */
  42002. upperBetaLimit: number;
  42003. /**
  42004. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42005. * This can help limiting how the Camera is able to move in the scene.
  42006. */
  42007. lowerRadiusLimit: Nullable<number>;
  42008. /**
  42009. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42010. * This can help limiting how the Camera is able to move in the scene.
  42011. */
  42012. upperRadiusLimit: Nullable<number>;
  42013. /**
  42014. * Defines the current inertia value used during panning of the camera along the X axis.
  42015. */
  42016. inertialPanningX: number;
  42017. /**
  42018. * Defines the current inertia value used during panning of the camera along the Y axis.
  42019. */
  42020. inertialPanningY: number;
  42021. /**
  42022. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42023. * Basically if your fingers moves away from more than this distance you will be considered
  42024. * in pinch mode.
  42025. */
  42026. pinchToPanMaxDistance: number;
  42027. /**
  42028. * Defines the maximum distance the camera can pan.
  42029. * This could help keeping the cammera always in your scene.
  42030. */
  42031. panningDistanceLimit: Nullable<number>;
  42032. /**
  42033. * Defines the target of the camera before paning.
  42034. */
  42035. panningOriginTarget: Vector3;
  42036. /**
  42037. * Defines the value of the inertia used during panning.
  42038. * 0 would mean stop inertia and one would mean no decelleration at all.
  42039. */
  42040. panningInertia: number;
  42041. /**
  42042. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42043. */
  42044. get angularSensibilityX(): number;
  42045. set angularSensibilityX(value: number);
  42046. /**
  42047. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42048. */
  42049. get angularSensibilityY(): number;
  42050. set angularSensibilityY(value: number);
  42051. /**
  42052. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42053. */
  42054. get pinchPrecision(): number;
  42055. set pinchPrecision(value: number);
  42056. /**
  42057. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42058. * It will be used instead of pinchDeltaPrecision if different from 0.
  42059. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42060. */
  42061. get pinchDeltaPercentage(): number;
  42062. set pinchDeltaPercentage(value: number);
  42063. /**
  42064. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42065. * and pinch delta percentage.
  42066. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42067. * that any object in the plane at the camera's target point will scale
  42068. * perfectly with finger motion.
  42069. */
  42070. get useNaturalPinchZoom(): boolean;
  42071. set useNaturalPinchZoom(value: boolean);
  42072. /**
  42073. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42074. */
  42075. get panningSensibility(): number;
  42076. set panningSensibility(value: number);
  42077. /**
  42078. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42079. */
  42080. get keysUp(): number[];
  42081. set keysUp(value: number[]);
  42082. /**
  42083. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42084. */
  42085. get keysDown(): number[];
  42086. set keysDown(value: number[]);
  42087. /**
  42088. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42089. */
  42090. get keysLeft(): number[];
  42091. set keysLeft(value: number[]);
  42092. /**
  42093. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42094. */
  42095. get keysRight(): number[];
  42096. set keysRight(value: number[]);
  42097. /**
  42098. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42099. */
  42100. get wheelPrecision(): number;
  42101. set wheelPrecision(value: number);
  42102. /**
  42103. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42104. * It will be used instead of pinchDeltaPrecision if different from 0.
  42105. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42106. */
  42107. get wheelDeltaPercentage(): number;
  42108. set wheelDeltaPercentage(value: number);
  42109. /**
  42110. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42111. */
  42112. zoomOnFactor: number;
  42113. /**
  42114. * Defines a screen offset for the camera position.
  42115. */
  42116. targetScreenOffset: Vector2;
  42117. /**
  42118. * Allows the camera to be completely reversed.
  42119. * If false the camera can not arrive upside down.
  42120. */
  42121. allowUpsideDown: boolean;
  42122. /**
  42123. * Define if double tap/click is used to restore the previously saved state of the camera.
  42124. */
  42125. useInputToRestoreState: boolean;
  42126. /** @hidden */
  42127. _viewMatrix: Matrix;
  42128. /** @hidden */
  42129. _useCtrlForPanning: boolean;
  42130. /** @hidden */
  42131. _panningMouseButton: number;
  42132. /**
  42133. * Defines the input associated to the camera.
  42134. */
  42135. inputs: ArcRotateCameraInputsManager;
  42136. /** @hidden */
  42137. _reset: () => void;
  42138. /**
  42139. * Defines the allowed panning axis.
  42140. */
  42141. panningAxis: Vector3;
  42142. protected _localDirection: Vector3;
  42143. protected _transformedDirection: Vector3;
  42144. private _bouncingBehavior;
  42145. /**
  42146. * Gets the bouncing behavior of the camera if it has been enabled.
  42147. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42148. */
  42149. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42150. /**
  42151. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42152. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42153. */
  42154. get useBouncingBehavior(): boolean;
  42155. set useBouncingBehavior(value: boolean);
  42156. private _framingBehavior;
  42157. /**
  42158. * Gets the framing behavior of the camera if it has been enabled.
  42159. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42160. */
  42161. get framingBehavior(): Nullable<FramingBehavior>;
  42162. /**
  42163. * Defines if the framing behavior of the camera is enabled on the camera.
  42164. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42165. */
  42166. get useFramingBehavior(): boolean;
  42167. set useFramingBehavior(value: boolean);
  42168. private _autoRotationBehavior;
  42169. /**
  42170. * Gets the auto rotation behavior of the camera if it has been enabled.
  42171. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42172. */
  42173. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42174. /**
  42175. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42176. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42177. */
  42178. get useAutoRotationBehavior(): boolean;
  42179. set useAutoRotationBehavior(value: boolean);
  42180. /**
  42181. * Observable triggered when the mesh target has been changed on the camera.
  42182. */
  42183. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42184. /**
  42185. * Event raised when the camera is colliding with a mesh.
  42186. */
  42187. onCollide: (collidedMesh: AbstractMesh) => void;
  42188. /**
  42189. * Defines whether the camera should check collision with the objects oh the scene.
  42190. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42191. */
  42192. checkCollisions: boolean;
  42193. /**
  42194. * Defines the collision radius of the camera.
  42195. * This simulates a sphere around the camera.
  42196. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42197. */
  42198. collisionRadius: Vector3;
  42199. protected _collider: Collider;
  42200. protected _previousPosition: Vector3;
  42201. protected _collisionVelocity: Vector3;
  42202. protected _newPosition: Vector3;
  42203. protected _previousAlpha: number;
  42204. protected _previousBeta: number;
  42205. protected _previousRadius: number;
  42206. protected _collisionTriggered: boolean;
  42207. protected _targetBoundingCenter: Nullable<Vector3>;
  42208. private _computationVector;
  42209. /**
  42210. * Instantiates a new ArcRotateCamera in a given scene
  42211. * @param name Defines the name of the camera
  42212. * @param alpha Defines the camera rotation along the logitudinal axis
  42213. * @param beta Defines the camera rotation along the latitudinal axis
  42214. * @param radius Defines the camera distance from its target
  42215. * @param target Defines the camera target
  42216. * @param scene Defines the scene the camera belongs to
  42217. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42218. */
  42219. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42220. /** @hidden */
  42221. _initCache(): void;
  42222. /** @hidden */
  42223. _updateCache(ignoreParentClass?: boolean): void;
  42224. protected _getTargetPosition(): Vector3;
  42225. private _storedAlpha;
  42226. private _storedBeta;
  42227. private _storedRadius;
  42228. private _storedTarget;
  42229. private _storedTargetScreenOffset;
  42230. /**
  42231. * Stores the current state of the camera (alpha, beta, radius and target)
  42232. * @returns the camera itself
  42233. */
  42234. storeState(): Camera;
  42235. /**
  42236. * @hidden
  42237. * Restored camera state. You must call storeState() first
  42238. */
  42239. _restoreStateValues(): boolean;
  42240. /** @hidden */
  42241. _isSynchronizedViewMatrix(): boolean;
  42242. /**
  42243. * Attached controls to the current camera.
  42244. * @param element Defines the element the controls should be listened from
  42245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42246. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42247. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42248. */
  42249. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42250. /**
  42251. * Detach the current controls from the camera.
  42252. * The camera will stop reacting to inputs.
  42253. * @param element Defines the element to stop listening the inputs from
  42254. */
  42255. detachControl(element: HTMLElement): void;
  42256. /** @hidden */
  42257. _checkInputs(): void;
  42258. protected _checkLimits(): void;
  42259. /**
  42260. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42261. */
  42262. rebuildAnglesAndRadius(): void;
  42263. /**
  42264. * Use a position to define the current camera related information like alpha, beta and radius
  42265. * @param position Defines the position to set the camera at
  42266. */
  42267. setPosition(position: Vector3): void;
  42268. /**
  42269. * Defines the target the camera should look at.
  42270. * This will automatically adapt alpha beta and radius to fit within the new target.
  42271. * @param target Defines the new target as a Vector or a mesh
  42272. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42273. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42274. */
  42275. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42276. /** @hidden */
  42277. _getViewMatrix(): Matrix;
  42278. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42279. /**
  42280. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42281. * @param meshes Defines the mesh to zoom on
  42282. * @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)
  42283. */
  42284. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42285. /**
  42286. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42287. * The target will be changed but the radius
  42288. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  42289. * @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)
  42290. */
  42291. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  42292. min: Vector3;
  42293. max: Vector3;
  42294. distance: number;
  42295. }, doNotUpdateMaxZ?: boolean): void;
  42296. /**
  42297. * @override
  42298. * Override Camera.createRigCamera
  42299. */
  42300. createRigCamera(name: string, cameraIndex: number): Camera;
  42301. /**
  42302. * @hidden
  42303. * @override
  42304. * Override Camera._updateRigCameras
  42305. */
  42306. _updateRigCameras(): void;
  42307. /**
  42308. * Destroy the camera and release the current resources hold by it.
  42309. */
  42310. dispose(): void;
  42311. /**
  42312. * Gets the current object class name.
  42313. * @return the class name
  42314. */
  42315. getClassName(): string;
  42316. }
  42317. }
  42318. declare module BABYLON {
  42319. /**
  42320. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  42321. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42322. */
  42323. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  42324. /**
  42325. * Gets the name of the behavior.
  42326. */
  42327. get name(): string;
  42328. private _zoomStopsAnimation;
  42329. private _idleRotationSpeed;
  42330. private _idleRotationWaitTime;
  42331. private _idleRotationSpinupTime;
  42332. /**
  42333. * Sets the flag that indicates if user zooming should stop animation.
  42334. */
  42335. set zoomStopsAnimation(flag: boolean);
  42336. /**
  42337. * Gets the flag that indicates if user zooming should stop animation.
  42338. */
  42339. get zoomStopsAnimation(): boolean;
  42340. /**
  42341. * Sets the default speed at which the camera rotates around the model.
  42342. */
  42343. set idleRotationSpeed(speed: number);
  42344. /**
  42345. * Gets the default speed at which the camera rotates around the model.
  42346. */
  42347. get idleRotationSpeed(): number;
  42348. /**
  42349. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  42350. */
  42351. set idleRotationWaitTime(time: number);
  42352. /**
  42353. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  42354. */
  42355. get idleRotationWaitTime(): number;
  42356. /**
  42357. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42358. */
  42359. set idleRotationSpinupTime(time: number);
  42360. /**
  42361. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  42362. */
  42363. get idleRotationSpinupTime(): number;
  42364. /**
  42365. * Gets a value indicating if the camera is currently rotating because of this behavior
  42366. */
  42367. get rotationInProgress(): boolean;
  42368. private _onPrePointerObservableObserver;
  42369. private _onAfterCheckInputsObserver;
  42370. private _attachedCamera;
  42371. private _isPointerDown;
  42372. private _lastFrameTime;
  42373. private _lastInteractionTime;
  42374. private _cameraRotationSpeed;
  42375. /**
  42376. * Initializes the behavior.
  42377. */
  42378. init(): void;
  42379. /**
  42380. * Attaches the behavior to its arc rotate camera.
  42381. * @param camera Defines the camera to attach the behavior to
  42382. */
  42383. attach(camera: ArcRotateCamera): void;
  42384. /**
  42385. * Detaches the behavior from its current arc rotate camera.
  42386. */
  42387. detach(): void;
  42388. /**
  42389. * Returns true if user is scrolling.
  42390. * @return true if user is scrolling.
  42391. */
  42392. private _userIsZooming;
  42393. private _lastFrameRadius;
  42394. private _shouldAnimationStopForInteraction;
  42395. /**
  42396. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42397. */
  42398. private _applyUserInteraction;
  42399. private _userIsMoving;
  42400. }
  42401. }
  42402. declare module BABYLON {
  42403. /**
  42404. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  42405. */
  42406. export class AttachToBoxBehavior implements Behavior<Mesh> {
  42407. private ui;
  42408. /**
  42409. * The name of the behavior
  42410. */
  42411. name: string;
  42412. /**
  42413. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  42414. */
  42415. distanceAwayFromFace: number;
  42416. /**
  42417. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  42418. */
  42419. distanceAwayFromBottomOfFace: number;
  42420. private _faceVectors;
  42421. private _target;
  42422. private _scene;
  42423. private _onRenderObserver;
  42424. private _tmpMatrix;
  42425. private _tmpVector;
  42426. /**
  42427. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  42428. * @param ui The transform node that should be attched to the mesh
  42429. */
  42430. constructor(ui: TransformNode);
  42431. /**
  42432. * Initializes the behavior
  42433. */
  42434. init(): void;
  42435. private _closestFace;
  42436. private _zeroVector;
  42437. private _lookAtTmpMatrix;
  42438. private _lookAtToRef;
  42439. /**
  42440. * Attaches the AttachToBoxBehavior to the passed in mesh
  42441. * @param target The mesh that the specified node will be attached to
  42442. */
  42443. attach(target: Mesh): void;
  42444. /**
  42445. * Detaches the behavior from the mesh
  42446. */
  42447. detach(): void;
  42448. }
  42449. }
  42450. declare module BABYLON {
  42451. /**
  42452. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  42453. */
  42454. export class FadeInOutBehavior implements Behavior<Mesh> {
  42455. /**
  42456. * Time in milliseconds to delay before fading in (Default: 0)
  42457. */
  42458. delay: number;
  42459. /**
  42460. * Time in milliseconds for the mesh to fade in (Default: 300)
  42461. */
  42462. fadeInTime: number;
  42463. private _millisecondsPerFrame;
  42464. private _hovered;
  42465. private _hoverValue;
  42466. private _ownerNode;
  42467. /**
  42468. * Instatiates the FadeInOutBehavior
  42469. */
  42470. constructor();
  42471. /**
  42472. * The name of the behavior
  42473. */
  42474. get name(): string;
  42475. /**
  42476. * Initializes the behavior
  42477. */
  42478. init(): void;
  42479. /**
  42480. * Attaches the fade behavior on the passed in mesh
  42481. * @param ownerNode The mesh that will be faded in/out once attached
  42482. */
  42483. attach(ownerNode: Mesh): void;
  42484. /**
  42485. * Detaches the behavior from the mesh
  42486. */
  42487. detach(): void;
  42488. /**
  42489. * Triggers the mesh to begin fading in or out
  42490. * @param value if the object should fade in or out (true to fade in)
  42491. */
  42492. fadeIn(value: boolean): void;
  42493. private _update;
  42494. private _setAllVisibility;
  42495. }
  42496. }
  42497. declare module BABYLON {
  42498. /**
  42499. * Class containing a set of static utilities functions for managing Pivots
  42500. * @hidden
  42501. */
  42502. export class PivotTools {
  42503. private static _PivotCached;
  42504. private static _OldPivotPoint;
  42505. private static _PivotTranslation;
  42506. private static _PivotTmpVector;
  42507. /** @hidden */
  42508. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  42509. /** @hidden */
  42510. static _RestorePivotPoint(mesh: AbstractMesh): void;
  42511. }
  42512. }
  42513. declare module BABYLON {
  42514. /**
  42515. * Class containing static functions to help procedurally build meshes
  42516. */
  42517. export class PlaneBuilder {
  42518. /**
  42519. * Creates a plane mesh
  42520. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  42521. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  42522. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  42523. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42524. * * 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
  42525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42526. * @param name defines the name of the mesh
  42527. * @param options defines the options used to create the mesh
  42528. * @param scene defines the hosting scene
  42529. * @returns the plane mesh
  42530. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  42531. */
  42532. static CreatePlane(name: string, options: {
  42533. size?: number;
  42534. width?: number;
  42535. height?: number;
  42536. sideOrientation?: number;
  42537. frontUVs?: Vector4;
  42538. backUVs?: Vector4;
  42539. updatable?: boolean;
  42540. sourcePlane?: Plane;
  42541. }, scene?: Nullable<Scene>): Mesh;
  42542. }
  42543. }
  42544. declare module BABYLON {
  42545. /**
  42546. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  42547. */
  42548. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  42549. private static _AnyMouseID;
  42550. /**
  42551. * Abstract mesh the behavior is set on
  42552. */
  42553. attachedNode: AbstractMesh;
  42554. private _dragPlane;
  42555. private _scene;
  42556. private _pointerObserver;
  42557. private _beforeRenderObserver;
  42558. private static _planeScene;
  42559. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  42560. /**
  42561. * 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)
  42562. */
  42563. maxDragAngle: number;
  42564. /**
  42565. * @hidden
  42566. */
  42567. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  42568. /**
  42569. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42570. */
  42571. currentDraggingPointerID: number;
  42572. /**
  42573. * The last position where the pointer hit the drag plane in world space
  42574. */
  42575. lastDragPosition: Vector3;
  42576. /**
  42577. * If the behavior is currently in a dragging state
  42578. */
  42579. dragging: boolean;
  42580. /**
  42581. * 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)
  42582. */
  42583. dragDeltaRatio: number;
  42584. /**
  42585. * If the drag plane orientation should be updated during the dragging (Default: true)
  42586. */
  42587. updateDragPlane: boolean;
  42588. private _debugMode;
  42589. private _moving;
  42590. /**
  42591. * Fires each time the attached mesh is dragged with the pointer
  42592. * * delta between last drag position and current drag position in world space
  42593. * * dragDistance along the drag axis
  42594. * * dragPlaneNormal normal of the current drag plane used during the drag
  42595. * * dragPlanePoint in world space where the drag intersects the drag plane
  42596. */
  42597. onDragObservable: Observable<{
  42598. delta: Vector3;
  42599. dragPlanePoint: Vector3;
  42600. dragPlaneNormal: Vector3;
  42601. dragDistance: number;
  42602. pointerId: number;
  42603. }>;
  42604. /**
  42605. * Fires each time a drag begins (eg. mouse down on mesh)
  42606. */
  42607. onDragStartObservable: Observable<{
  42608. dragPlanePoint: Vector3;
  42609. pointerId: number;
  42610. }>;
  42611. /**
  42612. * Fires each time a drag ends (eg. mouse release after drag)
  42613. */
  42614. onDragEndObservable: Observable<{
  42615. dragPlanePoint: Vector3;
  42616. pointerId: number;
  42617. }>;
  42618. /**
  42619. * If the attached mesh should be moved when dragged
  42620. */
  42621. moveAttached: boolean;
  42622. /**
  42623. * If the drag behavior will react to drag events (Default: true)
  42624. */
  42625. enabled: boolean;
  42626. /**
  42627. * If pointer events should start and release the drag (Default: true)
  42628. */
  42629. startAndReleaseDragOnPointerEvents: boolean;
  42630. /**
  42631. * If camera controls should be detached during the drag
  42632. */
  42633. detachCameraControls: boolean;
  42634. /**
  42635. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  42636. */
  42637. useObjectOrientationForDragging: boolean;
  42638. private _options;
  42639. /**
  42640. * Gets the options used by the behavior
  42641. */
  42642. get options(): {
  42643. dragAxis?: Vector3;
  42644. dragPlaneNormal?: Vector3;
  42645. };
  42646. /**
  42647. * Sets the options used by the behavior
  42648. */
  42649. set options(options: {
  42650. dragAxis?: Vector3;
  42651. dragPlaneNormal?: Vector3;
  42652. });
  42653. /**
  42654. * Creates a pointer drag behavior that can be attached to a mesh
  42655. * @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)
  42656. */
  42657. constructor(options?: {
  42658. dragAxis?: Vector3;
  42659. dragPlaneNormal?: Vector3;
  42660. });
  42661. /**
  42662. * Predicate to determine if it is valid to move the object to a new position when it is moved
  42663. */
  42664. validateDrag: (targetPosition: Vector3) => boolean;
  42665. /**
  42666. * The name of the behavior
  42667. */
  42668. get name(): string;
  42669. /**
  42670. * Initializes the behavior
  42671. */
  42672. init(): void;
  42673. private _tmpVector;
  42674. private _alternatePickedPoint;
  42675. private _worldDragAxis;
  42676. private _targetPosition;
  42677. private _attachedElement;
  42678. /**
  42679. * Attaches the drag behavior the passed in mesh
  42680. * @param ownerNode The mesh that will be dragged around once attached
  42681. * @param predicate Predicate to use for pick filtering
  42682. */
  42683. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  42684. /**
  42685. * Force relase the drag action by code.
  42686. */
  42687. releaseDrag(): void;
  42688. private _startDragRay;
  42689. private _lastPointerRay;
  42690. /**
  42691. * Simulates the start of a pointer drag event on the behavior
  42692. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  42693. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  42694. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  42695. */
  42696. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  42697. private _startDrag;
  42698. private _dragDelta;
  42699. private _moveDrag;
  42700. private _pickWithRayOnDragPlane;
  42701. private _pointA;
  42702. private _pointB;
  42703. private _pointC;
  42704. private _lineA;
  42705. private _lineB;
  42706. private _localAxis;
  42707. private _lookAt;
  42708. private _updateDragPlanePosition;
  42709. /**
  42710. * Detaches the behavior from the mesh
  42711. */
  42712. detach(): void;
  42713. }
  42714. }
  42715. declare module BABYLON {
  42716. /**
  42717. * A behavior that when attached to a mesh will allow the mesh to be scaled
  42718. */
  42719. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  42720. private _dragBehaviorA;
  42721. private _dragBehaviorB;
  42722. private _startDistance;
  42723. private _initialScale;
  42724. private _targetScale;
  42725. private _ownerNode;
  42726. private _sceneRenderObserver;
  42727. /**
  42728. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  42729. */
  42730. constructor();
  42731. /**
  42732. * The name of the behavior
  42733. */
  42734. get name(): string;
  42735. /**
  42736. * Initializes the behavior
  42737. */
  42738. init(): void;
  42739. private _getCurrentDistance;
  42740. /**
  42741. * Attaches the scale behavior the passed in mesh
  42742. * @param ownerNode The mesh that will be scaled around once attached
  42743. */
  42744. attach(ownerNode: Mesh): void;
  42745. /**
  42746. * Detaches the behavior from the mesh
  42747. */
  42748. detach(): void;
  42749. }
  42750. }
  42751. declare module BABYLON {
  42752. /**
  42753. * 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
  42754. */
  42755. export class SixDofDragBehavior implements Behavior<Mesh> {
  42756. private static _virtualScene;
  42757. private _ownerNode;
  42758. private _sceneRenderObserver;
  42759. private _scene;
  42760. private _targetPosition;
  42761. private _virtualOriginMesh;
  42762. private _virtualDragMesh;
  42763. private _pointerObserver;
  42764. private _moving;
  42765. private _startingOrientation;
  42766. private _attachedElement;
  42767. /**
  42768. * 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)
  42769. */
  42770. private zDragFactor;
  42771. /**
  42772. * If the object should rotate to face the drag origin
  42773. */
  42774. rotateDraggedObject: boolean;
  42775. /**
  42776. * If the behavior is currently in a dragging state
  42777. */
  42778. dragging: boolean;
  42779. /**
  42780. * 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)
  42781. */
  42782. dragDeltaRatio: number;
  42783. /**
  42784. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  42785. */
  42786. currentDraggingPointerID: number;
  42787. /**
  42788. * If camera controls should be detached during the drag
  42789. */
  42790. detachCameraControls: boolean;
  42791. /**
  42792. * Fires each time a drag starts
  42793. */
  42794. onDragStartObservable: Observable<{}>;
  42795. /**
  42796. * Fires each time a drag ends (eg. mouse release after drag)
  42797. */
  42798. onDragEndObservable: Observable<{}>;
  42799. /**
  42800. * 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
  42801. */
  42802. constructor();
  42803. /**
  42804. * The name of the behavior
  42805. */
  42806. get name(): string;
  42807. /**
  42808. * Initializes the behavior
  42809. */
  42810. init(): void;
  42811. /**
  42812. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  42813. */
  42814. private get _pointerCamera();
  42815. /**
  42816. * Attaches the scale behavior the passed in mesh
  42817. * @param ownerNode The mesh that will be scaled around once attached
  42818. */
  42819. attach(ownerNode: Mesh): void;
  42820. /**
  42821. * Detaches the behavior from the mesh
  42822. */
  42823. detach(): void;
  42824. }
  42825. }
  42826. declare module BABYLON {
  42827. /**
  42828. * Class used to apply inverse kinematics to bones
  42829. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  42830. */
  42831. export class BoneIKController {
  42832. private static _tmpVecs;
  42833. private static _tmpQuat;
  42834. private static _tmpMats;
  42835. /**
  42836. * Gets or sets the target mesh
  42837. */
  42838. targetMesh: AbstractMesh;
  42839. /** Gets or sets the mesh used as pole */
  42840. poleTargetMesh: AbstractMesh;
  42841. /**
  42842. * Gets or sets the bone used as pole
  42843. */
  42844. poleTargetBone: Nullable<Bone>;
  42845. /**
  42846. * Gets or sets the target position
  42847. */
  42848. targetPosition: Vector3;
  42849. /**
  42850. * Gets or sets the pole target position
  42851. */
  42852. poleTargetPosition: Vector3;
  42853. /**
  42854. * Gets or sets the pole target local offset
  42855. */
  42856. poleTargetLocalOffset: Vector3;
  42857. /**
  42858. * Gets or sets the pole angle
  42859. */
  42860. poleAngle: number;
  42861. /**
  42862. * Gets or sets the mesh associated with the controller
  42863. */
  42864. mesh: AbstractMesh;
  42865. /**
  42866. * 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)
  42867. */
  42868. slerpAmount: number;
  42869. private _bone1Quat;
  42870. private _bone1Mat;
  42871. private _bone2Ang;
  42872. private _bone1;
  42873. private _bone2;
  42874. private _bone1Length;
  42875. private _bone2Length;
  42876. private _maxAngle;
  42877. private _maxReach;
  42878. private _rightHandedSystem;
  42879. private _bendAxis;
  42880. private _slerping;
  42881. private _adjustRoll;
  42882. /**
  42883. * Gets or sets maximum allowed angle
  42884. */
  42885. get maxAngle(): number;
  42886. set maxAngle(value: number);
  42887. /**
  42888. * Creates a new BoneIKController
  42889. * @param mesh defines the mesh to control
  42890. * @param bone defines the bone to control
  42891. * @param options defines options to set up the controller
  42892. */
  42893. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  42894. targetMesh?: AbstractMesh;
  42895. poleTargetMesh?: AbstractMesh;
  42896. poleTargetBone?: Bone;
  42897. poleTargetLocalOffset?: Vector3;
  42898. poleAngle?: number;
  42899. bendAxis?: Vector3;
  42900. maxAngle?: number;
  42901. slerpAmount?: number;
  42902. });
  42903. private _setMaxAngle;
  42904. /**
  42905. * Force the controller to update the bones
  42906. */
  42907. update(): void;
  42908. }
  42909. }
  42910. declare module BABYLON {
  42911. /**
  42912. * Class used to make a bone look toward a point in space
  42913. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  42914. */
  42915. export class BoneLookController {
  42916. private static _tmpVecs;
  42917. private static _tmpQuat;
  42918. private static _tmpMats;
  42919. /**
  42920. * The target Vector3 that the bone will look at
  42921. */
  42922. target: Vector3;
  42923. /**
  42924. * The mesh that the bone is attached to
  42925. */
  42926. mesh: AbstractMesh;
  42927. /**
  42928. * The bone that will be looking to the target
  42929. */
  42930. bone: Bone;
  42931. /**
  42932. * The up axis of the coordinate system that is used when the bone is rotated
  42933. */
  42934. upAxis: Vector3;
  42935. /**
  42936. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  42937. */
  42938. upAxisSpace: Space;
  42939. /**
  42940. * Used to make an adjustment to the yaw of the bone
  42941. */
  42942. adjustYaw: number;
  42943. /**
  42944. * Used to make an adjustment to the pitch of the bone
  42945. */
  42946. adjustPitch: number;
  42947. /**
  42948. * Used to make an adjustment to the roll of the bone
  42949. */
  42950. adjustRoll: number;
  42951. /**
  42952. * 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)
  42953. */
  42954. slerpAmount: number;
  42955. private _minYaw;
  42956. private _maxYaw;
  42957. private _minPitch;
  42958. private _maxPitch;
  42959. private _minYawSin;
  42960. private _minYawCos;
  42961. private _maxYawSin;
  42962. private _maxYawCos;
  42963. private _midYawConstraint;
  42964. private _minPitchTan;
  42965. private _maxPitchTan;
  42966. private _boneQuat;
  42967. private _slerping;
  42968. private _transformYawPitch;
  42969. private _transformYawPitchInv;
  42970. private _firstFrameSkipped;
  42971. private _yawRange;
  42972. private _fowardAxis;
  42973. /**
  42974. * Gets or sets the minimum yaw angle that the bone can look to
  42975. */
  42976. get minYaw(): number;
  42977. set minYaw(value: number);
  42978. /**
  42979. * Gets or sets the maximum yaw angle that the bone can look to
  42980. */
  42981. get maxYaw(): number;
  42982. set maxYaw(value: number);
  42983. /**
  42984. * Gets or sets the minimum pitch angle that the bone can look to
  42985. */
  42986. get minPitch(): number;
  42987. set minPitch(value: number);
  42988. /**
  42989. * Gets or sets the maximum pitch angle that the bone can look to
  42990. */
  42991. get maxPitch(): number;
  42992. set maxPitch(value: number);
  42993. /**
  42994. * Create a BoneLookController
  42995. * @param mesh the mesh that the bone belongs to
  42996. * @param bone the bone that will be looking to the target
  42997. * @param target the target Vector3 to look at
  42998. * @param options optional settings:
  42999. * * maxYaw: the maximum angle the bone will yaw to
  43000. * * minYaw: the minimum angle the bone will yaw to
  43001. * * maxPitch: the maximum angle the bone will pitch to
  43002. * * minPitch: the minimum angle the bone will yaw to
  43003. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43004. * * upAxis: the up axis of the coordinate system
  43005. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43006. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43007. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43008. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43009. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43010. * * adjustRoll: used to make an adjustment to the roll of the bone
  43011. **/
  43012. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43013. maxYaw?: number;
  43014. minYaw?: number;
  43015. maxPitch?: number;
  43016. minPitch?: number;
  43017. slerpAmount?: number;
  43018. upAxis?: Vector3;
  43019. upAxisSpace?: Space;
  43020. yawAxis?: Vector3;
  43021. pitchAxis?: Vector3;
  43022. adjustYaw?: number;
  43023. adjustPitch?: number;
  43024. adjustRoll?: number;
  43025. });
  43026. /**
  43027. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43028. */
  43029. update(): void;
  43030. private _getAngleDiff;
  43031. private _getAngleBetween;
  43032. private _isAngleBetween;
  43033. }
  43034. }
  43035. declare module BABYLON {
  43036. /**
  43037. * Manage the gamepad inputs to control an arc rotate camera.
  43038. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43039. */
  43040. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43041. /**
  43042. * Defines the camera the input is attached to.
  43043. */
  43044. camera: ArcRotateCamera;
  43045. /**
  43046. * Defines the gamepad the input is gathering event from.
  43047. */
  43048. gamepad: Nullable<Gamepad>;
  43049. /**
  43050. * Defines the gamepad rotation sensiblity.
  43051. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43052. */
  43053. gamepadRotationSensibility: number;
  43054. /**
  43055. * Defines the gamepad move sensiblity.
  43056. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43057. */
  43058. gamepadMoveSensibility: number;
  43059. private _yAxisScale;
  43060. /**
  43061. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43062. */
  43063. get invertYAxis(): boolean;
  43064. set invertYAxis(value: boolean);
  43065. private _onGamepadConnectedObserver;
  43066. private _onGamepadDisconnectedObserver;
  43067. /**
  43068. * Attach the input controls to a specific dom element to get the input from.
  43069. * @param element Defines the element the controls should be listened from
  43070. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43071. */
  43072. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43073. /**
  43074. * Detach the current controls from the specified dom element.
  43075. * @param element Defines the element to stop listening the inputs from
  43076. */
  43077. detachControl(element: Nullable<HTMLElement>): void;
  43078. /**
  43079. * Update the current camera state depending on the inputs that have been used this frame.
  43080. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43081. */
  43082. checkInputs(): void;
  43083. /**
  43084. * Gets the class name of the current intput.
  43085. * @returns the class name
  43086. */
  43087. getClassName(): string;
  43088. /**
  43089. * Get the friendly name associated with the input class.
  43090. * @returns the input friendly name
  43091. */
  43092. getSimpleName(): string;
  43093. }
  43094. }
  43095. declare module BABYLON {
  43096. interface ArcRotateCameraInputsManager {
  43097. /**
  43098. * Add orientation input support to the input manager.
  43099. * @returns the current input manager
  43100. */
  43101. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43102. }
  43103. /**
  43104. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43105. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43106. */
  43107. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43108. /**
  43109. * Defines the camera the input is attached to.
  43110. */
  43111. camera: ArcRotateCamera;
  43112. /**
  43113. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43114. */
  43115. alphaCorrection: number;
  43116. /**
  43117. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43118. */
  43119. gammaCorrection: number;
  43120. private _alpha;
  43121. private _gamma;
  43122. private _dirty;
  43123. private _deviceOrientationHandler;
  43124. /**
  43125. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43126. */
  43127. constructor();
  43128. /**
  43129. * Attach the input controls to a specific dom element to get the input from.
  43130. * @param element Defines the element the controls should be listened from
  43131. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43132. */
  43133. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43134. /** @hidden */
  43135. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43136. /**
  43137. * Update the current camera state depending on the inputs that have been used this frame.
  43138. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43139. */
  43140. checkInputs(): void;
  43141. /**
  43142. * Detach the current controls from the specified dom element.
  43143. * @param element Defines the element to stop listening the inputs from
  43144. */
  43145. detachControl(element: Nullable<HTMLElement>): void;
  43146. /**
  43147. * Gets the class name of the current intput.
  43148. * @returns the class name
  43149. */
  43150. getClassName(): string;
  43151. /**
  43152. * Get the friendly name associated with the input class.
  43153. * @returns the input friendly name
  43154. */
  43155. getSimpleName(): string;
  43156. }
  43157. }
  43158. declare module BABYLON {
  43159. /**
  43160. * Listen to mouse events to control the camera.
  43161. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43162. */
  43163. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43164. /**
  43165. * Defines the camera the input is attached to.
  43166. */
  43167. camera: FlyCamera;
  43168. /**
  43169. * Defines if touch is enabled. (Default is true.)
  43170. */
  43171. touchEnabled: boolean;
  43172. /**
  43173. * Defines the buttons associated with the input to handle camera rotation.
  43174. */
  43175. buttons: number[];
  43176. /**
  43177. * Assign buttons for Yaw control.
  43178. */
  43179. buttonsYaw: number[];
  43180. /**
  43181. * Assign buttons for Pitch control.
  43182. */
  43183. buttonsPitch: number[];
  43184. /**
  43185. * Assign buttons for Roll control.
  43186. */
  43187. buttonsRoll: number[];
  43188. /**
  43189. * Detect if any button is being pressed while mouse is moved.
  43190. * -1 = Mouse locked.
  43191. * 0 = Left button.
  43192. * 1 = Middle Button.
  43193. * 2 = Right Button.
  43194. */
  43195. activeButton: number;
  43196. /**
  43197. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43198. * Higher values reduce its sensitivity.
  43199. */
  43200. angularSensibility: number;
  43201. private _mousemoveCallback;
  43202. private _observer;
  43203. private _rollObserver;
  43204. private previousPosition;
  43205. private noPreventDefault;
  43206. private element;
  43207. /**
  43208. * Listen to mouse events to control the camera.
  43209. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43210. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43211. */
  43212. constructor(touchEnabled?: boolean);
  43213. /**
  43214. * Attach the mouse control to the HTML DOM element.
  43215. * @param element Defines the element that listens to the input events.
  43216. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43217. */
  43218. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43219. /**
  43220. * Detach the current controls from the specified dom element.
  43221. * @param element Defines the element to stop listening the inputs from
  43222. */
  43223. detachControl(element: Nullable<HTMLElement>): void;
  43224. /**
  43225. * Gets the class name of the current input.
  43226. * @returns the class name.
  43227. */
  43228. getClassName(): string;
  43229. /**
  43230. * Get the friendly name associated with the input class.
  43231. * @returns the input's friendly name.
  43232. */
  43233. getSimpleName(): string;
  43234. private _pointerInput;
  43235. private _onMouseMove;
  43236. /**
  43237. * Rotate camera by mouse offset.
  43238. */
  43239. private rotateCamera;
  43240. }
  43241. }
  43242. declare module BABYLON {
  43243. /**
  43244. * Default Inputs manager for the FlyCamera.
  43245. * It groups all the default supported inputs for ease of use.
  43246. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43247. */
  43248. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43249. /**
  43250. * Instantiates a new FlyCameraInputsManager.
  43251. * @param camera Defines the camera the inputs belong to.
  43252. */
  43253. constructor(camera: FlyCamera);
  43254. /**
  43255. * Add keyboard input support to the input manager.
  43256. * @returns the new FlyCameraKeyboardMoveInput().
  43257. */
  43258. addKeyboard(): FlyCameraInputsManager;
  43259. /**
  43260. * Add mouse input support to the input manager.
  43261. * @param touchEnabled Enable touch screen support.
  43262. * @returns the new FlyCameraMouseInput().
  43263. */
  43264. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43265. }
  43266. }
  43267. declare module BABYLON {
  43268. /**
  43269. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43270. * such as in a 3D Space Shooter or a Flight Simulator.
  43271. */
  43272. export class FlyCamera extends TargetCamera {
  43273. /**
  43274. * Define the collision ellipsoid of the camera.
  43275. * This is helpful for simulating a camera body, like a player's body.
  43276. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43277. */
  43278. ellipsoid: Vector3;
  43279. /**
  43280. * Define an offset for the position of the ellipsoid around the camera.
  43281. * This can be helpful if the camera is attached away from the player's body center,
  43282. * such as at its head.
  43283. */
  43284. ellipsoidOffset: Vector3;
  43285. /**
  43286. * Enable or disable collisions of the camera with the rest of the scene objects.
  43287. */
  43288. checkCollisions: boolean;
  43289. /**
  43290. * Enable or disable gravity on the camera.
  43291. */
  43292. applyGravity: boolean;
  43293. /**
  43294. * Define the current direction the camera is moving to.
  43295. */
  43296. cameraDirection: Vector3;
  43297. /**
  43298. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  43299. * This overrides and empties cameraRotation.
  43300. */
  43301. rotationQuaternion: Quaternion;
  43302. /**
  43303. * Track Roll to maintain the wanted Rolling when looking around.
  43304. */
  43305. _trackRoll: number;
  43306. /**
  43307. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  43308. */
  43309. rollCorrect: number;
  43310. /**
  43311. * Mimic a banked turn, Rolling the camera when Yawing.
  43312. * It's recommended to use rollCorrect = 10 for faster banking correction.
  43313. */
  43314. bankedTurn: boolean;
  43315. /**
  43316. * Limit in radians for how much Roll banking will add. (Default: 90°)
  43317. */
  43318. bankedTurnLimit: number;
  43319. /**
  43320. * Value of 0 disables the banked Roll.
  43321. * Value of 1 is equal to the Yaw angle in radians.
  43322. */
  43323. bankedTurnMultiplier: number;
  43324. /**
  43325. * The inputs manager loads all the input sources, such as keyboard and mouse.
  43326. */
  43327. inputs: FlyCameraInputsManager;
  43328. /**
  43329. * Gets the input sensibility for mouse input.
  43330. * Higher values reduce sensitivity.
  43331. */
  43332. get angularSensibility(): number;
  43333. /**
  43334. * Sets the input sensibility for a mouse input.
  43335. * Higher values reduce sensitivity.
  43336. */
  43337. set angularSensibility(value: number);
  43338. /**
  43339. * Get the keys for camera movement forward.
  43340. */
  43341. get keysForward(): number[];
  43342. /**
  43343. * Set the keys for camera movement forward.
  43344. */
  43345. set keysForward(value: number[]);
  43346. /**
  43347. * Get the keys for camera movement backward.
  43348. */
  43349. get keysBackward(): number[];
  43350. set keysBackward(value: number[]);
  43351. /**
  43352. * Get the keys for camera movement up.
  43353. */
  43354. get keysUp(): number[];
  43355. /**
  43356. * Set the keys for camera movement up.
  43357. */
  43358. set keysUp(value: number[]);
  43359. /**
  43360. * Get the keys for camera movement down.
  43361. */
  43362. get keysDown(): number[];
  43363. /**
  43364. * Set the keys for camera movement down.
  43365. */
  43366. set keysDown(value: number[]);
  43367. /**
  43368. * Get the keys for camera movement left.
  43369. */
  43370. get keysLeft(): number[];
  43371. /**
  43372. * Set the keys for camera movement left.
  43373. */
  43374. set keysLeft(value: number[]);
  43375. /**
  43376. * Set the keys for camera movement right.
  43377. */
  43378. get keysRight(): number[];
  43379. /**
  43380. * Set the keys for camera movement right.
  43381. */
  43382. set keysRight(value: number[]);
  43383. /**
  43384. * Event raised when the camera collides with a mesh in the scene.
  43385. */
  43386. onCollide: (collidedMesh: AbstractMesh) => void;
  43387. private _collider;
  43388. private _needMoveForGravity;
  43389. private _oldPosition;
  43390. private _diffPosition;
  43391. private _newPosition;
  43392. /** @hidden */
  43393. _localDirection: Vector3;
  43394. /** @hidden */
  43395. _transformedDirection: Vector3;
  43396. /**
  43397. * Instantiates a FlyCamera.
  43398. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43399. * such as in a 3D Space Shooter or a Flight Simulator.
  43400. * @param name Define the name of the camera in the scene.
  43401. * @param position Define the starting position of the camera in the scene.
  43402. * @param scene Define the scene the camera belongs to.
  43403. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  43404. */
  43405. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43406. /**
  43407. * Attach a control to the HTML DOM element.
  43408. * @param element Defines the element that listens to the input events.
  43409. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  43410. */
  43411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43412. /**
  43413. * Detach a control from the HTML DOM element.
  43414. * The camera will stop reacting to that input.
  43415. * @param element Defines the element that listens to the input events.
  43416. */
  43417. detachControl(element: HTMLElement): void;
  43418. private _collisionMask;
  43419. /**
  43420. * Get the mask that the camera ignores in collision events.
  43421. */
  43422. get collisionMask(): number;
  43423. /**
  43424. * Set the mask that the camera ignores in collision events.
  43425. */
  43426. set collisionMask(mask: number);
  43427. /** @hidden */
  43428. _collideWithWorld(displacement: Vector3): void;
  43429. /** @hidden */
  43430. private _onCollisionPositionChange;
  43431. /** @hidden */
  43432. _checkInputs(): void;
  43433. /** @hidden */
  43434. _decideIfNeedsToMove(): boolean;
  43435. /** @hidden */
  43436. _updatePosition(): void;
  43437. /**
  43438. * Restore the Roll to its target value at the rate specified.
  43439. * @param rate - Higher means slower restoring.
  43440. * @hidden
  43441. */
  43442. restoreRoll(rate: number): void;
  43443. /**
  43444. * Destroy the camera and release the current resources held by it.
  43445. */
  43446. dispose(): void;
  43447. /**
  43448. * Get the current object class name.
  43449. * @returns the class name.
  43450. */
  43451. getClassName(): string;
  43452. }
  43453. }
  43454. declare module BABYLON {
  43455. /**
  43456. * Listen to keyboard events to control the camera.
  43457. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43458. */
  43459. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  43460. /**
  43461. * Defines the camera the input is attached to.
  43462. */
  43463. camera: FlyCamera;
  43464. /**
  43465. * The list of keyboard keys used to control the forward move of the camera.
  43466. */
  43467. keysForward: number[];
  43468. /**
  43469. * The list of keyboard keys used to control the backward move of the camera.
  43470. */
  43471. keysBackward: number[];
  43472. /**
  43473. * The list of keyboard keys used to control the forward move of the camera.
  43474. */
  43475. keysUp: number[];
  43476. /**
  43477. * The list of keyboard keys used to control the backward move of the camera.
  43478. */
  43479. keysDown: number[];
  43480. /**
  43481. * The list of keyboard keys used to control the right strafe move of the camera.
  43482. */
  43483. keysRight: number[];
  43484. /**
  43485. * The list of keyboard keys used to control the left strafe move of the camera.
  43486. */
  43487. keysLeft: number[];
  43488. private _keys;
  43489. private _onCanvasBlurObserver;
  43490. private _onKeyboardObserver;
  43491. private _engine;
  43492. private _scene;
  43493. /**
  43494. * Attach the input controls to a specific dom element to get the input from.
  43495. * @param element Defines the element the controls should be listened from
  43496. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43497. */
  43498. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43499. /**
  43500. * Detach the current controls from the specified dom element.
  43501. * @param element Defines the element to stop listening the inputs from
  43502. */
  43503. detachControl(element: Nullable<HTMLElement>): void;
  43504. /**
  43505. * Gets the class name of the current intput.
  43506. * @returns the class name
  43507. */
  43508. getClassName(): string;
  43509. /** @hidden */
  43510. _onLostFocus(e: FocusEvent): void;
  43511. /**
  43512. * Get the friendly name associated with the input class.
  43513. * @returns the input friendly name
  43514. */
  43515. getSimpleName(): string;
  43516. /**
  43517. * Update the current camera state depending on the inputs that have been used this frame.
  43518. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43519. */
  43520. checkInputs(): void;
  43521. }
  43522. }
  43523. declare module BABYLON {
  43524. /**
  43525. * Manage the mouse wheel inputs to control a follow camera.
  43526. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43527. */
  43528. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  43529. /**
  43530. * Defines the camera the input is attached to.
  43531. */
  43532. camera: FollowCamera;
  43533. /**
  43534. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  43535. */
  43536. axisControlRadius: boolean;
  43537. /**
  43538. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  43539. */
  43540. axisControlHeight: boolean;
  43541. /**
  43542. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  43543. */
  43544. axisControlRotation: boolean;
  43545. /**
  43546. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  43547. * relation to mouseWheel events.
  43548. */
  43549. wheelPrecision: number;
  43550. /**
  43551. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43552. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43553. */
  43554. wheelDeltaPercentage: number;
  43555. private _wheel;
  43556. private _observer;
  43557. /**
  43558. * Attach the input controls to a specific dom element to get the input from.
  43559. * @param element Defines the element the controls should be listened from
  43560. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43561. */
  43562. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43563. /**
  43564. * Detach the current controls from the specified dom element.
  43565. * @param element Defines the element to stop listening the inputs from
  43566. */
  43567. detachControl(element: Nullable<HTMLElement>): void;
  43568. /**
  43569. * Gets the class name of the current intput.
  43570. * @returns the class name
  43571. */
  43572. getClassName(): string;
  43573. /**
  43574. * Get the friendly name associated with the input class.
  43575. * @returns the input friendly name
  43576. */
  43577. getSimpleName(): string;
  43578. }
  43579. }
  43580. declare module BABYLON {
  43581. /**
  43582. * Manage the pointers inputs to control an follow camera.
  43583. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43584. */
  43585. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  43586. /**
  43587. * Defines the camera the input is attached to.
  43588. */
  43589. camera: FollowCamera;
  43590. /**
  43591. * Gets the class name of the current input.
  43592. * @returns the class name
  43593. */
  43594. getClassName(): string;
  43595. /**
  43596. * Defines the pointer angular sensibility along the X axis or how fast is
  43597. * the camera rotating.
  43598. * A negative number will reverse the axis direction.
  43599. */
  43600. angularSensibilityX: number;
  43601. /**
  43602. * Defines the pointer angular sensibility along the Y axis or how fast is
  43603. * the camera rotating.
  43604. * A negative number will reverse the axis direction.
  43605. */
  43606. angularSensibilityY: number;
  43607. /**
  43608. * Defines the pointer pinch precision or how fast is the camera zooming.
  43609. * A negative number will reverse the axis direction.
  43610. */
  43611. pinchPrecision: number;
  43612. /**
  43613. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43614. * from 0.
  43615. * It defines the percentage of current camera.radius to use as delta when
  43616. * pinch zoom is used.
  43617. */
  43618. pinchDeltaPercentage: number;
  43619. /**
  43620. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  43621. */
  43622. axisXControlRadius: boolean;
  43623. /**
  43624. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  43625. */
  43626. axisXControlHeight: boolean;
  43627. /**
  43628. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  43629. */
  43630. axisXControlRotation: boolean;
  43631. /**
  43632. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  43633. */
  43634. axisYControlRadius: boolean;
  43635. /**
  43636. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  43637. */
  43638. axisYControlHeight: boolean;
  43639. /**
  43640. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  43641. */
  43642. axisYControlRotation: boolean;
  43643. /**
  43644. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  43645. */
  43646. axisPinchControlRadius: boolean;
  43647. /**
  43648. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  43649. */
  43650. axisPinchControlHeight: boolean;
  43651. /**
  43652. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  43653. */
  43654. axisPinchControlRotation: boolean;
  43655. /**
  43656. * Log error messages if basic misconfiguration has occurred.
  43657. */
  43658. warningEnable: boolean;
  43659. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43660. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43661. private _warningCounter;
  43662. private _warning;
  43663. }
  43664. }
  43665. declare module BABYLON {
  43666. /**
  43667. * Default Inputs manager for the FollowCamera.
  43668. * It groups all the default supported inputs for ease of use.
  43669. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43670. */
  43671. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  43672. /**
  43673. * Instantiates a new FollowCameraInputsManager.
  43674. * @param camera Defines the camera the inputs belong to
  43675. */
  43676. constructor(camera: FollowCamera);
  43677. /**
  43678. * Add keyboard input support to the input manager.
  43679. * @returns the current input manager
  43680. */
  43681. addKeyboard(): FollowCameraInputsManager;
  43682. /**
  43683. * Add mouse wheel input support to the input manager.
  43684. * @returns the current input manager
  43685. */
  43686. addMouseWheel(): FollowCameraInputsManager;
  43687. /**
  43688. * Add pointers input support to the input manager.
  43689. * @returns the current input manager
  43690. */
  43691. addPointers(): FollowCameraInputsManager;
  43692. /**
  43693. * Add orientation input support to the input manager.
  43694. * @returns the current input manager
  43695. */
  43696. addVRDeviceOrientation(): FollowCameraInputsManager;
  43697. }
  43698. }
  43699. declare module BABYLON {
  43700. /**
  43701. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  43702. * an arc rotate version arcFollowCamera are available.
  43703. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43704. */
  43705. export class FollowCamera extends TargetCamera {
  43706. /**
  43707. * Distance the follow camera should follow an object at
  43708. */
  43709. radius: number;
  43710. /**
  43711. * Minimum allowed distance of the camera to the axis of rotation
  43712. * (The camera can not get closer).
  43713. * This can help limiting how the Camera is able to move in the scene.
  43714. */
  43715. lowerRadiusLimit: Nullable<number>;
  43716. /**
  43717. * Maximum allowed distance of the camera to the axis of rotation
  43718. * (The camera can not get further).
  43719. * This can help limiting how the Camera is able to move in the scene.
  43720. */
  43721. upperRadiusLimit: Nullable<number>;
  43722. /**
  43723. * Define a rotation offset between the camera and the object it follows
  43724. */
  43725. rotationOffset: number;
  43726. /**
  43727. * Minimum allowed angle to camera position relative to target object.
  43728. * This can help limiting how the Camera is able to move in the scene.
  43729. */
  43730. lowerRotationOffsetLimit: Nullable<number>;
  43731. /**
  43732. * Maximum allowed angle to camera position relative to target object.
  43733. * This can help limiting how the Camera is able to move in the scene.
  43734. */
  43735. upperRotationOffsetLimit: Nullable<number>;
  43736. /**
  43737. * Define a height offset between the camera and the object it follows.
  43738. * It can help following an object from the top (like a car chaing a plane)
  43739. */
  43740. heightOffset: number;
  43741. /**
  43742. * Minimum allowed height of camera position relative to target object.
  43743. * This can help limiting how the Camera is able to move in the scene.
  43744. */
  43745. lowerHeightOffsetLimit: Nullable<number>;
  43746. /**
  43747. * Maximum allowed height of camera position relative to target object.
  43748. * This can help limiting how the Camera is able to move in the scene.
  43749. */
  43750. upperHeightOffsetLimit: Nullable<number>;
  43751. /**
  43752. * Define how fast the camera can accelerate to follow it s target.
  43753. */
  43754. cameraAcceleration: number;
  43755. /**
  43756. * Define the speed limit of the camera following an object.
  43757. */
  43758. maxCameraSpeed: number;
  43759. /**
  43760. * Define the target of the camera.
  43761. */
  43762. lockedTarget: Nullable<AbstractMesh>;
  43763. /**
  43764. * Defines the input associated with the camera.
  43765. */
  43766. inputs: FollowCameraInputsManager;
  43767. /**
  43768. * Instantiates the follow camera.
  43769. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43770. * @param name Define the name of the camera in the scene
  43771. * @param position Define the position of the camera
  43772. * @param scene Define the scene the camera belong to
  43773. * @param lockedTarget Define the target of the camera
  43774. */
  43775. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  43776. private _follow;
  43777. /**
  43778. * Attached controls to the current camera.
  43779. * @param element Defines the element the controls should be listened from
  43780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43781. */
  43782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43783. /**
  43784. * Detach the current controls from the camera.
  43785. * The camera will stop reacting to inputs.
  43786. * @param element Defines the element to stop listening the inputs from
  43787. */
  43788. detachControl(element: HTMLElement): void;
  43789. /** @hidden */
  43790. _checkInputs(): void;
  43791. private _checkLimits;
  43792. /**
  43793. * Gets the camera class name.
  43794. * @returns the class name
  43795. */
  43796. getClassName(): string;
  43797. }
  43798. /**
  43799. * Arc Rotate version of the follow camera.
  43800. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  43801. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43802. */
  43803. export class ArcFollowCamera extends TargetCamera {
  43804. /** The longitudinal angle of the camera */
  43805. alpha: number;
  43806. /** The latitudinal angle of the camera */
  43807. beta: number;
  43808. /** The radius of the camera from its target */
  43809. radius: number;
  43810. /** Define the camera target (the mesh it should follow) */
  43811. target: Nullable<AbstractMesh>;
  43812. private _cartesianCoordinates;
  43813. /**
  43814. * Instantiates a new ArcFollowCamera
  43815. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  43816. * @param name Define the name of the camera
  43817. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  43818. * @param beta Define the rotation angle of the camera around the elevation axis
  43819. * @param radius Define the radius of the camera from its target point
  43820. * @param target Define the target of the camera
  43821. * @param scene Define the scene the camera belongs to
  43822. */
  43823. constructor(name: string,
  43824. /** The longitudinal angle of the camera */
  43825. alpha: number,
  43826. /** The latitudinal angle of the camera */
  43827. beta: number,
  43828. /** The radius of the camera from its target */
  43829. radius: number,
  43830. /** Define the camera target (the mesh it should follow) */
  43831. target: Nullable<AbstractMesh>, scene: Scene);
  43832. private _follow;
  43833. /** @hidden */
  43834. _checkInputs(): void;
  43835. /**
  43836. * Returns the class name of the object.
  43837. * It is mostly used internally for serialization purposes.
  43838. */
  43839. getClassName(): string;
  43840. }
  43841. }
  43842. declare module BABYLON {
  43843. /**
  43844. * Manage the keyboard inputs to control the movement of a follow camera.
  43845. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43846. */
  43847. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  43848. /**
  43849. * Defines the camera the input is attached to.
  43850. */
  43851. camera: FollowCamera;
  43852. /**
  43853. * Defines the list of key codes associated with the up action (increase heightOffset)
  43854. */
  43855. keysHeightOffsetIncr: number[];
  43856. /**
  43857. * Defines the list of key codes associated with the down action (decrease heightOffset)
  43858. */
  43859. keysHeightOffsetDecr: number[];
  43860. /**
  43861. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  43862. */
  43863. keysHeightOffsetModifierAlt: boolean;
  43864. /**
  43865. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  43866. */
  43867. keysHeightOffsetModifierCtrl: boolean;
  43868. /**
  43869. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  43870. */
  43871. keysHeightOffsetModifierShift: boolean;
  43872. /**
  43873. * Defines the list of key codes associated with the left action (increase rotationOffset)
  43874. */
  43875. keysRotationOffsetIncr: number[];
  43876. /**
  43877. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  43878. */
  43879. keysRotationOffsetDecr: number[];
  43880. /**
  43881. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  43882. */
  43883. keysRotationOffsetModifierAlt: boolean;
  43884. /**
  43885. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  43886. */
  43887. keysRotationOffsetModifierCtrl: boolean;
  43888. /**
  43889. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  43890. */
  43891. keysRotationOffsetModifierShift: boolean;
  43892. /**
  43893. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  43894. */
  43895. keysRadiusIncr: number[];
  43896. /**
  43897. * Defines the list of key codes associated with the zoom-out action (increase radius)
  43898. */
  43899. keysRadiusDecr: number[];
  43900. /**
  43901. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  43902. */
  43903. keysRadiusModifierAlt: boolean;
  43904. /**
  43905. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  43906. */
  43907. keysRadiusModifierCtrl: boolean;
  43908. /**
  43909. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  43910. */
  43911. keysRadiusModifierShift: boolean;
  43912. /**
  43913. * Defines the rate of change of heightOffset.
  43914. */
  43915. heightSensibility: number;
  43916. /**
  43917. * Defines the rate of change of rotationOffset.
  43918. */
  43919. rotationSensibility: number;
  43920. /**
  43921. * Defines the rate of change of radius.
  43922. */
  43923. radiusSensibility: number;
  43924. private _keys;
  43925. private _ctrlPressed;
  43926. private _altPressed;
  43927. private _shiftPressed;
  43928. private _onCanvasBlurObserver;
  43929. private _onKeyboardObserver;
  43930. private _engine;
  43931. private _scene;
  43932. /**
  43933. * Attach the input controls to a specific dom element to get the input from.
  43934. * @param element Defines the element the controls should be listened from
  43935. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43936. */
  43937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43938. /**
  43939. * Detach the current controls from the specified dom element.
  43940. * @param element Defines the element to stop listening the inputs from
  43941. */
  43942. detachControl(element: Nullable<HTMLElement>): void;
  43943. /**
  43944. * Update the current camera state depending on the inputs that have been used this frame.
  43945. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43946. */
  43947. checkInputs(): void;
  43948. /**
  43949. * Gets the class name of the current input.
  43950. * @returns the class name
  43951. */
  43952. getClassName(): string;
  43953. /**
  43954. * Get the friendly name associated with the input class.
  43955. * @returns the input friendly name
  43956. */
  43957. getSimpleName(): string;
  43958. /**
  43959. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43960. * allow modification of the heightOffset value.
  43961. */
  43962. private _modifierHeightOffset;
  43963. /**
  43964. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43965. * allow modification of the rotationOffset value.
  43966. */
  43967. private _modifierRotationOffset;
  43968. /**
  43969. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  43970. * allow modification of the radius value.
  43971. */
  43972. private _modifierRadius;
  43973. }
  43974. }
  43975. declare module BABYLON {
  43976. interface FreeCameraInputsManager {
  43977. /**
  43978. * @hidden
  43979. */
  43980. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  43981. /**
  43982. * Add orientation input support to the input manager.
  43983. * @returns the current input manager
  43984. */
  43985. addDeviceOrientation(): FreeCameraInputsManager;
  43986. }
  43987. /**
  43988. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  43989. * Screen rotation is taken into account.
  43990. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43991. */
  43992. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  43993. private _camera;
  43994. private _screenOrientationAngle;
  43995. private _constantTranform;
  43996. private _screenQuaternion;
  43997. private _alpha;
  43998. private _beta;
  43999. private _gamma;
  44000. /**
  44001. * Can be used to detect if a device orientation sensor is available on a device
  44002. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44003. * @returns a promise that will resolve on orientation change
  44004. */
  44005. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44006. /**
  44007. * @hidden
  44008. */
  44009. _onDeviceOrientationChangedObservable: Observable<void>;
  44010. /**
  44011. * Instantiates a new input
  44012. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44013. */
  44014. constructor();
  44015. /**
  44016. * Define the camera controlled by the input.
  44017. */
  44018. get camera(): FreeCamera;
  44019. set camera(camera: FreeCamera);
  44020. /**
  44021. * Attach the input controls to a specific dom element to get the input from.
  44022. * @param element Defines the element the controls should be listened from
  44023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44024. */
  44025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44026. private _orientationChanged;
  44027. private _deviceOrientation;
  44028. /**
  44029. * Detach the current controls from the specified dom element.
  44030. * @param element Defines the element to stop listening the inputs from
  44031. */
  44032. detachControl(element: Nullable<HTMLElement>): void;
  44033. /**
  44034. * Update the current camera state depending on the inputs that have been used this frame.
  44035. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44036. */
  44037. checkInputs(): void;
  44038. /**
  44039. * Gets the class name of the current intput.
  44040. * @returns the class name
  44041. */
  44042. getClassName(): string;
  44043. /**
  44044. * Get the friendly name associated with the input class.
  44045. * @returns the input friendly name
  44046. */
  44047. getSimpleName(): string;
  44048. }
  44049. }
  44050. declare module BABYLON {
  44051. /**
  44052. * Manage the gamepad inputs to control a free camera.
  44053. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44054. */
  44055. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44056. /**
  44057. * Define the camera the input is attached to.
  44058. */
  44059. camera: FreeCamera;
  44060. /**
  44061. * Define the Gamepad controlling the input
  44062. */
  44063. gamepad: Nullable<Gamepad>;
  44064. /**
  44065. * Defines the gamepad rotation sensiblity.
  44066. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44067. */
  44068. gamepadAngularSensibility: number;
  44069. /**
  44070. * Defines the gamepad move sensiblity.
  44071. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44072. */
  44073. gamepadMoveSensibility: number;
  44074. private _yAxisScale;
  44075. /**
  44076. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44077. */
  44078. get invertYAxis(): boolean;
  44079. set invertYAxis(value: boolean);
  44080. private _onGamepadConnectedObserver;
  44081. private _onGamepadDisconnectedObserver;
  44082. private _cameraTransform;
  44083. private _deltaTransform;
  44084. private _vector3;
  44085. private _vector2;
  44086. /**
  44087. * Attach the input controls to a specific dom element to get the input from.
  44088. * @param element Defines the element the controls should be listened from
  44089. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44090. */
  44091. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44092. /**
  44093. * Detach the current controls from the specified dom element.
  44094. * @param element Defines the element to stop listening the inputs from
  44095. */
  44096. detachControl(element: Nullable<HTMLElement>): void;
  44097. /**
  44098. * Update the current camera state depending on the inputs that have been used this frame.
  44099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44100. */
  44101. checkInputs(): void;
  44102. /**
  44103. * Gets the class name of the current intput.
  44104. * @returns the class name
  44105. */
  44106. getClassName(): string;
  44107. /**
  44108. * Get the friendly name associated with the input class.
  44109. * @returns the input friendly name
  44110. */
  44111. getSimpleName(): string;
  44112. }
  44113. }
  44114. declare module BABYLON {
  44115. /**
  44116. * Defines the potential axis of a Joystick
  44117. */
  44118. export enum JoystickAxis {
  44119. /** X axis */
  44120. X = 0,
  44121. /** Y axis */
  44122. Y = 1,
  44123. /** Z axis */
  44124. Z = 2
  44125. }
  44126. /**
  44127. * Represents the different customization options available
  44128. * for VirtualJoystick
  44129. */
  44130. interface VirtualJoystickCustomizations {
  44131. /**
  44132. * Size of the joystick's puck
  44133. */
  44134. puckSize: number;
  44135. /**
  44136. * Size of the joystick's container
  44137. */
  44138. containerSize: number;
  44139. /**
  44140. * Color of the joystick && puck
  44141. */
  44142. color: string;
  44143. /**
  44144. * Image URL for the joystick's puck
  44145. */
  44146. puckImage?: string;
  44147. /**
  44148. * Image URL for the joystick's container
  44149. */
  44150. containerImage?: string;
  44151. /**
  44152. * Defines the unmoving position of the joystick container
  44153. */
  44154. position?: {
  44155. x: number;
  44156. y: number;
  44157. };
  44158. /**
  44159. * Defines whether or not the joystick container is always visible
  44160. */
  44161. alwaysVisible: boolean;
  44162. /**
  44163. * Defines whether or not to limit the movement of the puck to the joystick's container
  44164. */
  44165. limitToContainer: boolean;
  44166. }
  44167. /**
  44168. * Class used to define virtual joystick (used in touch mode)
  44169. */
  44170. export class VirtualJoystick {
  44171. /**
  44172. * Gets or sets a boolean indicating that left and right values must be inverted
  44173. */
  44174. reverseLeftRight: boolean;
  44175. /**
  44176. * Gets or sets a boolean indicating that up and down values must be inverted
  44177. */
  44178. reverseUpDown: boolean;
  44179. /**
  44180. * Gets the offset value for the position (ie. the change of the position value)
  44181. */
  44182. deltaPosition: Vector3;
  44183. /**
  44184. * Gets a boolean indicating if the virtual joystick was pressed
  44185. */
  44186. pressed: boolean;
  44187. /**
  44188. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44189. */
  44190. static Canvas: Nullable<HTMLCanvasElement>;
  44191. /**
  44192. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44193. */
  44194. limitToContainer: boolean;
  44195. private static _globalJoystickIndex;
  44196. private static _alwaysVisibleSticks;
  44197. private static vjCanvasContext;
  44198. private static vjCanvasWidth;
  44199. private static vjCanvasHeight;
  44200. private static halfWidth;
  44201. private static _GetDefaultOptions;
  44202. private _action;
  44203. private _axisTargetedByLeftAndRight;
  44204. private _axisTargetedByUpAndDown;
  44205. private _joystickSensibility;
  44206. private _inversedSensibility;
  44207. private _joystickPointerID;
  44208. private _joystickColor;
  44209. private _joystickPointerPos;
  44210. private _joystickPreviousPointerPos;
  44211. private _joystickPointerStartPos;
  44212. private _deltaJoystickVector;
  44213. private _leftJoystick;
  44214. private _touches;
  44215. private _joystickPosition;
  44216. private _alwaysVisible;
  44217. private _puckImage;
  44218. private _containerImage;
  44219. private _joystickPuckSize;
  44220. private _joystickContainerSize;
  44221. private _clearPuckSize;
  44222. private _clearContainerSize;
  44223. private _clearPuckSizeOffset;
  44224. private _clearContainerSizeOffset;
  44225. private _onPointerDownHandlerRef;
  44226. private _onPointerMoveHandlerRef;
  44227. private _onPointerUpHandlerRef;
  44228. private _onResize;
  44229. /**
  44230. * Creates a new virtual joystick
  44231. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44232. * @param customizations Defines the options we want to customize the VirtualJoystick
  44233. */
  44234. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44235. /**
  44236. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44237. * @param newJoystickSensibility defines the new sensibility
  44238. */
  44239. setJoystickSensibility(newJoystickSensibility: number): void;
  44240. private _onPointerDown;
  44241. private _onPointerMove;
  44242. private _onPointerUp;
  44243. /**
  44244. * Change the color of the virtual joystick
  44245. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44246. */
  44247. setJoystickColor(newColor: string): void;
  44248. /**
  44249. * Size of the joystick's container
  44250. */
  44251. set containerSize(newSize: number);
  44252. get containerSize(): number;
  44253. /**
  44254. * Size of the joystick's puck
  44255. */
  44256. set puckSize(newSize: number);
  44257. get puckSize(): number;
  44258. /**
  44259. * Clears the set position of the joystick
  44260. */
  44261. clearPosition(): void;
  44262. /**
  44263. * Defines whether or not the joystick container is always visible
  44264. */
  44265. set alwaysVisible(value: boolean);
  44266. get alwaysVisible(): boolean;
  44267. /**
  44268. * Sets the constant position of the Joystick container
  44269. * @param x X axis coordinate
  44270. * @param y Y axis coordinate
  44271. */
  44272. setPosition(x: number, y: number): void;
  44273. /**
  44274. * Defines a callback to call when the joystick is touched
  44275. * @param action defines the callback
  44276. */
  44277. setActionOnTouch(action: () => any): void;
  44278. /**
  44279. * Defines which axis you'd like to control for left & right
  44280. * @param axis defines the axis to use
  44281. */
  44282. setAxisForLeftRight(axis: JoystickAxis): void;
  44283. /**
  44284. * Defines which axis you'd like to control for up & down
  44285. * @param axis defines the axis to use
  44286. */
  44287. setAxisForUpDown(axis: JoystickAxis): void;
  44288. /**
  44289. * Clears the canvas from the previous puck / container draw
  44290. */
  44291. private _clearPreviousDraw;
  44292. /**
  44293. * Loads `urlPath` to be used for the container's image
  44294. * @param urlPath defines the urlPath of an image to use
  44295. */
  44296. setContainerImage(urlPath: string): void;
  44297. /**
  44298. * Loads `urlPath` to be used for the puck's image
  44299. * @param urlPath defines the urlPath of an image to use
  44300. */
  44301. setPuckImage(urlPath: string): void;
  44302. /**
  44303. * Draws the Virtual Joystick's container
  44304. */
  44305. private _drawContainer;
  44306. /**
  44307. * Draws the Virtual Joystick's puck
  44308. */
  44309. private _drawPuck;
  44310. private _drawVirtualJoystick;
  44311. /**
  44312. * Release internal HTML canvas
  44313. */
  44314. releaseCanvas(): void;
  44315. }
  44316. }
  44317. declare module BABYLON {
  44318. interface FreeCameraInputsManager {
  44319. /**
  44320. * Add virtual joystick input support to the input manager.
  44321. * @returns the current input manager
  44322. */
  44323. addVirtualJoystick(): FreeCameraInputsManager;
  44324. }
  44325. /**
  44326. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  44327. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44328. */
  44329. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  44330. /**
  44331. * Defines the camera the input is attached to.
  44332. */
  44333. camera: FreeCamera;
  44334. private _leftjoystick;
  44335. private _rightjoystick;
  44336. /**
  44337. * Gets the left stick of the virtual joystick.
  44338. * @returns The virtual Joystick
  44339. */
  44340. getLeftJoystick(): VirtualJoystick;
  44341. /**
  44342. * Gets the right stick of the virtual joystick.
  44343. * @returns The virtual Joystick
  44344. */
  44345. getRightJoystick(): VirtualJoystick;
  44346. /**
  44347. * Update the current camera state depending on the inputs that have been used this frame.
  44348. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44349. */
  44350. checkInputs(): void;
  44351. /**
  44352. * Attach the input controls to a specific dom element to get the input from.
  44353. * @param element Defines the element the controls should be listened from
  44354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44355. */
  44356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44357. /**
  44358. * Detach the current controls from the specified dom element.
  44359. * @param element Defines the element to stop listening the inputs from
  44360. */
  44361. detachControl(element: Nullable<HTMLElement>): void;
  44362. /**
  44363. * Gets the class name of the current intput.
  44364. * @returns the class name
  44365. */
  44366. getClassName(): string;
  44367. /**
  44368. * Get the friendly name associated with the input class.
  44369. * @returns the input friendly name
  44370. */
  44371. getSimpleName(): string;
  44372. }
  44373. }
  44374. declare module BABYLON {
  44375. /**
  44376. * This represents a FPS type of camera controlled by touch.
  44377. * This is like a universal camera minus the Gamepad controls.
  44378. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  44379. */
  44380. export class TouchCamera extends FreeCamera {
  44381. /**
  44382. * Defines the touch sensibility for rotation.
  44383. * The higher the faster.
  44384. */
  44385. get touchAngularSensibility(): number;
  44386. set touchAngularSensibility(value: number);
  44387. /**
  44388. * Defines the touch sensibility for move.
  44389. * The higher the faster.
  44390. */
  44391. get touchMoveSensibility(): number;
  44392. set touchMoveSensibility(value: number);
  44393. /**
  44394. * Instantiates a new touch camera.
  44395. * This represents a FPS type of camera controlled by touch.
  44396. * This is like a universal camera minus the Gamepad controls.
  44397. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  44398. * @param name Define the name of the camera in the scene
  44399. * @param position Define the start position of the camera in the scene
  44400. * @param scene Define the scene the camera belongs to
  44401. */
  44402. constructor(name: string, position: Vector3, scene: Scene);
  44403. /**
  44404. * Gets the current object class name.
  44405. * @return the class name
  44406. */
  44407. getClassName(): string;
  44408. /** @hidden */
  44409. _setupInputs(): void;
  44410. }
  44411. }
  44412. declare module BABYLON {
  44413. /**
  44414. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  44415. * being tilted forward or back and left or right.
  44416. */
  44417. export class DeviceOrientationCamera extends FreeCamera {
  44418. private _initialQuaternion;
  44419. private _quaternionCache;
  44420. private _tmpDragQuaternion;
  44421. private _disablePointerInputWhenUsingDeviceOrientation;
  44422. /**
  44423. * Creates a new device orientation camera
  44424. * @param name The name of the camera
  44425. * @param position The start position camera
  44426. * @param scene The scene the camera belongs to
  44427. */
  44428. constructor(name: string, position: Vector3, scene: Scene);
  44429. /**
  44430. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  44431. */
  44432. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  44433. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  44434. private _dragFactor;
  44435. /**
  44436. * Enabled turning on the y axis when the orientation sensor is active
  44437. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  44438. */
  44439. enableHorizontalDragging(dragFactor?: number): void;
  44440. /**
  44441. * Gets the current instance class name ("DeviceOrientationCamera").
  44442. * This helps avoiding instanceof at run time.
  44443. * @returns the class name
  44444. */
  44445. getClassName(): string;
  44446. /**
  44447. * @hidden
  44448. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  44449. */
  44450. _checkInputs(): void;
  44451. /**
  44452. * Reset the camera to its default orientation on the specified axis only.
  44453. * @param axis The axis to reset
  44454. */
  44455. resetToCurrentRotation(axis?: Axis): void;
  44456. }
  44457. }
  44458. declare module BABYLON {
  44459. /**
  44460. * Defines supported buttons for XBox360 compatible gamepads
  44461. */
  44462. export enum Xbox360Button {
  44463. /** A */
  44464. A = 0,
  44465. /** B */
  44466. B = 1,
  44467. /** X */
  44468. X = 2,
  44469. /** Y */
  44470. Y = 3,
  44471. /** Left button */
  44472. LB = 4,
  44473. /** Right button */
  44474. RB = 5,
  44475. /** Back */
  44476. Back = 8,
  44477. /** Start */
  44478. Start = 9,
  44479. /** Left stick */
  44480. LeftStick = 10,
  44481. /** Right stick */
  44482. RightStick = 11
  44483. }
  44484. /** Defines values for XBox360 DPad */
  44485. export enum Xbox360Dpad {
  44486. /** Up */
  44487. Up = 12,
  44488. /** Down */
  44489. Down = 13,
  44490. /** Left */
  44491. Left = 14,
  44492. /** Right */
  44493. Right = 15
  44494. }
  44495. /**
  44496. * Defines a XBox360 gamepad
  44497. */
  44498. export class Xbox360Pad extends Gamepad {
  44499. private _leftTrigger;
  44500. private _rightTrigger;
  44501. private _onlefttriggerchanged;
  44502. private _onrighttriggerchanged;
  44503. private _onbuttondown;
  44504. private _onbuttonup;
  44505. private _ondpaddown;
  44506. private _ondpadup;
  44507. /** Observable raised when a button is pressed */
  44508. onButtonDownObservable: Observable<Xbox360Button>;
  44509. /** Observable raised when a button is released */
  44510. onButtonUpObservable: Observable<Xbox360Button>;
  44511. /** Observable raised when a pad is pressed */
  44512. onPadDownObservable: Observable<Xbox360Dpad>;
  44513. /** Observable raised when a pad is released */
  44514. onPadUpObservable: Observable<Xbox360Dpad>;
  44515. private _buttonA;
  44516. private _buttonB;
  44517. private _buttonX;
  44518. private _buttonY;
  44519. private _buttonBack;
  44520. private _buttonStart;
  44521. private _buttonLB;
  44522. private _buttonRB;
  44523. private _buttonLeftStick;
  44524. private _buttonRightStick;
  44525. private _dPadUp;
  44526. private _dPadDown;
  44527. private _dPadLeft;
  44528. private _dPadRight;
  44529. private _isXboxOnePad;
  44530. /**
  44531. * Creates a new XBox360 gamepad object
  44532. * @param id defines the id of this gamepad
  44533. * @param index defines its index
  44534. * @param gamepad defines the internal HTML gamepad object
  44535. * @param xboxOne defines if it is a XBox One gamepad
  44536. */
  44537. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  44538. /**
  44539. * Defines the callback to call when left trigger is pressed
  44540. * @param callback defines the callback to use
  44541. */
  44542. onlefttriggerchanged(callback: (value: number) => void): void;
  44543. /**
  44544. * Defines the callback to call when right trigger is pressed
  44545. * @param callback defines the callback to use
  44546. */
  44547. onrighttriggerchanged(callback: (value: number) => void): void;
  44548. /**
  44549. * Gets the left trigger value
  44550. */
  44551. get leftTrigger(): number;
  44552. /**
  44553. * Sets the left trigger value
  44554. */
  44555. set leftTrigger(newValue: number);
  44556. /**
  44557. * Gets the right trigger value
  44558. */
  44559. get rightTrigger(): number;
  44560. /**
  44561. * Sets the right trigger value
  44562. */
  44563. set rightTrigger(newValue: number);
  44564. /**
  44565. * Defines the callback to call when a button is pressed
  44566. * @param callback defines the callback to use
  44567. */
  44568. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  44569. /**
  44570. * Defines the callback to call when a button is released
  44571. * @param callback defines the callback to use
  44572. */
  44573. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  44574. /**
  44575. * Defines the callback to call when a pad is pressed
  44576. * @param callback defines the callback to use
  44577. */
  44578. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  44579. /**
  44580. * Defines the callback to call when a pad is released
  44581. * @param callback defines the callback to use
  44582. */
  44583. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  44584. private _setButtonValue;
  44585. private _setDPadValue;
  44586. /**
  44587. * Gets the value of the `A` button
  44588. */
  44589. get buttonA(): number;
  44590. /**
  44591. * Sets the value of the `A` button
  44592. */
  44593. set buttonA(value: number);
  44594. /**
  44595. * Gets the value of the `B` button
  44596. */
  44597. get buttonB(): number;
  44598. /**
  44599. * Sets the value of the `B` button
  44600. */
  44601. set buttonB(value: number);
  44602. /**
  44603. * Gets the value of the `X` button
  44604. */
  44605. get buttonX(): number;
  44606. /**
  44607. * Sets the value of the `X` button
  44608. */
  44609. set buttonX(value: number);
  44610. /**
  44611. * Gets the value of the `Y` button
  44612. */
  44613. get buttonY(): number;
  44614. /**
  44615. * Sets the value of the `Y` button
  44616. */
  44617. set buttonY(value: number);
  44618. /**
  44619. * Gets the value of the `Start` button
  44620. */
  44621. get buttonStart(): number;
  44622. /**
  44623. * Sets the value of the `Start` button
  44624. */
  44625. set buttonStart(value: number);
  44626. /**
  44627. * Gets the value of the `Back` button
  44628. */
  44629. get buttonBack(): number;
  44630. /**
  44631. * Sets the value of the `Back` button
  44632. */
  44633. set buttonBack(value: number);
  44634. /**
  44635. * Gets the value of the `Left` button
  44636. */
  44637. get buttonLB(): number;
  44638. /**
  44639. * Sets the value of the `Left` button
  44640. */
  44641. set buttonLB(value: number);
  44642. /**
  44643. * Gets the value of the `Right` button
  44644. */
  44645. get buttonRB(): number;
  44646. /**
  44647. * Sets the value of the `Right` button
  44648. */
  44649. set buttonRB(value: number);
  44650. /**
  44651. * Gets the value of the Left joystick
  44652. */
  44653. get buttonLeftStick(): number;
  44654. /**
  44655. * Sets the value of the Left joystick
  44656. */
  44657. set buttonLeftStick(value: number);
  44658. /**
  44659. * Gets the value of the Right joystick
  44660. */
  44661. get buttonRightStick(): number;
  44662. /**
  44663. * Sets the value of the Right joystick
  44664. */
  44665. set buttonRightStick(value: number);
  44666. /**
  44667. * Gets the value of D-pad up
  44668. */
  44669. get dPadUp(): number;
  44670. /**
  44671. * Sets the value of D-pad up
  44672. */
  44673. set dPadUp(value: number);
  44674. /**
  44675. * Gets the value of D-pad down
  44676. */
  44677. get dPadDown(): number;
  44678. /**
  44679. * Sets the value of D-pad down
  44680. */
  44681. set dPadDown(value: number);
  44682. /**
  44683. * Gets the value of D-pad left
  44684. */
  44685. get dPadLeft(): number;
  44686. /**
  44687. * Sets the value of D-pad left
  44688. */
  44689. set dPadLeft(value: number);
  44690. /**
  44691. * Gets the value of D-pad right
  44692. */
  44693. get dPadRight(): number;
  44694. /**
  44695. * Sets the value of D-pad right
  44696. */
  44697. set dPadRight(value: number);
  44698. /**
  44699. * Force the gamepad to synchronize with device values
  44700. */
  44701. update(): void;
  44702. /**
  44703. * Disposes the gamepad
  44704. */
  44705. dispose(): void;
  44706. }
  44707. }
  44708. declare module BABYLON {
  44709. /**
  44710. * Defines supported buttons for DualShock compatible gamepads
  44711. */
  44712. export enum DualShockButton {
  44713. /** Cross */
  44714. Cross = 0,
  44715. /** Circle */
  44716. Circle = 1,
  44717. /** Square */
  44718. Square = 2,
  44719. /** Triangle */
  44720. Triangle = 3,
  44721. /** L1 */
  44722. L1 = 4,
  44723. /** R1 */
  44724. R1 = 5,
  44725. /** Share */
  44726. Share = 8,
  44727. /** Options */
  44728. Options = 9,
  44729. /** Left stick */
  44730. LeftStick = 10,
  44731. /** Right stick */
  44732. RightStick = 11
  44733. }
  44734. /** Defines values for DualShock DPad */
  44735. export enum DualShockDpad {
  44736. /** Up */
  44737. Up = 12,
  44738. /** Down */
  44739. Down = 13,
  44740. /** Left */
  44741. Left = 14,
  44742. /** Right */
  44743. Right = 15
  44744. }
  44745. /**
  44746. * Defines a DualShock gamepad
  44747. */
  44748. export class DualShockPad extends Gamepad {
  44749. private _leftTrigger;
  44750. private _rightTrigger;
  44751. private _onlefttriggerchanged;
  44752. private _onrighttriggerchanged;
  44753. private _onbuttondown;
  44754. private _onbuttonup;
  44755. private _ondpaddown;
  44756. private _ondpadup;
  44757. /** Observable raised when a button is pressed */
  44758. onButtonDownObservable: Observable<DualShockButton>;
  44759. /** Observable raised when a button is released */
  44760. onButtonUpObservable: Observable<DualShockButton>;
  44761. /** Observable raised when a pad is pressed */
  44762. onPadDownObservable: Observable<DualShockDpad>;
  44763. /** Observable raised when a pad is released */
  44764. onPadUpObservable: Observable<DualShockDpad>;
  44765. private _buttonCross;
  44766. private _buttonCircle;
  44767. private _buttonSquare;
  44768. private _buttonTriangle;
  44769. private _buttonShare;
  44770. private _buttonOptions;
  44771. private _buttonL1;
  44772. private _buttonR1;
  44773. private _buttonLeftStick;
  44774. private _buttonRightStick;
  44775. private _dPadUp;
  44776. private _dPadDown;
  44777. private _dPadLeft;
  44778. private _dPadRight;
  44779. /**
  44780. * Creates a new DualShock gamepad object
  44781. * @param id defines the id of this gamepad
  44782. * @param index defines its index
  44783. * @param gamepad defines the internal HTML gamepad object
  44784. */
  44785. constructor(id: string, index: number, gamepad: any);
  44786. /**
  44787. * Defines the callback to call when left trigger is pressed
  44788. * @param callback defines the callback to use
  44789. */
  44790. onlefttriggerchanged(callback: (value: number) => void): void;
  44791. /**
  44792. * Defines the callback to call when right trigger is pressed
  44793. * @param callback defines the callback to use
  44794. */
  44795. onrighttriggerchanged(callback: (value: number) => void): void;
  44796. /**
  44797. * Gets the left trigger value
  44798. */
  44799. get leftTrigger(): number;
  44800. /**
  44801. * Sets the left trigger value
  44802. */
  44803. set leftTrigger(newValue: number);
  44804. /**
  44805. * Gets the right trigger value
  44806. */
  44807. get rightTrigger(): number;
  44808. /**
  44809. * Sets the right trigger value
  44810. */
  44811. set rightTrigger(newValue: number);
  44812. /**
  44813. * Defines the callback to call when a button is pressed
  44814. * @param callback defines the callback to use
  44815. */
  44816. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  44817. /**
  44818. * Defines the callback to call when a button is released
  44819. * @param callback defines the callback to use
  44820. */
  44821. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  44822. /**
  44823. * Defines the callback to call when a pad is pressed
  44824. * @param callback defines the callback to use
  44825. */
  44826. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  44827. /**
  44828. * Defines the callback to call when a pad is released
  44829. * @param callback defines the callback to use
  44830. */
  44831. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  44832. private _setButtonValue;
  44833. private _setDPadValue;
  44834. /**
  44835. * Gets the value of the `Cross` button
  44836. */
  44837. get buttonCross(): number;
  44838. /**
  44839. * Sets the value of the `Cross` button
  44840. */
  44841. set buttonCross(value: number);
  44842. /**
  44843. * Gets the value of the `Circle` button
  44844. */
  44845. get buttonCircle(): number;
  44846. /**
  44847. * Sets the value of the `Circle` button
  44848. */
  44849. set buttonCircle(value: number);
  44850. /**
  44851. * Gets the value of the `Square` button
  44852. */
  44853. get buttonSquare(): number;
  44854. /**
  44855. * Sets the value of the `Square` button
  44856. */
  44857. set buttonSquare(value: number);
  44858. /**
  44859. * Gets the value of the `Triangle` button
  44860. */
  44861. get buttonTriangle(): number;
  44862. /**
  44863. * Sets the value of the `Triangle` button
  44864. */
  44865. set buttonTriangle(value: number);
  44866. /**
  44867. * Gets the value of the `Options` button
  44868. */
  44869. get buttonOptions(): number;
  44870. /**
  44871. * Sets the value of the `Options` button
  44872. */
  44873. set buttonOptions(value: number);
  44874. /**
  44875. * Gets the value of the `Share` button
  44876. */
  44877. get buttonShare(): number;
  44878. /**
  44879. * Sets the value of the `Share` button
  44880. */
  44881. set buttonShare(value: number);
  44882. /**
  44883. * Gets the value of the `L1` button
  44884. */
  44885. get buttonL1(): number;
  44886. /**
  44887. * Sets the value of the `L1` button
  44888. */
  44889. set buttonL1(value: number);
  44890. /**
  44891. * Gets the value of the `R1` button
  44892. */
  44893. get buttonR1(): number;
  44894. /**
  44895. * Sets the value of the `R1` button
  44896. */
  44897. set buttonR1(value: number);
  44898. /**
  44899. * Gets the value of the Left joystick
  44900. */
  44901. get buttonLeftStick(): number;
  44902. /**
  44903. * Sets the value of the Left joystick
  44904. */
  44905. set buttonLeftStick(value: number);
  44906. /**
  44907. * Gets the value of the Right joystick
  44908. */
  44909. get buttonRightStick(): number;
  44910. /**
  44911. * Sets the value of the Right joystick
  44912. */
  44913. set buttonRightStick(value: number);
  44914. /**
  44915. * Gets the value of D-pad up
  44916. */
  44917. get dPadUp(): number;
  44918. /**
  44919. * Sets the value of D-pad up
  44920. */
  44921. set dPadUp(value: number);
  44922. /**
  44923. * Gets the value of D-pad down
  44924. */
  44925. get dPadDown(): number;
  44926. /**
  44927. * Sets the value of D-pad down
  44928. */
  44929. set dPadDown(value: number);
  44930. /**
  44931. * Gets the value of D-pad left
  44932. */
  44933. get dPadLeft(): number;
  44934. /**
  44935. * Sets the value of D-pad left
  44936. */
  44937. set dPadLeft(value: number);
  44938. /**
  44939. * Gets the value of D-pad right
  44940. */
  44941. get dPadRight(): number;
  44942. /**
  44943. * Sets the value of D-pad right
  44944. */
  44945. set dPadRight(value: number);
  44946. /**
  44947. * Force the gamepad to synchronize with device values
  44948. */
  44949. update(): void;
  44950. /**
  44951. * Disposes the gamepad
  44952. */
  44953. dispose(): void;
  44954. }
  44955. }
  44956. declare module BABYLON {
  44957. /**
  44958. * Manager for handling gamepads
  44959. */
  44960. export class GamepadManager {
  44961. private _scene?;
  44962. private _babylonGamepads;
  44963. private _oneGamepadConnected;
  44964. /** @hidden */
  44965. _isMonitoring: boolean;
  44966. private _gamepadEventSupported;
  44967. private _gamepadSupport?;
  44968. /**
  44969. * observable to be triggered when the gamepad controller has been connected
  44970. */
  44971. onGamepadConnectedObservable: Observable<Gamepad>;
  44972. /**
  44973. * observable to be triggered when the gamepad controller has been disconnected
  44974. */
  44975. onGamepadDisconnectedObservable: Observable<Gamepad>;
  44976. private _onGamepadConnectedEvent;
  44977. private _onGamepadDisconnectedEvent;
  44978. /**
  44979. * Initializes the gamepad manager
  44980. * @param _scene BabylonJS scene
  44981. */
  44982. constructor(_scene?: Scene | undefined);
  44983. /**
  44984. * The gamepads in the game pad manager
  44985. */
  44986. get gamepads(): Gamepad[];
  44987. /**
  44988. * Get the gamepad controllers based on type
  44989. * @param type The type of gamepad controller
  44990. * @returns Nullable gamepad
  44991. */
  44992. getGamepadByType(type?: number): Nullable<Gamepad>;
  44993. /**
  44994. * Disposes the gamepad manager
  44995. */
  44996. dispose(): void;
  44997. private _addNewGamepad;
  44998. private _startMonitoringGamepads;
  44999. private _stopMonitoringGamepads;
  45000. /** @hidden */
  45001. _checkGamepadsStatus(): void;
  45002. private _updateGamepadObjects;
  45003. }
  45004. }
  45005. declare module BABYLON {
  45006. interface Scene {
  45007. /** @hidden */
  45008. _gamepadManager: Nullable<GamepadManager>;
  45009. /**
  45010. * Gets the gamepad manager associated with the scene
  45011. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45012. */
  45013. gamepadManager: GamepadManager;
  45014. }
  45015. /**
  45016. * Interface representing a free camera inputs manager
  45017. */
  45018. interface FreeCameraInputsManager {
  45019. /**
  45020. * Adds gamepad input support to the FreeCameraInputsManager.
  45021. * @returns the FreeCameraInputsManager
  45022. */
  45023. addGamepad(): FreeCameraInputsManager;
  45024. }
  45025. /**
  45026. * Interface representing an arc rotate camera inputs manager
  45027. */
  45028. interface ArcRotateCameraInputsManager {
  45029. /**
  45030. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45031. * @returns the camera inputs manager
  45032. */
  45033. addGamepad(): ArcRotateCameraInputsManager;
  45034. }
  45035. /**
  45036. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45037. */
  45038. export class GamepadSystemSceneComponent implements ISceneComponent {
  45039. /**
  45040. * The component name helpfull to identify the component in the list of scene components.
  45041. */
  45042. readonly name: string;
  45043. /**
  45044. * The scene the component belongs to.
  45045. */
  45046. scene: Scene;
  45047. /**
  45048. * Creates a new instance of the component for the given scene
  45049. * @param scene Defines the scene to register the component in
  45050. */
  45051. constructor(scene: Scene);
  45052. /**
  45053. * Registers the component in a given scene
  45054. */
  45055. register(): void;
  45056. /**
  45057. * Rebuilds the elements related to this component in case of
  45058. * context lost for instance.
  45059. */
  45060. rebuild(): void;
  45061. /**
  45062. * Disposes the component and the associated ressources
  45063. */
  45064. dispose(): void;
  45065. private _beforeCameraUpdate;
  45066. }
  45067. }
  45068. declare module BABYLON {
  45069. /**
  45070. * 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,
  45071. * which still works and will still be found in many Playgrounds.
  45072. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45073. */
  45074. export class UniversalCamera extends TouchCamera {
  45075. /**
  45076. * Defines the gamepad rotation sensiblity.
  45077. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45078. */
  45079. get gamepadAngularSensibility(): number;
  45080. set gamepadAngularSensibility(value: number);
  45081. /**
  45082. * Defines the gamepad move sensiblity.
  45083. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45084. */
  45085. get gamepadMoveSensibility(): number;
  45086. set gamepadMoveSensibility(value: number);
  45087. /**
  45088. * 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,
  45089. * which still works and will still be found in many Playgrounds.
  45090. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45091. * @param name Define the name of the camera in the scene
  45092. * @param position Define the start position of the camera in the scene
  45093. * @param scene Define the scene the camera belongs to
  45094. */
  45095. constructor(name: string, position: Vector3, scene: Scene);
  45096. /**
  45097. * Gets the current object class name.
  45098. * @return the class name
  45099. */
  45100. getClassName(): string;
  45101. }
  45102. }
  45103. declare module BABYLON {
  45104. /**
  45105. * This represents a FPS type of camera. This is only here for back compat purpose.
  45106. * Please use the UniversalCamera instead as both are identical.
  45107. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45108. */
  45109. export class GamepadCamera extends UniversalCamera {
  45110. /**
  45111. * Instantiates a new Gamepad Camera
  45112. * This represents a FPS type of camera. This is only here for back compat purpose.
  45113. * Please use the UniversalCamera instead as both are identical.
  45114. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45115. * @param name Define the name of the camera in the scene
  45116. * @param position Define the start position of the camera in the scene
  45117. * @param scene Define the scene the camera belongs to
  45118. */
  45119. constructor(name: string, position: Vector3, scene: Scene);
  45120. /**
  45121. * Gets the current object class name.
  45122. * @return the class name
  45123. */
  45124. getClassName(): string;
  45125. }
  45126. }
  45127. declare module BABYLON {
  45128. /** @hidden */
  45129. export var passPixelShader: {
  45130. name: string;
  45131. shader: string;
  45132. };
  45133. }
  45134. declare module BABYLON {
  45135. /** @hidden */
  45136. export var passCubePixelShader: {
  45137. name: string;
  45138. shader: string;
  45139. };
  45140. }
  45141. declare module BABYLON {
  45142. /**
  45143. * PassPostProcess which produces an output the same as it's input
  45144. */
  45145. export class PassPostProcess extends PostProcess {
  45146. /**
  45147. * Creates the PassPostProcess
  45148. * @param name The name of the effect.
  45149. * @param options The required width/height ratio to downsize to before computing the render pass.
  45150. * @param camera The camera to apply the render pass to.
  45151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45152. * @param engine The engine which the post process will be applied. (default: current engine)
  45153. * @param reusable If the post process can be reused on the same frame. (default: false)
  45154. * @param textureType The type of texture to be used when performing the post processing.
  45155. * @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)
  45156. */
  45157. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45158. }
  45159. /**
  45160. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45161. */
  45162. export class PassCubePostProcess extends PostProcess {
  45163. private _face;
  45164. /**
  45165. * Gets or sets the cube face to display.
  45166. * * 0 is +X
  45167. * * 1 is -X
  45168. * * 2 is +Y
  45169. * * 3 is -Y
  45170. * * 4 is +Z
  45171. * * 5 is -Z
  45172. */
  45173. get face(): number;
  45174. set face(value: number);
  45175. /**
  45176. * Creates the PassCubePostProcess
  45177. * @param name The name of the effect.
  45178. * @param options The required width/height ratio to downsize to before computing the render pass.
  45179. * @param camera The camera to apply the render pass to.
  45180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45181. * @param engine The engine which the post process will be applied. (default: current engine)
  45182. * @param reusable If the post process can be reused on the same frame. (default: false)
  45183. * @param textureType The type of texture to be used when performing the post processing.
  45184. * @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)
  45185. */
  45186. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45187. }
  45188. }
  45189. declare module BABYLON {
  45190. /** @hidden */
  45191. export var anaglyphPixelShader: {
  45192. name: string;
  45193. shader: string;
  45194. };
  45195. }
  45196. declare module BABYLON {
  45197. /**
  45198. * Postprocess used to generate anaglyphic rendering
  45199. */
  45200. export class AnaglyphPostProcess extends PostProcess {
  45201. private _passedProcess;
  45202. /**
  45203. * Creates a new AnaglyphPostProcess
  45204. * @param name defines postprocess name
  45205. * @param options defines creation options or target ratio scale
  45206. * @param rigCameras defines cameras using this postprocess
  45207. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45208. * @param engine defines hosting engine
  45209. * @param reusable defines if the postprocess will be reused multiple times per frame
  45210. */
  45211. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45212. }
  45213. }
  45214. declare module BABYLON {
  45215. /**
  45216. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45217. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45218. */
  45219. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45220. /**
  45221. * Creates a new AnaglyphArcRotateCamera
  45222. * @param name defines camera name
  45223. * @param alpha defines alpha angle (in radians)
  45224. * @param beta defines beta angle (in radians)
  45225. * @param radius defines radius
  45226. * @param target defines camera target
  45227. * @param interaxialDistance defines distance between each color axis
  45228. * @param scene defines the hosting scene
  45229. */
  45230. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45231. /**
  45232. * Gets camera class name
  45233. * @returns AnaglyphArcRotateCamera
  45234. */
  45235. getClassName(): string;
  45236. }
  45237. }
  45238. declare module BABYLON {
  45239. /**
  45240. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45241. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45242. */
  45243. export class AnaglyphFreeCamera extends FreeCamera {
  45244. /**
  45245. * Creates a new AnaglyphFreeCamera
  45246. * @param name defines camera name
  45247. * @param position defines initial position
  45248. * @param interaxialDistance defines distance between each color axis
  45249. * @param scene defines the hosting scene
  45250. */
  45251. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45252. /**
  45253. * Gets camera class name
  45254. * @returns AnaglyphFreeCamera
  45255. */
  45256. getClassName(): string;
  45257. }
  45258. }
  45259. declare module BABYLON {
  45260. /**
  45261. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45262. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45263. */
  45264. export class AnaglyphGamepadCamera extends GamepadCamera {
  45265. /**
  45266. * Creates a new AnaglyphGamepadCamera
  45267. * @param name defines camera name
  45268. * @param position defines initial position
  45269. * @param interaxialDistance defines distance between each color axis
  45270. * @param scene defines the hosting scene
  45271. */
  45272. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45273. /**
  45274. * Gets camera class name
  45275. * @returns AnaglyphGamepadCamera
  45276. */
  45277. getClassName(): string;
  45278. }
  45279. }
  45280. declare module BABYLON {
  45281. /**
  45282. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45283. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45284. */
  45285. export class AnaglyphUniversalCamera extends UniversalCamera {
  45286. /**
  45287. * Creates a new AnaglyphUniversalCamera
  45288. * @param name defines camera name
  45289. * @param position defines initial position
  45290. * @param interaxialDistance defines distance between each color axis
  45291. * @param scene defines the hosting scene
  45292. */
  45293. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45294. /**
  45295. * Gets camera class name
  45296. * @returns AnaglyphUniversalCamera
  45297. */
  45298. getClassName(): string;
  45299. }
  45300. }
  45301. declare module BABYLON {
  45302. /**
  45303. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  45304. * @see https://doc.babylonjs.com/features/cameras
  45305. */
  45306. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  45307. /**
  45308. * Creates a new StereoscopicArcRotateCamera
  45309. * @param name defines camera name
  45310. * @param alpha defines alpha angle (in radians)
  45311. * @param beta defines beta angle (in radians)
  45312. * @param radius defines radius
  45313. * @param target defines camera target
  45314. * @param interaxialDistance defines distance between each color axis
  45315. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45316. * @param scene defines the hosting scene
  45317. */
  45318. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45319. /**
  45320. * Gets camera class name
  45321. * @returns StereoscopicArcRotateCamera
  45322. */
  45323. getClassName(): string;
  45324. }
  45325. }
  45326. declare module BABYLON {
  45327. /**
  45328. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  45329. * @see https://doc.babylonjs.com/features/cameras
  45330. */
  45331. export class StereoscopicFreeCamera extends FreeCamera {
  45332. /**
  45333. * Creates a new StereoscopicFreeCamera
  45334. * @param name defines camera name
  45335. * @param position defines initial position
  45336. * @param interaxialDistance defines distance between each color axis
  45337. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45338. * @param scene defines the hosting scene
  45339. */
  45340. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45341. /**
  45342. * Gets camera class name
  45343. * @returns StereoscopicFreeCamera
  45344. */
  45345. getClassName(): string;
  45346. }
  45347. }
  45348. declare module BABYLON {
  45349. /**
  45350. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  45351. * @see https://doc.babylonjs.com/features/cameras
  45352. */
  45353. export class StereoscopicGamepadCamera extends GamepadCamera {
  45354. /**
  45355. * Creates a new StereoscopicGamepadCamera
  45356. * @param name defines camera name
  45357. * @param position defines initial position
  45358. * @param interaxialDistance defines distance between each color axis
  45359. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45360. * @param scene defines the hosting scene
  45361. */
  45362. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45363. /**
  45364. * Gets camera class name
  45365. * @returns StereoscopicGamepadCamera
  45366. */
  45367. getClassName(): string;
  45368. }
  45369. }
  45370. declare module BABYLON {
  45371. /**
  45372. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  45373. * @see https://doc.babylonjs.com/features/cameras
  45374. */
  45375. export class StereoscopicUniversalCamera extends UniversalCamera {
  45376. /**
  45377. * Creates a new StereoscopicUniversalCamera
  45378. * @param name defines camera name
  45379. * @param position defines initial position
  45380. * @param interaxialDistance defines distance between each color axis
  45381. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  45382. * @param scene defines the hosting scene
  45383. */
  45384. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  45385. /**
  45386. * Gets camera class name
  45387. * @returns StereoscopicUniversalCamera
  45388. */
  45389. getClassName(): string;
  45390. }
  45391. }
  45392. declare module BABYLON {
  45393. /**
  45394. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  45395. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45396. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45397. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45398. */
  45399. export class VirtualJoysticksCamera extends FreeCamera {
  45400. /**
  45401. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  45402. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  45403. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  45404. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  45405. * @param name Define the name of the camera in the scene
  45406. * @param position Define the start position of the camera in the scene
  45407. * @param scene Define the scene the camera belongs to
  45408. */
  45409. constructor(name: string, position: Vector3, scene: Scene);
  45410. /**
  45411. * Gets the current object class name.
  45412. * @return the class name
  45413. */
  45414. getClassName(): string;
  45415. }
  45416. }
  45417. declare module BABYLON {
  45418. /**
  45419. * This represents all the required metrics to create a VR camera.
  45420. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  45421. */
  45422. export class VRCameraMetrics {
  45423. /**
  45424. * Define the horizontal resolution off the screen.
  45425. */
  45426. hResolution: number;
  45427. /**
  45428. * Define the vertical resolution off the screen.
  45429. */
  45430. vResolution: number;
  45431. /**
  45432. * Define the horizontal screen size.
  45433. */
  45434. hScreenSize: number;
  45435. /**
  45436. * Define the vertical screen size.
  45437. */
  45438. vScreenSize: number;
  45439. /**
  45440. * Define the vertical screen center position.
  45441. */
  45442. vScreenCenter: number;
  45443. /**
  45444. * Define the distance of the eyes to the screen.
  45445. */
  45446. eyeToScreenDistance: number;
  45447. /**
  45448. * Define the distance between both lenses
  45449. */
  45450. lensSeparationDistance: number;
  45451. /**
  45452. * Define the distance between both viewer's eyes.
  45453. */
  45454. interpupillaryDistance: number;
  45455. /**
  45456. * Define the distortion factor of the VR postprocess.
  45457. * Please, touch with care.
  45458. */
  45459. distortionK: number[];
  45460. /**
  45461. * Define the chromatic aberration correction factors for the VR post process.
  45462. */
  45463. chromaAbCorrection: number[];
  45464. /**
  45465. * Define the scale factor of the post process.
  45466. * The smaller the better but the slower.
  45467. */
  45468. postProcessScaleFactor: number;
  45469. /**
  45470. * Define an offset for the lens center.
  45471. */
  45472. lensCenterOffset: number;
  45473. /**
  45474. * Define if the current vr camera should compensate the distortion of the lense or not.
  45475. */
  45476. compensateDistortion: boolean;
  45477. /**
  45478. * Defines if multiview should be enabled when rendering (Default: false)
  45479. */
  45480. multiviewEnabled: boolean;
  45481. /**
  45482. * Gets the rendering aspect ratio based on the provided resolutions.
  45483. */
  45484. get aspectRatio(): number;
  45485. /**
  45486. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  45487. */
  45488. get aspectRatioFov(): number;
  45489. /**
  45490. * @hidden
  45491. */
  45492. get leftHMatrix(): Matrix;
  45493. /**
  45494. * @hidden
  45495. */
  45496. get rightHMatrix(): Matrix;
  45497. /**
  45498. * @hidden
  45499. */
  45500. get leftPreViewMatrix(): Matrix;
  45501. /**
  45502. * @hidden
  45503. */
  45504. get rightPreViewMatrix(): Matrix;
  45505. /**
  45506. * Get the default VRMetrics based on the most generic setup.
  45507. * @returns the default vr metrics
  45508. */
  45509. static GetDefault(): VRCameraMetrics;
  45510. }
  45511. }
  45512. declare module BABYLON {
  45513. /** @hidden */
  45514. export var vrDistortionCorrectionPixelShader: {
  45515. name: string;
  45516. shader: string;
  45517. };
  45518. }
  45519. declare module BABYLON {
  45520. /**
  45521. * VRDistortionCorrectionPostProcess used for mobile VR
  45522. */
  45523. export class VRDistortionCorrectionPostProcess extends PostProcess {
  45524. private _isRightEye;
  45525. private _distortionFactors;
  45526. private _postProcessScaleFactor;
  45527. private _lensCenterOffset;
  45528. private _scaleIn;
  45529. private _scaleFactor;
  45530. private _lensCenter;
  45531. /**
  45532. * Initializes the VRDistortionCorrectionPostProcess
  45533. * @param name The name of the effect.
  45534. * @param camera The camera to apply the render pass to.
  45535. * @param isRightEye If this is for the right eye distortion
  45536. * @param vrMetrics All the required metrics for the VR camera
  45537. */
  45538. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  45539. }
  45540. }
  45541. declare module BABYLON {
  45542. /**
  45543. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  45544. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45545. */
  45546. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  45547. /**
  45548. * Creates a new VRDeviceOrientationArcRotateCamera
  45549. * @param name defines camera name
  45550. * @param alpha defines the camera rotation along the logitudinal axis
  45551. * @param beta defines the camera rotation along the latitudinal axis
  45552. * @param radius defines the camera distance from its target
  45553. * @param target defines the camera target
  45554. * @param scene defines the scene the camera belongs to
  45555. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45556. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45557. */
  45558. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45559. /**
  45560. * Gets camera class name
  45561. * @returns VRDeviceOrientationArcRotateCamera
  45562. */
  45563. getClassName(): string;
  45564. }
  45565. }
  45566. declare module BABYLON {
  45567. /**
  45568. * Camera used to simulate VR rendering (based on FreeCamera)
  45569. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45570. */
  45571. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  45572. /**
  45573. * Creates a new VRDeviceOrientationFreeCamera
  45574. * @param name defines camera name
  45575. * @param position defines the start position of the camera
  45576. * @param scene defines the scene the camera belongs to
  45577. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45578. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45579. */
  45580. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45581. /**
  45582. * Gets camera class name
  45583. * @returns VRDeviceOrientationFreeCamera
  45584. */
  45585. getClassName(): string;
  45586. }
  45587. }
  45588. declare module BABYLON {
  45589. /**
  45590. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  45591. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  45592. */
  45593. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  45594. /**
  45595. * Creates a new VRDeviceOrientationGamepadCamera
  45596. * @param name defines camera name
  45597. * @param position defines the start position of the camera
  45598. * @param scene defines the scene the camera belongs to
  45599. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  45600. * @param vrCameraMetrics defines the vr metrics associated to the camera
  45601. */
  45602. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  45603. /**
  45604. * Gets camera class name
  45605. * @returns VRDeviceOrientationGamepadCamera
  45606. */
  45607. getClassName(): string;
  45608. }
  45609. }
  45610. declare module BABYLON {
  45611. /**
  45612. * A class extending Texture allowing drawing on a texture
  45613. * @see https://doc.babylonjs.com/how_to/dynamictexture
  45614. */
  45615. export class DynamicTexture extends Texture {
  45616. private _generateMipMaps;
  45617. private _canvas;
  45618. private _context;
  45619. /**
  45620. * Creates a DynamicTexture
  45621. * @param name defines the name of the texture
  45622. * @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
  45623. * @param scene defines the scene where you want the texture
  45624. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  45625. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  45626. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  45627. */
  45628. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  45629. /**
  45630. * Get the current class name of the texture useful for serialization or dynamic coding.
  45631. * @returns "DynamicTexture"
  45632. */
  45633. getClassName(): string;
  45634. /**
  45635. * Gets the current state of canRescale
  45636. */
  45637. get canRescale(): boolean;
  45638. private _recreate;
  45639. /**
  45640. * Scales the texture
  45641. * @param ratio the scale factor to apply to both width and height
  45642. */
  45643. scale(ratio: number): void;
  45644. /**
  45645. * Resizes the texture
  45646. * @param width the new width
  45647. * @param height the new height
  45648. */
  45649. scaleTo(width: number, height: number): void;
  45650. /**
  45651. * Gets the context of the canvas used by the texture
  45652. * @returns the canvas context of the dynamic texture
  45653. */
  45654. getContext(): CanvasRenderingContext2D;
  45655. /**
  45656. * Clears the texture
  45657. */
  45658. clear(): void;
  45659. /**
  45660. * Updates the texture
  45661. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45662. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  45663. */
  45664. update(invertY?: boolean, premulAlpha?: boolean): void;
  45665. /**
  45666. * Draws text onto the texture
  45667. * @param text defines the text to be drawn
  45668. * @param x defines the placement of the text from the left
  45669. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  45670. * @param font defines the font to be used with font-style, font-size, font-name
  45671. * @param color defines the color used for the text
  45672. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  45673. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  45674. * @param update defines whether texture is immediately update (default is true)
  45675. */
  45676. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  45677. /**
  45678. * Clones the texture
  45679. * @returns the clone of the texture.
  45680. */
  45681. clone(): DynamicTexture;
  45682. /**
  45683. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  45684. * @returns a serialized dynamic texture object
  45685. */
  45686. serialize(): any;
  45687. private _IsCanvasElement;
  45688. /** @hidden */
  45689. _rebuild(): void;
  45690. }
  45691. }
  45692. declare module BABYLON {
  45693. /** @hidden */
  45694. export var imageProcessingPixelShader: {
  45695. name: string;
  45696. shader: string;
  45697. };
  45698. }
  45699. declare module BABYLON {
  45700. /**
  45701. * ImageProcessingPostProcess
  45702. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  45703. */
  45704. export class ImageProcessingPostProcess extends PostProcess {
  45705. /**
  45706. * Default configuration related to image processing available in the PBR Material.
  45707. */
  45708. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45709. /**
  45710. * Gets the image processing configuration used either in this material.
  45711. */
  45712. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45713. /**
  45714. * Sets the Default image processing configuration used either in the this material.
  45715. *
  45716. * If sets to null, the scene one is in use.
  45717. */
  45718. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  45719. /**
  45720. * Keep track of the image processing observer to allow dispose and replace.
  45721. */
  45722. private _imageProcessingObserver;
  45723. /**
  45724. * Attaches a new image processing configuration to the PBR Material.
  45725. * @param configuration
  45726. */
  45727. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  45728. /**
  45729. * If the post process is supported.
  45730. */
  45731. get isSupported(): boolean;
  45732. /**
  45733. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45734. */
  45735. get colorCurves(): Nullable<ColorCurves>;
  45736. /**
  45737. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  45738. */
  45739. set colorCurves(value: Nullable<ColorCurves>);
  45740. /**
  45741. * Gets wether the color curves effect is enabled.
  45742. */
  45743. get colorCurvesEnabled(): boolean;
  45744. /**
  45745. * Sets wether the color curves effect is enabled.
  45746. */
  45747. set colorCurvesEnabled(value: boolean);
  45748. /**
  45749. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45750. */
  45751. get colorGradingTexture(): Nullable<BaseTexture>;
  45752. /**
  45753. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  45754. */
  45755. set colorGradingTexture(value: Nullable<BaseTexture>);
  45756. /**
  45757. * Gets wether the color grading effect is enabled.
  45758. */
  45759. get colorGradingEnabled(): boolean;
  45760. /**
  45761. * Gets wether the color grading effect is enabled.
  45762. */
  45763. set colorGradingEnabled(value: boolean);
  45764. /**
  45765. * Gets exposure used in the effect.
  45766. */
  45767. get exposure(): number;
  45768. /**
  45769. * Sets exposure used in the effect.
  45770. */
  45771. set exposure(value: number);
  45772. /**
  45773. * Gets wether tonemapping is enabled or not.
  45774. */
  45775. get toneMappingEnabled(): boolean;
  45776. /**
  45777. * Sets wether tonemapping is enabled or not
  45778. */
  45779. set toneMappingEnabled(value: boolean);
  45780. /**
  45781. * Gets the type of tone mapping effect.
  45782. */
  45783. get toneMappingType(): number;
  45784. /**
  45785. * Sets the type of tone mapping effect.
  45786. */
  45787. set toneMappingType(value: number);
  45788. /**
  45789. * Gets contrast used in the effect.
  45790. */
  45791. get contrast(): number;
  45792. /**
  45793. * Sets contrast used in the effect.
  45794. */
  45795. set contrast(value: number);
  45796. /**
  45797. * Gets Vignette stretch size.
  45798. */
  45799. get vignetteStretch(): number;
  45800. /**
  45801. * Sets Vignette stretch size.
  45802. */
  45803. set vignetteStretch(value: number);
  45804. /**
  45805. * Gets Vignette centre X Offset.
  45806. */
  45807. get vignetteCentreX(): number;
  45808. /**
  45809. * Sets Vignette centre X Offset.
  45810. */
  45811. set vignetteCentreX(value: number);
  45812. /**
  45813. * Gets Vignette centre Y Offset.
  45814. */
  45815. get vignetteCentreY(): number;
  45816. /**
  45817. * Sets Vignette centre Y Offset.
  45818. */
  45819. set vignetteCentreY(value: number);
  45820. /**
  45821. * Gets Vignette weight or intensity of the vignette effect.
  45822. */
  45823. get vignetteWeight(): number;
  45824. /**
  45825. * Sets Vignette weight or intensity of the vignette effect.
  45826. */
  45827. set vignetteWeight(value: number);
  45828. /**
  45829. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45830. * if vignetteEnabled is set to true.
  45831. */
  45832. get vignetteColor(): Color4;
  45833. /**
  45834. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  45835. * if vignetteEnabled is set to true.
  45836. */
  45837. set vignetteColor(value: Color4);
  45838. /**
  45839. * Gets Camera field of view used by the Vignette effect.
  45840. */
  45841. get vignetteCameraFov(): number;
  45842. /**
  45843. * Sets Camera field of view used by the Vignette effect.
  45844. */
  45845. set vignetteCameraFov(value: number);
  45846. /**
  45847. * Gets the vignette blend mode allowing different kind of effect.
  45848. */
  45849. get vignetteBlendMode(): number;
  45850. /**
  45851. * Sets the vignette blend mode allowing different kind of effect.
  45852. */
  45853. set vignetteBlendMode(value: number);
  45854. /**
  45855. * Gets wether the vignette effect is enabled.
  45856. */
  45857. get vignetteEnabled(): boolean;
  45858. /**
  45859. * Sets wether the vignette effect is enabled.
  45860. */
  45861. set vignetteEnabled(value: boolean);
  45862. private _fromLinearSpace;
  45863. /**
  45864. * Gets wether the input of the processing is in Gamma or Linear Space.
  45865. */
  45866. get fromLinearSpace(): boolean;
  45867. /**
  45868. * Sets wether the input of the processing is in Gamma or Linear Space.
  45869. */
  45870. set fromLinearSpace(value: boolean);
  45871. /**
  45872. * Defines cache preventing GC.
  45873. */
  45874. private _defines;
  45875. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  45876. /**
  45877. * "ImageProcessingPostProcess"
  45878. * @returns "ImageProcessingPostProcess"
  45879. */
  45880. getClassName(): string;
  45881. /**
  45882. * @hidden
  45883. */
  45884. _updateParameters(): void;
  45885. dispose(camera?: Camera): void;
  45886. }
  45887. }
  45888. declare module BABYLON {
  45889. /**
  45890. * Class containing static functions to help procedurally build meshes
  45891. */
  45892. export class GroundBuilder {
  45893. /**
  45894. * Creates a ground mesh
  45895. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  45896. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  45897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45898. * @param name defines the name of the mesh
  45899. * @param options defines the options used to create the mesh
  45900. * @param scene defines the hosting scene
  45901. * @returns the ground mesh
  45902. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  45903. */
  45904. static CreateGround(name: string, options: {
  45905. width?: number;
  45906. height?: number;
  45907. subdivisions?: number;
  45908. subdivisionsX?: number;
  45909. subdivisionsY?: number;
  45910. updatable?: boolean;
  45911. }, scene: any): Mesh;
  45912. /**
  45913. * Creates a tiled ground mesh
  45914. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  45915. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  45916. * * 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
  45917. * * 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
  45918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45919. * @param name defines the name of the mesh
  45920. * @param options defines the options used to create the mesh
  45921. * @param scene defines the hosting scene
  45922. * @returns the tiled ground mesh
  45923. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  45924. */
  45925. static CreateTiledGround(name: string, options: {
  45926. xmin: number;
  45927. zmin: number;
  45928. xmax: number;
  45929. zmax: number;
  45930. subdivisions?: {
  45931. w: number;
  45932. h: number;
  45933. };
  45934. precision?: {
  45935. w: number;
  45936. h: number;
  45937. };
  45938. updatable?: boolean;
  45939. }, scene?: Nullable<Scene>): Mesh;
  45940. /**
  45941. * Creates a ground mesh from a height map
  45942. * * The parameter `url` sets the URL of the height map image resource.
  45943. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  45944. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  45945. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  45946. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  45947. * * 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.
  45948. * * 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).
  45949. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  45950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45951. * @param name defines the name of the mesh
  45952. * @param url defines the url to the height map
  45953. * @param options defines the options used to create the mesh
  45954. * @param scene defines the hosting scene
  45955. * @returns the ground mesh
  45956. * @see https://doc.babylonjs.com/babylon101/height_map
  45957. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  45958. */
  45959. static CreateGroundFromHeightMap(name: string, url: string, options: {
  45960. width?: number;
  45961. height?: number;
  45962. subdivisions?: number;
  45963. minHeight?: number;
  45964. maxHeight?: number;
  45965. colorFilter?: Color3;
  45966. alphaFilter?: number;
  45967. updatable?: boolean;
  45968. onReady?: (mesh: GroundMesh) => void;
  45969. }, scene?: Nullable<Scene>): GroundMesh;
  45970. }
  45971. }
  45972. declare module BABYLON {
  45973. /**
  45974. * Class containing static functions to help procedurally build meshes
  45975. */
  45976. export class TorusBuilder {
  45977. /**
  45978. * Creates a torus mesh
  45979. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  45980. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  45981. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  45982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45983. * * 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
  45984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  45985. * @param name defines the name of the mesh
  45986. * @param options defines the options used to create the mesh
  45987. * @param scene defines the hosting scene
  45988. * @returns the torus mesh
  45989. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  45990. */
  45991. static CreateTorus(name: string, options: {
  45992. diameter?: number;
  45993. thickness?: number;
  45994. tessellation?: number;
  45995. updatable?: boolean;
  45996. sideOrientation?: number;
  45997. frontUVs?: Vector4;
  45998. backUVs?: Vector4;
  45999. }, scene: any): Mesh;
  46000. }
  46001. }
  46002. declare module BABYLON {
  46003. /**
  46004. * Class containing static functions to help procedurally build meshes
  46005. */
  46006. export class CylinderBuilder {
  46007. /**
  46008. * Creates a cylinder or a cone mesh
  46009. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46010. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46011. * * 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.
  46012. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46013. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46014. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46015. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46016. * * 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).
  46017. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46018. * * 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).
  46019. * * 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
  46020. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46021. * * 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
  46022. * * 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.
  46023. * * If `enclose` is false, a ring surface is one element.
  46024. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46025. * * 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
  46026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46027. * * 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
  46028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46029. * @param name defines the name of the mesh
  46030. * @param options defines the options used to create the mesh
  46031. * @param scene defines the hosting scene
  46032. * @returns the cylinder mesh
  46033. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46034. */
  46035. static CreateCylinder(name: string, options: {
  46036. height?: number;
  46037. diameterTop?: number;
  46038. diameterBottom?: number;
  46039. diameter?: number;
  46040. tessellation?: number;
  46041. subdivisions?: number;
  46042. arc?: number;
  46043. faceColors?: Color4[];
  46044. faceUV?: Vector4[];
  46045. updatable?: boolean;
  46046. hasRings?: boolean;
  46047. enclose?: boolean;
  46048. cap?: number;
  46049. sideOrientation?: number;
  46050. frontUVs?: Vector4;
  46051. backUVs?: Vector4;
  46052. }, scene: any): Mesh;
  46053. }
  46054. }
  46055. declare module BABYLON {
  46056. /**
  46057. * States of the webXR experience
  46058. */
  46059. export enum WebXRState {
  46060. /**
  46061. * Transitioning to being in XR mode
  46062. */
  46063. ENTERING_XR = 0,
  46064. /**
  46065. * Transitioning to non XR mode
  46066. */
  46067. EXITING_XR = 1,
  46068. /**
  46069. * In XR mode and presenting
  46070. */
  46071. IN_XR = 2,
  46072. /**
  46073. * Not entered XR mode
  46074. */
  46075. NOT_IN_XR = 3
  46076. }
  46077. /**
  46078. * Abstraction of the XR render target
  46079. */
  46080. export interface WebXRRenderTarget extends IDisposable {
  46081. /**
  46082. * xrpresent context of the canvas which can be used to display/mirror xr content
  46083. */
  46084. canvasContext: WebGLRenderingContext;
  46085. /**
  46086. * xr layer for the canvas
  46087. */
  46088. xrLayer: Nullable<XRWebGLLayer>;
  46089. /**
  46090. * Initializes the xr layer for the session
  46091. * @param xrSession xr session
  46092. * @returns a promise that will resolve once the XR Layer has been created
  46093. */
  46094. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46095. }
  46096. }
  46097. declare module BABYLON {
  46098. /**
  46099. * COnfiguration object for WebXR output canvas
  46100. */
  46101. export class WebXRManagedOutputCanvasOptions {
  46102. /**
  46103. * An optional canvas in case you wish to create it yourself and provide it here.
  46104. * If not provided, a new canvas will be created
  46105. */
  46106. canvasElement?: HTMLCanvasElement;
  46107. /**
  46108. * Options for this XR Layer output
  46109. */
  46110. canvasOptions?: XRWebGLLayerOptions;
  46111. /**
  46112. * CSS styling for a newly created canvas (if not provided)
  46113. */
  46114. newCanvasCssStyle?: string;
  46115. /**
  46116. * Get the default values of the configuration object
  46117. * @returns default values of this configuration object
  46118. */
  46119. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46120. }
  46121. /**
  46122. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46123. */
  46124. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46125. private _options;
  46126. private _canvas;
  46127. private _engine;
  46128. private _originalCanvasSize;
  46129. /**
  46130. * Rendering context of the canvas which can be used to display/mirror xr content
  46131. */
  46132. canvasContext: WebGLRenderingContext;
  46133. /**
  46134. * xr layer for the canvas
  46135. */
  46136. xrLayer: Nullable<XRWebGLLayer>;
  46137. /**
  46138. * Obseervers registered here will be triggered when the xr layer was initialized
  46139. */
  46140. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46141. /**
  46142. * Initializes the canvas to be added/removed upon entering/exiting xr
  46143. * @param _xrSessionManager The XR Session manager
  46144. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46145. */
  46146. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46147. /**
  46148. * Disposes of the object
  46149. */
  46150. dispose(): void;
  46151. /**
  46152. * Initializes the xr layer for the session
  46153. * @param xrSession xr session
  46154. * @returns a promise that will resolve once the XR Layer has been created
  46155. */
  46156. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46157. private _addCanvas;
  46158. private _removeCanvas;
  46159. private _setCanvasSize;
  46160. private _setManagedOutputCanvas;
  46161. }
  46162. }
  46163. declare module BABYLON {
  46164. /**
  46165. * Manages an XRSession to work with Babylon's engine
  46166. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46167. */
  46168. export class WebXRSessionManager implements IDisposable {
  46169. /** The scene which the session should be created for */
  46170. scene: Scene;
  46171. private _referenceSpace;
  46172. private _rttProvider;
  46173. private _sessionEnded;
  46174. private _xrNavigator;
  46175. private baseLayer;
  46176. /**
  46177. * The base reference space from which the session started. good if you want to reset your
  46178. * reference space
  46179. */
  46180. baseReferenceSpace: XRReferenceSpace;
  46181. /**
  46182. * Current XR frame
  46183. */
  46184. currentFrame: Nullable<XRFrame>;
  46185. /** WebXR timestamp updated every frame */
  46186. currentTimestamp: number;
  46187. /**
  46188. * Used just in case of a failure to initialize an immersive session.
  46189. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46190. */
  46191. defaultHeightCompensation: number;
  46192. /**
  46193. * Fires every time a new xrFrame arrives which can be used to update the camera
  46194. */
  46195. onXRFrameObservable: Observable<XRFrame>;
  46196. /**
  46197. * Fires when the reference space changed
  46198. */
  46199. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46200. /**
  46201. * Fires when the xr session is ended either by the device or manually done
  46202. */
  46203. onXRSessionEnded: Observable<any>;
  46204. /**
  46205. * Fires when the xr session is ended either by the device or manually done
  46206. */
  46207. onXRSessionInit: Observable<XRSession>;
  46208. /**
  46209. * Underlying xr session
  46210. */
  46211. session: XRSession;
  46212. /**
  46213. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46214. * or get the offset the player is currently at.
  46215. */
  46216. viewerReferenceSpace: XRReferenceSpace;
  46217. /**
  46218. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46219. * @param scene The scene which the session should be created for
  46220. */
  46221. constructor(
  46222. /** The scene which the session should be created for */
  46223. scene: Scene);
  46224. /**
  46225. * The current reference space used in this session. This reference space can constantly change!
  46226. * It is mainly used to offset the camera's position.
  46227. */
  46228. get referenceSpace(): XRReferenceSpace;
  46229. /**
  46230. * Set a new reference space and triggers the observable
  46231. */
  46232. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46233. /**
  46234. * Disposes of the session manager
  46235. */
  46236. dispose(): void;
  46237. /**
  46238. * Stops the xrSession and restores the render loop
  46239. * @returns Promise which resolves after it exits XR
  46240. */
  46241. exitXRAsync(): Promise<void>;
  46242. /**
  46243. * Gets the correct render target texture to be rendered this frame for this eye
  46244. * @param eye the eye for which to get the render target
  46245. * @returns the render target for the specified eye
  46246. */
  46247. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46248. /**
  46249. * Creates a WebXRRenderTarget object for the XR session
  46250. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46251. * @param options optional options to provide when creating a new render target
  46252. * @returns a WebXR render target to which the session can render
  46253. */
  46254. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46255. /**
  46256. * Initializes the manager
  46257. * After initialization enterXR can be called to start an XR session
  46258. * @returns Promise which resolves after it is initialized
  46259. */
  46260. initializeAsync(): Promise<void>;
  46261. /**
  46262. * Initializes an xr session
  46263. * @param xrSessionMode mode to initialize
  46264. * @param xrSessionInit defines optional and required values to pass to the session builder
  46265. * @returns a promise which will resolve once the session has been initialized
  46266. */
  46267. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46268. /**
  46269. * Checks if a session would be supported for the creation options specified
  46270. * @param sessionMode session mode to check if supported eg. immersive-vr
  46271. * @returns A Promise that resolves to true if supported and false if not
  46272. */
  46273. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46274. /**
  46275. * Resets the reference space to the one started the session
  46276. */
  46277. resetReferenceSpace(): void;
  46278. /**
  46279. * Starts rendering to the xr layer
  46280. */
  46281. runXRRenderLoop(): void;
  46282. /**
  46283. * Sets the reference space on the xr session
  46284. * @param referenceSpaceType space to set
  46285. * @returns a promise that will resolve once the reference space has been set
  46286. */
  46287. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46288. /**
  46289. * Updates the render state of the session
  46290. * @param state state to set
  46291. * @returns a promise that resolves once the render state has been updated
  46292. */
  46293. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46294. /**
  46295. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46296. * @param sessionMode defines the session to test
  46297. * @returns a promise with boolean as final value
  46298. */
  46299. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46300. private _createRenderTargetTexture;
  46301. }
  46302. }
  46303. declare module BABYLON {
  46304. /**
  46305. * WebXR Camera which holds the views for the xrSession
  46306. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46307. */
  46308. export class WebXRCamera extends FreeCamera {
  46309. private _xrSessionManager;
  46310. private _firstFrame;
  46311. private _referenceQuaternion;
  46312. private _referencedPosition;
  46313. private _xrInvPositionCache;
  46314. private _xrInvQuaternionCache;
  46315. /**
  46316. * Should position compensation execute on first frame.
  46317. * This is used when copying the position from a native (non XR) camera
  46318. */
  46319. compensateOnFirstFrame: boolean;
  46320. /**
  46321. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46322. * @param name the name of the camera
  46323. * @param scene the scene to add the camera to
  46324. * @param _xrSessionManager a constructed xr session manager
  46325. */
  46326. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46327. /**
  46328. * Return the user's height, unrelated to the current ground.
  46329. * This will be the y position of this camera, when ground level is 0.
  46330. */
  46331. get realWorldHeight(): number;
  46332. /** @hidden */
  46333. _updateForDualEyeDebugging(): void;
  46334. /**
  46335. * Sets this camera's transformation based on a non-vr camera
  46336. * @param otherCamera the non-vr camera to copy the transformation from
  46337. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46338. */
  46339. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46340. /**
  46341. * Gets the current instance class name ("WebXRCamera").
  46342. * @returns the class name
  46343. */
  46344. getClassName(): string;
  46345. private _rotate180;
  46346. private _updateFromXRSession;
  46347. private _updateNumberOfRigCameras;
  46348. private _updateReferenceSpace;
  46349. private _updateReferenceSpaceOffset;
  46350. }
  46351. }
  46352. declare module BABYLON {
  46353. /**
  46354. * Defining the interface required for a (webxr) feature
  46355. */
  46356. export interface IWebXRFeature extends IDisposable {
  46357. /**
  46358. * Is this feature attached
  46359. */
  46360. attached: boolean;
  46361. /**
  46362. * Should auto-attach be disabled?
  46363. */
  46364. disableAutoAttach: boolean;
  46365. /**
  46366. * Attach the feature to the session
  46367. * Will usually be called by the features manager
  46368. *
  46369. * @param force should attachment be forced (even when already attached)
  46370. * @returns true if successful.
  46371. */
  46372. attach(force?: boolean): boolean;
  46373. /**
  46374. * Detach the feature from the session
  46375. * Will usually be called by the features manager
  46376. *
  46377. * @returns true if successful.
  46378. */
  46379. detach(): boolean;
  46380. }
  46381. /**
  46382. * A list of the currently available features without referencing them
  46383. */
  46384. export class WebXRFeatureName {
  46385. /**
  46386. * The name of the anchor system feature
  46387. */
  46388. static ANCHOR_SYSTEM: string;
  46389. /**
  46390. * The name of the background remover feature
  46391. */
  46392. static BACKGROUND_REMOVER: string;
  46393. /**
  46394. * The name of the hit test feature
  46395. */
  46396. static HIT_TEST: string;
  46397. /**
  46398. * physics impostors for xr controllers feature
  46399. */
  46400. static PHYSICS_CONTROLLERS: string;
  46401. /**
  46402. * The name of the plane detection feature
  46403. */
  46404. static PLANE_DETECTION: string;
  46405. /**
  46406. * The name of the pointer selection feature
  46407. */
  46408. static POINTER_SELECTION: string;
  46409. /**
  46410. * The name of the teleportation feature
  46411. */
  46412. static TELEPORTATION: string;
  46413. }
  46414. /**
  46415. * Defining the constructor of a feature. Used to register the modules.
  46416. */
  46417. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  46418. /**
  46419. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46420. * It is mainly used in AR sessions.
  46421. *
  46422. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46423. */
  46424. export class WebXRFeaturesManager implements IDisposable {
  46425. private _xrSessionManager;
  46426. private static readonly _AvailableFeatures;
  46427. private _features;
  46428. /**
  46429. * constructs a new features manages.
  46430. *
  46431. * @param _xrSessionManager an instance of WebXRSessionManager
  46432. */
  46433. constructor(_xrSessionManager: WebXRSessionManager);
  46434. /**
  46435. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46436. * Mainly used internally.
  46437. *
  46438. * @param featureName the name of the feature to register
  46439. * @param constructorFunction the function used to construct the module
  46440. * @param version the (babylon) version of the module
  46441. * @param stable is that a stable version of this module
  46442. */
  46443. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46444. /**
  46445. * Returns a constructor of a specific feature.
  46446. *
  46447. * @param featureName the name of the feature to construct
  46448. * @param version the version of the feature to load
  46449. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46450. * @param options optional options provided to the module.
  46451. * @returns a function that, when called, will return a new instance of this feature
  46452. */
  46453. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  46454. /**
  46455. * Can be used to return the list of features currently registered
  46456. *
  46457. * @returns an Array of available features
  46458. */
  46459. static GetAvailableFeatures(): string[];
  46460. /**
  46461. * Gets the versions available for a specific feature
  46462. * @param featureName the name of the feature
  46463. * @returns an array with the available versions
  46464. */
  46465. static GetAvailableVersions(featureName: string): string[];
  46466. /**
  46467. * Return the latest unstable version of this feature
  46468. * @param featureName the name of the feature to search
  46469. * @returns the version number. if not found will return -1
  46470. */
  46471. static GetLatestVersionOfFeature(featureName: string): number;
  46472. /**
  46473. * Return the latest stable version of this feature
  46474. * @param featureName the name of the feature to search
  46475. * @returns the version number. if not found will return -1
  46476. */
  46477. static GetStableVersionOfFeature(featureName: string): number;
  46478. /**
  46479. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  46480. * Can be used during a session to start a feature
  46481. * @param featureName the name of feature to attach
  46482. */
  46483. attachFeature(featureName: string): void;
  46484. /**
  46485. * Can be used inside a session or when the session ends to detach a specific feature
  46486. * @param featureName the name of the feature to detach
  46487. */
  46488. detachFeature(featureName: string): void;
  46489. /**
  46490. * Used to disable an already-enabled feature
  46491. * The feature will be disposed and will be recreated once enabled.
  46492. * @param featureName the feature to disable
  46493. * @returns true if disable was successful
  46494. */
  46495. disableFeature(featureName: string | {
  46496. Name: string;
  46497. }): boolean;
  46498. /**
  46499. * dispose this features manager
  46500. */
  46501. dispose(): void;
  46502. /**
  46503. * 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.
  46504. * 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.
  46505. *
  46506. * @param featureName the name of the feature to load or the class of the feature
  46507. * @param version optional version to load. if not provided the latest version will be enabled
  46508. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  46509. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  46510. * @returns a new constructed feature or throws an error if feature not found.
  46511. */
  46512. enableFeature(featureName: string | {
  46513. Name: string;
  46514. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  46515. /**
  46516. * get the implementation of an enabled feature.
  46517. * @param featureName the name of the feature to load
  46518. * @returns the feature class, if found
  46519. */
  46520. getEnabledFeature(featureName: string): IWebXRFeature;
  46521. /**
  46522. * Get the list of enabled features
  46523. * @returns an array of enabled features
  46524. */
  46525. getEnabledFeatures(): string[];
  46526. }
  46527. }
  46528. declare module BABYLON {
  46529. /**
  46530. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  46531. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  46532. */
  46533. export class WebXRExperienceHelper implements IDisposable {
  46534. private scene;
  46535. private _nonVRCamera;
  46536. private _originalSceneAutoClear;
  46537. private _supported;
  46538. /**
  46539. * Camera used to render xr content
  46540. */
  46541. camera: WebXRCamera;
  46542. /** A features manager for this xr session */
  46543. featuresManager: WebXRFeaturesManager;
  46544. /**
  46545. * Observers registered here will be triggered after the camera's initial transformation is set
  46546. * This can be used to set a different ground level or an extra rotation.
  46547. *
  46548. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  46549. * to the position set after this observable is done executing.
  46550. */
  46551. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  46552. /**
  46553. * Fires when the state of the experience helper has changed
  46554. */
  46555. onStateChangedObservable: Observable<WebXRState>;
  46556. /** Session manager used to keep track of xr session */
  46557. sessionManager: WebXRSessionManager;
  46558. /**
  46559. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  46560. */
  46561. state: WebXRState;
  46562. /**
  46563. * Creates a WebXRExperienceHelper
  46564. * @param scene The scene the helper should be created in
  46565. */
  46566. private constructor();
  46567. /**
  46568. * Creates the experience helper
  46569. * @param scene the scene to attach the experience helper to
  46570. * @returns a promise for the experience helper
  46571. */
  46572. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  46573. /**
  46574. * Disposes of the experience helper
  46575. */
  46576. dispose(): void;
  46577. /**
  46578. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  46579. * @param sessionMode options for the XR session
  46580. * @param referenceSpaceType frame of reference of the XR session
  46581. * @param renderTarget the output canvas that will be used to enter XR mode
  46582. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  46583. * @returns promise that resolves after xr mode has entered
  46584. */
  46585. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  46586. /**
  46587. * Exits XR mode and returns the scene to its original state
  46588. * @returns promise that resolves after xr mode has exited
  46589. */
  46590. exitXRAsync(): Promise<void>;
  46591. private _nonXRToXRCamera;
  46592. private _setState;
  46593. }
  46594. }
  46595. declare module BABYLON {
  46596. /**
  46597. * X-Y values for axes in WebXR
  46598. */
  46599. export interface IWebXRMotionControllerAxesValue {
  46600. /**
  46601. * The value of the x axis
  46602. */
  46603. x: number;
  46604. /**
  46605. * The value of the y-axis
  46606. */
  46607. y: number;
  46608. }
  46609. /**
  46610. * changed / previous values for the values of this component
  46611. */
  46612. export interface IWebXRMotionControllerComponentChangesValues<T> {
  46613. /**
  46614. * current (this frame) value
  46615. */
  46616. current: T;
  46617. /**
  46618. * previous (last change) value
  46619. */
  46620. previous: T;
  46621. }
  46622. /**
  46623. * Represents changes in the component between current frame and last values recorded
  46624. */
  46625. export interface IWebXRMotionControllerComponentChanges {
  46626. /**
  46627. * will be populated with previous and current values if axes changed
  46628. */
  46629. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  46630. /**
  46631. * will be populated with previous and current values if pressed changed
  46632. */
  46633. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46634. /**
  46635. * will be populated with previous and current values if touched changed
  46636. */
  46637. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  46638. /**
  46639. * will be populated with previous and current values if value changed
  46640. */
  46641. value?: IWebXRMotionControllerComponentChangesValues<number>;
  46642. }
  46643. /**
  46644. * This class represents a single component (for example button or thumbstick) of a motion controller
  46645. */
  46646. export class WebXRControllerComponent implements IDisposable {
  46647. /**
  46648. * the id of this component
  46649. */
  46650. id: string;
  46651. /**
  46652. * the type of the component
  46653. */
  46654. type: MotionControllerComponentType;
  46655. private _buttonIndex;
  46656. private _axesIndices;
  46657. private _axes;
  46658. private _changes;
  46659. private _currentValue;
  46660. private _hasChanges;
  46661. private _pressed;
  46662. private _touched;
  46663. /**
  46664. * button component type
  46665. */
  46666. static BUTTON_TYPE: MotionControllerComponentType;
  46667. /**
  46668. * squeeze component type
  46669. */
  46670. static SQUEEZE_TYPE: MotionControllerComponentType;
  46671. /**
  46672. * Thumbstick component type
  46673. */
  46674. static THUMBSTICK_TYPE: MotionControllerComponentType;
  46675. /**
  46676. * Touchpad component type
  46677. */
  46678. static TOUCHPAD_TYPE: MotionControllerComponentType;
  46679. /**
  46680. * trigger component type
  46681. */
  46682. static TRIGGER_TYPE: MotionControllerComponentType;
  46683. /**
  46684. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  46685. * the axes data changes
  46686. */
  46687. onAxisValueChangedObservable: Observable<{
  46688. x: number;
  46689. y: number;
  46690. }>;
  46691. /**
  46692. * Observers registered here will be triggered when the state of a button changes
  46693. * State change is either pressed / touched / value
  46694. */
  46695. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  46696. /**
  46697. * Creates a new component for a motion controller.
  46698. * It is created by the motion controller itself
  46699. *
  46700. * @param id the id of this component
  46701. * @param type the type of the component
  46702. * @param _buttonIndex index in the buttons array of the gamepad
  46703. * @param _axesIndices indices of the values in the axes array of the gamepad
  46704. */
  46705. constructor(
  46706. /**
  46707. * the id of this component
  46708. */
  46709. id: string,
  46710. /**
  46711. * the type of the component
  46712. */
  46713. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  46714. /**
  46715. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  46716. */
  46717. get axes(): IWebXRMotionControllerAxesValue;
  46718. /**
  46719. * Get the changes. Elements will be populated only if they changed with their previous and current value
  46720. */
  46721. get changes(): IWebXRMotionControllerComponentChanges;
  46722. /**
  46723. * Return whether or not the component changed the last frame
  46724. */
  46725. get hasChanges(): boolean;
  46726. /**
  46727. * is the button currently pressed
  46728. */
  46729. get pressed(): boolean;
  46730. /**
  46731. * is the button currently touched
  46732. */
  46733. get touched(): boolean;
  46734. /**
  46735. * Get the current value of this component
  46736. */
  46737. get value(): number;
  46738. /**
  46739. * Dispose this component
  46740. */
  46741. dispose(): void;
  46742. /**
  46743. * Are there axes correlating to this component
  46744. * @return true is axes data is available
  46745. */
  46746. isAxes(): boolean;
  46747. /**
  46748. * Is this component a button (hence - pressable)
  46749. * @returns true if can be pressed
  46750. */
  46751. isButton(): boolean;
  46752. /**
  46753. * update this component using the gamepad object it is in. Called on every frame
  46754. * @param nativeController the native gamepad controller object
  46755. */
  46756. update(nativeController: IMinimalMotionControllerObject): void;
  46757. }
  46758. }
  46759. declare module BABYLON {
  46760. /**
  46761. * Interface used to represent data loading progression
  46762. */
  46763. export interface ISceneLoaderProgressEvent {
  46764. /**
  46765. * Defines if data length to load can be evaluated
  46766. */
  46767. readonly lengthComputable: boolean;
  46768. /**
  46769. * Defines the loaded data length
  46770. */
  46771. readonly loaded: number;
  46772. /**
  46773. * Defines the data length to load
  46774. */
  46775. readonly total: number;
  46776. }
  46777. /**
  46778. * Interface used by SceneLoader plugins to define supported file extensions
  46779. */
  46780. export interface ISceneLoaderPluginExtensions {
  46781. /**
  46782. * Defines the list of supported extensions
  46783. */
  46784. [extension: string]: {
  46785. isBinary: boolean;
  46786. };
  46787. }
  46788. /**
  46789. * Interface used by SceneLoader plugin factory
  46790. */
  46791. export interface ISceneLoaderPluginFactory {
  46792. /**
  46793. * Defines the name of the factory
  46794. */
  46795. name: string;
  46796. /**
  46797. * Function called to create a new plugin
  46798. * @return the new plugin
  46799. */
  46800. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  46801. /**
  46802. * The callback that returns true if the data can be directly loaded.
  46803. * @param data string containing the file data
  46804. * @returns if the data can be loaded directly
  46805. */
  46806. canDirectLoad?(data: string): boolean;
  46807. }
  46808. /**
  46809. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  46810. */
  46811. export interface ISceneLoaderPluginBase {
  46812. /**
  46813. * The friendly name of this plugin.
  46814. */
  46815. name: string;
  46816. /**
  46817. * The file extensions supported by this plugin.
  46818. */
  46819. extensions: string | ISceneLoaderPluginExtensions;
  46820. /**
  46821. * The callback called when loading from a url.
  46822. * @param scene scene loading this url
  46823. * @param url url to load
  46824. * @param onSuccess callback called when the file successfully loads
  46825. * @param onProgress callback called while file is loading (if the server supports this mode)
  46826. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  46827. * @param onError callback called when the file fails to load
  46828. * @returns a file request object
  46829. */
  46830. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46831. /**
  46832. * The callback called when loading from a file object.
  46833. * @param scene scene loading this file
  46834. * @param file defines the file to load
  46835. * @param onSuccess defines the callback to call when data is loaded
  46836. * @param onProgress defines the callback to call during loading process
  46837. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  46838. * @param onError defines the callback to call when an error occurs
  46839. * @returns a file request object
  46840. */
  46841. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  46842. /**
  46843. * The callback that returns true if the data can be directly loaded.
  46844. * @param data string containing the file data
  46845. * @returns if the data can be loaded directly
  46846. */
  46847. canDirectLoad?(data: string): boolean;
  46848. /**
  46849. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  46850. * @param scene scene loading this data
  46851. * @param data string containing the data
  46852. * @returns data to pass to the plugin
  46853. */
  46854. directLoad?(scene: Scene, data: string): any;
  46855. /**
  46856. * The callback that allows custom handling of the root url based on the response url.
  46857. * @param rootUrl the original root url
  46858. * @param responseURL the response url if available
  46859. * @returns the new root url
  46860. */
  46861. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  46862. }
  46863. /**
  46864. * Interface used to define a SceneLoader plugin
  46865. */
  46866. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  46867. /**
  46868. * Import meshes into a scene.
  46869. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46870. * @param scene The scene to import into
  46871. * @param data The data to import
  46872. * @param rootUrl The root url for scene and resources
  46873. * @param meshes The meshes array to import into
  46874. * @param particleSystems The particle systems array to import into
  46875. * @param skeletons The skeletons array to import into
  46876. * @param onError The callback when import fails
  46877. * @returns True if successful or false otherwise
  46878. */
  46879. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  46880. /**
  46881. * Load into a scene.
  46882. * @param scene The scene to load into
  46883. * @param data The data to import
  46884. * @param rootUrl The root url for scene and resources
  46885. * @param onError The callback when import fails
  46886. * @returns True if successful or false otherwise
  46887. */
  46888. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  46889. /**
  46890. * Load into an asset container.
  46891. * @param scene The scene to load into
  46892. * @param data The data to import
  46893. * @param rootUrl The root url for scene and resources
  46894. * @param onError The callback when import fails
  46895. * @returns The loaded asset container
  46896. */
  46897. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  46898. }
  46899. /**
  46900. * Interface used to define an async SceneLoader plugin
  46901. */
  46902. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  46903. /**
  46904. * Import meshes into a scene.
  46905. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  46906. * @param scene The scene to import into
  46907. * @param data The data to import
  46908. * @param rootUrl The root url for scene and resources
  46909. * @param onProgress The callback when the load progresses
  46910. * @param fileName Defines the name of the file to load
  46911. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  46912. */
  46913. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  46914. meshes: AbstractMesh[];
  46915. particleSystems: IParticleSystem[];
  46916. skeletons: Skeleton[];
  46917. animationGroups: AnimationGroup[];
  46918. }>;
  46919. /**
  46920. * Load into a scene.
  46921. * @param scene The scene to load into
  46922. * @param data The data to import
  46923. * @param rootUrl The root url for scene and resources
  46924. * @param onProgress The callback when the load progresses
  46925. * @param fileName Defines the name of the file to load
  46926. * @returns Nothing
  46927. */
  46928. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  46929. /**
  46930. * Load into an asset container.
  46931. * @param scene The scene to load into
  46932. * @param data The data to import
  46933. * @param rootUrl The root url for scene and resources
  46934. * @param onProgress The callback when the load progresses
  46935. * @param fileName Defines the name of the file to load
  46936. * @returns The loaded asset container
  46937. */
  46938. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  46939. }
  46940. /**
  46941. * Mode that determines how to handle old animation groups before loading new ones.
  46942. */
  46943. export enum SceneLoaderAnimationGroupLoadingMode {
  46944. /**
  46945. * Reset all old animations to initial state then dispose them.
  46946. */
  46947. Clean = 0,
  46948. /**
  46949. * Stop all old animations.
  46950. */
  46951. Stop = 1,
  46952. /**
  46953. * Restart old animations from first frame.
  46954. */
  46955. Sync = 2,
  46956. /**
  46957. * Old animations remains untouched.
  46958. */
  46959. NoSync = 3
  46960. }
  46961. /**
  46962. * Class used to load scene from various file formats using registered plugins
  46963. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  46964. */
  46965. export class SceneLoader {
  46966. /**
  46967. * No logging while loading
  46968. */
  46969. static readonly NO_LOGGING: number;
  46970. /**
  46971. * Minimal logging while loading
  46972. */
  46973. static readonly MINIMAL_LOGGING: number;
  46974. /**
  46975. * Summary logging while loading
  46976. */
  46977. static readonly SUMMARY_LOGGING: number;
  46978. /**
  46979. * Detailled logging while loading
  46980. */
  46981. static readonly DETAILED_LOGGING: number;
  46982. /**
  46983. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  46984. */
  46985. static get ForceFullSceneLoadingForIncremental(): boolean;
  46986. static set ForceFullSceneLoadingForIncremental(value: boolean);
  46987. /**
  46988. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  46989. */
  46990. static get ShowLoadingScreen(): boolean;
  46991. static set ShowLoadingScreen(value: boolean);
  46992. /**
  46993. * Defines the current logging level (while loading the scene)
  46994. * @ignorenaming
  46995. */
  46996. static get loggingLevel(): number;
  46997. static set loggingLevel(value: number);
  46998. /**
  46999. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47000. */
  47001. static get CleanBoneMatrixWeights(): boolean;
  47002. static set CleanBoneMatrixWeights(value: boolean);
  47003. /**
  47004. * Event raised when a plugin is used to load a scene
  47005. */
  47006. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47007. private static _registeredPlugins;
  47008. private static _getDefaultPlugin;
  47009. private static _getPluginForExtension;
  47010. private static _getPluginForDirectLoad;
  47011. private static _getPluginForFilename;
  47012. private static _getDirectLoad;
  47013. private static _loadData;
  47014. private static _getFileInfo;
  47015. /**
  47016. * Gets a plugin that can load the given extension
  47017. * @param extension defines the extension to load
  47018. * @returns a plugin or null if none works
  47019. */
  47020. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47021. /**
  47022. * Gets a boolean indicating that the given extension can be loaded
  47023. * @param extension defines the extension to load
  47024. * @returns true if the extension is supported
  47025. */
  47026. static IsPluginForExtensionAvailable(extension: string): boolean;
  47027. /**
  47028. * Adds a new plugin to the list of registered plugins
  47029. * @param plugin defines the plugin to add
  47030. */
  47031. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47032. /**
  47033. * Import meshes into a scene
  47034. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47035. * @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)
  47036. * @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)
  47037. * @param scene the instance of BABYLON.Scene to append to
  47038. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47039. * @param onProgress a callback with a progress event for each file being loaded
  47040. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47041. * @param pluginExtension the extension used to determine the plugin
  47042. * @returns The loaded plugin
  47043. */
  47044. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47045. /**
  47046. * Import meshes into a scene
  47047. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47048. * @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)
  47049. * @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)
  47050. * @param scene the instance of BABYLON.Scene to append to
  47051. * @param onProgress a callback with a progress event for each file being loaded
  47052. * @param pluginExtension the extension used to determine the plugin
  47053. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47054. */
  47055. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47056. meshes: AbstractMesh[];
  47057. particleSystems: IParticleSystem[];
  47058. skeletons: Skeleton[];
  47059. animationGroups: AnimationGroup[];
  47060. }>;
  47061. /**
  47062. * Load a scene
  47063. * @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)
  47064. * @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)
  47065. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47066. * @param onSuccess a callback with the scene when import succeeds
  47067. * @param onProgress a callback with a progress event for each file being loaded
  47068. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47069. * @param pluginExtension the extension used to determine the plugin
  47070. * @returns The loaded plugin
  47071. */
  47072. 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>;
  47073. /**
  47074. * Load a scene
  47075. * @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)
  47076. * @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)
  47077. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47078. * @param onProgress a callback with a progress event for each file being loaded
  47079. * @param pluginExtension the extension used to determine the plugin
  47080. * @returns The loaded scene
  47081. */
  47082. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47083. /**
  47084. * Append a scene
  47085. * @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)
  47086. * @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)
  47087. * @param scene is the instance of BABYLON.Scene to append to
  47088. * @param onSuccess a callback with the scene when import succeeds
  47089. * @param onProgress a callback with a progress event for each file being loaded
  47090. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47091. * @param pluginExtension the extension used to determine the plugin
  47092. * @returns The loaded plugin
  47093. */
  47094. 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>;
  47095. /**
  47096. * Append a scene
  47097. * @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)
  47098. * @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)
  47099. * @param scene is the instance of BABYLON.Scene to append to
  47100. * @param onProgress a callback with a progress event for each file being loaded
  47101. * @param pluginExtension the extension used to determine the plugin
  47102. * @returns The given scene
  47103. */
  47104. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47105. /**
  47106. * Load a scene into an asset container
  47107. * @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)
  47108. * @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)
  47109. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47110. * @param onSuccess a callback with the scene when import succeeds
  47111. * @param onProgress a callback with a progress event for each file being loaded
  47112. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47113. * @param pluginExtension the extension used to determine the plugin
  47114. * @returns The loaded plugin
  47115. */
  47116. 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>;
  47117. /**
  47118. * Load a scene into an asset container
  47119. * @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)
  47120. * @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)
  47121. * @param scene is the instance of Scene to append to
  47122. * @param onProgress a callback with a progress event for each file being loaded
  47123. * @param pluginExtension the extension used to determine the plugin
  47124. * @returns The loaded asset container
  47125. */
  47126. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47127. /**
  47128. * Import animations from a file into a scene
  47129. * @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)
  47130. * @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)
  47131. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47132. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47133. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47134. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47135. * @param onSuccess a callback with the scene when import succeeds
  47136. * @param onProgress a callback with a progress event for each file being loaded
  47137. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47138. * @param pluginExtension the extension used to determine the plugin
  47139. */
  47140. 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;
  47141. /**
  47142. * Import animations from a file into a scene
  47143. * @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)
  47144. * @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)
  47145. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47146. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47147. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47148. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47149. * @param onSuccess a callback with the scene when import succeeds
  47150. * @param onProgress a callback with a progress event for each file being loaded
  47151. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47152. * @param pluginExtension the extension used to determine the plugin
  47153. * @returns the updated scene with imported animations
  47154. */
  47155. 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>;
  47156. }
  47157. }
  47158. declare module BABYLON {
  47159. /**
  47160. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47161. */
  47162. export type MotionControllerHandedness = "none" | "left" | "right";
  47163. /**
  47164. * The type of components available in motion controllers.
  47165. * This is not the name of the component.
  47166. */
  47167. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47168. /**
  47169. * The state of a controller component
  47170. */
  47171. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47172. /**
  47173. * The schema of motion controller layout.
  47174. * No object will be initialized using this interface
  47175. * This is used just to define the profile.
  47176. */
  47177. export interface IMotionControllerLayout {
  47178. /**
  47179. * Path to load the assets. Usually relative to the base path
  47180. */
  47181. assetPath: string;
  47182. /**
  47183. * Available components (unsorted)
  47184. */
  47185. components: {
  47186. /**
  47187. * A map of component Ids
  47188. */
  47189. [componentId: string]: {
  47190. /**
  47191. * The type of input the component outputs
  47192. */
  47193. type: MotionControllerComponentType;
  47194. /**
  47195. * The indices of this component in the gamepad object
  47196. */
  47197. gamepadIndices: {
  47198. /**
  47199. * Index of button
  47200. */
  47201. button?: number;
  47202. /**
  47203. * If available, index of x-axis
  47204. */
  47205. xAxis?: number;
  47206. /**
  47207. * If available, index of y-axis
  47208. */
  47209. yAxis?: number;
  47210. };
  47211. /**
  47212. * The mesh's root node name
  47213. */
  47214. rootNodeName: string;
  47215. /**
  47216. * Animation definitions for this model
  47217. */
  47218. visualResponses: {
  47219. [stateKey: string]: {
  47220. /**
  47221. * What property will be animated
  47222. */
  47223. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47224. /**
  47225. * What states influence this visual response
  47226. */
  47227. states: MotionControllerComponentStateType[];
  47228. /**
  47229. * Type of animation - movement or visibility
  47230. */
  47231. valueNodeProperty: "transform" | "visibility";
  47232. /**
  47233. * Base node name to move. Its position will be calculated according to the min and max nodes
  47234. */
  47235. valueNodeName?: string;
  47236. /**
  47237. * Minimum movement node
  47238. */
  47239. minNodeName?: string;
  47240. /**
  47241. * Max movement node
  47242. */
  47243. maxNodeName?: string;
  47244. };
  47245. };
  47246. /**
  47247. * If touch enabled, what is the name of node to display user feedback
  47248. */
  47249. touchPointNodeName?: string;
  47250. };
  47251. };
  47252. /**
  47253. * Is it xr standard mapping or not
  47254. */
  47255. gamepadMapping: "" | "xr-standard";
  47256. /**
  47257. * Base root node of this entire model
  47258. */
  47259. rootNodeName: string;
  47260. /**
  47261. * Defines the main button component id
  47262. */
  47263. selectComponentId: string;
  47264. }
  47265. /**
  47266. * A definition for the layout map in the input profile
  47267. */
  47268. export interface IMotionControllerLayoutMap {
  47269. /**
  47270. * Layouts with handedness type as a key
  47271. */
  47272. [handedness: string]: IMotionControllerLayout;
  47273. }
  47274. /**
  47275. * The XR Input profile schema
  47276. * Profiles can be found here:
  47277. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47278. */
  47279. export interface IMotionControllerProfile {
  47280. /**
  47281. * fallback profiles for this profileId
  47282. */
  47283. fallbackProfileIds: string[];
  47284. /**
  47285. * The layout map, with handedness as key
  47286. */
  47287. layouts: IMotionControllerLayoutMap;
  47288. /**
  47289. * The id of this profile
  47290. * correlates to the profile(s) in the xrInput.profiles array
  47291. */
  47292. profileId: string;
  47293. }
  47294. /**
  47295. * A helper-interface for the 3 meshes needed for controller button animation
  47296. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47297. */
  47298. export interface IMotionControllerButtonMeshMap {
  47299. /**
  47300. * the mesh that defines the pressed value mesh position.
  47301. * This is used to find the max-position of this button
  47302. */
  47303. pressedMesh: AbstractMesh;
  47304. /**
  47305. * the mesh that defines the unpressed value mesh position.
  47306. * This is used to find the min (or initial) position of this button
  47307. */
  47308. unpressedMesh: AbstractMesh;
  47309. /**
  47310. * The mesh that will be changed when value changes
  47311. */
  47312. valueMesh: AbstractMesh;
  47313. }
  47314. /**
  47315. * A helper-interface for the 3 meshes needed for controller axis animation.
  47316. * This will be expanded when touchpad animations are fully supported
  47317. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47318. */
  47319. export interface IMotionControllerMeshMap {
  47320. /**
  47321. * the mesh that defines the maximum value mesh position.
  47322. */
  47323. maxMesh?: AbstractMesh;
  47324. /**
  47325. * the mesh that defines the minimum value mesh position.
  47326. */
  47327. minMesh?: AbstractMesh;
  47328. /**
  47329. * The mesh that will be changed when axis value changes
  47330. */
  47331. valueMesh: AbstractMesh;
  47332. }
  47333. /**
  47334. * The elements needed for change-detection of the gamepad objects in motion controllers
  47335. */
  47336. export interface IMinimalMotionControllerObject {
  47337. /**
  47338. * Available axes of this controller
  47339. */
  47340. axes: number[];
  47341. /**
  47342. * An array of available buttons
  47343. */
  47344. buttons: Array<{
  47345. /**
  47346. * Value of the button/trigger
  47347. */
  47348. value: number;
  47349. /**
  47350. * If the button/trigger is currently touched
  47351. */
  47352. touched: boolean;
  47353. /**
  47354. * If the button/trigger is currently pressed
  47355. */
  47356. pressed: boolean;
  47357. }>;
  47358. /**
  47359. * EXPERIMENTAL haptic support.
  47360. */
  47361. hapticActuators?: Array<{
  47362. pulse: (value: number, duration: number) => Promise<boolean>;
  47363. }>;
  47364. }
  47365. /**
  47366. * An Abstract Motion controller
  47367. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47368. * Each component has an observable to check for changes in value and state
  47369. */
  47370. export abstract class WebXRAbstractMotionController implements IDisposable {
  47371. protected scene: Scene;
  47372. protected layout: IMotionControllerLayout;
  47373. /**
  47374. * The gamepad object correlating to this controller
  47375. */
  47376. gamepadObject: IMinimalMotionControllerObject;
  47377. /**
  47378. * handedness (left/right/none) of this controller
  47379. */
  47380. handedness: MotionControllerHandedness;
  47381. private _initComponent;
  47382. private _modelReady;
  47383. /**
  47384. * A map of components (WebXRControllerComponent) in this motion controller
  47385. * Components have a ComponentType and can also have both button and axis definitions
  47386. */
  47387. readonly components: {
  47388. [id: string]: WebXRControllerComponent;
  47389. };
  47390. /**
  47391. * Disable the model's animation. Can be set at any time.
  47392. */
  47393. disableAnimation: boolean;
  47394. /**
  47395. * Observers registered here will be triggered when the model of this controller is done loading
  47396. */
  47397. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47398. /**
  47399. * The profile id of this motion controller
  47400. */
  47401. abstract profileId: string;
  47402. /**
  47403. * The root mesh of the model. It is null if the model was not yet initialized
  47404. */
  47405. rootMesh: Nullable<AbstractMesh>;
  47406. /**
  47407. * constructs a new abstract motion controller
  47408. * @param scene the scene to which the model of the controller will be added
  47409. * @param layout The profile layout to load
  47410. * @param gamepadObject The gamepad object correlating to this controller
  47411. * @param handedness handedness (left/right/none) of this controller
  47412. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47413. */
  47414. constructor(scene: Scene, layout: IMotionControllerLayout,
  47415. /**
  47416. * The gamepad object correlating to this controller
  47417. */
  47418. gamepadObject: IMinimalMotionControllerObject,
  47419. /**
  47420. * handedness (left/right/none) of this controller
  47421. */
  47422. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47423. /**
  47424. * Dispose this controller, the model mesh and all its components
  47425. */
  47426. dispose(): void;
  47427. /**
  47428. * Returns all components of specific type
  47429. * @param type the type to search for
  47430. * @return an array of components with this type
  47431. */
  47432. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47433. /**
  47434. * get a component based an its component id as defined in layout.components
  47435. * @param id the id of the component
  47436. * @returns the component correlates to the id or undefined if not found
  47437. */
  47438. getComponent(id: string): WebXRControllerComponent;
  47439. /**
  47440. * Get the list of components available in this motion controller
  47441. * @returns an array of strings correlating to available components
  47442. */
  47443. getComponentIds(): string[];
  47444. /**
  47445. * Get the first component of specific type
  47446. * @param type type of component to find
  47447. * @return a controller component or null if not found
  47448. */
  47449. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  47450. /**
  47451. * Get the main (Select) component of this controller as defined in the layout
  47452. * @returns the main component of this controller
  47453. */
  47454. getMainComponent(): WebXRControllerComponent;
  47455. /**
  47456. * Loads the model correlating to this controller
  47457. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  47458. * @returns A promise fulfilled with the result of the model loading
  47459. */
  47460. loadModel(): Promise<boolean>;
  47461. /**
  47462. * Update this model using the current XRFrame
  47463. * @param xrFrame the current xr frame to use and update the model
  47464. */
  47465. updateFromXRFrame(xrFrame: XRFrame): void;
  47466. /**
  47467. * Backwards compatibility due to a deeply-integrated typo
  47468. */
  47469. get handness(): XREye;
  47470. /**
  47471. * Pulse (vibrate) this controller
  47472. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  47473. * Consecutive calls to this function will cancel the last pulse call
  47474. *
  47475. * @param value the strength of the pulse in 0.0...1.0 range
  47476. * @param duration Duration of the pulse in milliseconds
  47477. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  47478. * @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
  47479. */
  47480. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  47481. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47482. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  47483. /**
  47484. * Moves the axis on the controller mesh based on its current state
  47485. * @param axis the index of the axis
  47486. * @param axisValue the value of the axis which determines the meshes new position
  47487. * @hidden
  47488. */
  47489. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  47490. /**
  47491. * Update the model itself with the current frame data
  47492. * @param xrFrame the frame to use for updating the model mesh
  47493. */
  47494. protected updateModel(xrFrame: XRFrame): void;
  47495. /**
  47496. * Get the filename and path for this controller's model
  47497. * @returns a map of filename and path
  47498. */
  47499. protected abstract _getFilenameAndPath(): {
  47500. filename: string;
  47501. path: string;
  47502. };
  47503. /**
  47504. * This function is called before the mesh is loaded. It checks for loading constraints.
  47505. * For example, this function can check if the GLB loader is available
  47506. * If this function returns false, the generic controller will be loaded instead
  47507. * @returns Is the client ready to load the mesh
  47508. */
  47509. protected abstract _getModelLoadingConstraints(): boolean;
  47510. /**
  47511. * This function will be called after the model was successfully loaded and can be used
  47512. * for mesh transformations before it is available for the user
  47513. * @param meshes the loaded meshes
  47514. */
  47515. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  47516. /**
  47517. * Set the root mesh for this controller. Important for the WebXR controller class
  47518. * @param meshes the loaded meshes
  47519. */
  47520. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  47521. /**
  47522. * A function executed each frame that updates the mesh (if needed)
  47523. * @param xrFrame the current xrFrame
  47524. */
  47525. protected abstract _updateModel(xrFrame: XRFrame): void;
  47526. private _getGenericFilenameAndPath;
  47527. private _getGenericParentMesh;
  47528. }
  47529. }
  47530. declare module BABYLON {
  47531. /**
  47532. * A generic trigger-only motion controller for WebXR
  47533. */
  47534. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  47535. /**
  47536. * Static version of the profile id of this controller
  47537. */
  47538. static ProfileId: string;
  47539. profileId: string;
  47540. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  47541. protected _getFilenameAndPath(): {
  47542. filename: string;
  47543. path: string;
  47544. };
  47545. protected _getModelLoadingConstraints(): boolean;
  47546. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  47547. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47548. protected _updateModel(): void;
  47549. }
  47550. }
  47551. declare module BABYLON {
  47552. /**
  47553. * Class containing static functions to help procedurally build meshes
  47554. */
  47555. export class SphereBuilder {
  47556. /**
  47557. * Creates a sphere mesh
  47558. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47559. * * 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`)
  47560. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47561. * * 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
  47562. * * 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)
  47563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47564. * * 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
  47565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47566. * @param name defines the name of the mesh
  47567. * @param options defines the options used to create the mesh
  47568. * @param scene defines the hosting scene
  47569. * @returns the sphere mesh
  47570. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47571. */
  47572. static CreateSphere(name: string, options: {
  47573. segments?: number;
  47574. diameter?: number;
  47575. diameterX?: number;
  47576. diameterY?: number;
  47577. diameterZ?: number;
  47578. arc?: number;
  47579. slice?: number;
  47580. sideOrientation?: number;
  47581. frontUVs?: Vector4;
  47582. backUVs?: Vector4;
  47583. updatable?: boolean;
  47584. }, scene?: Nullable<Scene>): Mesh;
  47585. }
  47586. }
  47587. declare module BABYLON {
  47588. /**
  47589. * A profiled motion controller has its profile loaded from an online repository.
  47590. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  47591. */
  47592. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  47593. private _repositoryUrl;
  47594. private _buttonMeshMapping;
  47595. private _touchDots;
  47596. /**
  47597. * The profile ID of this controller. Will be populated when the controller initializes.
  47598. */
  47599. profileId: string;
  47600. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  47601. dispose(): void;
  47602. protected _getFilenameAndPath(): {
  47603. filename: string;
  47604. path: string;
  47605. };
  47606. protected _getModelLoadingConstraints(): boolean;
  47607. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  47608. protected _setRootMesh(meshes: AbstractMesh[]): void;
  47609. protected _updateModel(_xrFrame: XRFrame): void;
  47610. }
  47611. }
  47612. declare module BABYLON {
  47613. /**
  47614. * A construction function type to create a new controller based on an xrInput object
  47615. */
  47616. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  47617. /**
  47618. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  47619. *
  47620. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  47621. * it should be replaced with auto-loaded controllers.
  47622. *
  47623. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  47624. */
  47625. export class WebXRMotionControllerManager {
  47626. private static _AvailableControllers;
  47627. private static _Fallbacks;
  47628. private static _ProfileLoadingPromises;
  47629. private static _ProfilesList;
  47630. /**
  47631. * The base URL of the online controller repository. Can be changed at any time.
  47632. */
  47633. static BaseRepositoryUrl: string;
  47634. /**
  47635. * Which repository gets priority - local or online
  47636. */
  47637. static PrioritizeOnlineRepository: boolean;
  47638. /**
  47639. * Use the online repository, or use only locally-defined controllers
  47640. */
  47641. static UseOnlineRepository: boolean;
  47642. /**
  47643. * Clear the cache used for profile loading and reload when requested again
  47644. */
  47645. static ClearProfilesCache(): void;
  47646. /**
  47647. * Register the default fallbacks.
  47648. * This function is called automatically when this file is imported.
  47649. */
  47650. static DefaultFallbacks(): void;
  47651. /**
  47652. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  47653. * @param profileId the profile to which a fallback needs to be found
  47654. * @return an array with corresponding fallback profiles
  47655. */
  47656. static FindFallbackWithProfileId(profileId: string): string[];
  47657. /**
  47658. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  47659. * The order of search:
  47660. *
  47661. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  47662. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  47663. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  47664. * 4) return the generic trigger controller if none were found
  47665. *
  47666. * @param xrInput the xrInput to which a new controller is initialized
  47667. * @param scene the scene to which the model will be added
  47668. * @param forceProfile force a certain profile for this controller
  47669. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  47670. */
  47671. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  47672. /**
  47673. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  47674. *
  47675. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  47676. *
  47677. * @param type the profile type to register
  47678. * @param constructFunction the function to be called when loading this profile
  47679. */
  47680. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  47681. /**
  47682. * Register a fallback to a specific profile.
  47683. * @param profileId the profileId that will receive the fallbacks
  47684. * @param fallbacks A list of fallback profiles
  47685. */
  47686. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  47687. /**
  47688. * Will update the list of profiles available in the repository
  47689. * @return a promise that resolves to a map of profiles available online
  47690. */
  47691. static UpdateProfilesList(): Promise<{
  47692. [profile: string]: string;
  47693. }>;
  47694. private static _LoadProfileFromRepository;
  47695. private static _LoadProfilesFromAvailableControllers;
  47696. }
  47697. }
  47698. declare module BABYLON {
  47699. /**
  47700. * Configuration options for the WebXR controller creation
  47701. */
  47702. export interface IWebXRControllerOptions {
  47703. /**
  47704. * Should the controller mesh be animated when a user interacts with it
  47705. * The pressed buttons / thumbstick and touchpad animations will be disabled
  47706. */
  47707. disableMotionControllerAnimation?: boolean;
  47708. /**
  47709. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  47710. */
  47711. doNotLoadControllerMesh?: boolean;
  47712. /**
  47713. * Force a specific controller type for this controller.
  47714. * This can be used when creating your own profile or when testing different controllers
  47715. */
  47716. forceControllerProfile?: string;
  47717. /**
  47718. * Defines a rendering group ID for meshes that will be loaded.
  47719. * This is for the default controllers only.
  47720. */
  47721. renderingGroupId?: number;
  47722. }
  47723. /**
  47724. * Represents an XR controller
  47725. */
  47726. export class WebXRInputSource {
  47727. private _scene;
  47728. /** The underlying input source for the controller */
  47729. inputSource: XRInputSource;
  47730. private _options;
  47731. private _tmpVector;
  47732. private _uniqueId;
  47733. /**
  47734. * 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
  47735. */
  47736. grip?: AbstractMesh;
  47737. /**
  47738. * If available, this is the gamepad object related to this controller.
  47739. * Using this object it is possible to get click events and trackpad changes of the
  47740. * webxr controller that is currently being used.
  47741. */
  47742. motionController?: WebXRAbstractMotionController;
  47743. /**
  47744. * Event that fires when the controller is removed/disposed.
  47745. * The object provided as event data is this controller, after associated assets were disposed.
  47746. * uniqueId is still available.
  47747. */
  47748. onDisposeObservable: Observable<WebXRInputSource>;
  47749. /**
  47750. * Will be triggered when the mesh associated with the motion controller is done loading.
  47751. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  47752. * A shortened version of controller -> motion controller -> on mesh loaded.
  47753. */
  47754. onMeshLoadedObservable: Observable<AbstractMesh>;
  47755. /**
  47756. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  47757. */
  47758. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  47759. /**
  47760. * Pointer which can be used to select objects or attach a visible laser to
  47761. */
  47762. pointer: AbstractMesh;
  47763. /**
  47764. * Creates the input source object
  47765. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  47766. * @param _scene the scene which the controller should be associated to
  47767. * @param inputSource the underlying input source for the controller
  47768. * @param _options options for this controller creation
  47769. */
  47770. constructor(_scene: Scene,
  47771. /** The underlying input source for the controller */
  47772. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  47773. /**
  47774. * Get this controllers unique id
  47775. */
  47776. get uniqueId(): string;
  47777. /**
  47778. * Disposes of the object
  47779. */
  47780. dispose(): void;
  47781. /**
  47782. * Gets a world space ray coming from the pointer or grip
  47783. * @param result the resulting ray
  47784. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  47785. */
  47786. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  47787. /**
  47788. * Updates the controller pose based on the given XRFrame
  47789. * @param xrFrame xr frame to update the pose with
  47790. * @param referenceSpace reference space to use
  47791. */
  47792. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  47793. }
  47794. }
  47795. declare module BABYLON {
  47796. /**
  47797. * The schema for initialization options of the XR Input class
  47798. */
  47799. export interface IWebXRInputOptions {
  47800. /**
  47801. * If set to true no model will be automatically loaded
  47802. */
  47803. doNotLoadControllerMeshes?: boolean;
  47804. /**
  47805. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  47806. * If not found, the xr input profile data will be used.
  47807. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  47808. */
  47809. forceInputProfile?: string;
  47810. /**
  47811. * Do not send a request to the controller repository to load the profile.
  47812. *
  47813. * Instead, use the controllers available in babylon itself.
  47814. */
  47815. disableOnlineControllerRepository?: boolean;
  47816. /**
  47817. * A custom URL for the controllers repository
  47818. */
  47819. customControllersRepositoryURL?: string;
  47820. /**
  47821. * Should the controller model's components not move according to the user input
  47822. */
  47823. disableControllerAnimation?: boolean;
  47824. /**
  47825. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  47826. */
  47827. controllerOptions?: IWebXRControllerOptions;
  47828. }
  47829. /**
  47830. * XR input used to track XR inputs such as controllers/rays
  47831. */
  47832. export class WebXRInput implements IDisposable {
  47833. /**
  47834. * the xr session manager for this session
  47835. */
  47836. xrSessionManager: WebXRSessionManager;
  47837. /**
  47838. * the WebXR camera for this session. Mainly used for teleportation
  47839. */
  47840. xrCamera: WebXRCamera;
  47841. private readonly options;
  47842. /**
  47843. * XR controllers being tracked
  47844. */
  47845. controllers: Array<WebXRInputSource>;
  47846. private _frameObserver;
  47847. private _sessionEndedObserver;
  47848. private _sessionInitObserver;
  47849. /**
  47850. * Event when a controller has been connected/added
  47851. */
  47852. onControllerAddedObservable: Observable<WebXRInputSource>;
  47853. /**
  47854. * Event when a controller has been removed/disconnected
  47855. */
  47856. onControllerRemovedObservable: Observable<WebXRInputSource>;
  47857. /**
  47858. * Initializes the WebXRInput
  47859. * @param xrSessionManager the xr session manager for this session
  47860. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  47861. * @param options = initialization options for this xr input
  47862. */
  47863. constructor(
  47864. /**
  47865. * the xr session manager for this session
  47866. */
  47867. xrSessionManager: WebXRSessionManager,
  47868. /**
  47869. * the WebXR camera for this session. Mainly used for teleportation
  47870. */
  47871. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  47872. private _onInputSourcesChange;
  47873. private _addAndRemoveControllers;
  47874. /**
  47875. * Disposes of the object
  47876. */
  47877. dispose(): void;
  47878. }
  47879. }
  47880. declare module BABYLON {
  47881. /**
  47882. * This is the base class for all WebXR features.
  47883. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  47884. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  47885. */
  47886. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  47887. protected _xrSessionManager: WebXRSessionManager;
  47888. private _attached;
  47889. private _removeOnDetach;
  47890. /**
  47891. * Should auto-attach be disabled?
  47892. */
  47893. disableAutoAttach: boolean;
  47894. /**
  47895. * Construct a new (abstract) WebXR feature
  47896. * @param _xrSessionManager the xr session manager for this feature
  47897. */
  47898. constructor(_xrSessionManager: WebXRSessionManager);
  47899. /**
  47900. * Is this feature attached
  47901. */
  47902. get attached(): boolean;
  47903. /**
  47904. * attach this feature
  47905. *
  47906. * @param force should attachment be forced (even when already attached)
  47907. * @returns true if successful, false is failed or already attached
  47908. */
  47909. attach(force?: boolean): boolean;
  47910. /**
  47911. * detach this feature.
  47912. *
  47913. * @returns true if successful, false if failed or already detached
  47914. */
  47915. detach(): boolean;
  47916. /**
  47917. * Dispose this feature and all of the resources attached
  47918. */
  47919. dispose(): void;
  47920. /**
  47921. * This is used to register callbacks that will automatically be removed when detach is called.
  47922. * @param observable the observable to which the observer will be attached
  47923. * @param callback the callback to register
  47924. */
  47925. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  47926. /**
  47927. * Code in this function will be executed on each xrFrame received from the browser.
  47928. * This function will not execute after the feature is detached.
  47929. * @param _xrFrame the current frame
  47930. */
  47931. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  47932. }
  47933. }
  47934. declare module BABYLON {
  47935. /**
  47936. * Renders a layer on top of an existing scene
  47937. */
  47938. export class UtilityLayerRenderer implements IDisposable {
  47939. /** the original scene that will be rendered on top of */
  47940. originalScene: Scene;
  47941. private _pointerCaptures;
  47942. private _lastPointerEvents;
  47943. private static _DefaultUtilityLayer;
  47944. private static _DefaultKeepDepthUtilityLayer;
  47945. private _sharedGizmoLight;
  47946. private _renderCamera;
  47947. /**
  47948. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  47949. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  47950. * @returns the camera that is used when rendering the utility layer
  47951. */
  47952. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  47953. /**
  47954. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  47955. * @param cam the camera that should be used when rendering the utility layer
  47956. */
  47957. setRenderCamera(cam: Nullable<Camera>): void;
  47958. /**
  47959. * @hidden
  47960. * Light which used by gizmos to get light shading
  47961. */
  47962. _getSharedGizmoLight(): HemisphericLight;
  47963. /**
  47964. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  47965. */
  47966. pickUtilitySceneFirst: boolean;
  47967. /**
  47968. * 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)
  47969. */
  47970. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  47971. /**
  47972. * 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)
  47973. */
  47974. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  47975. /**
  47976. * The scene that is rendered on top of the original scene
  47977. */
  47978. utilityLayerScene: Scene;
  47979. /**
  47980. * If the utility layer should automatically be rendered on top of existing scene
  47981. */
  47982. shouldRender: boolean;
  47983. /**
  47984. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  47985. */
  47986. onlyCheckPointerDownEvents: boolean;
  47987. /**
  47988. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  47989. */
  47990. processAllEvents: boolean;
  47991. /**
  47992. * Observable raised when the pointer move from the utility layer scene to the main scene
  47993. */
  47994. onPointerOutObservable: Observable<number>;
  47995. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  47996. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  47997. private _afterRenderObserver;
  47998. private _sceneDisposeObserver;
  47999. private _originalPointerObserver;
  48000. /**
  48001. * Instantiates a UtilityLayerRenderer
  48002. * @param originalScene the original scene that will be rendered on top of
  48003. * @param handleEvents boolean indicating if the utility layer should handle events
  48004. */
  48005. constructor(
  48006. /** the original scene that will be rendered on top of */
  48007. originalScene: Scene, handleEvents?: boolean);
  48008. private _notifyObservers;
  48009. /**
  48010. * Renders the utility layers scene on top of the original scene
  48011. */
  48012. render(): void;
  48013. /**
  48014. * Disposes of the renderer
  48015. */
  48016. dispose(): void;
  48017. private _updateCamera;
  48018. }
  48019. }
  48020. declare module BABYLON {
  48021. /**
  48022. * Options interface for the pointer selection module
  48023. */
  48024. export interface IWebXRControllerPointerSelectionOptions {
  48025. /**
  48026. * if provided, this scene will be used to render meshes.
  48027. */
  48028. customUtilityLayerScene?: Scene;
  48029. /**
  48030. * 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)
  48031. * If not disabled, the last picked point will be used to execute a pointer up event
  48032. * If disabled, pointer up event will be triggered right after the pointer down event.
  48033. * Used in screen and gaze target ray mode only
  48034. */
  48035. disablePointerUpOnTouchOut: boolean;
  48036. /**
  48037. * For gaze mode (time to select instead of press)
  48038. */
  48039. forceGazeMode: boolean;
  48040. /**
  48041. * 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
  48042. * to start a new countdown to the pointer down event.
  48043. * Defaults to 1.
  48044. */
  48045. gazeModePointerMovedFactor?: number;
  48046. /**
  48047. * Different button type to use instead of the main component
  48048. */
  48049. overrideButtonId?: string;
  48050. /**
  48051. * use this rendering group id for the meshes (optional)
  48052. */
  48053. renderingGroupId?: number;
  48054. /**
  48055. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48056. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48057. * 3000 means 3 seconds between pointing at something and selecting it
  48058. */
  48059. timeToSelect?: number;
  48060. /**
  48061. * Should meshes created here be added to a utility layer or the main scene
  48062. */
  48063. useUtilityLayer?: boolean;
  48064. /**
  48065. * the xr input to use with this pointer selection
  48066. */
  48067. xrInput: WebXRInput;
  48068. }
  48069. /**
  48070. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48071. */
  48072. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48073. private readonly _options;
  48074. private static _idCounter;
  48075. private _attachController;
  48076. private _controllers;
  48077. private _scene;
  48078. private _tmpVectorForPickCompare;
  48079. /**
  48080. * The module's name
  48081. */
  48082. static readonly Name: string;
  48083. /**
  48084. * The (Babylon) version of this module.
  48085. * This is an integer representing the implementation version.
  48086. * This number does not correspond to the WebXR specs version
  48087. */
  48088. static readonly Version: number;
  48089. /**
  48090. * Disable lighting on the laser pointer (so it will always be visible)
  48091. */
  48092. disablePointerLighting: boolean;
  48093. /**
  48094. * Disable lighting on the selection mesh (so it will always be visible)
  48095. */
  48096. disableSelectionMeshLighting: boolean;
  48097. /**
  48098. * Should the laser pointer be displayed
  48099. */
  48100. displayLaserPointer: boolean;
  48101. /**
  48102. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48103. */
  48104. displaySelectionMesh: boolean;
  48105. /**
  48106. * This color will be set to the laser pointer when selection is triggered
  48107. */
  48108. laserPointerPickedColor: Color3;
  48109. /**
  48110. * Default color of the laser pointer
  48111. */
  48112. laserPointerDefaultColor: Color3;
  48113. /**
  48114. * default color of the selection ring
  48115. */
  48116. selectionMeshDefaultColor: Color3;
  48117. /**
  48118. * This color will be applied to the selection ring when selection is triggered
  48119. */
  48120. selectionMeshPickedColor: Color3;
  48121. /**
  48122. * Optional filter to be used for ray selection. This predicate shares behavior with
  48123. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48124. */
  48125. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48126. /**
  48127. * constructs a new background remover module
  48128. * @param _xrSessionManager the session manager for this module
  48129. * @param _options read-only options to be used in this module
  48130. */
  48131. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48132. /**
  48133. * attach this feature
  48134. * Will usually be called by the features manager
  48135. *
  48136. * @returns true if successful.
  48137. */
  48138. attach(): boolean;
  48139. /**
  48140. * detach this feature.
  48141. * Will usually be called by the features manager
  48142. *
  48143. * @returns true if successful.
  48144. */
  48145. detach(): boolean;
  48146. /**
  48147. * Will get the mesh under a specific pointer.
  48148. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48149. * @param controllerId the controllerId to check
  48150. * @returns The mesh under pointer or null if no mesh is under the pointer
  48151. */
  48152. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48153. /**
  48154. * Get the xr controller that correlates to the pointer id in the pointer event
  48155. *
  48156. * @param id the pointer id to search for
  48157. * @returns the controller that correlates to this id or null if not found
  48158. */
  48159. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48160. protected _onXRFrame(_xrFrame: XRFrame): void;
  48161. private _attachGazeMode;
  48162. private _attachScreenRayMode;
  48163. private _attachTrackedPointerRayMode;
  48164. private _convertNormalToDirectionOfRay;
  48165. private _detachController;
  48166. private _generateNewMeshPair;
  48167. private _pickingMoved;
  48168. private _updatePointerDistance;
  48169. /** @hidden */
  48170. get lasterPointerDefaultColor(): Color3;
  48171. }
  48172. }
  48173. declare module BABYLON {
  48174. /**
  48175. * Button which can be used to enter a different mode of XR
  48176. */
  48177. export class WebXREnterExitUIButton {
  48178. /** button element */
  48179. element: HTMLElement;
  48180. /** XR initialization options for the button */
  48181. sessionMode: XRSessionMode;
  48182. /** Reference space type */
  48183. referenceSpaceType: XRReferenceSpaceType;
  48184. /**
  48185. * Creates a WebXREnterExitUIButton
  48186. * @param element button element
  48187. * @param sessionMode XR initialization session mode
  48188. * @param referenceSpaceType the type of reference space to be used
  48189. */
  48190. constructor(
  48191. /** button element */
  48192. element: HTMLElement,
  48193. /** XR initialization options for the button */
  48194. sessionMode: XRSessionMode,
  48195. /** Reference space type */
  48196. referenceSpaceType: XRReferenceSpaceType);
  48197. /**
  48198. * Extendable function which can be used to update the button's visuals when the state changes
  48199. * @param activeButton the current active button in the UI
  48200. */
  48201. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48202. }
  48203. /**
  48204. * Options to create the webXR UI
  48205. */
  48206. export class WebXREnterExitUIOptions {
  48207. /**
  48208. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48209. */
  48210. customButtons?: Array<WebXREnterExitUIButton>;
  48211. /**
  48212. * A reference space type to use when creating the default button.
  48213. * Default is local-floor
  48214. */
  48215. referenceSpaceType?: XRReferenceSpaceType;
  48216. /**
  48217. * Context to enter xr with
  48218. */
  48219. renderTarget?: Nullable<WebXRRenderTarget>;
  48220. /**
  48221. * A session mode to use when creating the default button.
  48222. * Default is immersive-vr
  48223. */
  48224. sessionMode?: XRSessionMode;
  48225. /**
  48226. * A list of optional features to init the session with
  48227. */
  48228. optionalFeatures?: string[];
  48229. /**
  48230. * A list of optional features to init the session with
  48231. */
  48232. requiredFeatures?: string[];
  48233. }
  48234. /**
  48235. * UI to allow the user to enter/exit XR mode
  48236. */
  48237. export class WebXREnterExitUI implements IDisposable {
  48238. private scene;
  48239. /** version of the options passed to this UI */
  48240. options: WebXREnterExitUIOptions;
  48241. private _activeButton;
  48242. private _buttons;
  48243. private _overlay;
  48244. /**
  48245. * Fired every time the active button is changed.
  48246. *
  48247. * When xr is entered via a button that launches xr that button will be the callback parameter
  48248. *
  48249. * When exiting xr the callback parameter will be null)
  48250. */
  48251. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48252. /**
  48253. *
  48254. * @param scene babylon scene object to use
  48255. * @param options (read-only) version of the options passed to this UI
  48256. */
  48257. private constructor();
  48258. /**
  48259. * Creates UI to allow the user to enter/exit XR mode
  48260. * @param scene the scene to add the ui to
  48261. * @param helper the xr experience helper to enter/exit xr with
  48262. * @param options options to configure the UI
  48263. * @returns the created ui
  48264. */
  48265. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48266. /**
  48267. * Disposes of the XR UI component
  48268. */
  48269. dispose(): void;
  48270. private _updateButtons;
  48271. }
  48272. }
  48273. declare module BABYLON {
  48274. /**
  48275. * Class containing static functions to help procedurally build meshes
  48276. */
  48277. export class LinesBuilder {
  48278. /**
  48279. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48280. * * 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
  48281. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48282. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48283. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48284. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48285. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48286. * * 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
  48287. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48290. * @param name defines the name of the new line system
  48291. * @param options defines the options used to create the line system
  48292. * @param scene defines the hosting scene
  48293. * @returns a new line system mesh
  48294. */
  48295. static CreateLineSystem(name: string, options: {
  48296. lines: Vector3[][];
  48297. updatable?: boolean;
  48298. instance?: Nullable<LinesMesh>;
  48299. colors?: Nullable<Color4[][]>;
  48300. useVertexAlpha?: boolean;
  48301. }, scene: Nullable<Scene>): LinesMesh;
  48302. /**
  48303. * Creates a line mesh
  48304. * 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
  48305. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48306. * * The parameter `points` is an array successive Vector3
  48307. * * 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
  48308. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48309. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48310. * * When updating an instance, remember that only point positions can change, not the number of points
  48311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48313. * @param name defines the name of the new line system
  48314. * @param options defines the options used to create the line system
  48315. * @param scene defines the hosting scene
  48316. * @returns a new line mesh
  48317. */
  48318. static CreateLines(name: string, options: {
  48319. points: Vector3[];
  48320. updatable?: boolean;
  48321. instance?: Nullable<LinesMesh>;
  48322. colors?: Color4[];
  48323. useVertexAlpha?: boolean;
  48324. }, scene?: Nullable<Scene>): LinesMesh;
  48325. /**
  48326. * Creates a dashed line mesh
  48327. * * 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
  48328. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48329. * * The parameter `points` is an array successive Vector3
  48330. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48331. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48332. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48333. * * 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
  48334. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48335. * * When updating an instance, remember that only point positions can change, not the number of points
  48336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48337. * @param name defines the name of the mesh
  48338. * @param options defines the options used to create the mesh
  48339. * @param scene defines the hosting scene
  48340. * @returns the dashed line mesh
  48341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48342. */
  48343. static CreateDashedLines(name: string, options: {
  48344. points: Vector3[];
  48345. dashSize?: number;
  48346. gapSize?: number;
  48347. dashNb?: number;
  48348. updatable?: boolean;
  48349. instance?: LinesMesh;
  48350. useVertexAlpha?: boolean;
  48351. }, scene?: Nullable<Scene>): LinesMesh;
  48352. }
  48353. }
  48354. declare module BABYLON {
  48355. /**
  48356. * Construction options for a timer
  48357. */
  48358. export interface ITimerOptions<T> {
  48359. /**
  48360. * Time-to-end
  48361. */
  48362. timeout: number;
  48363. /**
  48364. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48365. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48366. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48367. */
  48368. contextObservable: Observable<T>;
  48369. /**
  48370. * Optional parameters when adding an observer to the observable
  48371. */
  48372. observableParameters?: {
  48373. mask?: number;
  48374. insertFirst?: boolean;
  48375. scope?: any;
  48376. };
  48377. /**
  48378. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48379. */
  48380. breakCondition?: (data?: ITimerData<T>) => boolean;
  48381. /**
  48382. * Will be triggered when the time condition has met
  48383. */
  48384. onEnded?: (data: ITimerData<any>) => void;
  48385. /**
  48386. * Will be triggered when the break condition has met (prematurely ended)
  48387. */
  48388. onAborted?: (data: ITimerData<any>) => void;
  48389. /**
  48390. * Optional function to execute on each tick (or count)
  48391. */
  48392. onTick?: (data: ITimerData<any>) => void;
  48393. }
  48394. /**
  48395. * An interface defining the data sent by the timer
  48396. */
  48397. export interface ITimerData<T> {
  48398. /**
  48399. * When did it start
  48400. */
  48401. startTime: number;
  48402. /**
  48403. * Time now
  48404. */
  48405. currentTime: number;
  48406. /**
  48407. * Time passed since started
  48408. */
  48409. deltaTime: number;
  48410. /**
  48411. * How much is completed, in [0.0...1.0].
  48412. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48413. */
  48414. completeRate: number;
  48415. /**
  48416. * What the registered observable sent in the last count
  48417. */
  48418. payload: T;
  48419. }
  48420. /**
  48421. * The current state of the timer
  48422. */
  48423. export enum TimerState {
  48424. /**
  48425. * Timer initialized, not yet started
  48426. */
  48427. INIT = 0,
  48428. /**
  48429. * Timer started and counting
  48430. */
  48431. STARTED = 1,
  48432. /**
  48433. * Timer ended (whether aborted or time reached)
  48434. */
  48435. ENDED = 2
  48436. }
  48437. /**
  48438. * A simple version of the timer. Will take options and start the timer immediately after calling it
  48439. *
  48440. * @param options options with which to initialize this timer
  48441. */
  48442. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  48443. /**
  48444. * An advanced implementation of a timer class
  48445. */
  48446. export class AdvancedTimer<T = any> implements IDisposable {
  48447. /**
  48448. * Will notify each time the timer calculates the remaining time
  48449. */
  48450. onEachCountObservable: Observable<ITimerData<T>>;
  48451. /**
  48452. * Will trigger when the timer was aborted due to the break condition
  48453. */
  48454. onTimerAbortedObservable: Observable<ITimerData<T>>;
  48455. /**
  48456. * Will trigger when the timer ended successfully
  48457. */
  48458. onTimerEndedObservable: Observable<ITimerData<T>>;
  48459. /**
  48460. * Will trigger when the timer state has changed
  48461. */
  48462. onStateChangedObservable: Observable<TimerState>;
  48463. private _observer;
  48464. private _contextObservable;
  48465. private _observableParameters;
  48466. private _startTime;
  48467. private _timer;
  48468. private _state;
  48469. private _breakCondition;
  48470. private _timeToEnd;
  48471. private _breakOnNextTick;
  48472. /**
  48473. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  48474. * @param options construction options for this advanced timer
  48475. */
  48476. constructor(options: ITimerOptions<T>);
  48477. /**
  48478. * set a breaking condition for this timer. Default is to never break during count
  48479. * @param predicate the new break condition. Returns true to break, false otherwise
  48480. */
  48481. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  48482. /**
  48483. * Reset ALL associated observables in this advanced timer
  48484. */
  48485. clearObservables(): void;
  48486. /**
  48487. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  48488. *
  48489. * @param timeToEnd how much time to measure until timer ended
  48490. */
  48491. start(timeToEnd?: number): void;
  48492. /**
  48493. * Will force a stop on the next tick.
  48494. */
  48495. stop(): void;
  48496. /**
  48497. * Dispose this timer, clearing all resources
  48498. */
  48499. dispose(): void;
  48500. private _setState;
  48501. private _tick;
  48502. private _stop;
  48503. }
  48504. }
  48505. declare module BABYLON {
  48506. /**
  48507. * The options container for the teleportation module
  48508. */
  48509. export interface IWebXRTeleportationOptions {
  48510. /**
  48511. * if provided, this scene will be used to render meshes.
  48512. */
  48513. customUtilityLayerScene?: Scene;
  48514. /**
  48515. * Values to configure the default target mesh
  48516. */
  48517. defaultTargetMeshOptions?: {
  48518. /**
  48519. * Fill color of the teleportation area
  48520. */
  48521. teleportationFillColor?: string;
  48522. /**
  48523. * Border color for the teleportation area
  48524. */
  48525. teleportationBorderColor?: string;
  48526. /**
  48527. * Disable the mesh's animation sequence
  48528. */
  48529. disableAnimation?: boolean;
  48530. /**
  48531. * Disable lighting on the material or the ring and arrow
  48532. */
  48533. disableLighting?: boolean;
  48534. /**
  48535. * Override the default material of the torus and arrow
  48536. */
  48537. torusArrowMaterial?: Material;
  48538. };
  48539. /**
  48540. * A list of meshes to use as floor meshes.
  48541. * Meshes can be added and removed after initializing the feature using the
  48542. * addFloorMesh and removeFloorMesh functions
  48543. * If empty, rotation will still work
  48544. */
  48545. floorMeshes?: AbstractMesh[];
  48546. /**
  48547. * use this rendering group id for the meshes (optional)
  48548. */
  48549. renderingGroupId?: number;
  48550. /**
  48551. * Should teleportation move only to snap points
  48552. */
  48553. snapPointsOnly?: boolean;
  48554. /**
  48555. * An array of points to which the teleportation will snap to.
  48556. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  48557. */
  48558. snapPositions?: Vector3[];
  48559. /**
  48560. * How close should the teleportation ray be in order to snap to position.
  48561. * Default to 0.8 units (meters)
  48562. */
  48563. snapToPositionRadius?: number;
  48564. /**
  48565. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  48566. * If you want to support rotation, make sure your mesh has a direction indicator.
  48567. *
  48568. * When left untouched, the default mesh will be initialized.
  48569. */
  48570. teleportationTargetMesh?: AbstractMesh;
  48571. /**
  48572. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  48573. */
  48574. timeToTeleport?: number;
  48575. /**
  48576. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  48577. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  48578. */
  48579. useMainComponentOnly?: boolean;
  48580. /**
  48581. * Should meshes created here be added to a utility layer or the main scene
  48582. */
  48583. useUtilityLayer?: boolean;
  48584. /**
  48585. * Babylon XR Input class for controller
  48586. */
  48587. xrInput: WebXRInput;
  48588. }
  48589. /**
  48590. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  48591. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  48592. * the input of the attached controllers.
  48593. */
  48594. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  48595. private _options;
  48596. private _controllers;
  48597. private _currentTeleportationControllerId;
  48598. private _floorMeshes;
  48599. private _quadraticBezierCurve;
  48600. private _selectionFeature;
  48601. private _snapToPositions;
  48602. private _snappedToPoint;
  48603. private _teleportationRingMaterial?;
  48604. private _tmpRay;
  48605. private _tmpVector;
  48606. /**
  48607. * The module's name
  48608. */
  48609. static readonly Name: string;
  48610. /**
  48611. * The (Babylon) version of this module.
  48612. * This is an integer representing the implementation version.
  48613. * This number does not correspond to the webxr specs version
  48614. */
  48615. static readonly Version: number;
  48616. /**
  48617. * Is movement backwards enabled
  48618. */
  48619. backwardsMovementEnabled: boolean;
  48620. /**
  48621. * Distance to travel when moving backwards
  48622. */
  48623. backwardsTeleportationDistance: number;
  48624. /**
  48625. * The distance from the user to the inspection point in the direction of the controller
  48626. * A higher number will allow the user to move further
  48627. * defaults to 5 (meters, in xr units)
  48628. */
  48629. parabolicCheckRadius: number;
  48630. /**
  48631. * Should the module support parabolic ray on top of direct ray
  48632. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  48633. * Very helpful when moving between floors / different heights
  48634. */
  48635. parabolicRayEnabled: boolean;
  48636. /**
  48637. * How much rotation should be applied when rotating right and left
  48638. */
  48639. rotationAngle: number;
  48640. /**
  48641. * Is rotation enabled when moving forward?
  48642. * Disabling this feature will prevent the user from deciding the direction when teleporting
  48643. */
  48644. rotationEnabled: boolean;
  48645. /**
  48646. * constructs a new anchor system
  48647. * @param _xrSessionManager an instance of WebXRSessionManager
  48648. * @param _options configuration object for this feature
  48649. */
  48650. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  48651. /**
  48652. * Get the snapPointsOnly flag
  48653. */
  48654. get snapPointsOnly(): boolean;
  48655. /**
  48656. * Sets the snapPointsOnly flag
  48657. * @param snapToPoints should teleportation be exclusively to snap points
  48658. */
  48659. set snapPointsOnly(snapToPoints: boolean);
  48660. /**
  48661. * Add a new mesh to the floor meshes array
  48662. * @param mesh the mesh to use as floor mesh
  48663. */
  48664. addFloorMesh(mesh: AbstractMesh): void;
  48665. /**
  48666. * Add a new snap-to point to fix teleportation to this position
  48667. * @param newSnapPoint The new Snap-To point
  48668. */
  48669. addSnapPoint(newSnapPoint: Vector3): void;
  48670. attach(): boolean;
  48671. detach(): boolean;
  48672. dispose(): void;
  48673. /**
  48674. * Remove a mesh from the floor meshes array
  48675. * @param mesh the mesh to remove
  48676. */
  48677. removeFloorMesh(mesh: AbstractMesh): void;
  48678. /**
  48679. * Remove a mesh from the floor meshes array using its name
  48680. * @param name the mesh name to remove
  48681. */
  48682. removeFloorMeshByName(name: string): void;
  48683. /**
  48684. * 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
  48685. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  48686. * @returns was the point found and removed or not
  48687. */
  48688. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  48689. /**
  48690. * This function sets a selection feature that will be disabled when
  48691. * the forward ray is shown and will be reattached when hidden.
  48692. * This is used to remove the selection rays when moving.
  48693. * @param selectionFeature the feature to disable when forward movement is enabled
  48694. */
  48695. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  48696. protected _onXRFrame(_xrFrame: XRFrame): void;
  48697. private _attachController;
  48698. private _createDefaultTargetMesh;
  48699. private _detachController;
  48700. private _findClosestSnapPointWithRadius;
  48701. private _setTargetMeshPosition;
  48702. private _setTargetMeshVisibility;
  48703. private _showParabolicPath;
  48704. private _teleportForward;
  48705. }
  48706. }
  48707. declare module BABYLON {
  48708. /**
  48709. * Options for the default xr helper
  48710. */
  48711. export class WebXRDefaultExperienceOptions {
  48712. /**
  48713. * Enable or disable default UI to enter XR
  48714. */
  48715. disableDefaultUI?: boolean;
  48716. /**
  48717. * Should teleportation not initialize. defaults to false.
  48718. */
  48719. disableTeleportation?: boolean;
  48720. /**
  48721. * Floor meshes that will be used for teleport
  48722. */
  48723. floorMeshes?: Array<AbstractMesh>;
  48724. /**
  48725. * If set to true, the first frame will not be used to reset position
  48726. * The first frame is mainly used when copying transformation from the old camera
  48727. * Mainly used in AR
  48728. */
  48729. ignoreNativeCameraTransformation?: boolean;
  48730. /**
  48731. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  48732. */
  48733. inputOptions?: IWebXRInputOptions;
  48734. /**
  48735. * optional configuration for the output canvas
  48736. */
  48737. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  48738. /**
  48739. * optional UI options. This can be used among other to change session mode and reference space type
  48740. */
  48741. uiOptions?: WebXREnterExitUIOptions;
  48742. /**
  48743. * When loading teleportation and pointer select, use stable versions instead of latest.
  48744. */
  48745. useStablePlugins?: boolean;
  48746. /**
  48747. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  48748. */
  48749. renderingGroupId?: number;
  48750. /**
  48751. * A list of optional features to init the session with
  48752. * If set to true, all features we support will be added
  48753. */
  48754. optionalFeatures?: boolean | string[];
  48755. }
  48756. /**
  48757. * Default experience which provides a similar setup to the previous webVRExperience
  48758. */
  48759. export class WebXRDefaultExperience {
  48760. /**
  48761. * Base experience
  48762. */
  48763. baseExperience: WebXRExperienceHelper;
  48764. /**
  48765. * Enables ui for entering/exiting xr
  48766. */
  48767. enterExitUI: WebXREnterExitUI;
  48768. /**
  48769. * Input experience extension
  48770. */
  48771. input: WebXRInput;
  48772. /**
  48773. * Enables laser pointer and selection
  48774. */
  48775. pointerSelection: WebXRControllerPointerSelection;
  48776. /**
  48777. * Default target xr should render to
  48778. */
  48779. renderTarget: WebXRRenderTarget;
  48780. /**
  48781. * Enables teleportation
  48782. */
  48783. teleportation: WebXRMotionControllerTeleportation;
  48784. private constructor();
  48785. /**
  48786. * Creates the default xr experience
  48787. * @param scene scene
  48788. * @param options options for basic configuration
  48789. * @returns resulting WebXRDefaultExperience
  48790. */
  48791. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  48792. /**
  48793. * DIsposes of the experience helper
  48794. */
  48795. dispose(): void;
  48796. }
  48797. }
  48798. declare module BABYLON {
  48799. /**
  48800. * Options to modify the vr teleportation behavior.
  48801. */
  48802. export interface VRTeleportationOptions {
  48803. /**
  48804. * The name of the mesh which should be used as the teleportation floor. (default: null)
  48805. */
  48806. floorMeshName?: string;
  48807. /**
  48808. * A list of meshes to be used as the teleportation floor. (default: empty)
  48809. */
  48810. floorMeshes?: Mesh[];
  48811. /**
  48812. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  48813. */
  48814. teleportationMode?: number;
  48815. /**
  48816. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  48817. */
  48818. teleportationTime?: number;
  48819. /**
  48820. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  48821. */
  48822. teleportationSpeed?: number;
  48823. /**
  48824. * The easing function used in the animation or null for Linear. (default CircleEase)
  48825. */
  48826. easingFunction?: EasingFunction;
  48827. }
  48828. /**
  48829. * Options to modify the vr experience helper's behavior.
  48830. */
  48831. export interface VRExperienceHelperOptions extends WebVROptions {
  48832. /**
  48833. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  48834. */
  48835. createDeviceOrientationCamera?: boolean;
  48836. /**
  48837. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  48838. */
  48839. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  48840. /**
  48841. * Uses the main button on the controller to toggle the laser casted. (default: true)
  48842. */
  48843. laserToggle?: boolean;
  48844. /**
  48845. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  48846. */
  48847. floorMeshes?: Mesh[];
  48848. /**
  48849. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  48850. */
  48851. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  48852. /**
  48853. * Defines if WebXR should be used instead of WebVR (if available)
  48854. */
  48855. useXR?: boolean;
  48856. }
  48857. /**
  48858. * Event containing information after VR has been entered
  48859. */
  48860. export class OnAfterEnteringVRObservableEvent {
  48861. /**
  48862. * If entering vr was successful
  48863. */
  48864. success: boolean;
  48865. }
  48866. /**
  48867. * Helps to quickly add VR support to an existing scene.
  48868. * See https://doc.babylonjs.com/how_to/webvr_helper
  48869. */
  48870. export class VRExperienceHelper {
  48871. /** Options to modify the vr experience helper's behavior. */
  48872. webVROptions: VRExperienceHelperOptions;
  48873. private _scene;
  48874. private _position;
  48875. private _btnVR;
  48876. private _btnVRDisplayed;
  48877. private _webVRsupported;
  48878. private _webVRready;
  48879. private _webVRrequesting;
  48880. private _webVRpresenting;
  48881. private _hasEnteredVR;
  48882. private _fullscreenVRpresenting;
  48883. private _inputElement;
  48884. private _webVRCamera;
  48885. private _vrDeviceOrientationCamera;
  48886. private _deviceOrientationCamera;
  48887. private _existingCamera;
  48888. private _onKeyDown;
  48889. private _onVrDisplayPresentChange;
  48890. private _onVRDisplayChanged;
  48891. private _onVRRequestPresentStart;
  48892. private _onVRRequestPresentComplete;
  48893. /**
  48894. * 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)
  48895. */
  48896. enableGazeEvenWhenNoPointerLock: boolean;
  48897. /**
  48898. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  48899. */
  48900. exitVROnDoubleTap: boolean;
  48901. /**
  48902. * Observable raised right before entering VR.
  48903. */
  48904. onEnteringVRObservable: Observable<VRExperienceHelper>;
  48905. /**
  48906. * Observable raised when entering VR has completed.
  48907. */
  48908. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  48909. /**
  48910. * Observable raised when exiting VR.
  48911. */
  48912. onExitingVRObservable: Observable<VRExperienceHelper>;
  48913. /**
  48914. * Observable raised when controller mesh is loaded.
  48915. */
  48916. onControllerMeshLoadedObservable: Observable<WebVRController>;
  48917. /** Return this.onEnteringVRObservable
  48918. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  48919. */
  48920. get onEnteringVR(): Observable<VRExperienceHelper>;
  48921. /** Return this.onExitingVRObservable
  48922. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  48923. */
  48924. get onExitingVR(): Observable<VRExperienceHelper>;
  48925. /** Return this.onControllerMeshLoadedObservable
  48926. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  48927. */
  48928. get onControllerMeshLoaded(): Observable<WebVRController>;
  48929. private _rayLength;
  48930. private _useCustomVRButton;
  48931. private _teleportationRequested;
  48932. private _teleportActive;
  48933. private _floorMeshName;
  48934. private _floorMeshesCollection;
  48935. private _teleportationMode;
  48936. private _teleportationTime;
  48937. private _teleportationSpeed;
  48938. private _teleportationEasing;
  48939. private _rotationAllowed;
  48940. private _teleportBackwardsVector;
  48941. private _teleportationTarget;
  48942. private _isDefaultTeleportationTarget;
  48943. private _postProcessMove;
  48944. private _teleportationFillColor;
  48945. private _teleportationBorderColor;
  48946. private _rotationAngle;
  48947. private _haloCenter;
  48948. private _cameraGazer;
  48949. private _padSensibilityUp;
  48950. private _padSensibilityDown;
  48951. private _leftController;
  48952. private _rightController;
  48953. private _gazeColor;
  48954. private _laserColor;
  48955. private _pickedLaserColor;
  48956. private _pickedGazeColor;
  48957. /**
  48958. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  48959. */
  48960. onNewMeshSelected: Observable<AbstractMesh>;
  48961. /**
  48962. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  48963. * This observable will provide the mesh and the controller used to select the mesh
  48964. */
  48965. onMeshSelectedWithController: Observable<{
  48966. mesh: AbstractMesh;
  48967. controller: WebVRController;
  48968. }>;
  48969. /**
  48970. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  48971. */
  48972. onNewMeshPicked: Observable<PickingInfo>;
  48973. private _circleEase;
  48974. /**
  48975. * Observable raised before camera teleportation
  48976. */
  48977. onBeforeCameraTeleport: Observable<Vector3>;
  48978. /**
  48979. * Observable raised after camera teleportation
  48980. */
  48981. onAfterCameraTeleport: Observable<Vector3>;
  48982. /**
  48983. * Observable raised when current selected mesh gets unselected
  48984. */
  48985. onSelectedMeshUnselected: Observable<AbstractMesh>;
  48986. private _raySelectionPredicate;
  48987. /**
  48988. * To be optionaly changed by user to define custom ray selection
  48989. */
  48990. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48991. /**
  48992. * To be optionaly changed by user to define custom selection logic (after ray selection)
  48993. */
  48994. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48995. /**
  48996. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  48997. */
  48998. teleportationEnabled: boolean;
  48999. private _defaultHeight;
  49000. private _teleportationInitialized;
  49001. private _interactionsEnabled;
  49002. private _interactionsRequested;
  49003. private _displayGaze;
  49004. private _displayLaserPointer;
  49005. /**
  49006. * The mesh used to display where the user is going to teleport.
  49007. */
  49008. get teleportationTarget(): Mesh;
  49009. /**
  49010. * Sets the mesh to be used to display where the user is going to teleport.
  49011. */
  49012. set teleportationTarget(value: Mesh);
  49013. /**
  49014. * 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
  49015. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49016. * See https://doc.babylonjs.com/resources/baking_transformations
  49017. */
  49018. get gazeTrackerMesh(): Mesh;
  49019. set gazeTrackerMesh(value: Mesh);
  49020. /**
  49021. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49022. */
  49023. updateGazeTrackerScale: boolean;
  49024. /**
  49025. * If the gaze trackers color should be updated when selecting meshes
  49026. */
  49027. updateGazeTrackerColor: boolean;
  49028. /**
  49029. * If the controller laser color should be updated when selecting meshes
  49030. */
  49031. updateControllerLaserColor: boolean;
  49032. /**
  49033. * The gaze tracking mesh corresponding to the left controller
  49034. */
  49035. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49036. /**
  49037. * The gaze tracking mesh corresponding to the right controller
  49038. */
  49039. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49040. /**
  49041. * If the ray of the gaze should be displayed.
  49042. */
  49043. get displayGaze(): boolean;
  49044. /**
  49045. * Sets if the ray of the gaze should be displayed.
  49046. */
  49047. set displayGaze(value: boolean);
  49048. /**
  49049. * If the ray of the LaserPointer should be displayed.
  49050. */
  49051. get displayLaserPointer(): boolean;
  49052. /**
  49053. * Sets if the ray of the LaserPointer should be displayed.
  49054. */
  49055. set displayLaserPointer(value: boolean);
  49056. /**
  49057. * The deviceOrientationCamera used as the camera when not in VR.
  49058. */
  49059. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49060. /**
  49061. * Based on the current WebVR support, returns the current VR camera used.
  49062. */
  49063. get currentVRCamera(): Nullable<Camera>;
  49064. /**
  49065. * The webVRCamera which is used when in VR.
  49066. */
  49067. get webVRCamera(): WebVRFreeCamera;
  49068. /**
  49069. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49070. */
  49071. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49072. /**
  49073. * The html button that is used to trigger entering into VR.
  49074. */
  49075. get vrButton(): Nullable<HTMLButtonElement>;
  49076. private get _teleportationRequestInitiated();
  49077. /**
  49078. * Defines whether or not Pointer lock should be requested when switching to
  49079. * full screen.
  49080. */
  49081. requestPointerLockOnFullScreen: boolean;
  49082. /**
  49083. * If asking to force XR, this will be populated with the default xr experience
  49084. */
  49085. xr: WebXRDefaultExperience;
  49086. /**
  49087. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49088. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49089. */
  49090. xrTestDone: boolean;
  49091. /**
  49092. * Instantiates a VRExperienceHelper.
  49093. * Helps to quickly add VR support to an existing scene.
  49094. * @param scene The scene the VRExperienceHelper belongs to.
  49095. * @param webVROptions Options to modify the vr experience helper's behavior.
  49096. */
  49097. constructor(scene: Scene,
  49098. /** Options to modify the vr experience helper's behavior. */
  49099. webVROptions?: VRExperienceHelperOptions);
  49100. private completeVRInit;
  49101. private _onDefaultMeshLoaded;
  49102. private _onResize;
  49103. private _onFullscreenChange;
  49104. /**
  49105. * Gets a value indicating if we are currently in VR mode.
  49106. */
  49107. get isInVRMode(): boolean;
  49108. private onVrDisplayPresentChange;
  49109. private onVRDisplayChanged;
  49110. private moveButtonToBottomRight;
  49111. private displayVRButton;
  49112. private updateButtonVisibility;
  49113. private _cachedAngularSensibility;
  49114. /**
  49115. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49116. * Otherwise, will use the fullscreen API.
  49117. */
  49118. enterVR(): void;
  49119. /**
  49120. * Attempt to exit VR, or fullscreen.
  49121. */
  49122. exitVR(): void;
  49123. /**
  49124. * The position of the vr experience helper.
  49125. */
  49126. get position(): Vector3;
  49127. /**
  49128. * Sets the position of the vr experience helper.
  49129. */
  49130. set position(value: Vector3);
  49131. /**
  49132. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49133. */
  49134. enableInteractions(): void;
  49135. private get _noControllerIsActive();
  49136. private beforeRender;
  49137. private _isTeleportationFloor;
  49138. /**
  49139. * Adds a floor mesh to be used for teleportation.
  49140. * @param floorMesh the mesh to be used for teleportation.
  49141. */
  49142. addFloorMesh(floorMesh: Mesh): void;
  49143. /**
  49144. * Removes a floor mesh from being used for teleportation.
  49145. * @param floorMesh the mesh to be removed.
  49146. */
  49147. removeFloorMesh(floorMesh: Mesh): void;
  49148. /**
  49149. * Enables interactions and teleportation using the VR controllers and gaze.
  49150. * @param vrTeleportationOptions options to modify teleportation behavior.
  49151. */
  49152. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49153. private _onNewGamepadConnected;
  49154. private _tryEnableInteractionOnController;
  49155. private _onNewGamepadDisconnected;
  49156. private _enableInteractionOnController;
  49157. private _checkTeleportWithRay;
  49158. private _checkRotate;
  49159. private _checkTeleportBackwards;
  49160. private _enableTeleportationOnController;
  49161. private _createTeleportationCircles;
  49162. private _displayTeleportationTarget;
  49163. private _hideTeleportationTarget;
  49164. private _rotateCamera;
  49165. private _moveTeleportationSelectorTo;
  49166. private _workingVector;
  49167. private _workingQuaternion;
  49168. private _workingMatrix;
  49169. /**
  49170. * Time Constant Teleportation Mode
  49171. */
  49172. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49173. /**
  49174. * Speed Constant Teleportation Mode
  49175. */
  49176. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49177. /**
  49178. * Teleports the users feet to the desired location
  49179. * @param location The location where the user's feet should be placed
  49180. */
  49181. teleportCamera(location: Vector3): void;
  49182. private _convertNormalToDirectionOfRay;
  49183. private _castRayAndSelectObject;
  49184. private _notifySelectedMeshUnselected;
  49185. /**
  49186. * Permanently set new colors for the laser pointer
  49187. * @param color the new laser color
  49188. * @param pickedColor the new laser color when picked mesh detected
  49189. */
  49190. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49191. /**
  49192. * Set lighting enabled / disabled on the laser pointer of both controllers
  49193. * @param enabled should the lighting be enabled on the laser pointer
  49194. */
  49195. setLaserLightingState(enabled?: boolean): void;
  49196. /**
  49197. * Permanently set new colors for the gaze pointer
  49198. * @param color the new gaze color
  49199. * @param pickedColor the new gaze color when picked mesh detected
  49200. */
  49201. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49202. /**
  49203. * Sets the color of the laser ray from the vr controllers.
  49204. * @param color new color for the ray.
  49205. */
  49206. changeLaserColor(color: Color3): void;
  49207. /**
  49208. * Sets the color of the ray from the vr headsets gaze.
  49209. * @param color new color for the ray.
  49210. */
  49211. changeGazeColor(color: Color3): void;
  49212. /**
  49213. * Exits VR and disposes of the vr experience helper
  49214. */
  49215. dispose(): void;
  49216. /**
  49217. * Gets the name of the VRExperienceHelper class
  49218. * @returns "VRExperienceHelper"
  49219. */
  49220. getClassName(): string;
  49221. }
  49222. }
  49223. declare module BABYLON {
  49224. /**
  49225. * Contains an array of blocks representing the octree
  49226. */
  49227. export interface IOctreeContainer<T> {
  49228. /**
  49229. * Blocks within the octree
  49230. */
  49231. blocks: Array<OctreeBlock<T>>;
  49232. }
  49233. /**
  49234. * Class used to store a cell in an octree
  49235. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49236. */
  49237. export class OctreeBlock<T> {
  49238. /**
  49239. * Gets the content of the current block
  49240. */
  49241. entries: T[];
  49242. /**
  49243. * Gets the list of block children
  49244. */
  49245. blocks: Array<OctreeBlock<T>>;
  49246. private _depth;
  49247. private _maxDepth;
  49248. private _capacity;
  49249. private _minPoint;
  49250. private _maxPoint;
  49251. private _boundingVectors;
  49252. private _creationFunc;
  49253. /**
  49254. * Creates a new block
  49255. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49256. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49257. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49258. * @param depth defines the current depth of this block in the octree
  49259. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49260. * @param creationFunc defines a callback to call when an element is added to the block
  49261. */
  49262. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49263. /**
  49264. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49265. */
  49266. get capacity(): number;
  49267. /**
  49268. * Gets the minimum vector (in world space) of the block's bounding box
  49269. */
  49270. get minPoint(): Vector3;
  49271. /**
  49272. * Gets the maximum vector (in world space) of the block's bounding box
  49273. */
  49274. get maxPoint(): Vector3;
  49275. /**
  49276. * Add a new element to this block
  49277. * @param entry defines the element to add
  49278. */
  49279. addEntry(entry: T): void;
  49280. /**
  49281. * Remove an element from this block
  49282. * @param entry defines the element to remove
  49283. */
  49284. removeEntry(entry: T): void;
  49285. /**
  49286. * Add an array of elements to this block
  49287. * @param entries defines the array of elements to add
  49288. */
  49289. addEntries(entries: T[]): void;
  49290. /**
  49291. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49292. * @param frustumPlanes defines the frustum planes to test
  49293. * @param selection defines the array to store current content if selection is positive
  49294. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49295. */
  49296. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49297. /**
  49298. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49299. * @param sphereCenter defines the bounding sphere center
  49300. * @param sphereRadius defines the bounding sphere radius
  49301. * @param selection defines the array to store current content if selection is positive
  49302. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49303. */
  49304. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49305. /**
  49306. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49307. * @param ray defines the ray to test with
  49308. * @param selection defines the array to store current content if selection is positive
  49309. */
  49310. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49311. /**
  49312. * Subdivide the content into child blocks (this block will then be empty)
  49313. */
  49314. createInnerBlocks(): void;
  49315. /**
  49316. * @hidden
  49317. */
  49318. 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;
  49319. }
  49320. }
  49321. declare module BABYLON {
  49322. /**
  49323. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49324. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49325. */
  49326. export class Octree<T> {
  49327. /** 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.) */
  49328. maxDepth: number;
  49329. /**
  49330. * Blocks within the octree containing objects
  49331. */
  49332. blocks: Array<OctreeBlock<T>>;
  49333. /**
  49334. * Content stored in the octree
  49335. */
  49336. dynamicContent: T[];
  49337. private _maxBlockCapacity;
  49338. private _selectionContent;
  49339. private _creationFunc;
  49340. /**
  49341. * Creates a octree
  49342. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49343. * @param creationFunc function to be used to instatiate the octree
  49344. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49345. * @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.)
  49346. */
  49347. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49348. /** 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.) */
  49349. maxDepth?: number);
  49350. /**
  49351. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49352. * @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);
  49353. * @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);
  49354. * @param entries meshes to be added to the octree blocks
  49355. */
  49356. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49357. /**
  49358. * Adds a mesh to the octree
  49359. * @param entry Mesh to add to the octree
  49360. */
  49361. addMesh(entry: T): void;
  49362. /**
  49363. * Remove an element from the octree
  49364. * @param entry defines the element to remove
  49365. */
  49366. removeMesh(entry: T): void;
  49367. /**
  49368. * Selects an array of meshes within the frustum
  49369. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49370. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49371. * @returns array of meshes within the frustum
  49372. */
  49373. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49374. /**
  49375. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49376. * @param sphereCenter defines the bounding sphere center
  49377. * @param sphereRadius defines the bounding sphere radius
  49378. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49379. * @returns an array of objects that intersect the sphere
  49380. */
  49381. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49382. /**
  49383. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49384. * @param ray defines the ray to test with
  49385. * @returns array of intersected objects
  49386. */
  49387. intersectsRay(ray: Ray): SmartArray<T>;
  49388. /**
  49389. * Adds a mesh into the octree block if it intersects the block
  49390. */
  49391. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49392. /**
  49393. * Adds a submesh into the octree block if it intersects the block
  49394. */
  49395. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49396. }
  49397. }
  49398. declare module BABYLON {
  49399. interface Scene {
  49400. /**
  49401. * @hidden
  49402. * Backing Filed
  49403. */
  49404. _selectionOctree: Octree<AbstractMesh>;
  49405. /**
  49406. * Gets the octree used to boost mesh selection (picking)
  49407. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49408. */
  49409. selectionOctree: Octree<AbstractMesh>;
  49410. /**
  49411. * Creates or updates the octree used to boost selection (picking)
  49412. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49413. * @param maxCapacity defines the maximum capacity per leaf
  49414. * @param maxDepth defines the maximum depth of the octree
  49415. * @returns an octree of AbstractMesh
  49416. */
  49417. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49418. }
  49419. interface AbstractMesh {
  49420. /**
  49421. * @hidden
  49422. * Backing Field
  49423. */
  49424. _submeshesOctree: Octree<SubMesh>;
  49425. /**
  49426. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49427. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49428. * @param maxCapacity defines the maximum size of each block (64 by default)
  49429. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49430. * @returns the new octree
  49431. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49432. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49433. */
  49434. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  49435. }
  49436. /**
  49437. * Defines the octree scene component responsible to manage any octrees
  49438. * in a given scene.
  49439. */
  49440. export class OctreeSceneComponent {
  49441. /**
  49442. * The component name help to identify the component in the list of scene components.
  49443. */
  49444. readonly name: string;
  49445. /**
  49446. * The scene the component belongs to.
  49447. */
  49448. scene: Scene;
  49449. /**
  49450. * Indicates if the meshes have been checked to make sure they are isEnabled()
  49451. */
  49452. readonly checksIsEnabled: boolean;
  49453. /**
  49454. * Creates a new instance of the component for the given scene
  49455. * @param scene Defines the scene to register the component in
  49456. */
  49457. constructor(scene: Scene);
  49458. /**
  49459. * Registers the component in a given scene
  49460. */
  49461. register(): void;
  49462. /**
  49463. * Return the list of active meshes
  49464. * @returns the list of active meshes
  49465. */
  49466. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  49467. /**
  49468. * Return the list of active sub meshes
  49469. * @param mesh The mesh to get the candidates sub meshes from
  49470. * @returns the list of active sub meshes
  49471. */
  49472. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  49473. private _tempRay;
  49474. /**
  49475. * Return the list of sub meshes intersecting with a given local ray
  49476. * @param mesh defines the mesh to find the submesh for
  49477. * @param localRay defines the ray in local space
  49478. * @returns the list of intersecting sub meshes
  49479. */
  49480. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  49481. /**
  49482. * Return the list of sub meshes colliding with a collider
  49483. * @param mesh defines the mesh to find the submesh for
  49484. * @param collider defines the collider to evaluate the collision against
  49485. * @returns the list of colliding sub meshes
  49486. */
  49487. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  49488. /**
  49489. * Rebuilds the elements related to this component in case of
  49490. * context lost for instance.
  49491. */
  49492. rebuild(): void;
  49493. /**
  49494. * Disposes the component and the associated ressources.
  49495. */
  49496. dispose(): void;
  49497. }
  49498. }
  49499. declare module BABYLON {
  49500. /**
  49501. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  49502. */
  49503. export class Gizmo implements IDisposable {
  49504. /** The utility layer the gizmo will be added to */
  49505. gizmoLayer: UtilityLayerRenderer;
  49506. /**
  49507. * The root mesh of the gizmo
  49508. */
  49509. _rootMesh: Mesh;
  49510. private _attachedMesh;
  49511. /**
  49512. * Ratio for the scale of the gizmo (Default: 1)
  49513. */
  49514. scaleRatio: number;
  49515. /**
  49516. * If a custom mesh has been set (Default: false)
  49517. */
  49518. protected _customMeshSet: boolean;
  49519. /**
  49520. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  49521. * * When set, interactions will be enabled
  49522. */
  49523. get attachedMesh(): Nullable<AbstractMesh>;
  49524. set attachedMesh(value: Nullable<AbstractMesh>);
  49525. /**
  49526. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49527. * @param mesh The mesh to replace the default mesh of the gizmo
  49528. */
  49529. setCustomMesh(mesh: Mesh): void;
  49530. /**
  49531. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  49532. */
  49533. updateGizmoRotationToMatchAttachedMesh: boolean;
  49534. /**
  49535. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  49536. */
  49537. updateGizmoPositionToMatchAttachedMesh: boolean;
  49538. /**
  49539. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  49540. */
  49541. updateScale: boolean;
  49542. protected _interactionsEnabled: boolean;
  49543. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49544. private _beforeRenderObserver;
  49545. private _tempVector;
  49546. /**
  49547. * Creates a gizmo
  49548. * @param gizmoLayer The utility layer the gizmo will be added to
  49549. */
  49550. constructor(
  49551. /** The utility layer the gizmo will be added to */
  49552. gizmoLayer?: UtilityLayerRenderer);
  49553. /**
  49554. * Updates the gizmo to match the attached mesh's position/rotation
  49555. */
  49556. protected _update(): void;
  49557. /**
  49558. * Disposes of the gizmo
  49559. */
  49560. dispose(): void;
  49561. }
  49562. }
  49563. declare module BABYLON {
  49564. /**
  49565. * Single plane drag gizmo
  49566. */
  49567. export class PlaneDragGizmo extends Gizmo {
  49568. /**
  49569. * Drag behavior responsible for the gizmos dragging interactions
  49570. */
  49571. dragBehavior: PointerDragBehavior;
  49572. private _pointerObserver;
  49573. /**
  49574. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49575. */
  49576. snapDistance: number;
  49577. /**
  49578. * Event that fires each time the gizmo snaps to a new location.
  49579. * * snapDistance is the the change in distance
  49580. */
  49581. onSnapObservable: Observable<{
  49582. snapDistance: number;
  49583. }>;
  49584. private _plane;
  49585. private _coloredMaterial;
  49586. private _hoverMaterial;
  49587. private _isEnabled;
  49588. private _parent;
  49589. /** @hidden */
  49590. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  49591. /** @hidden */
  49592. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49593. /**
  49594. * Creates a PlaneDragGizmo
  49595. * @param gizmoLayer The utility layer the gizmo will be added to
  49596. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  49597. * @param color The color of the gizmo
  49598. */
  49599. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49600. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49601. /**
  49602. * If the gizmo is enabled
  49603. */
  49604. set isEnabled(value: boolean);
  49605. get isEnabled(): boolean;
  49606. /**
  49607. * Disposes of the gizmo
  49608. */
  49609. dispose(): void;
  49610. }
  49611. }
  49612. declare module BABYLON {
  49613. /**
  49614. * Gizmo that enables dragging a mesh along 3 axis
  49615. */
  49616. export class PositionGizmo extends Gizmo {
  49617. /**
  49618. * Internal gizmo used for interactions on the x axis
  49619. */
  49620. xGizmo: AxisDragGizmo;
  49621. /**
  49622. * Internal gizmo used for interactions on the y axis
  49623. */
  49624. yGizmo: AxisDragGizmo;
  49625. /**
  49626. * Internal gizmo used for interactions on the z axis
  49627. */
  49628. zGizmo: AxisDragGizmo;
  49629. /**
  49630. * Internal gizmo used for interactions on the yz plane
  49631. */
  49632. xPlaneGizmo: PlaneDragGizmo;
  49633. /**
  49634. * Internal gizmo used for interactions on the xz plane
  49635. */
  49636. yPlaneGizmo: PlaneDragGizmo;
  49637. /**
  49638. * Internal gizmo used for interactions on the xy plane
  49639. */
  49640. zPlaneGizmo: PlaneDragGizmo;
  49641. /**
  49642. * private variables
  49643. */
  49644. private _meshAttached;
  49645. private _updateGizmoRotationToMatchAttachedMesh;
  49646. private _snapDistance;
  49647. private _scaleRatio;
  49648. /** Fires an event when any of it's sub gizmos are dragged */
  49649. onDragStartObservable: Observable<unknown>;
  49650. /** Fires an event when any of it's sub gizmos are released from dragging */
  49651. onDragEndObservable: Observable<unknown>;
  49652. /**
  49653. * If set to true, planar drag is enabled
  49654. */
  49655. private _planarGizmoEnabled;
  49656. get attachedMesh(): Nullable<AbstractMesh>;
  49657. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49658. /**
  49659. * Creates a PositionGizmo
  49660. * @param gizmoLayer The utility layer the gizmo will be added to
  49661. */
  49662. constructor(gizmoLayer?: UtilityLayerRenderer);
  49663. /**
  49664. * If the planar drag gizmo is enabled
  49665. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  49666. */
  49667. set planarGizmoEnabled(value: boolean);
  49668. get planarGizmoEnabled(): boolean;
  49669. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49670. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49671. /**
  49672. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49673. */
  49674. set snapDistance(value: number);
  49675. get snapDistance(): number;
  49676. /**
  49677. * Ratio for the scale of the gizmo (Default: 1)
  49678. */
  49679. set scaleRatio(value: number);
  49680. get scaleRatio(): number;
  49681. /**
  49682. * Disposes of the gizmo
  49683. */
  49684. dispose(): void;
  49685. /**
  49686. * CustomMeshes are not supported by this gizmo
  49687. * @param mesh The mesh to replace the default mesh of the gizmo
  49688. */
  49689. setCustomMesh(mesh: Mesh): void;
  49690. }
  49691. }
  49692. declare module BABYLON {
  49693. /**
  49694. * Single axis drag gizmo
  49695. */
  49696. export class AxisDragGizmo extends Gizmo {
  49697. /**
  49698. * Drag behavior responsible for the gizmos dragging interactions
  49699. */
  49700. dragBehavior: PointerDragBehavior;
  49701. private _pointerObserver;
  49702. /**
  49703. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49704. */
  49705. snapDistance: number;
  49706. /**
  49707. * Event that fires each time the gizmo snaps to a new location.
  49708. * * snapDistance is the the change in distance
  49709. */
  49710. onSnapObservable: Observable<{
  49711. snapDistance: number;
  49712. }>;
  49713. private _isEnabled;
  49714. private _parent;
  49715. private _arrow;
  49716. private _coloredMaterial;
  49717. private _hoverMaterial;
  49718. /** @hidden */
  49719. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  49720. /** @hidden */
  49721. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  49722. /**
  49723. * Creates an AxisDragGizmo
  49724. * @param gizmoLayer The utility layer the gizmo will be added to
  49725. * @param dragAxis The axis which the gizmo will be able to drag on
  49726. * @param color The color of the gizmo
  49727. */
  49728. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  49729. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49730. /**
  49731. * If the gizmo is enabled
  49732. */
  49733. set isEnabled(value: boolean);
  49734. get isEnabled(): boolean;
  49735. /**
  49736. * Disposes of the gizmo
  49737. */
  49738. dispose(): void;
  49739. }
  49740. }
  49741. declare module BABYLON.Debug {
  49742. /**
  49743. * The Axes viewer will show 3 axes in a specific point in space
  49744. */
  49745. export class AxesViewer {
  49746. private _xAxis;
  49747. private _yAxis;
  49748. private _zAxis;
  49749. private _scaleLinesFactor;
  49750. private _instanced;
  49751. /**
  49752. * Gets the hosting scene
  49753. */
  49754. scene: Scene;
  49755. /**
  49756. * Gets or sets a number used to scale line length
  49757. */
  49758. scaleLines: number;
  49759. /** Gets the node hierarchy used to render x-axis */
  49760. get xAxis(): TransformNode;
  49761. /** Gets the node hierarchy used to render y-axis */
  49762. get yAxis(): TransformNode;
  49763. /** Gets the node hierarchy used to render z-axis */
  49764. get zAxis(): TransformNode;
  49765. /**
  49766. * Creates a new AxesViewer
  49767. * @param scene defines the hosting scene
  49768. * @param scaleLines defines a number used to scale line length (1 by default)
  49769. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  49770. * @param xAxis defines the node hierarchy used to render the x-axis
  49771. * @param yAxis defines the node hierarchy used to render the y-axis
  49772. * @param zAxis defines the node hierarchy used to render the z-axis
  49773. */
  49774. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  49775. /**
  49776. * Force the viewer to update
  49777. * @param position defines the position of the viewer
  49778. * @param xaxis defines the x axis of the viewer
  49779. * @param yaxis defines the y axis of the viewer
  49780. * @param zaxis defines the z axis of the viewer
  49781. */
  49782. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  49783. /**
  49784. * Creates an instance of this axes viewer.
  49785. * @returns a new axes viewer with instanced meshes
  49786. */
  49787. createInstance(): AxesViewer;
  49788. /** Releases resources */
  49789. dispose(): void;
  49790. private static _SetRenderingGroupId;
  49791. }
  49792. }
  49793. declare module BABYLON.Debug {
  49794. /**
  49795. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  49796. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  49797. */
  49798. export class BoneAxesViewer extends AxesViewer {
  49799. /**
  49800. * Gets or sets the target mesh where to display the axes viewer
  49801. */
  49802. mesh: Nullable<Mesh>;
  49803. /**
  49804. * Gets or sets the target bone where to display the axes viewer
  49805. */
  49806. bone: Nullable<Bone>;
  49807. /** Gets current position */
  49808. pos: Vector3;
  49809. /** Gets direction of X axis */
  49810. xaxis: Vector3;
  49811. /** Gets direction of Y axis */
  49812. yaxis: Vector3;
  49813. /** Gets direction of Z axis */
  49814. zaxis: Vector3;
  49815. /**
  49816. * Creates a new BoneAxesViewer
  49817. * @param scene defines the hosting scene
  49818. * @param bone defines the target bone
  49819. * @param mesh defines the target mesh
  49820. * @param scaleLines defines a scaling factor for line length (1 by default)
  49821. */
  49822. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  49823. /**
  49824. * Force the viewer to update
  49825. */
  49826. update(): void;
  49827. /** Releases resources */
  49828. dispose(): void;
  49829. }
  49830. }
  49831. declare module BABYLON {
  49832. /**
  49833. * Interface used to define scene explorer extensibility option
  49834. */
  49835. export interface IExplorerExtensibilityOption {
  49836. /**
  49837. * Define the option label
  49838. */
  49839. label: string;
  49840. /**
  49841. * Defines the action to execute on click
  49842. */
  49843. action: (entity: any) => void;
  49844. }
  49845. /**
  49846. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  49847. */
  49848. export interface IExplorerExtensibilityGroup {
  49849. /**
  49850. * Defines a predicate to test if a given type mut be extended
  49851. */
  49852. predicate: (entity: any) => boolean;
  49853. /**
  49854. * Gets the list of options added to a type
  49855. */
  49856. entries: IExplorerExtensibilityOption[];
  49857. }
  49858. /**
  49859. * Interface used to define the options to use to create the Inspector
  49860. */
  49861. export interface IInspectorOptions {
  49862. /**
  49863. * Display in overlay mode (default: false)
  49864. */
  49865. overlay?: boolean;
  49866. /**
  49867. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  49868. */
  49869. globalRoot?: HTMLElement;
  49870. /**
  49871. * Display the Scene explorer
  49872. */
  49873. showExplorer?: boolean;
  49874. /**
  49875. * Display the property inspector
  49876. */
  49877. showInspector?: boolean;
  49878. /**
  49879. * Display in embed mode (both panes on the right)
  49880. */
  49881. embedMode?: boolean;
  49882. /**
  49883. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  49884. */
  49885. handleResize?: boolean;
  49886. /**
  49887. * Allow the panes to popup (default: true)
  49888. */
  49889. enablePopup?: boolean;
  49890. /**
  49891. * Allow the panes to be closed by users (default: true)
  49892. */
  49893. enableClose?: boolean;
  49894. /**
  49895. * Optional list of extensibility entries
  49896. */
  49897. explorerExtensibility?: IExplorerExtensibilityGroup[];
  49898. /**
  49899. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  49900. */
  49901. inspectorURL?: string;
  49902. /**
  49903. * Optional initial tab (default to DebugLayerTab.Properties)
  49904. */
  49905. initialTab?: DebugLayerTab;
  49906. }
  49907. interface Scene {
  49908. /**
  49909. * @hidden
  49910. * Backing field
  49911. */
  49912. _debugLayer: DebugLayer;
  49913. /**
  49914. * Gets the debug layer (aka Inspector) associated with the scene
  49915. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49916. */
  49917. debugLayer: DebugLayer;
  49918. }
  49919. /**
  49920. * Enum of inspector action tab
  49921. */
  49922. export enum DebugLayerTab {
  49923. /**
  49924. * Properties tag (default)
  49925. */
  49926. Properties = 0,
  49927. /**
  49928. * Debug tab
  49929. */
  49930. Debug = 1,
  49931. /**
  49932. * Statistics tab
  49933. */
  49934. Statistics = 2,
  49935. /**
  49936. * Tools tab
  49937. */
  49938. Tools = 3,
  49939. /**
  49940. * Settings tab
  49941. */
  49942. Settings = 4
  49943. }
  49944. /**
  49945. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49946. * what is happening in your scene
  49947. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49948. */
  49949. export class DebugLayer {
  49950. /**
  49951. * Define the url to get the inspector script from.
  49952. * By default it uses the babylonjs CDN.
  49953. * @ignoreNaming
  49954. */
  49955. static InspectorURL: string;
  49956. private _scene;
  49957. private BJSINSPECTOR;
  49958. private _onPropertyChangedObservable?;
  49959. /**
  49960. * Observable triggered when a property is changed through the inspector.
  49961. */
  49962. get onPropertyChangedObservable(): any;
  49963. /**
  49964. * Instantiates a new debug layer.
  49965. * The debug layer (aka Inspector) is the go to tool in order to better understand
  49966. * what is happening in your scene
  49967. * @see https://doc.babylonjs.com/features/playground_debuglayer
  49968. * @param scene Defines the scene to inspect
  49969. */
  49970. constructor(scene: Scene);
  49971. /** Creates the inspector window. */
  49972. private _createInspector;
  49973. /**
  49974. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  49975. * @param entity defines the entity to select
  49976. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  49977. */
  49978. select(entity: any, lineContainerTitles?: string | string[]): void;
  49979. /** Get the inspector from bundle or global */
  49980. private _getGlobalInspector;
  49981. /**
  49982. * Get if the inspector is visible or not.
  49983. * @returns true if visible otherwise, false
  49984. */
  49985. isVisible(): boolean;
  49986. /**
  49987. * Hide the inspector and close its window.
  49988. */
  49989. hide(): void;
  49990. /**
  49991. * Update the scene in the inspector
  49992. */
  49993. setAsActiveScene(): void;
  49994. /**
  49995. * Launch the debugLayer.
  49996. * @param config Define the configuration of the inspector
  49997. * @return a promise fulfilled when the debug layer is visible
  49998. */
  49999. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50000. }
  50001. }
  50002. declare module BABYLON {
  50003. /**
  50004. * Class containing static functions to help procedurally build meshes
  50005. */
  50006. export class BoxBuilder {
  50007. /**
  50008. * Creates a box mesh
  50009. * * The parameter `size` sets the size (float) of each box side (default 1)
  50010. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50011. * * 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)
  50012. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50014. * * 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
  50015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50016. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50017. * @param name defines the name of the mesh
  50018. * @param options defines the options used to create the mesh
  50019. * @param scene defines the hosting scene
  50020. * @returns the box mesh
  50021. */
  50022. static CreateBox(name: string, options: {
  50023. size?: number;
  50024. width?: number;
  50025. height?: number;
  50026. depth?: number;
  50027. faceUV?: Vector4[];
  50028. faceColors?: Color4[];
  50029. sideOrientation?: number;
  50030. frontUVs?: Vector4;
  50031. backUVs?: Vector4;
  50032. wrap?: boolean;
  50033. topBaseAt?: number;
  50034. bottomBaseAt?: number;
  50035. updatable?: boolean;
  50036. }, scene?: Nullable<Scene>): Mesh;
  50037. }
  50038. }
  50039. declare module BABYLON.Debug {
  50040. /**
  50041. * Used to show the physics impostor around the specific mesh
  50042. */
  50043. export class PhysicsViewer {
  50044. /** @hidden */
  50045. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50046. /** @hidden */
  50047. protected _meshes: Array<Nullable<AbstractMesh>>;
  50048. /** @hidden */
  50049. protected _scene: Nullable<Scene>;
  50050. /** @hidden */
  50051. protected _numMeshes: number;
  50052. /** @hidden */
  50053. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50054. private _renderFunction;
  50055. private _utilityLayer;
  50056. private _debugBoxMesh;
  50057. private _debugSphereMesh;
  50058. private _debugCylinderMesh;
  50059. private _debugMaterial;
  50060. private _debugMeshMeshes;
  50061. /**
  50062. * Creates a new PhysicsViewer
  50063. * @param scene defines the hosting scene
  50064. */
  50065. constructor(scene: Scene);
  50066. /** @hidden */
  50067. protected _updateDebugMeshes(): void;
  50068. /**
  50069. * Renders a specified physic impostor
  50070. * @param impostor defines the impostor to render
  50071. * @param targetMesh defines the mesh represented by the impostor
  50072. * @returns the new debug mesh used to render the impostor
  50073. */
  50074. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50075. /**
  50076. * Hides a specified physic impostor
  50077. * @param impostor defines the impostor to hide
  50078. */
  50079. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50080. private _getDebugMaterial;
  50081. private _getDebugBoxMesh;
  50082. private _getDebugSphereMesh;
  50083. private _getDebugCylinderMesh;
  50084. private _getDebugMeshMesh;
  50085. private _getDebugMesh;
  50086. /** Releases all resources */
  50087. dispose(): void;
  50088. }
  50089. }
  50090. declare module BABYLON {
  50091. /**
  50092. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50093. * in order to better appreciate the issue one might have.
  50094. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50095. */
  50096. export class RayHelper {
  50097. /**
  50098. * Defines the ray we are currently tryin to visualize.
  50099. */
  50100. ray: Nullable<Ray>;
  50101. private _renderPoints;
  50102. private _renderLine;
  50103. private _renderFunction;
  50104. private _scene;
  50105. private _updateToMeshFunction;
  50106. private _attachedToMesh;
  50107. private _meshSpaceDirection;
  50108. private _meshSpaceOrigin;
  50109. /**
  50110. * Helper function to create a colored helper in a scene in one line.
  50111. * @param ray Defines the ray we are currently tryin to visualize
  50112. * @param scene Defines the scene the ray is used in
  50113. * @param color Defines the color we want to see the ray in
  50114. * @returns The newly created ray helper.
  50115. */
  50116. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50117. /**
  50118. * Instantiate a new ray helper.
  50119. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50120. * in order to better appreciate the issue one might have.
  50121. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50122. * @param ray Defines the ray we are currently tryin to visualize
  50123. */
  50124. constructor(ray: Ray);
  50125. /**
  50126. * Shows the ray we are willing to debug.
  50127. * @param scene Defines the scene the ray needs to be rendered in
  50128. * @param color Defines the color the ray needs to be rendered in
  50129. */
  50130. show(scene: Scene, color?: Color3): void;
  50131. /**
  50132. * Hides the ray we are debugging.
  50133. */
  50134. hide(): void;
  50135. private _render;
  50136. /**
  50137. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50138. * @param mesh Defines the mesh we want the helper attached to
  50139. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50140. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50141. * @param length Defines the length of the ray
  50142. */
  50143. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50144. /**
  50145. * Detach the ray helper from the mesh it has previously been attached to.
  50146. */
  50147. detachFromMesh(): void;
  50148. private _updateToMesh;
  50149. /**
  50150. * Dispose the helper and release its associated resources.
  50151. */
  50152. dispose(): void;
  50153. }
  50154. }
  50155. declare module BABYLON.Debug {
  50156. /**
  50157. * Class used to render a debug view of a given skeleton
  50158. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50159. */
  50160. export class SkeletonViewer {
  50161. /** defines the skeleton to render */
  50162. skeleton: Skeleton;
  50163. /** defines the mesh attached to the skeleton */
  50164. mesh: AbstractMesh;
  50165. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50166. autoUpdateBonesMatrices: boolean;
  50167. /** defines the rendering group id to use with the viewer */
  50168. renderingGroupId: number;
  50169. /** Gets or sets the color used to render the skeleton */
  50170. color: Color3;
  50171. private _scene;
  50172. private _debugLines;
  50173. private _debugMesh;
  50174. private _isEnabled;
  50175. private _renderFunction;
  50176. private _utilityLayer;
  50177. /**
  50178. * Returns the mesh used to render the bones
  50179. */
  50180. get debugMesh(): Nullable<LinesMesh>;
  50181. /**
  50182. * Creates a new SkeletonViewer
  50183. * @param skeleton defines the skeleton to render
  50184. * @param mesh defines the mesh attached to the skeleton
  50185. * @param scene defines the hosting scene
  50186. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50187. * @param renderingGroupId defines the rendering group id to use with the viewer
  50188. */
  50189. constructor(
  50190. /** defines the skeleton to render */
  50191. skeleton: Skeleton,
  50192. /** defines the mesh attached to the skeleton */
  50193. mesh: AbstractMesh, scene: Scene,
  50194. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50195. autoUpdateBonesMatrices?: boolean,
  50196. /** defines the rendering group id to use with the viewer */
  50197. renderingGroupId?: number);
  50198. /** Gets or sets a boolean indicating if the viewer is enabled */
  50199. set isEnabled(value: boolean);
  50200. get isEnabled(): boolean;
  50201. private _getBonePosition;
  50202. private _getLinesForBonesWithLength;
  50203. private _getLinesForBonesNoLength;
  50204. /** Update the viewer to sync with current skeleton state */
  50205. update(): void;
  50206. /** Release associated resources */
  50207. dispose(): void;
  50208. }
  50209. }
  50210. declare module BABYLON {
  50211. /**
  50212. * Enum for Device Types
  50213. */
  50214. export enum DeviceType {
  50215. /** Generic */
  50216. Generic = 0,
  50217. /** Keyboard */
  50218. Keyboard = 1,
  50219. /** Mouse */
  50220. Mouse = 2,
  50221. /** Touch Pointers */
  50222. Touch = 3,
  50223. /** PS4 Dual Shock */
  50224. DualShock = 4,
  50225. /** Xbox */
  50226. Xbox = 5,
  50227. /** Switch Controller */
  50228. Switch = 6
  50229. }
  50230. /**
  50231. * Enum for All Pointers (Touch/Mouse)
  50232. */
  50233. export enum PointerInput {
  50234. /** Horizontal Axis */
  50235. Horizontal = 0,
  50236. /** Vertical Axis */
  50237. Vertical = 1,
  50238. /** Left Click or Touch */
  50239. LeftClick = 2,
  50240. /** Middle Click */
  50241. MiddleClick = 3,
  50242. /** Right Click */
  50243. RightClick = 4,
  50244. /** Browser Back */
  50245. BrowserBack = 5,
  50246. /** Browser Forward */
  50247. BrowserForward = 6
  50248. }
  50249. /**
  50250. * Enum for Dual Shock Gamepad
  50251. */
  50252. export enum DualShockInput {
  50253. /** Cross */
  50254. Cross = 0,
  50255. /** Circle */
  50256. Circle = 1,
  50257. /** Square */
  50258. Square = 2,
  50259. /** Triangle */
  50260. Triangle = 3,
  50261. /** L1 */
  50262. L1 = 4,
  50263. /** R1 */
  50264. R1 = 5,
  50265. /** L2 */
  50266. L2 = 6,
  50267. /** R2 */
  50268. R2 = 7,
  50269. /** Share */
  50270. Share = 8,
  50271. /** Options */
  50272. Options = 9,
  50273. /** L3 */
  50274. L3 = 10,
  50275. /** R3 */
  50276. R3 = 11,
  50277. /** DPadUp */
  50278. DPadUp = 12,
  50279. /** DPadDown */
  50280. DPadDown = 13,
  50281. /** DPadLeft */
  50282. DPadLeft = 14,
  50283. /** DRight */
  50284. DPadRight = 15,
  50285. /** Home */
  50286. Home = 16,
  50287. /** TouchPad */
  50288. TouchPad = 17,
  50289. /** LStickXAxis */
  50290. LStickXAxis = 18,
  50291. /** LStickYAxis */
  50292. LStickYAxis = 19,
  50293. /** RStickXAxis */
  50294. RStickXAxis = 20,
  50295. /** RStickYAxis */
  50296. RStickYAxis = 21
  50297. }
  50298. /**
  50299. * Enum for Xbox Gamepad
  50300. */
  50301. export enum XboxInput {
  50302. /** A */
  50303. A = 0,
  50304. /** B */
  50305. B = 1,
  50306. /** X */
  50307. X = 2,
  50308. /** Y */
  50309. Y = 3,
  50310. /** LB */
  50311. LB = 4,
  50312. /** RB */
  50313. RB = 5,
  50314. /** LT */
  50315. LT = 6,
  50316. /** RT */
  50317. RT = 7,
  50318. /** Back */
  50319. Back = 8,
  50320. /** Start */
  50321. Start = 9,
  50322. /** LS */
  50323. LS = 10,
  50324. /** RS */
  50325. RS = 11,
  50326. /** DPadUp */
  50327. DPadUp = 12,
  50328. /** DPadDown */
  50329. DPadDown = 13,
  50330. /** DPadLeft */
  50331. DPadLeft = 14,
  50332. /** DRight */
  50333. DPadRight = 15,
  50334. /** Home */
  50335. Home = 16,
  50336. /** LStickXAxis */
  50337. LStickXAxis = 17,
  50338. /** LStickYAxis */
  50339. LStickYAxis = 18,
  50340. /** RStickXAxis */
  50341. RStickXAxis = 19,
  50342. /** RStickYAxis */
  50343. RStickYAxis = 20
  50344. }
  50345. /**
  50346. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50347. */
  50348. export enum SwitchInput {
  50349. /** B */
  50350. B = 0,
  50351. /** A */
  50352. A = 1,
  50353. /** Y */
  50354. Y = 2,
  50355. /** X */
  50356. X = 3,
  50357. /** L */
  50358. L = 4,
  50359. /** R */
  50360. R = 5,
  50361. /** ZL */
  50362. ZL = 6,
  50363. /** ZR */
  50364. ZR = 7,
  50365. /** Minus */
  50366. Minus = 8,
  50367. /** Plus */
  50368. Plus = 9,
  50369. /** LS */
  50370. LS = 10,
  50371. /** RS */
  50372. RS = 11,
  50373. /** DPadUp */
  50374. DPadUp = 12,
  50375. /** DPadDown */
  50376. DPadDown = 13,
  50377. /** DPadLeft */
  50378. DPadLeft = 14,
  50379. /** DRight */
  50380. DPadRight = 15,
  50381. /** Home */
  50382. Home = 16,
  50383. /** Capture */
  50384. Capture = 17,
  50385. /** LStickXAxis */
  50386. LStickXAxis = 18,
  50387. /** LStickYAxis */
  50388. LStickYAxis = 19,
  50389. /** RStickXAxis */
  50390. RStickXAxis = 20,
  50391. /** RStickYAxis */
  50392. RStickYAxis = 21
  50393. }
  50394. }
  50395. declare module BABYLON {
  50396. /**
  50397. * This class will take all inputs from Keyboard, Pointer, and
  50398. * any Gamepads and provide a polling system that all devices
  50399. * will use. This class assumes that there will only be one
  50400. * pointer device and one keyboard.
  50401. */
  50402. export class DeviceInputSystem implements IDisposable {
  50403. /**
  50404. * Callback to be triggered when a device is connected
  50405. */
  50406. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50407. /**
  50408. * Callback to be triggered when a device is disconnected
  50409. */
  50410. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50411. /**
  50412. * Callback to be triggered when event driven input is updated
  50413. */
  50414. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50415. private _inputs;
  50416. private _gamepads;
  50417. private _keyboardActive;
  50418. private _pointerActive;
  50419. private _elementToAttachTo;
  50420. private _keyboardDownEvent;
  50421. private _keyboardUpEvent;
  50422. private _pointerMoveEvent;
  50423. private _pointerDownEvent;
  50424. private _pointerUpEvent;
  50425. private _gamepadConnectedEvent;
  50426. private _gamepadDisconnectedEvent;
  50427. private static _MAX_KEYCODES;
  50428. private static _MAX_POINTER_INPUTS;
  50429. private constructor();
  50430. /**
  50431. * Creates a new DeviceInputSystem instance
  50432. * @param engine Engine to pull input element from
  50433. * @returns The new instance
  50434. */
  50435. static Create(engine: Engine): DeviceInputSystem;
  50436. /**
  50437. * Checks for current device input value, given an id and input index
  50438. * @param deviceName Id of connected device
  50439. * @param inputIndex Index of device input
  50440. * @returns Current value of input
  50441. */
  50442. /**
  50443. * Checks for current device input value, given an id and input index
  50444. * @param deviceType Enum specifiying device type
  50445. * @param deviceSlot "Slot" or index that device is referenced in
  50446. * @param inputIndex Id of input to be checked
  50447. * @returns Current value of input
  50448. */
  50449. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  50450. /**
  50451. * Dispose of all the eventlisteners
  50452. */
  50453. dispose(): void;
  50454. /**
  50455. * Add device and inputs to device array
  50456. * @param deviceType Enum specifiying device type
  50457. * @param deviceSlot "Slot" or index that device is referenced in
  50458. * @param numberOfInputs Number of input entries to create for given device
  50459. */
  50460. private _registerDevice;
  50461. /**
  50462. * Given a specific device name, remove that device from the device map
  50463. * @param deviceType Enum specifiying device type
  50464. * @param deviceSlot "Slot" or index that device is referenced in
  50465. */
  50466. private _unregisterDevice;
  50467. /**
  50468. * Handle all actions that come from keyboard interaction
  50469. */
  50470. private _handleKeyActions;
  50471. /**
  50472. * Handle all actions that come from pointer interaction
  50473. */
  50474. private _handlePointerActions;
  50475. /**
  50476. * Handle all actions that come from gamepad interaction
  50477. */
  50478. private _handleGamepadActions;
  50479. /**
  50480. * Update all non-event based devices with each frame
  50481. * @param deviceType Enum specifiying device type
  50482. * @param deviceSlot "Slot" or index that device is referenced in
  50483. * @param inputIndex Id of input to be checked
  50484. */
  50485. private _updateDevice;
  50486. /**
  50487. * Gets DeviceType from the device name
  50488. * @param deviceName Name of Device from DeviceInputSystem
  50489. * @returns DeviceType enum value
  50490. */
  50491. private _getGamepadDeviceType;
  50492. }
  50493. }
  50494. declare module BABYLON {
  50495. /**
  50496. * Type to handle enforcement of inputs
  50497. */
  50498. 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;
  50499. }
  50500. declare module BABYLON {
  50501. /**
  50502. * Class that handles all input for a specific device
  50503. */
  50504. export class DeviceSource<T extends DeviceType> {
  50505. /** Type of device */
  50506. readonly deviceType: DeviceType;
  50507. /** "Slot" or index that device is referenced in */
  50508. readonly deviceSlot: number;
  50509. /**
  50510. * Observable to handle device input changes per device
  50511. */
  50512. readonly onInputChangedObservable: Observable<{
  50513. inputIndex: DeviceInput<T>;
  50514. previousState: Nullable<number>;
  50515. currentState: Nullable<number>;
  50516. }>;
  50517. private readonly _deviceInputSystem;
  50518. /**
  50519. * Default Constructor
  50520. * @param deviceInputSystem Reference to DeviceInputSystem
  50521. * @param deviceType Type of device
  50522. * @param deviceSlot "Slot" or index that device is referenced in
  50523. */
  50524. constructor(deviceInputSystem: DeviceInputSystem,
  50525. /** Type of device */
  50526. deviceType: DeviceType,
  50527. /** "Slot" or index that device is referenced in */
  50528. deviceSlot?: number);
  50529. /**
  50530. * Get input for specific input
  50531. * @param inputIndex index of specific input on device
  50532. * @returns Input value from DeviceInputSystem
  50533. */
  50534. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  50535. }
  50536. /**
  50537. * Class to keep track of devices
  50538. */
  50539. export class DeviceSourceManager implements IDisposable {
  50540. /**
  50541. * Observable to be triggered when before a device is connected
  50542. */
  50543. readonly onBeforeDeviceConnectedObservable: Observable<{
  50544. deviceType: DeviceType;
  50545. deviceSlot: number;
  50546. }>;
  50547. /**
  50548. * Observable to be triggered when before a device is disconnected
  50549. */
  50550. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  50551. deviceType: DeviceType;
  50552. deviceSlot: number;
  50553. }>;
  50554. /**
  50555. * Observable to be triggered when after a device is connected
  50556. */
  50557. readonly onAfterDeviceConnectedObservable: Observable<{
  50558. deviceType: DeviceType;
  50559. deviceSlot: number;
  50560. }>;
  50561. /**
  50562. * Observable to be triggered when after a device is disconnected
  50563. */
  50564. readonly onAfterDeviceDisconnectedObservable: Observable<{
  50565. deviceType: DeviceType;
  50566. deviceSlot: number;
  50567. }>;
  50568. private readonly _devices;
  50569. private readonly _firstDevice;
  50570. private readonly _deviceInputSystem;
  50571. /**
  50572. * Default Constructor
  50573. * @param engine engine to pull input element from
  50574. */
  50575. constructor(engine: Engine);
  50576. /**
  50577. * Gets a DeviceSource, given a type and slot
  50578. * @param deviceType Enum specifying device type
  50579. * @param deviceSlot "Slot" or index that device is referenced in
  50580. * @returns DeviceSource object
  50581. */
  50582. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  50583. /**
  50584. * Gets an array of DeviceSource objects for a given device type
  50585. * @param deviceType Enum specifying device type
  50586. * @returns Array of DeviceSource objects
  50587. */
  50588. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  50589. /**
  50590. * Dispose of DeviceInputSystem and other parts
  50591. */
  50592. dispose(): void;
  50593. /**
  50594. * Function to add device name to device list
  50595. * @param deviceType Enum specifying device type
  50596. * @param deviceSlot "Slot" or index that device is referenced in
  50597. */
  50598. private _addDevice;
  50599. /**
  50600. * Function to remove device name to device list
  50601. * @param deviceType Enum specifying device type
  50602. * @param deviceSlot "Slot" or index that device is referenced in
  50603. */
  50604. private _removeDevice;
  50605. /**
  50606. * Updates array storing first connected device of each type
  50607. * @param type Type of Device
  50608. */
  50609. private _updateFirstDevices;
  50610. }
  50611. }
  50612. declare module BABYLON {
  50613. /**
  50614. * Options to create the null engine
  50615. */
  50616. export class NullEngineOptions {
  50617. /**
  50618. * Render width (Default: 512)
  50619. */
  50620. renderWidth: number;
  50621. /**
  50622. * Render height (Default: 256)
  50623. */
  50624. renderHeight: number;
  50625. /**
  50626. * Texture size (Default: 512)
  50627. */
  50628. textureSize: number;
  50629. /**
  50630. * If delta time between frames should be constant
  50631. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50632. */
  50633. deterministicLockstep: boolean;
  50634. /**
  50635. * Maximum about of steps between frames (Default: 4)
  50636. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50637. */
  50638. lockstepMaxSteps: number;
  50639. }
  50640. /**
  50641. * The null engine class provides support for headless version of babylon.js.
  50642. * This can be used in server side scenario or for testing purposes
  50643. */
  50644. export class NullEngine extends Engine {
  50645. private _options;
  50646. /**
  50647. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  50648. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50649. * @returns true if engine is in deterministic lock step mode
  50650. */
  50651. isDeterministicLockStep(): boolean;
  50652. /**
  50653. * Gets the max steps when engine is running in deterministic lock step
  50654. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  50655. * @returns the max steps
  50656. */
  50657. getLockstepMaxSteps(): number;
  50658. /**
  50659. * Gets the current hardware scaling level.
  50660. * By default the hardware scaling level is computed from the window device ratio.
  50661. * 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.
  50662. * @returns a number indicating the current hardware scaling level
  50663. */
  50664. getHardwareScalingLevel(): number;
  50665. constructor(options?: NullEngineOptions);
  50666. /**
  50667. * Creates a vertex buffer
  50668. * @param vertices the data for the vertex buffer
  50669. * @returns the new WebGL static buffer
  50670. */
  50671. createVertexBuffer(vertices: FloatArray): DataBuffer;
  50672. /**
  50673. * Creates a new index buffer
  50674. * @param indices defines the content of the index buffer
  50675. * @param updatable defines if the index buffer must be updatable
  50676. * @returns a new webGL buffer
  50677. */
  50678. createIndexBuffer(indices: IndicesArray): DataBuffer;
  50679. /**
  50680. * Clear the current render buffer or the current render target (if any is set up)
  50681. * @param color defines the color to use
  50682. * @param backBuffer defines if the back buffer must be cleared
  50683. * @param depth defines if the depth buffer must be cleared
  50684. * @param stencil defines if the stencil buffer must be cleared
  50685. */
  50686. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  50687. /**
  50688. * Gets the current render width
  50689. * @param useScreen defines if screen size must be used (or the current render target if any)
  50690. * @returns a number defining the current render width
  50691. */
  50692. getRenderWidth(useScreen?: boolean): number;
  50693. /**
  50694. * Gets the current render height
  50695. * @param useScreen defines if screen size must be used (or the current render target if any)
  50696. * @returns a number defining the current render height
  50697. */
  50698. getRenderHeight(useScreen?: boolean): number;
  50699. /**
  50700. * Set the WebGL's viewport
  50701. * @param viewport defines the viewport element to be used
  50702. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  50703. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  50704. */
  50705. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  50706. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  50707. /**
  50708. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  50709. * @param pipelineContext defines the pipeline context to use
  50710. * @param uniformsNames defines the list of uniform names
  50711. * @returns an array of webGL uniform locations
  50712. */
  50713. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  50714. /**
  50715. * Gets the lsit of active attributes for a given webGL program
  50716. * @param pipelineContext defines the pipeline context to use
  50717. * @param attributesNames defines the list of attribute names to get
  50718. * @returns an array of indices indicating the offset of each attribute
  50719. */
  50720. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  50721. /**
  50722. * Binds an effect to the webGL context
  50723. * @param effect defines the effect to bind
  50724. */
  50725. bindSamplers(effect: Effect): void;
  50726. /**
  50727. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  50728. * @param effect defines the effect to activate
  50729. */
  50730. enableEffect(effect: Effect): void;
  50731. /**
  50732. * Set various states to the webGL context
  50733. * @param culling defines backface culling state
  50734. * @param zOffset defines the value to apply to zOffset (0 by default)
  50735. * @param force defines if states must be applied even if cache is up to date
  50736. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  50737. */
  50738. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  50739. /**
  50740. * Set the value of an uniform to an array of int32
  50741. * @param uniform defines the webGL uniform location where to store the value
  50742. * @param array defines the array of int32 to store
  50743. */
  50744. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50745. /**
  50746. * Set the value of an uniform to an array of int32 (stored as vec2)
  50747. * @param uniform defines the webGL uniform location where to store the value
  50748. * @param array defines the array of int32 to store
  50749. */
  50750. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50751. /**
  50752. * Set the value of an uniform to an array of int32 (stored as vec3)
  50753. * @param uniform defines the webGL uniform location where to store the value
  50754. * @param array defines the array of int32 to store
  50755. */
  50756. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50757. /**
  50758. * Set the value of an uniform to an array of int32 (stored as vec4)
  50759. * @param uniform defines the webGL uniform location where to store the value
  50760. * @param array defines the array of int32 to store
  50761. */
  50762. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50763. /**
  50764. * Set the value of an uniform to an array of float32
  50765. * @param uniform defines the webGL uniform location where to store the value
  50766. * @param array defines the array of float32 to store
  50767. */
  50768. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50769. /**
  50770. * Set the value of an uniform to an array of float32 (stored as vec2)
  50771. * @param uniform defines the webGL uniform location where to store the value
  50772. * @param array defines the array of float32 to store
  50773. */
  50774. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50775. /**
  50776. * Set the value of an uniform to an array of float32 (stored as vec3)
  50777. * @param uniform defines the webGL uniform location where to store the value
  50778. * @param array defines the array of float32 to store
  50779. */
  50780. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50781. /**
  50782. * Set the value of an uniform to an array of float32 (stored as vec4)
  50783. * @param uniform defines the webGL uniform location where to store the value
  50784. * @param array defines the array of float32 to store
  50785. */
  50786. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50787. /**
  50788. * Set the value of an uniform to an array of number
  50789. * @param uniform defines the webGL uniform location where to store the value
  50790. * @param array defines the array of number to store
  50791. */
  50792. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50793. /**
  50794. * Set the value of an uniform to an array of number (stored as vec2)
  50795. * @param uniform defines the webGL uniform location where to store the value
  50796. * @param array defines the array of number to store
  50797. */
  50798. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50799. /**
  50800. * Set the value of an uniform to an array of number (stored as vec3)
  50801. * @param uniform defines the webGL uniform location where to store the value
  50802. * @param array defines the array of number to store
  50803. */
  50804. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50805. /**
  50806. * Set the value of an uniform to an array of number (stored as vec4)
  50807. * @param uniform defines the webGL uniform location where to store the value
  50808. * @param array defines the array of number to store
  50809. */
  50810. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50811. /**
  50812. * Set the value of an uniform to an array of float32 (stored as matrices)
  50813. * @param uniform defines the webGL uniform location where to store the value
  50814. * @param matrices defines the array of float32 to store
  50815. */
  50816. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50817. /**
  50818. * Set the value of an uniform to a matrix (3x3)
  50819. * @param uniform defines the webGL uniform location where to store the value
  50820. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  50821. */
  50822. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50823. /**
  50824. * Set the value of an uniform to a matrix (2x2)
  50825. * @param uniform defines the webGL uniform location where to store the value
  50826. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  50827. */
  50828. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50829. /**
  50830. * Set the value of an uniform to a number (float)
  50831. * @param uniform defines the webGL uniform location where to store the value
  50832. * @param value defines the float number to store
  50833. */
  50834. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50835. /**
  50836. * Set the value of an uniform to a vec2
  50837. * @param uniform defines the webGL uniform location where to store the value
  50838. * @param x defines the 1st component of the value
  50839. * @param y defines the 2nd component of the value
  50840. */
  50841. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50842. /**
  50843. * Set the value of an uniform to a vec3
  50844. * @param uniform defines the webGL uniform location where to store the value
  50845. * @param x defines the 1st component of the value
  50846. * @param y defines the 2nd component of the value
  50847. * @param z defines the 3rd component of the value
  50848. */
  50849. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50850. /**
  50851. * Set the value of an uniform to a boolean
  50852. * @param uniform defines the webGL uniform location where to store the value
  50853. * @param bool defines the boolean to store
  50854. */
  50855. setBool(uniform: WebGLUniformLocation, bool: number): void;
  50856. /**
  50857. * Set the value of an uniform to a vec4
  50858. * @param uniform defines the webGL uniform location where to store the value
  50859. * @param x defines the 1st component of the value
  50860. * @param y defines the 2nd component of the value
  50861. * @param z defines the 3rd component of the value
  50862. * @param w defines the 4th component of the value
  50863. */
  50864. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50865. /**
  50866. * Sets the current alpha mode
  50867. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  50868. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  50869. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50870. */
  50871. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50872. /**
  50873. * Bind webGl buffers directly to the webGL context
  50874. * @param vertexBuffers defines the vertex buffer to bind
  50875. * @param indexBuffer defines the index buffer to bind
  50876. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  50877. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  50878. * @param effect defines the effect associated with the vertex buffer
  50879. */
  50880. bindBuffers(vertexBuffers: {
  50881. [key: string]: VertexBuffer;
  50882. }, indexBuffer: DataBuffer, effect: Effect): void;
  50883. /**
  50884. * Force the entire cache to be cleared
  50885. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  50886. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  50887. */
  50888. wipeCaches(bruteForce?: boolean): void;
  50889. /**
  50890. * Send a draw order
  50891. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  50892. * @param indexStart defines the starting index
  50893. * @param indexCount defines the number of index to draw
  50894. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50895. */
  50896. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  50897. /**
  50898. * Draw a list of indexed primitives
  50899. * @param fillMode defines the primitive to use
  50900. * @param indexStart defines the starting index
  50901. * @param indexCount defines the number of index to draw
  50902. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50903. */
  50904. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  50905. /**
  50906. * Draw a list of unindexed primitives
  50907. * @param fillMode defines the primitive to use
  50908. * @param verticesStart defines the index of first vertex to draw
  50909. * @param verticesCount defines the count of vertices to draw
  50910. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  50911. */
  50912. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  50913. /** @hidden */
  50914. _createTexture(): WebGLTexture;
  50915. /** @hidden */
  50916. _releaseTexture(texture: InternalTexture): void;
  50917. /**
  50918. * Usually called from Texture.ts.
  50919. * Passed information to create a WebGLTexture
  50920. * @param urlArg defines a value which contains one of the following:
  50921. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50922. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50923. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50924. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50925. * @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)
  50926. * @param scene needed for loading to the correct scene
  50927. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50928. * @param onLoad optional callback to be called upon successful completion
  50929. * @param onError optional callback to be called upon failure
  50930. * @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
  50931. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50932. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50933. * @param forcedExtension defines the extension to use to pick the right loader
  50934. * @param mimeType defines an optional mime type
  50935. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50936. */
  50937. 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;
  50938. /**
  50939. * Creates a new render target texture
  50940. * @param size defines the size of the texture
  50941. * @param options defines the options used to create the texture
  50942. * @returns a new render target texture stored in an InternalTexture
  50943. */
  50944. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  50945. /**
  50946. * Update the sampling mode of a given texture
  50947. * @param samplingMode defines the required sampling mode
  50948. * @param texture defines the texture to update
  50949. */
  50950. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50951. /**
  50952. * Binds the frame buffer to the specified texture.
  50953. * @param texture The texture to render to or null for the default canvas
  50954. * @param faceIndex The face of the texture to render to in case of cube texture
  50955. * @param requiredWidth The width of the target to render to
  50956. * @param requiredHeight The height of the target to render to
  50957. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  50958. * @param lodLevel defines le lod level to bind to the frame buffer
  50959. */
  50960. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50961. /**
  50962. * Unbind the current render target texture from the webGL context
  50963. * @param texture defines the render target texture to unbind
  50964. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  50965. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  50966. */
  50967. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50968. /**
  50969. * Creates a dynamic vertex buffer
  50970. * @param vertices the data for the dynamic vertex buffer
  50971. * @returns the new WebGL dynamic buffer
  50972. */
  50973. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  50974. /**
  50975. * Update the content of a dynamic texture
  50976. * @param texture defines the texture to update
  50977. * @param canvas defines the canvas containing the source
  50978. * @param invertY defines if data must be stored with Y axis inverted
  50979. * @param premulAlpha defines if alpha is stored as premultiplied
  50980. * @param format defines the format of the data
  50981. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  50982. */
  50983. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  50984. /**
  50985. * Gets a boolean indicating if all created effects are ready
  50986. * @returns true if all effects are ready
  50987. */
  50988. areAllEffectsReady(): boolean;
  50989. /**
  50990. * @hidden
  50991. * Get the current error code of the webGL context
  50992. * @returns the error code
  50993. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  50994. */
  50995. getError(): number;
  50996. /** @hidden */
  50997. _getUnpackAlignement(): number;
  50998. /** @hidden */
  50999. _unpackFlipY(value: boolean): void;
  51000. /**
  51001. * Update a dynamic index buffer
  51002. * @param indexBuffer defines the target index buffer
  51003. * @param indices defines the data to update
  51004. * @param offset defines the offset in the target index buffer where update should start
  51005. */
  51006. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51007. /**
  51008. * Updates a dynamic vertex buffer.
  51009. * @param vertexBuffer the vertex buffer to update
  51010. * @param vertices the data used to update the vertex buffer
  51011. * @param byteOffset the byte offset of the data (optional)
  51012. * @param byteLength the byte length of the data (optional)
  51013. */
  51014. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51015. /** @hidden */
  51016. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51017. /** @hidden */
  51018. _bindTexture(channel: number, texture: InternalTexture): void;
  51019. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51020. /**
  51021. * 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
  51022. */
  51023. releaseEffects(): void;
  51024. displayLoadingUI(): void;
  51025. hideLoadingUI(): void;
  51026. /** @hidden */
  51027. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51028. /** @hidden */
  51029. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51030. /** @hidden */
  51031. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51032. /** @hidden */
  51033. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51034. }
  51035. }
  51036. declare module BABYLON {
  51037. /**
  51038. * @hidden
  51039. **/
  51040. export class _TimeToken {
  51041. _startTimeQuery: Nullable<WebGLQuery>;
  51042. _endTimeQuery: Nullable<WebGLQuery>;
  51043. _timeElapsedQuery: Nullable<WebGLQuery>;
  51044. _timeElapsedQueryEnded: boolean;
  51045. }
  51046. }
  51047. declare module BABYLON {
  51048. /** @hidden */
  51049. export class _OcclusionDataStorage {
  51050. /** @hidden */
  51051. occlusionInternalRetryCounter: number;
  51052. /** @hidden */
  51053. isOcclusionQueryInProgress: boolean;
  51054. /** @hidden */
  51055. isOccluded: boolean;
  51056. /** @hidden */
  51057. occlusionRetryCount: number;
  51058. /** @hidden */
  51059. occlusionType: number;
  51060. /** @hidden */
  51061. occlusionQueryAlgorithmType: number;
  51062. }
  51063. interface Engine {
  51064. /**
  51065. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51066. * @return the new query
  51067. */
  51068. createQuery(): WebGLQuery;
  51069. /**
  51070. * Delete and release a webGL query
  51071. * @param query defines the query to delete
  51072. * @return the current engine
  51073. */
  51074. deleteQuery(query: WebGLQuery): Engine;
  51075. /**
  51076. * Check if a given query has resolved and got its value
  51077. * @param query defines the query to check
  51078. * @returns true if the query got its value
  51079. */
  51080. isQueryResultAvailable(query: WebGLQuery): boolean;
  51081. /**
  51082. * Gets the value of a given query
  51083. * @param query defines the query to check
  51084. * @returns the value of the query
  51085. */
  51086. getQueryResult(query: WebGLQuery): number;
  51087. /**
  51088. * Initiates an occlusion query
  51089. * @param algorithmType defines the algorithm to use
  51090. * @param query defines the query to use
  51091. * @returns the current engine
  51092. * @see https://doc.babylonjs.com/features/occlusionquery
  51093. */
  51094. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51095. /**
  51096. * Ends an occlusion query
  51097. * @see https://doc.babylonjs.com/features/occlusionquery
  51098. * @param algorithmType defines the algorithm to use
  51099. * @returns the current engine
  51100. */
  51101. endOcclusionQuery(algorithmType: number): Engine;
  51102. /**
  51103. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51104. * Please note that only one query can be issued at a time
  51105. * @returns a time token used to track the time span
  51106. */
  51107. startTimeQuery(): Nullable<_TimeToken>;
  51108. /**
  51109. * Ends a time query
  51110. * @param token defines the token used to measure the time span
  51111. * @returns the time spent (in ns)
  51112. */
  51113. endTimeQuery(token: _TimeToken): int;
  51114. /** @hidden */
  51115. _currentNonTimestampToken: Nullable<_TimeToken>;
  51116. /** @hidden */
  51117. _createTimeQuery(): WebGLQuery;
  51118. /** @hidden */
  51119. _deleteTimeQuery(query: WebGLQuery): void;
  51120. /** @hidden */
  51121. _getGlAlgorithmType(algorithmType: number): number;
  51122. /** @hidden */
  51123. _getTimeQueryResult(query: WebGLQuery): any;
  51124. /** @hidden */
  51125. _getTimeQueryAvailability(query: WebGLQuery): any;
  51126. }
  51127. interface AbstractMesh {
  51128. /**
  51129. * Backing filed
  51130. * @hidden
  51131. */
  51132. __occlusionDataStorage: _OcclusionDataStorage;
  51133. /**
  51134. * Access property
  51135. * @hidden
  51136. */
  51137. _occlusionDataStorage: _OcclusionDataStorage;
  51138. /**
  51139. * 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.
  51140. * The default value is -1 which means don't break the query and wait till the result
  51141. * @see https://doc.babylonjs.com/features/occlusionquery
  51142. */
  51143. occlusionRetryCount: number;
  51144. /**
  51145. * 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:
  51146. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51147. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51148. * * 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.
  51149. * @see https://doc.babylonjs.com/features/occlusionquery
  51150. */
  51151. occlusionType: number;
  51152. /**
  51153. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51154. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51155. * * 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.
  51156. * @see https://doc.babylonjs.com/features/occlusionquery
  51157. */
  51158. occlusionQueryAlgorithmType: number;
  51159. /**
  51160. * 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
  51161. * @see https://doc.babylonjs.com/features/occlusionquery
  51162. */
  51163. isOccluded: boolean;
  51164. /**
  51165. * Flag to check the progress status of the query
  51166. * @see https://doc.babylonjs.com/features/occlusionquery
  51167. */
  51168. isOcclusionQueryInProgress: boolean;
  51169. }
  51170. }
  51171. declare module BABYLON {
  51172. /** @hidden */
  51173. export var _forceTransformFeedbackToBundle: boolean;
  51174. interface Engine {
  51175. /**
  51176. * Creates a webGL transform feedback object
  51177. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51178. * @returns the webGL transform feedback object
  51179. */
  51180. createTransformFeedback(): WebGLTransformFeedback;
  51181. /**
  51182. * Delete a webGL transform feedback object
  51183. * @param value defines the webGL transform feedback object to delete
  51184. */
  51185. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51186. /**
  51187. * Bind a webGL transform feedback object to the webgl context
  51188. * @param value defines the webGL transform feedback object to bind
  51189. */
  51190. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51191. /**
  51192. * Begins a transform feedback operation
  51193. * @param usePoints defines if points or triangles must be used
  51194. */
  51195. beginTransformFeedback(usePoints: boolean): void;
  51196. /**
  51197. * Ends a transform feedback operation
  51198. */
  51199. endTransformFeedback(): void;
  51200. /**
  51201. * Specify the varyings to use with transform feedback
  51202. * @param program defines the associated webGL program
  51203. * @param value defines the list of strings representing the varying names
  51204. */
  51205. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51206. /**
  51207. * Bind a webGL buffer for a transform feedback operation
  51208. * @param value defines the webGL buffer to bind
  51209. */
  51210. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51211. }
  51212. }
  51213. declare module BABYLON {
  51214. /**
  51215. * Creation options of the multi render target texture.
  51216. */
  51217. export interface IMultiRenderTargetOptions {
  51218. /**
  51219. * Define if the texture needs to create mip maps after render.
  51220. */
  51221. generateMipMaps?: boolean;
  51222. /**
  51223. * Define the types of all the draw buffers we want to create
  51224. */
  51225. types?: number[];
  51226. /**
  51227. * Define the sampling modes of all the draw buffers we want to create
  51228. */
  51229. samplingModes?: number[];
  51230. /**
  51231. * Define if a depth buffer is required
  51232. */
  51233. generateDepthBuffer?: boolean;
  51234. /**
  51235. * Define if a stencil buffer is required
  51236. */
  51237. generateStencilBuffer?: boolean;
  51238. /**
  51239. * Define if a depth texture is required instead of a depth buffer
  51240. */
  51241. generateDepthTexture?: boolean;
  51242. /**
  51243. * Define the number of desired draw buffers
  51244. */
  51245. textureCount?: number;
  51246. /**
  51247. * Define if aspect ratio should be adapted to the texture or stay the scene one
  51248. */
  51249. doNotChangeAspectRatio?: boolean;
  51250. /**
  51251. * Define the default type of the buffers we are creating
  51252. */
  51253. defaultType?: number;
  51254. }
  51255. /**
  51256. * A multi render target, like a render target provides the ability to render to a texture.
  51257. * Unlike the render target, it can render to several draw buffers in one draw.
  51258. * This is specially interesting in deferred rendering or for any effects requiring more than
  51259. * just one color from a single pass.
  51260. */
  51261. export class MultiRenderTarget extends RenderTargetTexture {
  51262. private _internalTextures;
  51263. private _textures;
  51264. private _multiRenderTargetOptions;
  51265. private _count;
  51266. /**
  51267. * Get if draw buffers are currently supported by the used hardware and browser.
  51268. */
  51269. get isSupported(): boolean;
  51270. /**
  51271. * Get the list of textures generated by the multi render target.
  51272. */
  51273. get textures(): Texture[];
  51274. /**
  51275. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  51276. */
  51277. get count(): number;
  51278. /**
  51279. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  51280. */
  51281. get depthTexture(): Texture;
  51282. /**
  51283. * Set the wrapping mode on U of all the textures we are rendering to.
  51284. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51285. */
  51286. set wrapU(wrap: number);
  51287. /**
  51288. * Set the wrapping mode on V of all the textures we are rendering to.
  51289. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  51290. */
  51291. set wrapV(wrap: number);
  51292. /**
  51293. * Instantiate a new multi render target texture.
  51294. * A multi render target, like a render target provides the ability to render to a texture.
  51295. * Unlike the render target, it can render to several draw buffers in one draw.
  51296. * This is specially interesting in deferred rendering or for any effects requiring more than
  51297. * just one color from a single pass.
  51298. * @param name Define the name of the texture
  51299. * @param size Define the size of the buffers to render to
  51300. * @param count Define the number of target we are rendering into
  51301. * @param scene Define the scene the texture belongs to
  51302. * @param options Define the options used to create the multi render target
  51303. */
  51304. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  51305. /** @hidden */
  51306. _rebuild(): void;
  51307. private _createInternalTextures;
  51308. private _createTextures;
  51309. /**
  51310. * Define the number of samples used if MSAA is enabled.
  51311. */
  51312. get samples(): number;
  51313. set samples(value: number);
  51314. /**
  51315. * Resize all the textures in the multi render target.
  51316. * Be carrefull as it will recreate all the data in the new texture.
  51317. * @param size Define the new size
  51318. */
  51319. resize(size: any): void;
  51320. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  51321. /**
  51322. * Dispose the render targets and their associated resources
  51323. */
  51324. dispose(): void;
  51325. /**
  51326. * Release all the underlying texture used as draw buffers.
  51327. */
  51328. releaseInternalTextures(): void;
  51329. }
  51330. }
  51331. declare module BABYLON {
  51332. interface ThinEngine {
  51333. /**
  51334. * Unbind a list of render target textures from the webGL context
  51335. * This is used only when drawBuffer extension or webGL2 are active
  51336. * @param textures defines the render target textures to unbind
  51337. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51338. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51339. */
  51340. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  51341. /**
  51342. * Create a multi render target texture
  51343. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  51344. * @param size defines the size of the texture
  51345. * @param options defines the creation options
  51346. * @returns the cube texture as an InternalTexture
  51347. */
  51348. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  51349. /**
  51350. * Update the sample count for a given multiple render target texture
  51351. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  51352. * @param textures defines the textures to update
  51353. * @param samples defines the sample count to set
  51354. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  51355. */
  51356. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  51357. /**
  51358. * Select a subsets of attachments to draw to.
  51359. * @param attachments gl attachments
  51360. */
  51361. bindAttachments(attachments: number[]): void;
  51362. }
  51363. }
  51364. declare module BABYLON {
  51365. /**
  51366. * Class used to define an additional view for the engine
  51367. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51368. */
  51369. export class EngineView {
  51370. /** Defines the canvas where to render the view */
  51371. target: HTMLCanvasElement;
  51372. /** Defines an optional camera used to render the view (will use active camera else) */
  51373. camera?: Camera;
  51374. }
  51375. interface Engine {
  51376. /**
  51377. * Gets or sets the HTML element to use for attaching events
  51378. */
  51379. inputElement: Nullable<HTMLElement>;
  51380. /**
  51381. * Gets the current engine view
  51382. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51383. */
  51384. activeView: Nullable<EngineView>;
  51385. /** Gets or sets the list of views */
  51386. views: EngineView[];
  51387. /**
  51388. * Register a new child canvas
  51389. * @param canvas defines the canvas to register
  51390. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51391. * @returns the associated view
  51392. */
  51393. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51394. /**
  51395. * Remove a registered child canvas
  51396. * @param canvas defines the canvas to remove
  51397. * @returns the current engine
  51398. */
  51399. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51400. }
  51401. }
  51402. declare module BABYLON {
  51403. interface Engine {
  51404. /** @hidden */
  51405. _excludedCompressedTextures: string[];
  51406. /** @hidden */
  51407. _textureFormatInUse: string;
  51408. /**
  51409. * Gets the list of texture formats supported
  51410. */
  51411. readonly texturesSupported: Array<string>;
  51412. /**
  51413. * Gets the texture format in use
  51414. */
  51415. readonly textureFormatInUse: Nullable<string>;
  51416. /**
  51417. * Set the compressed texture extensions or file names to skip.
  51418. *
  51419. * @param skippedFiles defines the list of those texture files you want to skip
  51420. * Example: [".dds", ".env", "myfile.png"]
  51421. */
  51422. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51423. /**
  51424. * Set the compressed texture format to use, based on the formats you have, and the formats
  51425. * supported by the hardware / browser.
  51426. *
  51427. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51428. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51429. * to API arguments needed to compressed textures. This puts the burden on the container
  51430. * generator to house the arcane code for determining these for current & future formats.
  51431. *
  51432. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51433. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51434. *
  51435. * Note: The result of this call is not taken into account when a texture is base64.
  51436. *
  51437. * @param formatsAvailable defines the list of those format families you have created
  51438. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51439. *
  51440. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51441. * @returns The extension selected.
  51442. */
  51443. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51444. }
  51445. }
  51446. declare module BABYLON {
  51447. /**
  51448. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51449. */
  51450. export interface CubeMapInfo {
  51451. /**
  51452. * The pixel array for the front face.
  51453. * This is stored in format, left to right, up to down format.
  51454. */
  51455. front: Nullable<ArrayBufferView>;
  51456. /**
  51457. * The pixel array for the back face.
  51458. * This is stored in format, left to right, up to down format.
  51459. */
  51460. back: Nullable<ArrayBufferView>;
  51461. /**
  51462. * The pixel array for the left face.
  51463. * This is stored in format, left to right, up to down format.
  51464. */
  51465. left: Nullable<ArrayBufferView>;
  51466. /**
  51467. * The pixel array for the right face.
  51468. * This is stored in format, left to right, up to down format.
  51469. */
  51470. right: Nullable<ArrayBufferView>;
  51471. /**
  51472. * The pixel array for the up face.
  51473. * This is stored in format, left to right, up to down format.
  51474. */
  51475. up: Nullable<ArrayBufferView>;
  51476. /**
  51477. * The pixel array for the down face.
  51478. * This is stored in format, left to right, up to down format.
  51479. */
  51480. down: Nullable<ArrayBufferView>;
  51481. /**
  51482. * The size of the cubemap stored.
  51483. *
  51484. * Each faces will be size * size pixels.
  51485. */
  51486. size: number;
  51487. /**
  51488. * The format of the texture.
  51489. *
  51490. * RGBA, RGB.
  51491. */
  51492. format: number;
  51493. /**
  51494. * The type of the texture data.
  51495. *
  51496. * UNSIGNED_INT, FLOAT.
  51497. */
  51498. type: number;
  51499. /**
  51500. * Specifies whether the texture is in gamma space.
  51501. */
  51502. gammaSpace: boolean;
  51503. }
  51504. /**
  51505. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51506. */
  51507. export class PanoramaToCubeMapTools {
  51508. private static FACE_LEFT;
  51509. private static FACE_RIGHT;
  51510. private static FACE_FRONT;
  51511. private static FACE_BACK;
  51512. private static FACE_DOWN;
  51513. private static FACE_UP;
  51514. /**
  51515. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51516. *
  51517. * @param float32Array The source data.
  51518. * @param inputWidth The width of the input panorama.
  51519. * @param inputHeight The height of the input panorama.
  51520. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51521. * @return The cubemap data
  51522. */
  51523. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51524. private static CreateCubemapTexture;
  51525. private static CalcProjectionSpherical;
  51526. }
  51527. }
  51528. declare module BABYLON {
  51529. /**
  51530. * Helper class dealing with the extraction of spherical polynomial dataArray
  51531. * from a cube map.
  51532. */
  51533. export class CubeMapToSphericalPolynomialTools {
  51534. private static FileFaces;
  51535. /**
  51536. * Converts a texture to the according Spherical Polynomial data.
  51537. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51538. *
  51539. * @param texture The texture to extract the information from.
  51540. * @return The Spherical Polynomial data.
  51541. */
  51542. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51543. /**
  51544. * Converts a cubemap to the according Spherical Polynomial data.
  51545. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51546. *
  51547. * @param cubeInfo The Cube map to extract the information from.
  51548. * @return The Spherical Polynomial data.
  51549. */
  51550. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51551. }
  51552. }
  51553. declare module BABYLON {
  51554. interface BaseTexture {
  51555. /**
  51556. * Get the polynomial representation of the texture data.
  51557. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51558. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51559. */
  51560. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51561. }
  51562. }
  51563. declare module BABYLON {
  51564. /** @hidden */
  51565. export var rgbdEncodePixelShader: {
  51566. name: string;
  51567. shader: string;
  51568. };
  51569. }
  51570. declare module BABYLON {
  51571. /** @hidden */
  51572. export var rgbdDecodePixelShader: {
  51573. name: string;
  51574. shader: string;
  51575. };
  51576. }
  51577. declare module BABYLON {
  51578. /**
  51579. * Raw texture data and descriptor sufficient for WebGL texture upload
  51580. */
  51581. export interface EnvironmentTextureInfo {
  51582. /**
  51583. * Version of the environment map
  51584. */
  51585. version: number;
  51586. /**
  51587. * Width of image
  51588. */
  51589. width: number;
  51590. /**
  51591. * Irradiance information stored in the file.
  51592. */
  51593. irradiance: any;
  51594. /**
  51595. * Specular information stored in the file.
  51596. */
  51597. specular: any;
  51598. }
  51599. /**
  51600. * Defines One Image in the file. It requires only the position in the file
  51601. * as well as the length.
  51602. */
  51603. interface BufferImageData {
  51604. /**
  51605. * Length of the image data.
  51606. */
  51607. length: number;
  51608. /**
  51609. * Position of the data from the null terminator delimiting the end of the JSON.
  51610. */
  51611. position: number;
  51612. }
  51613. /**
  51614. * Defines the specular data enclosed in the file.
  51615. * This corresponds to the version 1 of the data.
  51616. */
  51617. export interface EnvironmentTextureSpecularInfoV1 {
  51618. /**
  51619. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  51620. */
  51621. specularDataPosition?: number;
  51622. /**
  51623. * This contains all the images data needed to reconstruct the cubemap.
  51624. */
  51625. mipmaps: Array<BufferImageData>;
  51626. /**
  51627. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  51628. */
  51629. lodGenerationScale: number;
  51630. }
  51631. /**
  51632. * Sets of helpers addressing the serialization and deserialization of environment texture
  51633. * stored in a BabylonJS env file.
  51634. * Those files are usually stored as .env files.
  51635. */
  51636. export class EnvironmentTextureTools {
  51637. /**
  51638. * Magic number identifying the env file.
  51639. */
  51640. private static _MagicBytes;
  51641. /**
  51642. * Gets the environment info from an env file.
  51643. * @param data The array buffer containing the .env bytes.
  51644. * @returns the environment file info (the json header) if successfully parsed.
  51645. */
  51646. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  51647. /**
  51648. * Creates an environment texture from a loaded cube texture.
  51649. * @param texture defines the cube texture to convert in env file
  51650. * @return a promise containing the environment data if succesfull.
  51651. */
  51652. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  51653. /**
  51654. * Creates a JSON representation of the spherical data.
  51655. * @param texture defines the texture containing the polynomials
  51656. * @return the JSON representation of the spherical info
  51657. */
  51658. private static _CreateEnvTextureIrradiance;
  51659. /**
  51660. * Creates the ArrayBufferViews used for initializing environment texture image data.
  51661. * @param data the image data
  51662. * @param info parameters that determine what views will be created for accessing the underlying buffer
  51663. * @return the views described by info providing access to the underlying buffer
  51664. */
  51665. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  51666. /**
  51667. * Uploads the texture info contained in the env file to the GPU.
  51668. * @param texture defines the internal texture to upload to
  51669. * @param data defines the data to load
  51670. * @param info defines the texture info retrieved through the GetEnvInfo method
  51671. * @returns a promise
  51672. */
  51673. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  51674. private static _OnImageReadyAsync;
  51675. /**
  51676. * Uploads the levels of image data to the GPU.
  51677. * @param texture defines the internal texture to upload to
  51678. * @param imageData defines the array buffer views of image data [mipmap][face]
  51679. * @returns a promise
  51680. */
  51681. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  51682. /**
  51683. * Uploads spherical polynomials information to the texture.
  51684. * @param texture defines the texture we are trying to upload the information to
  51685. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  51686. */
  51687. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  51688. /** @hidden */
  51689. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51690. }
  51691. }
  51692. declare module BABYLON {
  51693. /**
  51694. * Class used to inline functions in shader code
  51695. */
  51696. export class ShaderCodeInliner {
  51697. private static readonly _RegexpFindFunctionNameAndType;
  51698. private _sourceCode;
  51699. private _functionDescr;
  51700. private _numMaxIterations;
  51701. /** Gets or sets the token used to mark the functions to inline */
  51702. inlineToken: string;
  51703. /** Gets or sets the debug mode */
  51704. debug: boolean;
  51705. /** Gets the code after the inlining process */
  51706. get code(): string;
  51707. /**
  51708. * Initializes the inliner
  51709. * @param sourceCode shader code source to inline
  51710. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  51711. */
  51712. constructor(sourceCode: string, numMaxIterations?: number);
  51713. /**
  51714. * Start the processing of the shader code
  51715. */
  51716. processCode(): void;
  51717. private _collectFunctions;
  51718. private _processInlining;
  51719. private _extractBetweenMarkers;
  51720. private _skipWhitespaces;
  51721. private _removeComments;
  51722. private _replaceFunctionCallsByCode;
  51723. private _findBackward;
  51724. private _escapeRegExp;
  51725. private _replaceNames;
  51726. }
  51727. }
  51728. declare module BABYLON {
  51729. /**
  51730. * Container for accessors for natively-stored mesh data buffers.
  51731. */
  51732. class NativeDataBuffer extends DataBuffer {
  51733. /**
  51734. * Accessor value used to identify/retrieve a natively-stored index buffer.
  51735. */
  51736. nativeIndexBuffer?: any;
  51737. /**
  51738. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  51739. */
  51740. nativeVertexBuffer?: any;
  51741. }
  51742. /** @hidden */
  51743. class NativeTexture extends InternalTexture {
  51744. getInternalTexture(): InternalTexture;
  51745. getViewCount(): number;
  51746. }
  51747. /** @hidden */
  51748. export class NativeEngine extends Engine {
  51749. private readonly _native;
  51750. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  51751. private readonly INVALID_HANDLE;
  51752. getHardwareScalingLevel(): number;
  51753. constructor();
  51754. dispose(): void;
  51755. /**
  51756. * Can be used to override the current requestAnimationFrame requester.
  51757. * @hidden
  51758. */
  51759. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  51760. /**
  51761. * Override default engine behavior.
  51762. * @param color
  51763. * @param backBuffer
  51764. * @param depth
  51765. * @param stencil
  51766. */
  51767. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  51768. /**
  51769. * Gets host document
  51770. * @returns the host document object
  51771. */
  51772. getHostDocument(): Nullable<Document>;
  51773. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51774. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  51775. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  51776. recordVertexArrayObject(vertexBuffers: {
  51777. [key: string]: VertexBuffer;
  51778. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  51779. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51780. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  51781. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51782. /**
  51783. * Draw a list of indexed primitives
  51784. * @param fillMode defines the primitive to use
  51785. * @param indexStart defines the starting index
  51786. * @param indexCount defines the number of index to draw
  51787. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51788. */
  51789. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51790. /**
  51791. * Draw a list of unindexed primitives
  51792. * @param fillMode defines the primitive to use
  51793. * @param verticesStart defines the index of first vertex to draw
  51794. * @param verticesCount defines the count of vertices to draw
  51795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51796. */
  51797. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51798. createPipelineContext(): IPipelineContext;
  51799. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  51800. /** @hidden */
  51801. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  51802. /** @hidden */
  51803. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  51804. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51805. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  51806. protected _setProgram(program: WebGLProgram): void;
  51807. _releaseEffect(effect: Effect): void;
  51808. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  51809. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  51810. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  51811. bindSamplers(effect: Effect): void;
  51812. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  51813. getRenderWidth(useScreen?: boolean): number;
  51814. getRenderHeight(useScreen?: boolean): number;
  51815. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  51816. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51817. /**
  51818. * Set the z offset to apply to current rendering
  51819. * @param value defines the offset to apply
  51820. */
  51821. setZOffset(value: number): void;
  51822. /**
  51823. * Gets the current value of the zOffset
  51824. * @returns the current zOffset state
  51825. */
  51826. getZOffset(): number;
  51827. /**
  51828. * Enable or disable depth buffering
  51829. * @param enable defines the state to set
  51830. */
  51831. setDepthBuffer(enable: boolean): void;
  51832. /**
  51833. * Gets a boolean indicating if depth writing is enabled
  51834. * @returns the current depth writing state
  51835. */
  51836. getDepthWrite(): boolean;
  51837. /**
  51838. * Enable or disable depth writing
  51839. * @param enable defines the state to set
  51840. */
  51841. setDepthWrite(enable: boolean): void;
  51842. /**
  51843. * Enable or disable color writing
  51844. * @param enable defines the state to set
  51845. */
  51846. setColorWrite(enable: boolean): void;
  51847. /**
  51848. * Gets a boolean indicating if color writing is enabled
  51849. * @returns the current color writing state
  51850. */
  51851. getColorWrite(): boolean;
  51852. /**
  51853. * Sets alpha constants used by some alpha blending modes
  51854. * @param r defines the red component
  51855. * @param g defines the green component
  51856. * @param b defines the blue component
  51857. * @param a defines the alpha component
  51858. */
  51859. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  51860. /**
  51861. * Sets the current alpha mode
  51862. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  51863. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51864. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51865. */
  51866. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51867. /**
  51868. * Gets the current alpha mode
  51869. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51870. * @returns the current alpha mode
  51871. */
  51872. getAlphaMode(): number;
  51873. setInt(uniform: WebGLUniformLocation, int: number): void;
  51874. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51875. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51876. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51877. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51878. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51879. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51880. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51881. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51882. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51883. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51884. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51885. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51886. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51887. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51888. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51889. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51890. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51891. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51892. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51893. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  51894. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  51895. wipeCaches(bruteForce?: boolean): void;
  51896. _createTexture(): WebGLTexture;
  51897. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  51898. /**
  51899. * Usually called from Texture.ts.
  51900. * Passed information to create a WebGLTexture
  51901. * @param url defines a value which contains one of the following:
  51902. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51903. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51904. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51905. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51906. * @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)
  51907. * @param scene needed for loading to the correct scene
  51908. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51909. * @param onLoad optional callback to be called upon successful completion
  51910. * @param onError optional callback to be called upon failure
  51911. * @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
  51912. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51913. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51914. * @param forcedExtension defines the extension to use to pick the right loader
  51915. * @param mimeType defines an optional mime type
  51916. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51917. */
  51918. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  51919. /**
  51920. * Creates a cube texture
  51921. * @param rootUrl defines the url where the files to load is located
  51922. * @param scene defines the current scene
  51923. * @param files defines the list of files to load (1 per face)
  51924. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  51925. * @param onLoad defines an optional callback raised when the texture is loaded
  51926. * @param onError defines an optional callback raised if there is an issue to load the texture
  51927. * @param format defines the format of the data
  51928. * @param forcedExtension defines the extension to use to pick the right loader
  51929. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  51930. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51931. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51932. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  51933. * @returns the cube texture as an InternalTexture
  51934. */
  51935. 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;
  51936. private _getSamplingFilter;
  51937. private static _GetNativeTextureFormat;
  51938. createRenderTargetTexture(size: number | {
  51939. width: number;
  51940. height: number;
  51941. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  51942. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51943. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51944. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51945. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  51946. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  51947. /**
  51948. * Updates a dynamic vertex buffer.
  51949. * @param vertexBuffer the vertex buffer to update
  51950. * @param data the data used to update the vertex buffer
  51951. * @param byteOffset the byte offset of the data (optional)
  51952. * @param byteLength the byte length of the data (optional)
  51953. */
  51954. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  51955. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  51956. private _updateAnisotropicLevel;
  51957. private _getAddressMode;
  51958. /** @hidden */
  51959. _bindTexture(channel: number, texture: InternalTexture): void;
  51960. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  51961. releaseEffects(): void;
  51962. /** @hidden */
  51963. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51964. /** @hidden */
  51965. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51966. /** @hidden */
  51967. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51968. /** @hidden */
  51969. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51970. }
  51971. }
  51972. declare module BABYLON {
  51973. /**
  51974. * Gather the list of clipboard event types as constants.
  51975. */
  51976. export class ClipboardEventTypes {
  51977. /**
  51978. * The clipboard event is fired when a copy command is active (pressed).
  51979. */
  51980. static readonly COPY: number;
  51981. /**
  51982. * The clipboard event is fired when a cut command is active (pressed).
  51983. */
  51984. static readonly CUT: number;
  51985. /**
  51986. * The clipboard event is fired when a paste command is active (pressed).
  51987. */
  51988. static readonly PASTE: number;
  51989. }
  51990. /**
  51991. * This class is used to store clipboard related info for the onClipboardObservable event.
  51992. */
  51993. export class ClipboardInfo {
  51994. /**
  51995. * Defines the type of event (BABYLON.ClipboardEventTypes)
  51996. */
  51997. type: number;
  51998. /**
  51999. * Defines the related dom event
  52000. */
  52001. event: ClipboardEvent;
  52002. /**
  52003. *Creates an instance of ClipboardInfo.
  52004. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52005. * @param event Defines the related dom event
  52006. */
  52007. constructor(
  52008. /**
  52009. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52010. */
  52011. type: number,
  52012. /**
  52013. * Defines the related dom event
  52014. */
  52015. event: ClipboardEvent);
  52016. /**
  52017. * Get the clipboard event's type from the keycode.
  52018. * @param keyCode Defines the keyCode for the current keyboard event.
  52019. * @return {number}
  52020. */
  52021. static GetTypeFromCharacter(keyCode: number): number;
  52022. }
  52023. }
  52024. declare module BABYLON {
  52025. /**
  52026. * Google Daydream controller
  52027. */
  52028. export class DaydreamController extends WebVRController {
  52029. /**
  52030. * Base Url for the controller model.
  52031. */
  52032. static MODEL_BASE_URL: string;
  52033. /**
  52034. * File name for the controller model.
  52035. */
  52036. static MODEL_FILENAME: string;
  52037. /**
  52038. * Gamepad Id prefix used to identify Daydream Controller.
  52039. */
  52040. static readonly GAMEPAD_ID_PREFIX: string;
  52041. /**
  52042. * Creates a new DaydreamController from a gamepad
  52043. * @param vrGamepad the gamepad that the controller should be created from
  52044. */
  52045. constructor(vrGamepad: any);
  52046. /**
  52047. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52048. * @param scene scene in which to add meshes
  52049. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52050. */
  52051. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52052. /**
  52053. * Called once for each button that changed state since the last frame
  52054. * @param buttonIdx Which button index changed
  52055. * @param state New state of the button
  52056. * @param changes Which properties on the state changed since last frame
  52057. */
  52058. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52059. }
  52060. }
  52061. declare module BABYLON {
  52062. /**
  52063. * Gear VR Controller
  52064. */
  52065. export class GearVRController extends WebVRController {
  52066. /**
  52067. * Base Url for the controller model.
  52068. */
  52069. static MODEL_BASE_URL: string;
  52070. /**
  52071. * File name for the controller model.
  52072. */
  52073. static MODEL_FILENAME: string;
  52074. /**
  52075. * Gamepad Id prefix used to identify this controller.
  52076. */
  52077. static readonly GAMEPAD_ID_PREFIX: string;
  52078. private readonly _buttonIndexToObservableNameMap;
  52079. /**
  52080. * Creates a new GearVRController from a gamepad
  52081. * @param vrGamepad the gamepad that the controller should be created from
  52082. */
  52083. constructor(vrGamepad: any);
  52084. /**
  52085. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52086. * @param scene scene in which to add meshes
  52087. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52088. */
  52089. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52090. /**
  52091. * Called once for each button that changed state since the last frame
  52092. * @param buttonIdx Which button index changed
  52093. * @param state New state of the button
  52094. * @param changes Which properties on the state changed since last frame
  52095. */
  52096. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52097. }
  52098. }
  52099. declare module BABYLON {
  52100. /**
  52101. * Generic Controller
  52102. */
  52103. export class GenericController extends WebVRController {
  52104. /**
  52105. * Base Url for the controller model.
  52106. */
  52107. static readonly MODEL_BASE_URL: string;
  52108. /**
  52109. * File name for the controller model.
  52110. */
  52111. static readonly MODEL_FILENAME: string;
  52112. /**
  52113. * Creates a new GenericController from a gamepad
  52114. * @param vrGamepad the gamepad that the controller should be created from
  52115. */
  52116. constructor(vrGamepad: any);
  52117. /**
  52118. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52119. * @param scene scene in which to add meshes
  52120. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52121. */
  52122. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52123. /**
  52124. * Called once for each button that changed state since the last frame
  52125. * @param buttonIdx Which button index changed
  52126. * @param state New state of the button
  52127. * @param changes Which properties on the state changed since last frame
  52128. */
  52129. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52130. }
  52131. }
  52132. declare module BABYLON {
  52133. /**
  52134. * Oculus Touch Controller
  52135. */
  52136. export class OculusTouchController extends WebVRController {
  52137. /**
  52138. * Base Url for the controller model.
  52139. */
  52140. static MODEL_BASE_URL: string;
  52141. /**
  52142. * File name for the left controller model.
  52143. */
  52144. static MODEL_LEFT_FILENAME: string;
  52145. /**
  52146. * File name for the right controller model.
  52147. */
  52148. static MODEL_RIGHT_FILENAME: string;
  52149. /**
  52150. * Base Url for the Quest controller model.
  52151. */
  52152. static QUEST_MODEL_BASE_URL: string;
  52153. /**
  52154. * @hidden
  52155. * If the controllers are running on a device that needs the updated Quest controller models
  52156. */
  52157. static _IsQuest: boolean;
  52158. /**
  52159. * Fired when the secondary trigger on this controller is modified
  52160. */
  52161. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52162. /**
  52163. * Fired when the thumb rest on this controller is modified
  52164. */
  52165. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52166. /**
  52167. * Creates a new OculusTouchController from a gamepad
  52168. * @param vrGamepad the gamepad that the controller should be created from
  52169. */
  52170. constructor(vrGamepad: any);
  52171. /**
  52172. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52173. * @param scene scene in which to add meshes
  52174. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52175. */
  52176. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52177. /**
  52178. * Fired when the A button on this controller is modified
  52179. */
  52180. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52181. /**
  52182. * Fired when the B button on this controller is modified
  52183. */
  52184. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52185. /**
  52186. * Fired when the X button on this controller is modified
  52187. */
  52188. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52189. /**
  52190. * Fired when the Y button on this controller is modified
  52191. */
  52192. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52193. /**
  52194. * Called once for each button that changed state since the last frame
  52195. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52196. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52197. * 2) secondary trigger (same)
  52198. * 3) A (right) X (left), touch, pressed = value
  52199. * 4) B / Y
  52200. * 5) thumb rest
  52201. * @param buttonIdx Which button index changed
  52202. * @param state New state of the button
  52203. * @param changes Which properties on the state changed since last frame
  52204. */
  52205. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52206. }
  52207. }
  52208. declare module BABYLON {
  52209. /**
  52210. * Vive Controller
  52211. */
  52212. export class ViveController extends WebVRController {
  52213. /**
  52214. * Base Url for the controller model.
  52215. */
  52216. static MODEL_BASE_URL: string;
  52217. /**
  52218. * File name for the controller model.
  52219. */
  52220. static MODEL_FILENAME: string;
  52221. /**
  52222. * Creates a new ViveController from a gamepad
  52223. * @param vrGamepad the gamepad that the controller should be created from
  52224. */
  52225. constructor(vrGamepad: any);
  52226. /**
  52227. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52228. * @param scene scene in which to add meshes
  52229. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52230. */
  52231. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52232. /**
  52233. * Fired when the left button on this controller is modified
  52234. */
  52235. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52236. /**
  52237. * Fired when the right button on this controller is modified
  52238. */
  52239. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52240. /**
  52241. * Fired when the menu button on this controller is modified
  52242. */
  52243. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52244. /**
  52245. * Called once for each button that changed state since the last frame
  52246. * Vive mapping:
  52247. * 0: touchpad
  52248. * 1: trigger
  52249. * 2: left AND right buttons
  52250. * 3: menu button
  52251. * @param buttonIdx Which button index changed
  52252. * @param state New state of the button
  52253. * @param changes Which properties on the state changed since last frame
  52254. */
  52255. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52256. }
  52257. }
  52258. declare module BABYLON {
  52259. /**
  52260. * Defines the WindowsMotionController object that the state of the windows motion controller
  52261. */
  52262. export class WindowsMotionController extends WebVRController {
  52263. /**
  52264. * The base url used to load the left and right controller models
  52265. */
  52266. static MODEL_BASE_URL: string;
  52267. /**
  52268. * The name of the left controller model file
  52269. */
  52270. static MODEL_LEFT_FILENAME: string;
  52271. /**
  52272. * The name of the right controller model file
  52273. */
  52274. static MODEL_RIGHT_FILENAME: string;
  52275. /**
  52276. * The controller name prefix for this controller type
  52277. */
  52278. static readonly GAMEPAD_ID_PREFIX: string;
  52279. /**
  52280. * The controller id pattern for this controller type
  52281. */
  52282. private static readonly GAMEPAD_ID_PATTERN;
  52283. private _loadedMeshInfo;
  52284. protected readonly _mapping: {
  52285. buttons: string[];
  52286. buttonMeshNames: {
  52287. trigger: string;
  52288. menu: string;
  52289. grip: string;
  52290. thumbstick: string;
  52291. trackpad: string;
  52292. };
  52293. buttonObservableNames: {
  52294. trigger: string;
  52295. menu: string;
  52296. grip: string;
  52297. thumbstick: string;
  52298. trackpad: string;
  52299. };
  52300. axisMeshNames: string[];
  52301. pointingPoseMeshName: string;
  52302. };
  52303. /**
  52304. * Fired when the trackpad on this controller is clicked
  52305. */
  52306. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52307. /**
  52308. * Fired when the trackpad on this controller is modified
  52309. */
  52310. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52311. /**
  52312. * The current x and y values of this controller's trackpad
  52313. */
  52314. trackpad: StickValues;
  52315. /**
  52316. * Creates a new WindowsMotionController from a gamepad
  52317. * @param vrGamepad the gamepad that the controller should be created from
  52318. */
  52319. constructor(vrGamepad: any);
  52320. /**
  52321. * Fired when the trigger on this controller is modified
  52322. */
  52323. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52324. /**
  52325. * Fired when the menu button on this controller is modified
  52326. */
  52327. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52328. /**
  52329. * Fired when the grip button on this controller is modified
  52330. */
  52331. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52332. /**
  52333. * Fired when the thumbstick button on this controller is modified
  52334. */
  52335. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52336. /**
  52337. * Fired when the touchpad button on this controller is modified
  52338. */
  52339. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52340. /**
  52341. * Fired when the touchpad values on this controller are modified
  52342. */
  52343. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52344. protected _updateTrackpad(): void;
  52345. /**
  52346. * Called once per frame by the engine.
  52347. */
  52348. update(): void;
  52349. /**
  52350. * Called once for each button that changed state since the last frame
  52351. * @param buttonIdx Which button index changed
  52352. * @param state New state of the button
  52353. * @param changes Which properties on the state changed since last frame
  52354. */
  52355. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52356. /**
  52357. * Moves the buttons on the controller mesh based on their current state
  52358. * @param buttonName the name of the button to move
  52359. * @param buttonValue the value of the button which determines the buttons new position
  52360. */
  52361. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52362. /**
  52363. * Moves the axis on the controller mesh based on its current state
  52364. * @param axis the index of the axis
  52365. * @param axisValue the value of the axis which determines the meshes new position
  52366. * @hidden
  52367. */
  52368. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52369. /**
  52370. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52371. * @param scene scene in which to add meshes
  52372. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52373. */
  52374. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52375. /**
  52376. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52377. * can be transformed by button presses and axes values, based on this._mapping.
  52378. *
  52379. * @param scene scene in which the meshes exist
  52380. * @param meshes list of meshes that make up the controller model to process
  52381. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52382. */
  52383. private processModel;
  52384. private createMeshInfo;
  52385. /**
  52386. * Gets the ray of the controller in the direction the controller is pointing
  52387. * @param length the length the resulting ray should be
  52388. * @returns a ray in the direction the controller is pointing
  52389. */
  52390. getForwardRay(length?: number): Ray;
  52391. /**
  52392. * Disposes of the controller
  52393. */
  52394. dispose(): void;
  52395. }
  52396. /**
  52397. * This class represents a new windows motion controller in XR.
  52398. */
  52399. export class XRWindowsMotionController extends WindowsMotionController {
  52400. /**
  52401. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52402. */
  52403. protected readonly _mapping: {
  52404. buttons: string[];
  52405. buttonMeshNames: {
  52406. trigger: string;
  52407. menu: string;
  52408. grip: string;
  52409. thumbstick: string;
  52410. trackpad: string;
  52411. };
  52412. buttonObservableNames: {
  52413. trigger: string;
  52414. menu: string;
  52415. grip: string;
  52416. thumbstick: string;
  52417. trackpad: string;
  52418. };
  52419. axisMeshNames: string[];
  52420. pointingPoseMeshName: string;
  52421. };
  52422. /**
  52423. * Construct a new XR-Based windows motion controller
  52424. *
  52425. * @param gamepadInfo the gamepad object from the browser
  52426. */
  52427. constructor(gamepadInfo: any);
  52428. /**
  52429. * holds the thumbstick values (X,Y)
  52430. */
  52431. thumbstickValues: StickValues;
  52432. /**
  52433. * Fired when the thumbstick on this controller is clicked
  52434. */
  52435. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52436. /**
  52437. * Fired when the thumbstick on this controller is modified
  52438. */
  52439. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52440. /**
  52441. * Fired when the touchpad button on this controller is modified
  52442. */
  52443. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52444. /**
  52445. * Fired when the touchpad values on this controller are modified
  52446. */
  52447. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52448. /**
  52449. * Fired when the thumbstick button on this controller is modified
  52450. * here to prevent breaking changes
  52451. */
  52452. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52453. /**
  52454. * updating the thumbstick(!) and not the trackpad.
  52455. * This is named this way due to the difference between WebVR and XR and to avoid
  52456. * changing the parent class.
  52457. */
  52458. protected _updateTrackpad(): void;
  52459. /**
  52460. * Disposes the class with joy
  52461. */
  52462. dispose(): void;
  52463. }
  52464. }
  52465. declare module BABYLON {
  52466. /**
  52467. * Class containing static functions to help procedurally build meshes
  52468. */
  52469. export class PolyhedronBuilder {
  52470. /**
  52471. * Creates a polyhedron mesh
  52472. * * 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
  52473. * * The parameter `size` (positive float, default 1) sets the polygon size
  52474. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52475. * * 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`
  52476. * * 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
  52477. * * 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)`)
  52478. * * 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
  52479. * * 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
  52480. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52481. * * 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
  52482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52483. * @param name defines the name of the mesh
  52484. * @param options defines the options used to create the mesh
  52485. * @param scene defines the hosting scene
  52486. * @returns the polyhedron mesh
  52487. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52488. */
  52489. static CreatePolyhedron(name: string, options: {
  52490. type?: number;
  52491. size?: number;
  52492. sizeX?: number;
  52493. sizeY?: number;
  52494. sizeZ?: number;
  52495. custom?: any;
  52496. faceUV?: Vector4[];
  52497. faceColors?: Color4[];
  52498. flat?: boolean;
  52499. updatable?: boolean;
  52500. sideOrientation?: number;
  52501. frontUVs?: Vector4;
  52502. backUVs?: Vector4;
  52503. }, scene?: Nullable<Scene>): Mesh;
  52504. }
  52505. }
  52506. declare module BABYLON {
  52507. /**
  52508. * Gizmo that enables scaling a mesh along 3 axis
  52509. */
  52510. export class ScaleGizmo extends Gizmo {
  52511. /**
  52512. * Internal gizmo used for interactions on the x axis
  52513. */
  52514. xGizmo: AxisScaleGizmo;
  52515. /**
  52516. * Internal gizmo used for interactions on the y axis
  52517. */
  52518. yGizmo: AxisScaleGizmo;
  52519. /**
  52520. * Internal gizmo used for interactions on the z axis
  52521. */
  52522. zGizmo: AxisScaleGizmo;
  52523. /**
  52524. * Internal gizmo used to scale all axis equally
  52525. */
  52526. uniformScaleGizmo: AxisScaleGizmo;
  52527. private _meshAttached;
  52528. private _updateGizmoRotationToMatchAttachedMesh;
  52529. private _snapDistance;
  52530. private _scaleRatio;
  52531. private _uniformScalingMesh;
  52532. private _octahedron;
  52533. private _sensitivity;
  52534. /** Fires an event when any of it's sub gizmos are dragged */
  52535. onDragStartObservable: Observable<unknown>;
  52536. /** Fires an event when any of it's sub gizmos are released from dragging */
  52537. onDragEndObservable: Observable<unknown>;
  52538. get attachedMesh(): Nullable<AbstractMesh>;
  52539. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52540. /**
  52541. * Creates a ScaleGizmo
  52542. * @param gizmoLayer The utility layer the gizmo will be added to
  52543. */
  52544. constructor(gizmoLayer?: UtilityLayerRenderer);
  52545. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52546. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52547. /**
  52548. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52549. */
  52550. set snapDistance(value: number);
  52551. get snapDistance(): number;
  52552. /**
  52553. * Ratio for the scale of the gizmo (Default: 1)
  52554. */
  52555. set scaleRatio(value: number);
  52556. get scaleRatio(): number;
  52557. /**
  52558. * Sensitivity factor for dragging (Default: 1)
  52559. */
  52560. set sensitivity(value: number);
  52561. get sensitivity(): number;
  52562. /**
  52563. * Disposes of the gizmo
  52564. */
  52565. dispose(): void;
  52566. }
  52567. }
  52568. declare module BABYLON {
  52569. /**
  52570. * Single axis scale gizmo
  52571. */
  52572. export class AxisScaleGizmo extends Gizmo {
  52573. /**
  52574. * Drag behavior responsible for the gizmos dragging interactions
  52575. */
  52576. dragBehavior: PointerDragBehavior;
  52577. private _pointerObserver;
  52578. /**
  52579. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52580. */
  52581. snapDistance: number;
  52582. /**
  52583. * Event that fires each time the gizmo snaps to a new location.
  52584. * * snapDistance is the the change in distance
  52585. */
  52586. onSnapObservable: Observable<{
  52587. snapDistance: number;
  52588. }>;
  52589. /**
  52590. * If the scaling operation should be done on all axis (default: false)
  52591. */
  52592. uniformScaling: boolean;
  52593. /**
  52594. * Custom sensitivity value for the drag strength
  52595. */
  52596. sensitivity: number;
  52597. private _isEnabled;
  52598. private _parent;
  52599. private _arrow;
  52600. private _coloredMaterial;
  52601. private _hoverMaterial;
  52602. /**
  52603. * Creates an AxisScaleGizmo
  52604. * @param gizmoLayer The utility layer the gizmo will be added to
  52605. * @param dragAxis The axis which the gizmo will be able to scale on
  52606. * @param color The color of the gizmo
  52607. */
  52608. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  52609. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52610. /**
  52611. * If the gizmo is enabled
  52612. */
  52613. set isEnabled(value: boolean);
  52614. get isEnabled(): boolean;
  52615. /**
  52616. * Disposes of the gizmo
  52617. */
  52618. dispose(): void;
  52619. /**
  52620. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52621. * @param mesh The mesh to replace the default mesh of the gizmo
  52622. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  52623. */
  52624. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  52625. }
  52626. }
  52627. declare module BABYLON {
  52628. /**
  52629. * Bounding box gizmo
  52630. */
  52631. export class BoundingBoxGizmo extends Gizmo {
  52632. private _lineBoundingBox;
  52633. private _rotateSpheresParent;
  52634. private _scaleBoxesParent;
  52635. private _boundingDimensions;
  52636. private _renderObserver;
  52637. private _pointerObserver;
  52638. private _scaleDragSpeed;
  52639. private _tmpQuaternion;
  52640. private _tmpVector;
  52641. private _tmpRotationMatrix;
  52642. /**
  52643. * 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)
  52644. */
  52645. ignoreChildren: boolean;
  52646. /**
  52647. * 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)
  52648. */
  52649. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  52650. /**
  52651. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  52652. */
  52653. rotationSphereSize: number;
  52654. /**
  52655. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  52656. */
  52657. scaleBoxSize: number;
  52658. /**
  52659. * 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)
  52660. */
  52661. fixedDragMeshScreenSize: boolean;
  52662. /**
  52663. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  52664. */
  52665. fixedDragMeshScreenSizeDistanceFactor: number;
  52666. /**
  52667. * Fired when a rotation sphere or scale box is dragged
  52668. */
  52669. onDragStartObservable: Observable<{}>;
  52670. /**
  52671. * Fired when a scale box is dragged
  52672. */
  52673. onScaleBoxDragObservable: Observable<{}>;
  52674. /**
  52675. * Fired when a scale box drag is ended
  52676. */
  52677. onScaleBoxDragEndObservable: Observable<{}>;
  52678. /**
  52679. * Fired when a rotation sphere is dragged
  52680. */
  52681. onRotationSphereDragObservable: Observable<{}>;
  52682. /**
  52683. * Fired when a rotation sphere drag is ended
  52684. */
  52685. onRotationSphereDragEndObservable: Observable<{}>;
  52686. /**
  52687. * Relative bounding box pivot used when scaling the attached mesh. 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)
  52688. */
  52689. scalePivot: Nullable<Vector3>;
  52690. /**
  52691. * Mesh used as a pivot to rotate the attached mesh
  52692. */
  52693. private _anchorMesh;
  52694. private _existingMeshScale;
  52695. private _dragMesh;
  52696. private pointerDragBehavior;
  52697. private coloredMaterial;
  52698. private hoverColoredMaterial;
  52699. /**
  52700. * Sets the color of the bounding box gizmo
  52701. * @param color the color to set
  52702. */
  52703. setColor(color: Color3): void;
  52704. /**
  52705. * Creates an BoundingBoxGizmo
  52706. * @param gizmoLayer The utility layer the gizmo will be added to
  52707. * @param color The color of the gizmo
  52708. */
  52709. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  52710. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52711. private _selectNode;
  52712. /**
  52713. * Updates the bounding box information for the Gizmo
  52714. */
  52715. updateBoundingBox(): void;
  52716. private _updateRotationSpheres;
  52717. private _updateScaleBoxes;
  52718. /**
  52719. * Enables rotation on the specified axis and disables rotation on the others
  52720. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  52721. */
  52722. setEnabledRotationAxis(axis: string): void;
  52723. /**
  52724. * Enables/disables scaling
  52725. * @param enable if scaling should be enabled
  52726. * @param homogeneousScaling defines if scaling should only be homogeneous
  52727. */
  52728. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  52729. private _updateDummy;
  52730. /**
  52731. * Enables a pointer drag behavior on the bounding box of the gizmo
  52732. */
  52733. enableDragBehavior(): void;
  52734. /**
  52735. * Disposes of the gizmo
  52736. */
  52737. dispose(): void;
  52738. /**
  52739. * 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)
  52740. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  52741. * @returns the bounding box mesh with the passed in mesh as a child
  52742. */
  52743. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  52744. /**
  52745. * CustomMeshes are not supported by this gizmo
  52746. * @param mesh The mesh to replace the default mesh of the gizmo
  52747. */
  52748. setCustomMesh(mesh: Mesh): void;
  52749. }
  52750. }
  52751. declare module BABYLON {
  52752. /**
  52753. * Single plane rotation gizmo
  52754. */
  52755. export class PlaneRotationGizmo extends Gizmo {
  52756. /**
  52757. * Drag behavior responsible for the gizmos dragging interactions
  52758. */
  52759. dragBehavior: PointerDragBehavior;
  52760. private _pointerObserver;
  52761. /**
  52762. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  52763. */
  52764. snapDistance: number;
  52765. /**
  52766. * Event that fires each time the gizmo snaps to a new location.
  52767. * * snapDistance is the the change in distance
  52768. */
  52769. onSnapObservable: Observable<{
  52770. snapDistance: number;
  52771. }>;
  52772. private _isEnabled;
  52773. private _parent;
  52774. /**
  52775. * Creates a PlaneRotationGizmo
  52776. * @param gizmoLayer The utility layer the gizmo will be added to
  52777. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  52778. * @param color The color of the gizmo
  52779. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52780. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52781. */
  52782. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  52783. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  52784. /**
  52785. * If the gizmo is enabled
  52786. */
  52787. set isEnabled(value: boolean);
  52788. get isEnabled(): boolean;
  52789. /**
  52790. * Disposes of the gizmo
  52791. */
  52792. dispose(): void;
  52793. }
  52794. }
  52795. declare module BABYLON {
  52796. /**
  52797. * Gizmo that enables rotating a mesh along 3 axis
  52798. */
  52799. export class RotationGizmo extends Gizmo {
  52800. /**
  52801. * Internal gizmo used for interactions on the x axis
  52802. */
  52803. xGizmo: PlaneRotationGizmo;
  52804. /**
  52805. * Internal gizmo used for interactions on the y axis
  52806. */
  52807. yGizmo: PlaneRotationGizmo;
  52808. /**
  52809. * Internal gizmo used for interactions on the z axis
  52810. */
  52811. zGizmo: PlaneRotationGizmo;
  52812. /** Fires an event when any of it's sub gizmos are dragged */
  52813. onDragStartObservable: Observable<unknown>;
  52814. /** Fires an event when any of it's sub gizmos are released from dragging */
  52815. onDragEndObservable: Observable<unknown>;
  52816. private _meshAttached;
  52817. get attachedMesh(): Nullable<AbstractMesh>;
  52818. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52819. /**
  52820. * Creates a RotationGizmo
  52821. * @param gizmoLayer The utility layer the gizmo will be added to
  52822. * @param tessellation Amount of tessellation to be used when creating rotation circles
  52823. * @param useEulerRotation Use and update Euler angle instead of quaternion
  52824. */
  52825. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  52826. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52827. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52828. /**
  52829. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52830. */
  52831. set snapDistance(value: number);
  52832. get snapDistance(): number;
  52833. /**
  52834. * Ratio for the scale of the gizmo (Default: 1)
  52835. */
  52836. set scaleRatio(value: number);
  52837. get scaleRatio(): number;
  52838. /**
  52839. * Disposes of the gizmo
  52840. */
  52841. dispose(): void;
  52842. /**
  52843. * CustomMeshes are not supported by this gizmo
  52844. * @param mesh The mesh to replace the default mesh of the gizmo
  52845. */
  52846. setCustomMesh(mesh: Mesh): void;
  52847. }
  52848. }
  52849. declare module BABYLON {
  52850. /**
  52851. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  52852. */
  52853. export class GizmoManager implements IDisposable {
  52854. private scene;
  52855. /**
  52856. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  52857. */
  52858. gizmos: {
  52859. positionGizmo: Nullable<PositionGizmo>;
  52860. rotationGizmo: Nullable<RotationGizmo>;
  52861. scaleGizmo: Nullable<ScaleGizmo>;
  52862. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  52863. };
  52864. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  52865. clearGizmoOnEmptyPointerEvent: boolean;
  52866. /** Fires an event when the manager is attached to a mesh */
  52867. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  52868. private _gizmosEnabled;
  52869. private _pointerObserver;
  52870. private _attachedMesh;
  52871. private _boundingBoxColor;
  52872. private _defaultUtilityLayer;
  52873. private _defaultKeepDepthUtilityLayer;
  52874. /**
  52875. * When bounding box gizmo is enabled, this can be used to track drag/end events
  52876. */
  52877. boundingBoxDragBehavior: SixDofDragBehavior;
  52878. /**
  52879. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  52880. */
  52881. attachableMeshes: Nullable<Array<AbstractMesh>>;
  52882. /**
  52883. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  52884. */
  52885. usePointerToAttachGizmos: boolean;
  52886. /**
  52887. * Utility layer that the bounding box gizmo belongs to
  52888. */
  52889. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  52890. /**
  52891. * Utility layer that all gizmos besides bounding box belong to
  52892. */
  52893. get utilityLayer(): UtilityLayerRenderer;
  52894. /**
  52895. * Instatiates a gizmo manager
  52896. * @param scene the scene to overlay the gizmos on top of
  52897. */
  52898. constructor(scene: Scene);
  52899. /**
  52900. * Attaches a set of gizmos to the specified mesh
  52901. * @param mesh The mesh the gizmo's should be attached to
  52902. */
  52903. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52904. /**
  52905. * If the position gizmo is enabled
  52906. */
  52907. set positionGizmoEnabled(value: boolean);
  52908. get positionGizmoEnabled(): boolean;
  52909. /**
  52910. * If the rotation gizmo is enabled
  52911. */
  52912. set rotationGizmoEnabled(value: boolean);
  52913. get rotationGizmoEnabled(): boolean;
  52914. /**
  52915. * If the scale gizmo is enabled
  52916. */
  52917. set scaleGizmoEnabled(value: boolean);
  52918. get scaleGizmoEnabled(): boolean;
  52919. /**
  52920. * If the boundingBox gizmo is enabled
  52921. */
  52922. set boundingBoxGizmoEnabled(value: boolean);
  52923. get boundingBoxGizmoEnabled(): boolean;
  52924. /**
  52925. * Disposes of the gizmo manager
  52926. */
  52927. dispose(): void;
  52928. }
  52929. }
  52930. declare module BABYLON {
  52931. /**
  52932. * A directional light is defined by a direction (what a surprise!).
  52933. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  52934. * 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.
  52935. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52936. */
  52937. export class DirectionalLight extends ShadowLight {
  52938. private _shadowFrustumSize;
  52939. /**
  52940. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  52941. */
  52942. get shadowFrustumSize(): number;
  52943. /**
  52944. * Specifies a fix frustum size for the shadow generation.
  52945. */
  52946. set shadowFrustumSize(value: number);
  52947. private _shadowOrthoScale;
  52948. /**
  52949. * Gets the shadow projection scale against the optimal computed one.
  52950. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52951. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52952. */
  52953. get shadowOrthoScale(): number;
  52954. /**
  52955. * Sets the shadow projection scale against the optimal computed one.
  52956. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  52957. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  52958. */
  52959. set shadowOrthoScale(value: number);
  52960. /**
  52961. * Automatically compute the projection matrix to best fit (including all the casters)
  52962. * on each frame.
  52963. */
  52964. autoUpdateExtends: boolean;
  52965. /**
  52966. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  52967. * on each frame. autoUpdateExtends must be set to true for this to work
  52968. */
  52969. autoCalcShadowZBounds: boolean;
  52970. private _orthoLeft;
  52971. private _orthoRight;
  52972. private _orthoTop;
  52973. private _orthoBottom;
  52974. /**
  52975. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  52976. * The directional light is emitted from everywhere in the given direction.
  52977. * It can cast shadows.
  52978. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52979. * @param name The friendly name of the light
  52980. * @param direction The direction of the light
  52981. * @param scene The scene the light belongs to
  52982. */
  52983. constructor(name: string, direction: Vector3, scene: Scene);
  52984. /**
  52985. * Returns the string "DirectionalLight".
  52986. * @return The class name
  52987. */
  52988. getClassName(): string;
  52989. /**
  52990. * Returns the integer 1.
  52991. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52992. */
  52993. getTypeID(): number;
  52994. /**
  52995. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  52996. * Returns the DirectionalLight Shadow projection matrix.
  52997. */
  52998. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52999. /**
  53000. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53001. * Returns the DirectionalLight Shadow projection matrix.
  53002. */
  53003. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53004. /**
  53005. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53006. * Returns the DirectionalLight Shadow projection matrix.
  53007. */
  53008. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53009. protected _buildUniformLayout(): void;
  53010. /**
  53011. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53012. * @param effect The effect to update
  53013. * @param lightIndex The index of the light in the effect to update
  53014. * @returns The directional light
  53015. */
  53016. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53017. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53018. /**
  53019. * Gets the minZ used for shadow according to both the scene and the light.
  53020. *
  53021. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53022. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53023. * @param activeCamera The camera we are returning the min for
  53024. * @returns the depth min z
  53025. */
  53026. getDepthMinZ(activeCamera: Camera): number;
  53027. /**
  53028. * Gets the maxZ used for shadow according to both the scene and the light.
  53029. *
  53030. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53031. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53032. * @param activeCamera The camera we are returning the max for
  53033. * @returns the depth max z
  53034. */
  53035. getDepthMaxZ(activeCamera: Camera): number;
  53036. /**
  53037. * Prepares the list of defines specific to the light type.
  53038. * @param defines the list of defines
  53039. * @param lightIndex defines the index of the light for the effect
  53040. */
  53041. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53042. }
  53043. }
  53044. declare module BABYLON {
  53045. /**
  53046. * Class containing static functions to help procedurally build meshes
  53047. */
  53048. export class HemisphereBuilder {
  53049. /**
  53050. * Creates a hemisphere mesh
  53051. * @param name defines the name of the mesh
  53052. * @param options defines the options used to create the mesh
  53053. * @param scene defines the hosting scene
  53054. * @returns the hemisphere mesh
  53055. */
  53056. static CreateHemisphere(name: string, options: {
  53057. segments?: number;
  53058. diameter?: number;
  53059. sideOrientation?: number;
  53060. }, scene: any): Mesh;
  53061. }
  53062. }
  53063. declare module BABYLON {
  53064. /**
  53065. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53066. * These values define a cone of light starting from the position, emitting toward the direction.
  53067. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53068. * and the exponent defines the speed of the decay of the light with distance (reach).
  53069. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53070. */
  53071. export class SpotLight extends ShadowLight {
  53072. private _angle;
  53073. private _innerAngle;
  53074. private _cosHalfAngle;
  53075. private _lightAngleScale;
  53076. private _lightAngleOffset;
  53077. /**
  53078. * Gets the cone angle of the spot light in Radians.
  53079. */
  53080. get angle(): number;
  53081. /**
  53082. * Sets the cone angle of the spot light in Radians.
  53083. */
  53084. set angle(value: number);
  53085. /**
  53086. * Only used in gltf falloff mode, this defines the angle where
  53087. * the directional falloff will start before cutting at angle which could be seen
  53088. * as outer angle.
  53089. */
  53090. get innerAngle(): number;
  53091. /**
  53092. * Only used in gltf falloff mode, this defines the angle where
  53093. * the directional falloff will start before cutting at angle which could be seen
  53094. * as outer angle.
  53095. */
  53096. set innerAngle(value: number);
  53097. private _shadowAngleScale;
  53098. /**
  53099. * Allows scaling the angle of the light for shadow generation only.
  53100. */
  53101. get shadowAngleScale(): number;
  53102. /**
  53103. * Allows scaling the angle of the light for shadow generation only.
  53104. */
  53105. set shadowAngleScale(value: number);
  53106. /**
  53107. * The light decay speed with the distance from the emission spot.
  53108. */
  53109. exponent: number;
  53110. private _projectionTextureMatrix;
  53111. /**
  53112. * Allows reading the projecton texture
  53113. */
  53114. get projectionTextureMatrix(): Matrix;
  53115. protected _projectionTextureLightNear: number;
  53116. /**
  53117. * Gets the near clip of the Spotlight for texture projection.
  53118. */
  53119. get projectionTextureLightNear(): number;
  53120. /**
  53121. * Sets the near clip of the Spotlight for texture projection.
  53122. */
  53123. set projectionTextureLightNear(value: number);
  53124. protected _projectionTextureLightFar: number;
  53125. /**
  53126. * Gets the far clip of the Spotlight for texture projection.
  53127. */
  53128. get projectionTextureLightFar(): number;
  53129. /**
  53130. * Sets the far clip of the Spotlight for texture projection.
  53131. */
  53132. set projectionTextureLightFar(value: number);
  53133. protected _projectionTextureUpDirection: Vector3;
  53134. /**
  53135. * Gets the Up vector of the Spotlight for texture projection.
  53136. */
  53137. get projectionTextureUpDirection(): Vector3;
  53138. /**
  53139. * Sets the Up vector of the Spotlight for texture projection.
  53140. */
  53141. set projectionTextureUpDirection(value: Vector3);
  53142. private _projectionTexture;
  53143. /**
  53144. * Gets the projection texture of the light.
  53145. */
  53146. get projectionTexture(): Nullable<BaseTexture>;
  53147. /**
  53148. * Sets the projection texture of the light.
  53149. */
  53150. set projectionTexture(value: Nullable<BaseTexture>);
  53151. private _projectionTextureViewLightDirty;
  53152. private _projectionTextureProjectionLightDirty;
  53153. private _projectionTextureDirty;
  53154. private _projectionTextureViewTargetVector;
  53155. private _projectionTextureViewLightMatrix;
  53156. private _projectionTextureProjectionLightMatrix;
  53157. private _projectionTextureScalingMatrix;
  53158. /**
  53159. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53160. * It can cast shadows.
  53161. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53162. * @param name The light friendly name
  53163. * @param position The position of the spot light in the scene
  53164. * @param direction The direction of the light in the scene
  53165. * @param angle The cone angle of the light in Radians
  53166. * @param exponent The light decay speed with the distance from the emission spot
  53167. * @param scene The scene the lights belongs to
  53168. */
  53169. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53170. /**
  53171. * Returns the string "SpotLight".
  53172. * @returns the class name
  53173. */
  53174. getClassName(): string;
  53175. /**
  53176. * Returns the integer 2.
  53177. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53178. */
  53179. getTypeID(): number;
  53180. /**
  53181. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53182. */
  53183. protected _setDirection(value: Vector3): void;
  53184. /**
  53185. * Overrides the position setter to recompute the projection texture view light Matrix.
  53186. */
  53187. protected _setPosition(value: Vector3): void;
  53188. /**
  53189. * 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.
  53190. * Returns the SpotLight.
  53191. */
  53192. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53193. protected _computeProjectionTextureViewLightMatrix(): void;
  53194. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53195. /**
  53196. * Main function for light texture projection matrix computing.
  53197. */
  53198. protected _computeProjectionTextureMatrix(): void;
  53199. protected _buildUniformLayout(): void;
  53200. private _computeAngleValues;
  53201. /**
  53202. * Sets the passed Effect "effect" with the Light textures.
  53203. * @param effect The effect to update
  53204. * @param lightIndex The index of the light in the effect to update
  53205. * @returns The light
  53206. */
  53207. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53208. /**
  53209. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53210. * @param effect The effect to update
  53211. * @param lightIndex The index of the light in the effect to update
  53212. * @returns The spot light
  53213. */
  53214. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53215. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53216. /**
  53217. * Disposes the light and the associated resources.
  53218. */
  53219. dispose(): void;
  53220. /**
  53221. * Prepares the list of defines specific to the light type.
  53222. * @param defines the list of defines
  53223. * @param lightIndex defines the index of the light for the effect
  53224. */
  53225. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53226. }
  53227. }
  53228. declare module BABYLON {
  53229. /**
  53230. * Gizmo that enables viewing a light
  53231. */
  53232. export class LightGizmo extends Gizmo {
  53233. private _lightMesh;
  53234. private _material;
  53235. private _cachedPosition;
  53236. private _cachedForward;
  53237. private _attachedMeshParent;
  53238. /**
  53239. * Creates a LightGizmo
  53240. * @param gizmoLayer The utility layer the gizmo will be added to
  53241. */
  53242. constructor(gizmoLayer?: UtilityLayerRenderer);
  53243. private _light;
  53244. /**
  53245. * The light that the gizmo is attached to
  53246. */
  53247. set light(light: Nullable<Light>);
  53248. get light(): Nullable<Light>;
  53249. /**
  53250. * Gets the material used to render the light gizmo
  53251. */
  53252. get material(): StandardMaterial;
  53253. /**
  53254. * @hidden
  53255. * Updates the gizmo to match the attached mesh's position/rotation
  53256. */
  53257. protected _update(): void;
  53258. private static _Scale;
  53259. /**
  53260. * Creates the lines for a light mesh
  53261. */
  53262. private static _CreateLightLines;
  53263. /**
  53264. * Disposes of the light gizmo
  53265. */
  53266. dispose(): void;
  53267. private static _CreateHemisphericLightMesh;
  53268. private static _CreatePointLightMesh;
  53269. private static _CreateSpotLightMesh;
  53270. private static _CreateDirectionalLightMesh;
  53271. }
  53272. }
  53273. declare module BABYLON {
  53274. /** @hidden */
  53275. export var backgroundFragmentDeclaration: {
  53276. name: string;
  53277. shader: string;
  53278. };
  53279. }
  53280. declare module BABYLON {
  53281. /** @hidden */
  53282. export var backgroundUboDeclaration: {
  53283. name: string;
  53284. shader: string;
  53285. };
  53286. }
  53287. declare module BABYLON {
  53288. /** @hidden */
  53289. export var backgroundPixelShader: {
  53290. name: string;
  53291. shader: string;
  53292. };
  53293. }
  53294. declare module BABYLON {
  53295. /** @hidden */
  53296. export var backgroundVertexDeclaration: {
  53297. name: string;
  53298. shader: string;
  53299. };
  53300. }
  53301. declare module BABYLON {
  53302. /** @hidden */
  53303. export var backgroundVertexShader: {
  53304. name: string;
  53305. shader: string;
  53306. };
  53307. }
  53308. declare module BABYLON {
  53309. /**
  53310. * Background material used to create an efficient environement around your scene.
  53311. */
  53312. export class BackgroundMaterial extends PushMaterial {
  53313. /**
  53314. * Standard reflectance value at parallel view angle.
  53315. */
  53316. static StandardReflectance0: number;
  53317. /**
  53318. * Standard reflectance value at grazing angle.
  53319. */
  53320. static StandardReflectance90: number;
  53321. protected _primaryColor: Color3;
  53322. /**
  53323. * Key light Color (multiply against the environement texture)
  53324. */
  53325. primaryColor: Color3;
  53326. protected __perceptualColor: Nullable<Color3>;
  53327. /**
  53328. * Experimental Internal Use Only.
  53329. *
  53330. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53331. * This acts as a helper to set the primary color to a more "human friendly" value.
  53332. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53333. * output color as close as possible from the chosen value.
  53334. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53335. * part of lighting setup.)
  53336. */
  53337. get _perceptualColor(): Nullable<Color3>;
  53338. set _perceptualColor(value: Nullable<Color3>);
  53339. protected _primaryColorShadowLevel: float;
  53340. /**
  53341. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53342. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53343. */
  53344. get primaryColorShadowLevel(): float;
  53345. set primaryColorShadowLevel(value: float);
  53346. protected _primaryColorHighlightLevel: float;
  53347. /**
  53348. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53349. * The primary color is used at the level chosen to define what the white area would look.
  53350. */
  53351. get primaryColorHighlightLevel(): float;
  53352. set primaryColorHighlightLevel(value: float);
  53353. protected _reflectionTexture: Nullable<BaseTexture>;
  53354. /**
  53355. * Reflection Texture used in the material.
  53356. * Should be author in a specific way for the best result (refer to the documentation).
  53357. */
  53358. reflectionTexture: Nullable<BaseTexture>;
  53359. protected _reflectionBlur: float;
  53360. /**
  53361. * Reflection Texture level of blur.
  53362. *
  53363. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53364. * texture twice.
  53365. */
  53366. reflectionBlur: float;
  53367. protected _diffuseTexture: Nullable<BaseTexture>;
  53368. /**
  53369. * Diffuse Texture used in the material.
  53370. * Should be author in a specific way for the best result (refer to the documentation).
  53371. */
  53372. diffuseTexture: Nullable<BaseTexture>;
  53373. protected _shadowLights: Nullable<IShadowLight[]>;
  53374. /**
  53375. * Specify the list of lights casting shadow on the material.
  53376. * All scene shadow lights will be included if null.
  53377. */
  53378. shadowLights: Nullable<IShadowLight[]>;
  53379. protected _shadowLevel: float;
  53380. /**
  53381. * Helps adjusting the shadow to a softer level if required.
  53382. * 0 means black shadows and 1 means no shadows.
  53383. */
  53384. shadowLevel: float;
  53385. protected _sceneCenter: Vector3;
  53386. /**
  53387. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53388. * It is usually zero but might be interesting to modify according to your setup.
  53389. */
  53390. sceneCenter: Vector3;
  53391. protected _opacityFresnel: boolean;
  53392. /**
  53393. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53394. * This helps ensuring a nice transition when the camera goes under the ground.
  53395. */
  53396. opacityFresnel: boolean;
  53397. protected _reflectionFresnel: boolean;
  53398. /**
  53399. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53400. * This helps adding a mirror texture on the ground.
  53401. */
  53402. reflectionFresnel: boolean;
  53403. protected _reflectionFalloffDistance: number;
  53404. /**
  53405. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53406. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53407. */
  53408. reflectionFalloffDistance: number;
  53409. protected _reflectionAmount: number;
  53410. /**
  53411. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53412. */
  53413. reflectionAmount: number;
  53414. protected _reflectionReflectance0: number;
  53415. /**
  53416. * This specifies the weight of the reflection at grazing angle.
  53417. */
  53418. reflectionReflectance0: number;
  53419. protected _reflectionReflectance90: number;
  53420. /**
  53421. * This specifies the weight of the reflection at a perpendicular point of view.
  53422. */
  53423. reflectionReflectance90: number;
  53424. /**
  53425. * Sets the reflection reflectance fresnel values according to the default standard
  53426. * empirically know to work well :-)
  53427. */
  53428. set reflectionStandardFresnelWeight(value: number);
  53429. protected _useRGBColor: boolean;
  53430. /**
  53431. * Helps to directly use the maps channels instead of their level.
  53432. */
  53433. useRGBColor: boolean;
  53434. protected _enableNoise: boolean;
  53435. /**
  53436. * This helps reducing the banding effect that could occur on the background.
  53437. */
  53438. enableNoise: boolean;
  53439. /**
  53440. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53441. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53442. * Recommended to be keep at 1.0 except for special cases.
  53443. */
  53444. get fovMultiplier(): number;
  53445. set fovMultiplier(value: number);
  53446. private _fovMultiplier;
  53447. /**
  53448. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53449. */
  53450. useEquirectangularFOV: boolean;
  53451. private _maxSimultaneousLights;
  53452. /**
  53453. * Number of Simultaneous lights allowed on the material.
  53454. */
  53455. maxSimultaneousLights: int;
  53456. private _shadowOnly;
  53457. /**
  53458. * Make the material only render shadows
  53459. */
  53460. shadowOnly: boolean;
  53461. /**
  53462. * Default configuration related to image processing available in the Background Material.
  53463. */
  53464. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53465. /**
  53466. * Keep track of the image processing observer to allow dispose and replace.
  53467. */
  53468. private _imageProcessingObserver;
  53469. /**
  53470. * Attaches a new image processing configuration to the PBR Material.
  53471. * @param configuration (if null the scene configuration will be use)
  53472. */
  53473. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53474. /**
  53475. * Gets the image processing configuration used either in this material.
  53476. */
  53477. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53478. /**
  53479. * Sets the Default image processing configuration used either in the this material.
  53480. *
  53481. * If sets to null, the scene one is in use.
  53482. */
  53483. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53484. /**
  53485. * Gets wether the color curves effect is enabled.
  53486. */
  53487. get cameraColorCurvesEnabled(): boolean;
  53488. /**
  53489. * Sets wether the color curves effect is enabled.
  53490. */
  53491. set cameraColorCurvesEnabled(value: boolean);
  53492. /**
  53493. * Gets wether the color grading effect is enabled.
  53494. */
  53495. get cameraColorGradingEnabled(): boolean;
  53496. /**
  53497. * Gets wether the color grading effect is enabled.
  53498. */
  53499. set cameraColorGradingEnabled(value: boolean);
  53500. /**
  53501. * Gets wether tonemapping is enabled or not.
  53502. */
  53503. get cameraToneMappingEnabled(): boolean;
  53504. /**
  53505. * Sets wether tonemapping is enabled or not
  53506. */
  53507. set cameraToneMappingEnabled(value: boolean);
  53508. /**
  53509. * The camera exposure used on this material.
  53510. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53511. * This corresponds to a photographic exposure.
  53512. */
  53513. get cameraExposure(): float;
  53514. /**
  53515. * The camera exposure used on this material.
  53516. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53517. * This corresponds to a photographic exposure.
  53518. */
  53519. set cameraExposure(value: float);
  53520. /**
  53521. * Gets The camera contrast used on this material.
  53522. */
  53523. get cameraContrast(): float;
  53524. /**
  53525. * Sets The camera contrast used on this material.
  53526. */
  53527. set cameraContrast(value: float);
  53528. /**
  53529. * Gets the Color Grading 2D Lookup Texture.
  53530. */
  53531. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53532. /**
  53533. * Sets the Color Grading 2D Lookup Texture.
  53534. */
  53535. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53536. /**
  53537. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53538. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53539. * 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;
  53540. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53541. */
  53542. get cameraColorCurves(): Nullable<ColorCurves>;
  53543. /**
  53544. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53545. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53546. * 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;
  53547. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53548. */
  53549. set cameraColorCurves(value: Nullable<ColorCurves>);
  53550. /**
  53551. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  53552. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  53553. */
  53554. switchToBGR: boolean;
  53555. private _renderTargets;
  53556. private _reflectionControls;
  53557. private _white;
  53558. private _primaryShadowColor;
  53559. private _primaryHighlightColor;
  53560. /**
  53561. * Instantiates a Background Material in the given scene
  53562. * @param name The friendly name of the material
  53563. * @param scene The scene to add the material to
  53564. */
  53565. constructor(name: string, scene: Scene);
  53566. /**
  53567. * Gets a boolean indicating that current material needs to register RTT
  53568. */
  53569. get hasRenderTargetTextures(): boolean;
  53570. /**
  53571. * The entire material has been created in order to prevent overdraw.
  53572. * @returns false
  53573. */
  53574. needAlphaTesting(): boolean;
  53575. /**
  53576. * The entire material has been created in order to prevent overdraw.
  53577. * @returns true if blending is enable
  53578. */
  53579. needAlphaBlending(): boolean;
  53580. /**
  53581. * Checks wether the material is ready to be rendered for a given mesh.
  53582. * @param mesh The mesh to render
  53583. * @param subMesh The submesh to check against
  53584. * @param useInstances Specify wether or not the material is used with instances
  53585. * @returns true if all the dependencies are ready (Textures, Effects...)
  53586. */
  53587. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53588. /**
  53589. * Compute the primary color according to the chosen perceptual color.
  53590. */
  53591. private _computePrimaryColorFromPerceptualColor;
  53592. /**
  53593. * Compute the highlights and shadow colors according to their chosen levels.
  53594. */
  53595. private _computePrimaryColors;
  53596. /**
  53597. * Build the uniform buffer used in the material.
  53598. */
  53599. buildUniformLayout(): void;
  53600. /**
  53601. * Unbind the material.
  53602. */
  53603. unbind(): void;
  53604. /**
  53605. * Bind only the world matrix to the material.
  53606. * @param world The world matrix to bind.
  53607. */
  53608. bindOnlyWorldMatrix(world: Matrix): void;
  53609. /**
  53610. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  53611. * @param world The world matrix to bind.
  53612. * @param subMesh The submesh to bind for.
  53613. */
  53614. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53615. /**
  53616. * Checks to see if a texture is used in the material.
  53617. * @param texture - Base texture to use.
  53618. * @returns - Boolean specifying if a texture is used in the material.
  53619. */
  53620. hasTexture(texture: BaseTexture): boolean;
  53621. /**
  53622. * Dispose the material.
  53623. * @param forceDisposeEffect Force disposal of the associated effect.
  53624. * @param forceDisposeTextures Force disposal of the associated textures.
  53625. */
  53626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53627. /**
  53628. * Clones the material.
  53629. * @param name The cloned name.
  53630. * @returns The cloned material.
  53631. */
  53632. clone(name: string): BackgroundMaterial;
  53633. /**
  53634. * Serializes the current material to its JSON representation.
  53635. * @returns The JSON representation.
  53636. */
  53637. serialize(): any;
  53638. /**
  53639. * Gets the class name of the material
  53640. * @returns "BackgroundMaterial"
  53641. */
  53642. getClassName(): string;
  53643. /**
  53644. * Parse a JSON input to create back a background material.
  53645. * @param source The JSON data to parse
  53646. * @param scene The scene to create the parsed material in
  53647. * @param rootUrl The root url of the assets the material depends upon
  53648. * @returns the instantiated BackgroundMaterial.
  53649. */
  53650. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  53651. }
  53652. }
  53653. declare module BABYLON {
  53654. /**
  53655. * Represents the different options available during the creation of
  53656. * a Environment helper.
  53657. *
  53658. * This can control the default ground, skybox and image processing setup of your scene.
  53659. */
  53660. export interface IEnvironmentHelperOptions {
  53661. /**
  53662. * Specifies whether or not to create a ground.
  53663. * True by default.
  53664. */
  53665. createGround: boolean;
  53666. /**
  53667. * Specifies the ground size.
  53668. * 15 by default.
  53669. */
  53670. groundSize: number;
  53671. /**
  53672. * The texture used on the ground for the main color.
  53673. * Comes from the BabylonJS CDN by default.
  53674. *
  53675. * Remarks: Can be either a texture or a url.
  53676. */
  53677. groundTexture: string | BaseTexture;
  53678. /**
  53679. * The color mixed in the ground texture by default.
  53680. * BabylonJS clearColor by default.
  53681. */
  53682. groundColor: Color3;
  53683. /**
  53684. * Specifies the ground opacity.
  53685. * 1 by default.
  53686. */
  53687. groundOpacity: number;
  53688. /**
  53689. * Enables the ground to receive shadows.
  53690. * True by default.
  53691. */
  53692. enableGroundShadow: boolean;
  53693. /**
  53694. * Helps preventing the shadow to be fully black on the ground.
  53695. * 0.5 by default.
  53696. */
  53697. groundShadowLevel: number;
  53698. /**
  53699. * Creates a mirror texture attach to the ground.
  53700. * false by default.
  53701. */
  53702. enableGroundMirror: boolean;
  53703. /**
  53704. * Specifies the ground mirror size ratio.
  53705. * 0.3 by default as the default kernel is 64.
  53706. */
  53707. groundMirrorSizeRatio: number;
  53708. /**
  53709. * Specifies the ground mirror blur kernel size.
  53710. * 64 by default.
  53711. */
  53712. groundMirrorBlurKernel: number;
  53713. /**
  53714. * Specifies the ground mirror visibility amount.
  53715. * 1 by default
  53716. */
  53717. groundMirrorAmount: number;
  53718. /**
  53719. * Specifies the ground mirror reflectance weight.
  53720. * This uses the standard weight of the background material to setup the fresnel effect
  53721. * of the mirror.
  53722. * 1 by default.
  53723. */
  53724. groundMirrorFresnelWeight: number;
  53725. /**
  53726. * Specifies the ground mirror Falloff distance.
  53727. * This can helps reducing the size of the reflection.
  53728. * 0 by Default.
  53729. */
  53730. groundMirrorFallOffDistance: number;
  53731. /**
  53732. * Specifies the ground mirror texture type.
  53733. * Unsigned Int by Default.
  53734. */
  53735. groundMirrorTextureType: number;
  53736. /**
  53737. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  53738. * the shown objects.
  53739. */
  53740. groundYBias: number;
  53741. /**
  53742. * Specifies whether or not to create a skybox.
  53743. * True by default.
  53744. */
  53745. createSkybox: boolean;
  53746. /**
  53747. * Specifies the skybox size.
  53748. * 20 by default.
  53749. */
  53750. skyboxSize: number;
  53751. /**
  53752. * The texture used on the skybox for the main color.
  53753. * Comes from the BabylonJS CDN by default.
  53754. *
  53755. * Remarks: Can be either a texture or a url.
  53756. */
  53757. skyboxTexture: string | BaseTexture;
  53758. /**
  53759. * The color mixed in the skybox texture by default.
  53760. * BabylonJS clearColor by default.
  53761. */
  53762. skyboxColor: Color3;
  53763. /**
  53764. * The background rotation around the Y axis of the scene.
  53765. * This helps aligning the key lights of your scene with the background.
  53766. * 0 by default.
  53767. */
  53768. backgroundYRotation: number;
  53769. /**
  53770. * Compute automatically the size of the elements to best fit with the scene.
  53771. */
  53772. sizeAuto: boolean;
  53773. /**
  53774. * Default position of the rootMesh if autoSize is not true.
  53775. */
  53776. rootPosition: Vector3;
  53777. /**
  53778. * Sets up the image processing in the scene.
  53779. * true by default.
  53780. */
  53781. setupImageProcessing: boolean;
  53782. /**
  53783. * The texture used as your environment texture in the scene.
  53784. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  53785. *
  53786. * Remarks: Can be either a texture or a url.
  53787. */
  53788. environmentTexture: string | BaseTexture;
  53789. /**
  53790. * The value of the exposure to apply to the scene.
  53791. * 0.6 by default if setupImageProcessing is true.
  53792. */
  53793. cameraExposure: number;
  53794. /**
  53795. * The value of the contrast to apply to the scene.
  53796. * 1.6 by default if setupImageProcessing is true.
  53797. */
  53798. cameraContrast: number;
  53799. /**
  53800. * Specifies whether or not tonemapping should be enabled in the scene.
  53801. * true by default if setupImageProcessing is true.
  53802. */
  53803. toneMappingEnabled: boolean;
  53804. }
  53805. /**
  53806. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  53807. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  53808. * It also helps with the default setup of your imageProcessing configuration.
  53809. */
  53810. export class EnvironmentHelper {
  53811. /**
  53812. * Default ground texture URL.
  53813. */
  53814. private static _groundTextureCDNUrl;
  53815. /**
  53816. * Default skybox texture URL.
  53817. */
  53818. private static _skyboxTextureCDNUrl;
  53819. /**
  53820. * Default environment texture URL.
  53821. */
  53822. private static _environmentTextureCDNUrl;
  53823. /**
  53824. * Creates the default options for the helper.
  53825. */
  53826. private static _getDefaultOptions;
  53827. private _rootMesh;
  53828. /**
  53829. * Gets the root mesh created by the helper.
  53830. */
  53831. get rootMesh(): Mesh;
  53832. private _skybox;
  53833. /**
  53834. * Gets the skybox created by the helper.
  53835. */
  53836. get skybox(): Nullable<Mesh>;
  53837. private _skyboxTexture;
  53838. /**
  53839. * Gets the skybox texture created by the helper.
  53840. */
  53841. get skyboxTexture(): Nullable<BaseTexture>;
  53842. private _skyboxMaterial;
  53843. /**
  53844. * Gets the skybox material created by the helper.
  53845. */
  53846. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  53847. private _ground;
  53848. /**
  53849. * Gets the ground mesh created by the helper.
  53850. */
  53851. get ground(): Nullable<Mesh>;
  53852. private _groundTexture;
  53853. /**
  53854. * Gets the ground texture created by the helper.
  53855. */
  53856. get groundTexture(): Nullable<BaseTexture>;
  53857. private _groundMirror;
  53858. /**
  53859. * Gets the ground mirror created by the helper.
  53860. */
  53861. get groundMirror(): Nullable<MirrorTexture>;
  53862. /**
  53863. * Gets the ground mirror render list to helps pushing the meshes
  53864. * you wish in the ground reflection.
  53865. */
  53866. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  53867. private _groundMaterial;
  53868. /**
  53869. * Gets the ground material created by the helper.
  53870. */
  53871. get groundMaterial(): Nullable<BackgroundMaterial>;
  53872. /**
  53873. * Stores the creation options.
  53874. */
  53875. private readonly _scene;
  53876. private _options;
  53877. /**
  53878. * This observable will be notified with any error during the creation of the environment,
  53879. * mainly texture creation errors.
  53880. */
  53881. onErrorObservable: Observable<{
  53882. message?: string;
  53883. exception?: any;
  53884. }>;
  53885. /**
  53886. * constructor
  53887. * @param options Defines the options we want to customize the helper
  53888. * @param scene The scene to add the material to
  53889. */
  53890. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  53891. /**
  53892. * Updates the background according to the new options
  53893. * @param options
  53894. */
  53895. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  53896. /**
  53897. * Sets the primary color of all the available elements.
  53898. * @param color the main color to affect to the ground and the background
  53899. */
  53900. setMainColor(color: Color3): void;
  53901. /**
  53902. * Setup the image processing according to the specified options.
  53903. */
  53904. private _setupImageProcessing;
  53905. /**
  53906. * Setup the environment texture according to the specified options.
  53907. */
  53908. private _setupEnvironmentTexture;
  53909. /**
  53910. * Setup the background according to the specified options.
  53911. */
  53912. private _setupBackground;
  53913. /**
  53914. * Get the scene sizes according to the setup.
  53915. */
  53916. private _getSceneSize;
  53917. /**
  53918. * Setup the ground according to the specified options.
  53919. */
  53920. private _setupGround;
  53921. /**
  53922. * Setup the ground material according to the specified options.
  53923. */
  53924. private _setupGroundMaterial;
  53925. /**
  53926. * Setup the ground diffuse texture according to the specified options.
  53927. */
  53928. private _setupGroundDiffuseTexture;
  53929. /**
  53930. * Setup the ground mirror texture according to the specified options.
  53931. */
  53932. private _setupGroundMirrorTexture;
  53933. /**
  53934. * Setup the ground to receive the mirror texture.
  53935. */
  53936. private _setupMirrorInGroundMaterial;
  53937. /**
  53938. * Setup the skybox according to the specified options.
  53939. */
  53940. private _setupSkybox;
  53941. /**
  53942. * Setup the skybox material according to the specified options.
  53943. */
  53944. private _setupSkyboxMaterial;
  53945. /**
  53946. * Setup the skybox reflection texture according to the specified options.
  53947. */
  53948. private _setupSkyboxReflectionTexture;
  53949. private _errorHandler;
  53950. /**
  53951. * Dispose all the elements created by the Helper.
  53952. */
  53953. dispose(): void;
  53954. }
  53955. }
  53956. declare module BABYLON {
  53957. /**
  53958. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  53959. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  53960. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  53961. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53962. */
  53963. export class PhotoDome extends TransformNode {
  53964. /**
  53965. * Define the image as a Monoscopic panoramic 360 image.
  53966. */
  53967. static readonly MODE_MONOSCOPIC: number;
  53968. /**
  53969. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  53970. */
  53971. static readonly MODE_TOPBOTTOM: number;
  53972. /**
  53973. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  53974. */
  53975. static readonly MODE_SIDEBYSIDE: number;
  53976. private _useDirectMapping;
  53977. /**
  53978. * The texture being displayed on the sphere
  53979. */
  53980. protected _photoTexture: Texture;
  53981. /**
  53982. * Gets or sets the texture being displayed on the sphere
  53983. */
  53984. get photoTexture(): Texture;
  53985. set photoTexture(value: Texture);
  53986. /**
  53987. * Observable raised when an error occured while loading the 360 image
  53988. */
  53989. onLoadErrorObservable: Observable<string>;
  53990. /**
  53991. * The skybox material
  53992. */
  53993. protected _material: BackgroundMaterial;
  53994. /**
  53995. * The surface used for the skybox
  53996. */
  53997. protected _mesh: Mesh;
  53998. /**
  53999. * Gets the mesh used for the skybox.
  54000. */
  54001. get mesh(): Mesh;
  54002. /**
  54003. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54004. * Also see the options.resolution property.
  54005. */
  54006. get fovMultiplier(): number;
  54007. set fovMultiplier(value: number);
  54008. private _imageMode;
  54009. /**
  54010. * Gets or set the current video mode for the video. It can be:
  54011. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54012. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54013. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54014. */
  54015. get imageMode(): number;
  54016. set imageMode(value: number);
  54017. /**
  54018. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54019. * @param name Element's name, child elements will append suffixes for their own names.
  54020. * @param urlsOfPhoto defines the url of the photo to display
  54021. * @param options defines an object containing optional or exposed sub element properties
  54022. * @param onError defines a callback called when an error occured while loading the texture
  54023. */
  54024. constructor(name: string, urlOfPhoto: string, options: {
  54025. resolution?: number;
  54026. size?: number;
  54027. useDirectMapping?: boolean;
  54028. faceForward?: boolean;
  54029. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54030. private _onBeforeCameraRenderObserver;
  54031. private _changeImageMode;
  54032. /**
  54033. * Releases resources associated with this node.
  54034. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54035. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54036. */
  54037. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54038. }
  54039. }
  54040. declare module BABYLON {
  54041. /**
  54042. * Class used to host RGBD texture specific utilities
  54043. */
  54044. export class RGBDTextureTools {
  54045. /**
  54046. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54047. * @param texture the texture to expand.
  54048. */
  54049. static ExpandRGBDTexture(texture: Texture): void;
  54050. }
  54051. }
  54052. declare module BABYLON {
  54053. /**
  54054. * Class used to host texture specific utilities
  54055. */
  54056. export class BRDFTextureTools {
  54057. /**
  54058. * Prevents texture cache collision
  54059. */
  54060. private static _instanceNumber;
  54061. /**
  54062. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54063. * @param scene defines the hosting scene
  54064. * @returns the environment BRDF texture
  54065. */
  54066. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54067. private static _environmentBRDFBase64Texture;
  54068. }
  54069. }
  54070. declare module BABYLON {
  54071. /**
  54072. * @hidden
  54073. */
  54074. export interface IMaterialClearCoatDefines {
  54075. CLEARCOAT: boolean;
  54076. CLEARCOAT_DEFAULTIOR: boolean;
  54077. CLEARCOAT_TEXTURE: boolean;
  54078. CLEARCOAT_TEXTUREDIRECTUV: number;
  54079. CLEARCOAT_BUMP: boolean;
  54080. CLEARCOAT_BUMPDIRECTUV: number;
  54081. CLEARCOAT_TINT: boolean;
  54082. CLEARCOAT_TINT_TEXTURE: boolean;
  54083. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54084. /** @hidden */
  54085. _areTexturesDirty: boolean;
  54086. }
  54087. /**
  54088. * Define the code related to the clear coat parameters of the pbr material.
  54089. */
  54090. export class PBRClearCoatConfiguration {
  54091. /**
  54092. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54093. * The default fits with a polyurethane material.
  54094. */
  54095. private static readonly _DefaultIndexOfRefraction;
  54096. private _isEnabled;
  54097. /**
  54098. * Defines if the clear coat is enabled in the material.
  54099. */
  54100. isEnabled: boolean;
  54101. /**
  54102. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54103. */
  54104. intensity: number;
  54105. /**
  54106. * Defines the clear coat layer roughness.
  54107. */
  54108. roughness: number;
  54109. private _indexOfRefraction;
  54110. /**
  54111. * Defines the index of refraction of the clear coat.
  54112. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54113. * The default fits with a polyurethane material.
  54114. * Changing the default value is more performance intensive.
  54115. */
  54116. indexOfRefraction: number;
  54117. private _texture;
  54118. /**
  54119. * Stores the clear coat values in a texture.
  54120. */
  54121. texture: Nullable<BaseTexture>;
  54122. private _bumpTexture;
  54123. /**
  54124. * Define the clear coat specific bump texture.
  54125. */
  54126. bumpTexture: Nullable<BaseTexture>;
  54127. private _isTintEnabled;
  54128. /**
  54129. * Defines if the clear coat tint is enabled in the material.
  54130. */
  54131. isTintEnabled: boolean;
  54132. /**
  54133. * Defines the clear coat tint of the material.
  54134. * This is only use if tint is enabled
  54135. */
  54136. tintColor: Color3;
  54137. /**
  54138. * Defines the distance at which the tint color should be found in the
  54139. * clear coat media.
  54140. * This is only use if tint is enabled
  54141. */
  54142. tintColorAtDistance: number;
  54143. /**
  54144. * Defines the clear coat layer thickness.
  54145. * This is only use if tint is enabled
  54146. */
  54147. tintThickness: number;
  54148. private _tintTexture;
  54149. /**
  54150. * Stores the clear tint values in a texture.
  54151. * rgb is tint
  54152. * a is a thickness factor
  54153. */
  54154. tintTexture: Nullable<BaseTexture>;
  54155. /** @hidden */
  54156. private _internalMarkAllSubMeshesAsTexturesDirty;
  54157. /** @hidden */
  54158. _markAllSubMeshesAsTexturesDirty(): void;
  54159. /**
  54160. * Instantiate a new istance of clear coat configuration.
  54161. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54162. */
  54163. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54164. /**
  54165. * Gets wehter the submesh is ready to be used or not.
  54166. * @param defines the list of "defines" to update.
  54167. * @param scene defines the scene the material belongs to.
  54168. * @param engine defines the engine the material belongs to.
  54169. * @param disableBumpMap defines wether the material disables bump or not.
  54170. * @returns - boolean indicating that the submesh is ready or not.
  54171. */
  54172. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54173. /**
  54174. * Checks to see if a texture is used in the material.
  54175. * @param defines the list of "defines" to update.
  54176. * @param scene defines the scene to the material belongs to.
  54177. */
  54178. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54179. /**
  54180. * Binds the material data.
  54181. * @param uniformBuffer defines the Uniform buffer to fill in.
  54182. * @param scene defines the scene the material belongs to.
  54183. * @param engine defines the engine the material belongs to.
  54184. * @param disableBumpMap defines wether the material disables bump or not.
  54185. * @param isFrozen defines wether the material is frozen or not.
  54186. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54187. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54188. */
  54189. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54190. /**
  54191. * Checks to see if a texture is used in the material.
  54192. * @param texture - Base texture to use.
  54193. * @returns - Boolean specifying if a texture is used in the material.
  54194. */
  54195. hasTexture(texture: BaseTexture): boolean;
  54196. /**
  54197. * Returns an array of the actively used textures.
  54198. * @param activeTextures Array of BaseTextures
  54199. */
  54200. getActiveTextures(activeTextures: BaseTexture[]): void;
  54201. /**
  54202. * Returns the animatable textures.
  54203. * @param animatables Array of animatable textures.
  54204. */
  54205. getAnimatables(animatables: IAnimatable[]): void;
  54206. /**
  54207. * Disposes the resources of the material.
  54208. * @param forceDisposeTextures - Forces the disposal of all textures.
  54209. */
  54210. dispose(forceDisposeTextures?: boolean): void;
  54211. /**
  54212. * Get the current class name of the texture useful for serialization or dynamic coding.
  54213. * @returns "PBRClearCoatConfiguration"
  54214. */
  54215. getClassName(): string;
  54216. /**
  54217. * Add fallbacks to the effect fallbacks list.
  54218. * @param defines defines the Base texture to use.
  54219. * @param fallbacks defines the current fallback list.
  54220. * @param currentRank defines the current fallback rank.
  54221. * @returns the new fallback rank.
  54222. */
  54223. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54224. /**
  54225. * Add the required uniforms to the current list.
  54226. * @param uniforms defines the current uniform list.
  54227. */
  54228. static AddUniforms(uniforms: string[]): void;
  54229. /**
  54230. * Add the required samplers to the current list.
  54231. * @param samplers defines the current sampler list.
  54232. */
  54233. static AddSamplers(samplers: string[]): void;
  54234. /**
  54235. * Add the required uniforms to the current buffer.
  54236. * @param uniformBuffer defines the current uniform buffer.
  54237. */
  54238. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54239. /**
  54240. * Makes a duplicate of the current configuration into another one.
  54241. * @param clearCoatConfiguration define the config where to copy the info
  54242. */
  54243. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54244. /**
  54245. * Serializes this clear coat configuration.
  54246. * @returns - An object with the serialized config.
  54247. */
  54248. serialize(): any;
  54249. /**
  54250. * Parses a anisotropy Configuration from a serialized object.
  54251. * @param source - Serialized object.
  54252. * @param scene Defines the scene we are parsing for
  54253. * @param rootUrl Defines the rootUrl to load from
  54254. */
  54255. parse(source: any, scene: Scene, rootUrl: string): void;
  54256. }
  54257. }
  54258. declare module BABYLON {
  54259. /**
  54260. * @hidden
  54261. */
  54262. export interface IMaterialAnisotropicDefines {
  54263. ANISOTROPIC: boolean;
  54264. ANISOTROPIC_TEXTURE: boolean;
  54265. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54266. MAINUV1: boolean;
  54267. _areTexturesDirty: boolean;
  54268. _needUVs: boolean;
  54269. }
  54270. /**
  54271. * Define the code related to the anisotropic parameters of the pbr material.
  54272. */
  54273. export class PBRAnisotropicConfiguration {
  54274. private _isEnabled;
  54275. /**
  54276. * Defines if the anisotropy is enabled in the material.
  54277. */
  54278. isEnabled: boolean;
  54279. /**
  54280. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54281. */
  54282. intensity: number;
  54283. /**
  54284. * Defines if the effect is along the tangents, bitangents or in between.
  54285. * By default, the effect is "strectching" the highlights along the tangents.
  54286. */
  54287. direction: Vector2;
  54288. private _texture;
  54289. /**
  54290. * Stores the anisotropy values in a texture.
  54291. * rg is direction (like normal from -1 to 1)
  54292. * b is a intensity
  54293. */
  54294. texture: Nullable<BaseTexture>;
  54295. /** @hidden */
  54296. private _internalMarkAllSubMeshesAsTexturesDirty;
  54297. /** @hidden */
  54298. _markAllSubMeshesAsTexturesDirty(): void;
  54299. /**
  54300. * Instantiate a new istance of anisotropy configuration.
  54301. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54302. */
  54303. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54304. /**
  54305. * Specifies that the submesh is ready to be used.
  54306. * @param defines the list of "defines" to update.
  54307. * @param scene defines the scene the material belongs to.
  54308. * @returns - boolean indicating that the submesh is ready or not.
  54309. */
  54310. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54311. /**
  54312. * Checks to see if a texture is used in the material.
  54313. * @param defines the list of "defines" to update.
  54314. * @param mesh the mesh we are preparing the defines for.
  54315. * @param scene defines the scene the material belongs to.
  54316. */
  54317. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54318. /**
  54319. * Binds the material data.
  54320. * @param uniformBuffer defines the Uniform buffer to fill in.
  54321. * @param scene defines the scene the material belongs to.
  54322. * @param isFrozen defines wether the material is frozen or not.
  54323. */
  54324. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54325. /**
  54326. * Checks to see if a texture is used in the material.
  54327. * @param texture - Base texture to use.
  54328. * @returns - Boolean specifying if a texture is used in the material.
  54329. */
  54330. hasTexture(texture: BaseTexture): boolean;
  54331. /**
  54332. * Returns an array of the actively used textures.
  54333. * @param activeTextures Array of BaseTextures
  54334. */
  54335. getActiveTextures(activeTextures: BaseTexture[]): void;
  54336. /**
  54337. * Returns the animatable textures.
  54338. * @param animatables Array of animatable textures.
  54339. */
  54340. getAnimatables(animatables: IAnimatable[]): void;
  54341. /**
  54342. * Disposes the resources of the material.
  54343. * @param forceDisposeTextures - Forces the disposal of all textures.
  54344. */
  54345. dispose(forceDisposeTextures?: boolean): void;
  54346. /**
  54347. * Get the current class name of the texture useful for serialization or dynamic coding.
  54348. * @returns "PBRAnisotropicConfiguration"
  54349. */
  54350. getClassName(): string;
  54351. /**
  54352. * Add fallbacks to the effect fallbacks list.
  54353. * @param defines defines the Base texture to use.
  54354. * @param fallbacks defines the current fallback list.
  54355. * @param currentRank defines the current fallback rank.
  54356. * @returns the new fallback rank.
  54357. */
  54358. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54359. /**
  54360. * Add the required uniforms to the current list.
  54361. * @param uniforms defines the current uniform list.
  54362. */
  54363. static AddUniforms(uniforms: string[]): void;
  54364. /**
  54365. * Add the required uniforms to the current buffer.
  54366. * @param uniformBuffer defines the current uniform buffer.
  54367. */
  54368. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54369. /**
  54370. * Add the required samplers to the current list.
  54371. * @param samplers defines the current sampler list.
  54372. */
  54373. static AddSamplers(samplers: string[]): void;
  54374. /**
  54375. * Makes a duplicate of the current configuration into another one.
  54376. * @param anisotropicConfiguration define the config where to copy the info
  54377. */
  54378. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54379. /**
  54380. * Serializes this anisotropy configuration.
  54381. * @returns - An object with the serialized config.
  54382. */
  54383. serialize(): any;
  54384. /**
  54385. * Parses a anisotropy Configuration from a serialized object.
  54386. * @param source - Serialized object.
  54387. * @param scene Defines the scene we are parsing for
  54388. * @param rootUrl Defines the rootUrl to load from
  54389. */
  54390. parse(source: any, scene: Scene, rootUrl: string): void;
  54391. }
  54392. }
  54393. declare module BABYLON {
  54394. /**
  54395. * @hidden
  54396. */
  54397. export interface IMaterialBRDFDefines {
  54398. BRDF_V_HEIGHT_CORRELATED: boolean;
  54399. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54400. SPHERICAL_HARMONICS: boolean;
  54401. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54402. /** @hidden */
  54403. _areMiscDirty: boolean;
  54404. }
  54405. /**
  54406. * Define the code related to the BRDF parameters of the pbr material.
  54407. */
  54408. export class PBRBRDFConfiguration {
  54409. /**
  54410. * Default value used for the energy conservation.
  54411. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54412. */
  54413. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54414. /**
  54415. * Default value used for the Smith Visibility Height Correlated mode.
  54416. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54417. */
  54418. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54419. /**
  54420. * Default value used for the IBL diffuse part.
  54421. * This can help switching back to the polynomials mode globally which is a tiny bit
  54422. * less GPU intensive at the drawback of a lower quality.
  54423. */
  54424. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54425. /**
  54426. * Default value used for activating energy conservation for the specular workflow.
  54427. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54428. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54429. */
  54430. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54431. private _useEnergyConservation;
  54432. /**
  54433. * Defines if the material uses energy conservation.
  54434. */
  54435. useEnergyConservation: boolean;
  54436. private _useSmithVisibilityHeightCorrelated;
  54437. /**
  54438. * LEGACY Mode set to false
  54439. * Defines if the material uses height smith correlated visibility term.
  54440. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54441. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54442. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54443. * Not relying on height correlated will also disable energy conservation.
  54444. */
  54445. useSmithVisibilityHeightCorrelated: boolean;
  54446. private _useSphericalHarmonics;
  54447. /**
  54448. * LEGACY Mode set to false
  54449. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54450. * diffuse part of the IBL.
  54451. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54452. * to the ground truth.
  54453. */
  54454. useSphericalHarmonics: boolean;
  54455. private _useSpecularGlossinessInputEnergyConservation;
  54456. /**
  54457. * Defines if the material uses energy conservation, when the specular workflow is active.
  54458. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54459. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54460. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54461. */
  54462. useSpecularGlossinessInputEnergyConservation: boolean;
  54463. /** @hidden */
  54464. private _internalMarkAllSubMeshesAsMiscDirty;
  54465. /** @hidden */
  54466. _markAllSubMeshesAsMiscDirty(): void;
  54467. /**
  54468. * Instantiate a new istance of clear coat configuration.
  54469. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54470. */
  54471. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54472. /**
  54473. * Checks to see if a texture is used in the material.
  54474. * @param defines the list of "defines" to update.
  54475. */
  54476. prepareDefines(defines: IMaterialBRDFDefines): void;
  54477. /**
  54478. * Get the current class name of the texture useful for serialization or dynamic coding.
  54479. * @returns "PBRClearCoatConfiguration"
  54480. */
  54481. getClassName(): string;
  54482. /**
  54483. * Makes a duplicate of the current configuration into another one.
  54484. * @param brdfConfiguration define the config where to copy the info
  54485. */
  54486. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54487. /**
  54488. * Serializes this BRDF configuration.
  54489. * @returns - An object with the serialized config.
  54490. */
  54491. serialize(): any;
  54492. /**
  54493. * Parses a anisotropy Configuration from a serialized object.
  54494. * @param source - Serialized object.
  54495. * @param scene Defines the scene we are parsing for
  54496. * @param rootUrl Defines the rootUrl to load from
  54497. */
  54498. parse(source: any, scene: Scene, rootUrl: string): void;
  54499. }
  54500. }
  54501. declare module BABYLON {
  54502. /**
  54503. * @hidden
  54504. */
  54505. export interface IMaterialSheenDefines {
  54506. SHEEN: boolean;
  54507. SHEEN_TEXTURE: boolean;
  54508. SHEEN_TEXTUREDIRECTUV: number;
  54509. SHEEN_LINKWITHALBEDO: boolean;
  54510. SHEEN_ROUGHNESS: boolean;
  54511. SHEEN_ALBEDOSCALING: boolean;
  54512. /** @hidden */
  54513. _areTexturesDirty: boolean;
  54514. }
  54515. /**
  54516. * Define the code related to the Sheen parameters of the pbr material.
  54517. */
  54518. export class PBRSheenConfiguration {
  54519. private _isEnabled;
  54520. /**
  54521. * Defines if the material uses sheen.
  54522. */
  54523. isEnabled: boolean;
  54524. private _linkSheenWithAlbedo;
  54525. /**
  54526. * Defines if the sheen is linked to the sheen color.
  54527. */
  54528. linkSheenWithAlbedo: boolean;
  54529. /**
  54530. * Defines the sheen intensity.
  54531. */
  54532. intensity: number;
  54533. /**
  54534. * Defines the sheen color.
  54535. */
  54536. color: Color3;
  54537. private _texture;
  54538. /**
  54539. * Stores the sheen tint values in a texture.
  54540. * rgb is tint
  54541. * a is a intensity or roughness if roughness has been defined
  54542. */
  54543. texture: Nullable<BaseTexture>;
  54544. private _roughness;
  54545. /**
  54546. * Defines the sheen roughness.
  54547. * It is not taken into account if linkSheenWithAlbedo is true.
  54548. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54549. */
  54550. roughness: Nullable<number>;
  54551. private _albedoScaling;
  54552. /**
  54553. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  54554. * It allows the strength of the sheen effect to not depend on the base color of the material,
  54555. * making it easier to setup and tweak the effect
  54556. */
  54557. albedoScaling: boolean;
  54558. /** @hidden */
  54559. private _internalMarkAllSubMeshesAsTexturesDirty;
  54560. /** @hidden */
  54561. _markAllSubMeshesAsTexturesDirty(): void;
  54562. /**
  54563. * Instantiate a new istance of clear coat configuration.
  54564. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54565. */
  54566. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54567. /**
  54568. * Specifies that the submesh is ready to be used.
  54569. * @param defines the list of "defines" to update.
  54570. * @param scene defines the scene the material belongs to.
  54571. * @returns - boolean indicating that the submesh is ready or not.
  54572. */
  54573. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  54574. /**
  54575. * Checks to see if a texture is used in the material.
  54576. * @param defines the list of "defines" to update.
  54577. * @param scene defines the scene the material belongs to.
  54578. */
  54579. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  54580. /**
  54581. * Binds the material data.
  54582. * @param uniformBuffer defines the Uniform buffer to fill in.
  54583. * @param scene defines the scene the material belongs to.
  54584. * @param isFrozen defines wether the material is frozen or not.
  54585. */
  54586. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54587. /**
  54588. * Checks to see if a texture is used in the material.
  54589. * @param texture - Base texture to use.
  54590. * @returns - Boolean specifying if a texture is used in the material.
  54591. */
  54592. hasTexture(texture: BaseTexture): boolean;
  54593. /**
  54594. * Returns an array of the actively used textures.
  54595. * @param activeTextures Array of BaseTextures
  54596. */
  54597. getActiveTextures(activeTextures: BaseTexture[]): void;
  54598. /**
  54599. * Returns the animatable textures.
  54600. * @param animatables Array of animatable textures.
  54601. */
  54602. getAnimatables(animatables: IAnimatable[]): void;
  54603. /**
  54604. * Disposes the resources of the material.
  54605. * @param forceDisposeTextures - Forces the disposal of all textures.
  54606. */
  54607. dispose(forceDisposeTextures?: boolean): void;
  54608. /**
  54609. * Get the current class name of the texture useful for serialization or dynamic coding.
  54610. * @returns "PBRSheenConfiguration"
  54611. */
  54612. getClassName(): string;
  54613. /**
  54614. * Add fallbacks to the effect fallbacks list.
  54615. * @param defines defines the Base texture to use.
  54616. * @param fallbacks defines the current fallback list.
  54617. * @param currentRank defines the current fallback rank.
  54618. * @returns the new fallback rank.
  54619. */
  54620. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54621. /**
  54622. * Add the required uniforms to the current list.
  54623. * @param uniforms defines the current uniform list.
  54624. */
  54625. static AddUniforms(uniforms: string[]): void;
  54626. /**
  54627. * Add the required uniforms to the current buffer.
  54628. * @param uniformBuffer defines the current uniform buffer.
  54629. */
  54630. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54631. /**
  54632. * Add the required samplers to the current list.
  54633. * @param samplers defines the current sampler list.
  54634. */
  54635. static AddSamplers(samplers: string[]): void;
  54636. /**
  54637. * Makes a duplicate of the current configuration into another one.
  54638. * @param sheenConfiguration define the config where to copy the info
  54639. */
  54640. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  54641. /**
  54642. * Serializes this BRDF configuration.
  54643. * @returns - An object with the serialized config.
  54644. */
  54645. serialize(): any;
  54646. /**
  54647. * Parses a anisotropy Configuration from a serialized object.
  54648. * @param source - Serialized object.
  54649. * @param scene Defines the scene we are parsing for
  54650. * @param rootUrl Defines the rootUrl to load from
  54651. */
  54652. parse(source: any, scene: Scene, rootUrl: string): void;
  54653. }
  54654. }
  54655. declare module BABYLON {
  54656. /**
  54657. * @hidden
  54658. */
  54659. export interface IMaterialSubSurfaceDefines {
  54660. SUBSURFACE: boolean;
  54661. SS_REFRACTION: boolean;
  54662. SS_TRANSLUCENCY: boolean;
  54663. SS_SCATTERING: boolean;
  54664. SS_THICKNESSANDMASK_TEXTURE: boolean;
  54665. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  54666. SS_REFRACTIONMAP_3D: boolean;
  54667. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  54668. SS_LODINREFRACTIONALPHA: boolean;
  54669. SS_GAMMAREFRACTION: boolean;
  54670. SS_RGBDREFRACTION: boolean;
  54671. SS_LINEARSPECULARREFRACTION: boolean;
  54672. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  54673. SS_ALBEDOFORREFRACTIONTINT: boolean;
  54674. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  54675. /** @hidden */
  54676. _areTexturesDirty: boolean;
  54677. }
  54678. /**
  54679. * Define the code related to the sub surface parameters of the pbr material.
  54680. */
  54681. export class PBRSubSurfaceConfiguration {
  54682. private _isRefractionEnabled;
  54683. /**
  54684. * Defines if the refraction is enabled in the material.
  54685. */
  54686. isRefractionEnabled: boolean;
  54687. private _isTranslucencyEnabled;
  54688. /**
  54689. * Defines if the translucency is enabled in the material.
  54690. */
  54691. isTranslucencyEnabled: boolean;
  54692. private _isScatteringEnabled;
  54693. /**
  54694. * Defines if the sub surface scattering is enabled in the material.
  54695. */
  54696. isScatteringEnabled: boolean;
  54697. private _scatteringDiffusionProfileIndex;
  54698. /**
  54699. * Diffusion profile for subsurface scattering.
  54700. * Useful for better scattering in the skins or foliages.
  54701. */
  54702. get scatteringDiffusionProfile(): Nullable<Color3>;
  54703. set scatteringDiffusionProfile(c: Nullable<Color3>);
  54704. /**
  54705. * Defines the refraction intensity of the material.
  54706. * The refraction when enabled replaces the Diffuse part of the material.
  54707. * The intensity helps transitionning between diffuse and refraction.
  54708. */
  54709. refractionIntensity: number;
  54710. /**
  54711. * Defines the translucency intensity of the material.
  54712. * When translucency has been enabled, this defines how much of the "translucency"
  54713. * is addded to the diffuse part of the material.
  54714. */
  54715. translucencyIntensity: number;
  54716. /**
  54717. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  54718. */
  54719. useAlbedoToTintRefraction: boolean;
  54720. private _thicknessTexture;
  54721. /**
  54722. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  54723. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  54724. * 0 would mean minimumThickness
  54725. * 1 would mean maximumThickness
  54726. * The other channels might be use as a mask to vary the different effects intensity.
  54727. */
  54728. thicknessTexture: Nullable<BaseTexture>;
  54729. private _refractionTexture;
  54730. /**
  54731. * Defines the texture to use for refraction.
  54732. */
  54733. refractionTexture: Nullable<BaseTexture>;
  54734. private _indexOfRefraction;
  54735. /**
  54736. * Index of refraction of the material base layer.
  54737. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54738. *
  54739. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  54740. *
  54741. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  54742. */
  54743. indexOfRefraction: number;
  54744. private _volumeIndexOfRefraction;
  54745. /**
  54746. * Index of refraction of the material's volume.
  54747. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  54748. *
  54749. * This ONLY impacts refraction. If not provided or given a non-valid value,
  54750. * the volume will use the same IOR as the surface.
  54751. */
  54752. get volumeIndexOfRefraction(): number;
  54753. set volumeIndexOfRefraction(value: number);
  54754. private _invertRefractionY;
  54755. /**
  54756. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54757. */
  54758. invertRefractionY: boolean;
  54759. private _linkRefractionWithTransparency;
  54760. /**
  54761. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54762. * Materials half opaque for instance using refraction could benefit from this control.
  54763. */
  54764. linkRefractionWithTransparency: boolean;
  54765. /**
  54766. * Defines the minimum thickness stored in the thickness map.
  54767. * If no thickness map is defined, this value will be used to simulate thickness.
  54768. */
  54769. minimumThickness: number;
  54770. /**
  54771. * Defines the maximum thickness stored in the thickness map.
  54772. */
  54773. maximumThickness: number;
  54774. /**
  54775. * Defines the volume tint of the material.
  54776. * This is used for both translucency and scattering.
  54777. */
  54778. tintColor: Color3;
  54779. /**
  54780. * Defines the distance at which the tint color should be found in the media.
  54781. * This is used for refraction only.
  54782. */
  54783. tintColorAtDistance: number;
  54784. /**
  54785. * Defines how far each channel transmit through the media.
  54786. * It is defined as a color to simplify it selection.
  54787. */
  54788. diffusionDistance: Color3;
  54789. private _useMaskFromThicknessTexture;
  54790. /**
  54791. * Stores the intensity of the different subsurface effects in the thickness texture.
  54792. * * the green channel is the translucency intensity.
  54793. * * the blue channel is the scattering intensity.
  54794. * * the alpha channel is the refraction intensity.
  54795. */
  54796. useMaskFromThicknessTexture: boolean;
  54797. private _scene;
  54798. /** @hidden */
  54799. private _internalMarkAllSubMeshesAsTexturesDirty;
  54800. private _internalMarkScenePrePassDirty;
  54801. /** @hidden */
  54802. _markAllSubMeshesAsTexturesDirty(): void;
  54803. /** @hidden */
  54804. _markScenePrePassDirty(): void;
  54805. /**
  54806. * Instantiate a new istance of sub surface configuration.
  54807. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54808. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  54809. * @param scene The scene
  54810. */
  54811. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  54812. /**
  54813. * Gets wehter the submesh is ready to be used or not.
  54814. * @param defines the list of "defines" to update.
  54815. * @param scene defines the scene the material belongs to.
  54816. * @returns - boolean indicating that the submesh is ready or not.
  54817. */
  54818. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  54819. /**
  54820. * Checks to see if a texture is used in the material.
  54821. * @param defines the list of "defines" to update.
  54822. * @param scene defines the scene to the material belongs to.
  54823. */
  54824. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  54825. /**
  54826. * Binds the material data.
  54827. * @param uniformBuffer defines the Uniform buffer to fill in.
  54828. * @param scene defines the scene the material belongs to.
  54829. * @param engine defines the engine the material belongs to.
  54830. * @param isFrozen defines whether the material is frozen or not.
  54831. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  54832. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  54833. */
  54834. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  54835. /**
  54836. * Unbinds the material from the mesh.
  54837. * @param activeEffect defines the effect that should be unbound from.
  54838. * @returns true if unbound, otherwise false
  54839. */
  54840. unbind(activeEffect: Effect): boolean;
  54841. /**
  54842. * Returns the texture used for refraction or null if none is used.
  54843. * @param scene defines the scene the material belongs to.
  54844. * @returns - Refraction texture if present. If no refraction texture and refraction
  54845. * is linked with transparency, returns environment texture. Otherwise, returns null.
  54846. */
  54847. private _getRefractionTexture;
  54848. /**
  54849. * Returns true if alpha blending should be disabled.
  54850. */
  54851. get disableAlphaBlending(): boolean;
  54852. /**
  54853. * Fills the list of render target textures.
  54854. * @param renderTargets the list of render targets to update
  54855. */
  54856. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  54857. /**
  54858. * Checks to see if a texture is used in the material.
  54859. * @param texture - Base texture to use.
  54860. * @returns - Boolean specifying if a texture is used in the material.
  54861. */
  54862. hasTexture(texture: BaseTexture): boolean;
  54863. /**
  54864. * Gets a boolean indicating that current material needs to register RTT
  54865. * @returns true if this uses a render target otherwise false.
  54866. */
  54867. hasRenderTargetTextures(): boolean;
  54868. /**
  54869. * Returns an array of the actively used textures.
  54870. * @param activeTextures Array of BaseTextures
  54871. */
  54872. getActiveTextures(activeTextures: BaseTexture[]): void;
  54873. /**
  54874. * Returns the animatable textures.
  54875. * @param animatables Array of animatable textures.
  54876. */
  54877. getAnimatables(animatables: IAnimatable[]): void;
  54878. /**
  54879. * Disposes the resources of the material.
  54880. * @param forceDisposeTextures - Forces the disposal of all textures.
  54881. */
  54882. dispose(forceDisposeTextures?: boolean): void;
  54883. /**
  54884. * Get the current class name of the texture useful for serialization or dynamic coding.
  54885. * @returns "PBRSubSurfaceConfiguration"
  54886. */
  54887. getClassName(): string;
  54888. /**
  54889. * Add fallbacks to the effect fallbacks list.
  54890. * @param defines defines the Base texture to use.
  54891. * @param fallbacks defines the current fallback list.
  54892. * @param currentRank defines the current fallback rank.
  54893. * @returns the new fallback rank.
  54894. */
  54895. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54896. /**
  54897. * Add the required uniforms to the current list.
  54898. * @param uniforms defines the current uniform list.
  54899. */
  54900. static AddUniforms(uniforms: string[]): void;
  54901. /**
  54902. * Add the required samplers to the current list.
  54903. * @param samplers defines the current sampler list.
  54904. */
  54905. static AddSamplers(samplers: string[]): void;
  54906. /**
  54907. * Add the required uniforms to the current buffer.
  54908. * @param uniformBuffer defines the current uniform buffer.
  54909. */
  54910. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54911. /**
  54912. * Makes a duplicate of the current configuration into another one.
  54913. * @param configuration define the config where to copy the info
  54914. */
  54915. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  54916. /**
  54917. * Serializes this Sub Surface configuration.
  54918. * @returns - An object with the serialized config.
  54919. */
  54920. serialize(): any;
  54921. /**
  54922. * Parses a anisotropy Configuration from a serialized object.
  54923. * @param source - Serialized object.
  54924. * @param scene Defines the scene we are parsing for
  54925. * @param rootUrl Defines the rootUrl to load from
  54926. */
  54927. parse(source: any, scene: Scene, rootUrl: string): void;
  54928. }
  54929. }
  54930. declare module BABYLON {
  54931. /** @hidden */
  54932. export var pbrFragmentDeclaration: {
  54933. name: string;
  54934. shader: string;
  54935. };
  54936. }
  54937. declare module BABYLON {
  54938. /** @hidden */
  54939. export var pbrUboDeclaration: {
  54940. name: string;
  54941. shader: string;
  54942. };
  54943. }
  54944. declare module BABYLON {
  54945. /** @hidden */
  54946. export var pbrFragmentExtraDeclaration: {
  54947. name: string;
  54948. shader: string;
  54949. };
  54950. }
  54951. declare module BABYLON {
  54952. /** @hidden */
  54953. export var pbrFragmentSamplersDeclaration: {
  54954. name: string;
  54955. shader: string;
  54956. };
  54957. }
  54958. declare module BABYLON {
  54959. /** @hidden */
  54960. export var subSurfaceScatteringFunctions: {
  54961. name: string;
  54962. shader: string;
  54963. };
  54964. }
  54965. declare module BABYLON {
  54966. /** @hidden */
  54967. export var importanceSampling: {
  54968. name: string;
  54969. shader: string;
  54970. };
  54971. }
  54972. declare module BABYLON {
  54973. /** @hidden */
  54974. export var pbrHelperFunctions: {
  54975. name: string;
  54976. shader: string;
  54977. };
  54978. }
  54979. declare module BABYLON {
  54980. /** @hidden */
  54981. export var harmonicsFunctions: {
  54982. name: string;
  54983. shader: string;
  54984. };
  54985. }
  54986. declare module BABYLON {
  54987. /** @hidden */
  54988. export var pbrDirectLightingSetupFunctions: {
  54989. name: string;
  54990. shader: string;
  54991. };
  54992. }
  54993. declare module BABYLON {
  54994. /** @hidden */
  54995. export var pbrDirectLightingFalloffFunctions: {
  54996. name: string;
  54997. shader: string;
  54998. };
  54999. }
  55000. declare module BABYLON {
  55001. /** @hidden */
  55002. export var pbrBRDFFunctions: {
  55003. name: string;
  55004. shader: string;
  55005. };
  55006. }
  55007. declare module BABYLON {
  55008. /** @hidden */
  55009. export var hdrFilteringFunctions: {
  55010. name: string;
  55011. shader: string;
  55012. };
  55013. }
  55014. declare module BABYLON {
  55015. /** @hidden */
  55016. export var pbrDirectLightingFunctions: {
  55017. name: string;
  55018. shader: string;
  55019. };
  55020. }
  55021. declare module BABYLON {
  55022. /** @hidden */
  55023. export var pbrIBLFunctions: {
  55024. name: string;
  55025. shader: string;
  55026. };
  55027. }
  55028. declare module BABYLON {
  55029. /** @hidden */
  55030. export var pbrBlockAlbedoOpacity: {
  55031. name: string;
  55032. shader: string;
  55033. };
  55034. }
  55035. declare module BABYLON {
  55036. /** @hidden */
  55037. export var pbrBlockReflectivity: {
  55038. name: string;
  55039. shader: string;
  55040. };
  55041. }
  55042. declare module BABYLON {
  55043. /** @hidden */
  55044. export var pbrBlockAmbientOcclusion: {
  55045. name: string;
  55046. shader: string;
  55047. };
  55048. }
  55049. declare module BABYLON {
  55050. /** @hidden */
  55051. export var pbrBlockAlphaFresnel: {
  55052. name: string;
  55053. shader: string;
  55054. };
  55055. }
  55056. declare module BABYLON {
  55057. /** @hidden */
  55058. export var pbrBlockAnisotropic: {
  55059. name: string;
  55060. shader: string;
  55061. };
  55062. }
  55063. declare module BABYLON {
  55064. /** @hidden */
  55065. export var pbrBlockReflection: {
  55066. name: string;
  55067. shader: string;
  55068. };
  55069. }
  55070. declare module BABYLON {
  55071. /** @hidden */
  55072. export var pbrBlockSheen: {
  55073. name: string;
  55074. shader: string;
  55075. };
  55076. }
  55077. declare module BABYLON {
  55078. /** @hidden */
  55079. export var pbrBlockClearcoat: {
  55080. name: string;
  55081. shader: string;
  55082. };
  55083. }
  55084. declare module BABYLON {
  55085. /** @hidden */
  55086. export var pbrBlockSubSurface: {
  55087. name: string;
  55088. shader: string;
  55089. };
  55090. }
  55091. declare module BABYLON {
  55092. /** @hidden */
  55093. export var pbrBlockNormalGeometric: {
  55094. name: string;
  55095. shader: string;
  55096. };
  55097. }
  55098. declare module BABYLON {
  55099. /** @hidden */
  55100. export var pbrBlockNormalFinal: {
  55101. name: string;
  55102. shader: string;
  55103. };
  55104. }
  55105. declare module BABYLON {
  55106. /** @hidden */
  55107. export var pbrBlockGeometryInfo: {
  55108. name: string;
  55109. shader: string;
  55110. };
  55111. }
  55112. declare module BABYLON {
  55113. /** @hidden */
  55114. export var pbrBlockReflectance0: {
  55115. name: string;
  55116. shader: string;
  55117. };
  55118. }
  55119. declare module BABYLON {
  55120. /** @hidden */
  55121. export var pbrBlockReflectance: {
  55122. name: string;
  55123. shader: string;
  55124. };
  55125. }
  55126. declare module BABYLON {
  55127. /** @hidden */
  55128. export var pbrBlockDirectLighting: {
  55129. name: string;
  55130. shader: string;
  55131. };
  55132. }
  55133. declare module BABYLON {
  55134. /** @hidden */
  55135. export var pbrBlockFinalLitComponents: {
  55136. name: string;
  55137. shader: string;
  55138. };
  55139. }
  55140. declare module BABYLON {
  55141. /** @hidden */
  55142. export var pbrBlockFinalUnlitComponents: {
  55143. name: string;
  55144. shader: string;
  55145. };
  55146. }
  55147. declare module BABYLON {
  55148. /** @hidden */
  55149. export var pbrBlockFinalColorComposition: {
  55150. name: string;
  55151. shader: string;
  55152. };
  55153. }
  55154. declare module BABYLON {
  55155. /** @hidden */
  55156. export var pbrBlockImageProcessing: {
  55157. name: string;
  55158. shader: string;
  55159. };
  55160. }
  55161. declare module BABYLON {
  55162. /** @hidden */
  55163. export var pbrDebug: {
  55164. name: string;
  55165. shader: string;
  55166. };
  55167. }
  55168. declare module BABYLON {
  55169. /** @hidden */
  55170. export var pbrPixelShader: {
  55171. name: string;
  55172. shader: string;
  55173. };
  55174. }
  55175. declare module BABYLON {
  55176. /** @hidden */
  55177. export var pbrVertexDeclaration: {
  55178. name: string;
  55179. shader: string;
  55180. };
  55181. }
  55182. declare module BABYLON {
  55183. /** @hidden */
  55184. export var pbrVertexShader: {
  55185. name: string;
  55186. shader: string;
  55187. };
  55188. }
  55189. declare module BABYLON {
  55190. /**
  55191. * Manages the defines for the PBR Material.
  55192. * @hidden
  55193. */
  55194. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55195. PBR: boolean;
  55196. NUM_SAMPLES: string;
  55197. REALTIME_FILTERING: boolean;
  55198. MAINUV1: boolean;
  55199. MAINUV2: boolean;
  55200. UV1: boolean;
  55201. UV2: boolean;
  55202. ALBEDO: boolean;
  55203. GAMMAALBEDO: boolean;
  55204. ALBEDODIRECTUV: number;
  55205. VERTEXCOLOR: boolean;
  55206. DETAIL: boolean;
  55207. DETAILDIRECTUV: number;
  55208. DETAIL_NORMALBLENDMETHOD: number;
  55209. AMBIENT: boolean;
  55210. AMBIENTDIRECTUV: number;
  55211. AMBIENTINGRAYSCALE: boolean;
  55212. OPACITY: boolean;
  55213. VERTEXALPHA: boolean;
  55214. OPACITYDIRECTUV: number;
  55215. OPACITYRGB: boolean;
  55216. ALPHATEST: boolean;
  55217. DEPTHPREPASS: boolean;
  55218. ALPHABLEND: boolean;
  55219. ALPHAFROMALBEDO: boolean;
  55220. ALPHATESTVALUE: string;
  55221. SPECULAROVERALPHA: boolean;
  55222. RADIANCEOVERALPHA: boolean;
  55223. ALPHAFRESNEL: boolean;
  55224. LINEARALPHAFRESNEL: boolean;
  55225. PREMULTIPLYALPHA: boolean;
  55226. EMISSIVE: boolean;
  55227. EMISSIVEDIRECTUV: number;
  55228. REFLECTIVITY: boolean;
  55229. REFLECTIVITYDIRECTUV: number;
  55230. SPECULARTERM: boolean;
  55231. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55232. MICROSURFACEAUTOMATIC: boolean;
  55233. LODBASEDMICROSFURACE: boolean;
  55234. MICROSURFACEMAP: boolean;
  55235. MICROSURFACEMAPDIRECTUV: number;
  55236. METALLICWORKFLOW: boolean;
  55237. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55238. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55239. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55240. AOSTOREINMETALMAPRED: boolean;
  55241. METALLIC_REFLECTANCE: boolean;
  55242. METALLIC_REFLECTANCEDIRECTUV: number;
  55243. ENVIRONMENTBRDF: boolean;
  55244. ENVIRONMENTBRDF_RGBD: boolean;
  55245. NORMAL: boolean;
  55246. TANGENT: boolean;
  55247. BUMP: boolean;
  55248. BUMPDIRECTUV: number;
  55249. OBJECTSPACE_NORMALMAP: boolean;
  55250. PARALLAX: boolean;
  55251. PARALLAXOCCLUSION: boolean;
  55252. NORMALXYSCALE: boolean;
  55253. LIGHTMAP: boolean;
  55254. LIGHTMAPDIRECTUV: number;
  55255. USELIGHTMAPASSHADOWMAP: boolean;
  55256. GAMMALIGHTMAP: boolean;
  55257. RGBDLIGHTMAP: boolean;
  55258. REFLECTION: boolean;
  55259. REFLECTIONMAP_3D: boolean;
  55260. REFLECTIONMAP_SPHERICAL: boolean;
  55261. REFLECTIONMAP_PLANAR: boolean;
  55262. REFLECTIONMAP_CUBIC: boolean;
  55263. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55264. REFLECTIONMAP_PROJECTION: boolean;
  55265. REFLECTIONMAP_SKYBOX: boolean;
  55266. REFLECTIONMAP_EXPLICIT: boolean;
  55267. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55268. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55269. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55270. INVERTCUBICMAP: boolean;
  55271. USESPHERICALFROMREFLECTIONMAP: boolean;
  55272. USEIRRADIANCEMAP: boolean;
  55273. SPHERICAL_HARMONICS: boolean;
  55274. USESPHERICALINVERTEX: boolean;
  55275. REFLECTIONMAP_OPPOSITEZ: boolean;
  55276. LODINREFLECTIONALPHA: boolean;
  55277. GAMMAREFLECTION: boolean;
  55278. RGBDREFLECTION: boolean;
  55279. LINEARSPECULARREFLECTION: boolean;
  55280. RADIANCEOCCLUSION: boolean;
  55281. HORIZONOCCLUSION: boolean;
  55282. INSTANCES: boolean;
  55283. THIN_INSTANCES: boolean;
  55284. PREPASS: boolean;
  55285. SCENE_MRT_COUNT: number;
  55286. NUM_BONE_INFLUENCERS: number;
  55287. BonesPerMesh: number;
  55288. BONETEXTURE: boolean;
  55289. NONUNIFORMSCALING: boolean;
  55290. MORPHTARGETS: boolean;
  55291. MORPHTARGETS_NORMAL: boolean;
  55292. MORPHTARGETS_TANGENT: boolean;
  55293. MORPHTARGETS_UV: boolean;
  55294. NUM_MORPH_INFLUENCERS: number;
  55295. IMAGEPROCESSING: boolean;
  55296. VIGNETTE: boolean;
  55297. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55298. VIGNETTEBLENDMODEOPAQUE: boolean;
  55299. TONEMAPPING: boolean;
  55300. TONEMAPPING_ACES: boolean;
  55301. CONTRAST: boolean;
  55302. COLORCURVES: boolean;
  55303. COLORGRADING: boolean;
  55304. COLORGRADING3D: boolean;
  55305. SAMPLER3DGREENDEPTH: boolean;
  55306. SAMPLER3DBGRMAP: boolean;
  55307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55308. EXPOSURE: boolean;
  55309. MULTIVIEW: boolean;
  55310. USEPHYSICALLIGHTFALLOFF: boolean;
  55311. USEGLTFLIGHTFALLOFF: boolean;
  55312. TWOSIDEDLIGHTING: boolean;
  55313. SHADOWFLOAT: boolean;
  55314. CLIPPLANE: boolean;
  55315. CLIPPLANE2: boolean;
  55316. CLIPPLANE3: boolean;
  55317. CLIPPLANE4: boolean;
  55318. CLIPPLANE5: boolean;
  55319. CLIPPLANE6: boolean;
  55320. POINTSIZE: boolean;
  55321. FOG: boolean;
  55322. LOGARITHMICDEPTH: boolean;
  55323. FORCENORMALFORWARD: boolean;
  55324. SPECULARAA: boolean;
  55325. CLEARCOAT: boolean;
  55326. CLEARCOAT_DEFAULTIOR: boolean;
  55327. CLEARCOAT_TEXTURE: boolean;
  55328. CLEARCOAT_TEXTUREDIRECTUV: number;
  55329. CLEARCOAT_BUMP: boolean;
  55330. CLEARCOAT_BUMPDIRECTUV: number;
  55331. CLEARCOAT_TINT: boolean;
  55332. CLEARCOAT_TINT_TEXTURE: boolean;
  55333. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55334. ANISOTROPIC: boolean;
  55335. ANISOTROPIC_TEXTURE: boolean;
  55336. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55337. BRDF_V_HEIGHT_CORRELATED: boolean;
  55338. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55339. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55340. SHEEN: boolean;
  55341. SHEEN_TEXTURE: boolean;
  55342. SHEEN_TEXTUREDIRECTUV: number;
  55343. SHEEN_LINKWITHALBEDO: boolean;
  55344. SHEEN_ROUGHNESS: boolean;
  55345. SHEEN_ALBEDOSCALING: boolean;
  55346. SUBSURFACE: boolean;
  55347. SS_REFRACTION: boolean;
  55348. SS_TRANSLUCENCY: boolean;
  55349. SS_SCATTERING: boolean;
  55350. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55351. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55352. SS_REFRACTIONMAP_3D: boolean;
  55353. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55354. SS_LODINREFRACTIONALPHA: boolean;
  55355. SS_GAMMAREFRACTION: boolean;
  55356. SS_RGBDREFRACTION: boolean;
  55357. SS_LINEARSPECULARREFRACTION: boolean;
  55358. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55359. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55360. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55361. UNLIT: boolean;
  55362. DEBUGMODE: number;
  55363. /**
  55364. * Initializes the PBR Material defines.
  55365. */
  55366. constructor();
  55367. /**
  55368. * Resets the PBR Material defines.
  55369. */
  55370. reset(): void;
  55371. }
  55372. /**
  55373. * The Physically based material base class of BJS.
  55374. *
  55375. * This offers the main features of a standard PBR material.
  55376. * For more information, please refer to the documentation :
  55377. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55378. */
  55379. export abstract class PBRBaseMaterial extends PushMaterial {
  55380. /**
  55381. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55382. */
  55383. static readonly PBRMATERIAL_OPAQUE: number;
  55384. /**
  55385. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55386. */
  55387. static readonly PBRMATERIAL_ALPHATEST: number;
  55388. /**
  55389. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55390. */
  55391. static readonly PBRMATERIAL_ALPHABLEND: number;
  55392. /**
  55393. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55394. * They are also discarded below the alpha cutoff threshold to improve performances.
  55395. */
  55396. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55397. /**
  55398. * Defines the default value of how much AO map is occluding the analytical lights
  55399. * (point spot...).
  55400. */
  55401. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55402. /**
  55403. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55404. */
  55405. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55406. /**
  55407. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55408. * to enhance interoperability with other engines.
  55409. */
  55410. static readonly LIGHTFALLOFF_GLTF: number;
  55411. /**
  55412. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55413. * to enhance interoperability with other materials.
  55414. */
  55415. static readonly LIGHTFALLOFF_STANDARD: number;
  55416. /**
  55417. * Intensity of the direct lights e.g. the four lights available in your scene.
  55418. * This impacts both the direct diffuse and specular highlights.
  55419. */
  55420. protected _directIntensity: number;
  55421. /**
  55422. * Intensity of the emissive part of the material.
  55423. * This helps controlling the emissive effect without modifying the emissive color.
  55424. */
  55425. protected _emissiveIntensity: number;
  55426. /**
  55427. * Intensity of the environment e.g. how much the environment will light the object
  55428. * either through harmonics for rough material or through the refelction for shiny ones.
  55429. */
  55430. protected _environmentIntensity: number;
  55431. /**
  55432. * This is a special control allowing the reduction of the specular highlights coming from the
  55433. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55434. */
  55435. protected _specularIntensity: number;
  55436. /**
  55437. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55438. */
  55439. private _lightingInfos;
  55440. /**
  55441. * Debug Control allowing disabling the bump map on this material.
  55442. */
  55443. protected _disableBumpMap: boolean;
  55444. /**
  55445. * AKA Diffuse Texture in standard nomenclature.
  55446. */
  55447. protected _albedoTexture: Nullable<BaseTexture>;
  55448. /**
  55449. * AKA Occlusion Texture in other nomenclature.
  55450. */
  55451. protected _ambientTexture: Nullable<BaseTexture>;
  55452. /**
  55453. * AKA Occlusion Texture Intensity in other nomenclature.
  55454. */
  55455. protected _ambientTextureStrength: number;
  55456. /**
  55457. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55458. * 1 means it completely occludes it
  55459. * 0 mean it has no impact
  55460. */
  55461. protected _ambientTextureImpactOnAnalyticalLights: number;
  55462. /**
  55463. * Stores the alpha values in a texture.
  55464. */
  55465. protected _opacityTexture: Nullable<BaseTexture>;
  55466. /**
  55467. * Stores the reflection values in a texture.
  55468. */
  55469. protected _reflectionTexture: Nullable<BaseTexture>;
  55470. /**
  55471. * Stores the emissive values in a texture.
  55472. */
  55473. protected _emissiveTexture: Nullable<BaseTexture>;
  55474. /**
  55475. * AKA Specular texture in other nomenclature.
  55476. */
  55477. protected _reflectivityTexture: Nullable<BaseTexture>;
  55478. /**
  55479. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55480. */
  55481. protected _metallicTexture: Nullable<BaseTexture>;
  55482. /**
  55483. * Specifies the metallic scalar of the metallic/roughness workflow.
  55484. * Can also be used to scale the metalness values of the metallic texture.
  55485. */
  55486. protected _metallic: Nullable<number>;
  55487. /**
  55488. * Specifies the roughness scalar of the metallic/roughness workflow.
  55489. * Can also be used to scale the roughness values of the metallic texture.
  55490. */
  55491. protected _roughness: Nullable<number>;
  55492. /**
  55493. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55494. * By default the indexOfrefraction is used to compute F0;
  55495. *
  55496. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55497. *
  55498. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55499. * F90 = metallicReflectanceColor;
  55500. */
  55501. protected _metallicF0Factor: number;
  55502. /**
  55503. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55504. * By default the F90 is always 1;
  55505. *
  55506. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55507. *
  55508. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55509. * F90 = metallicReflectanceColor;
  55510. */
  55511. protected _metallicReflectanceColor: Color3;
  55512. /**
  55513. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55514. * This is multiply against the scalar values defined in the material.
  55515. */
  55516. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55517. /**
  55518. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55519. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55520. */
  55521. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55522. /**
  55523. * Stores surface normal data used to displace a mesh in a texture.
  55524. */
  55525. protected _bumpTexture: Nullable<BaseTexture>;
  55526. /**
  55527. * Stores the pre-calculated light information of a mesh in a texture.
  55528. */
  55529. protected _lightmapTexture: Nullable<BaseTexture>;
  55530. /**
  55531. * The color of a material in ambient lighting.
  55532. */
  55533. protected _ambientColor: Color3;
  55534. /**
  55535. * AKA Diffuse Color in other nomenclature.
  55536. */
  55537. protected _albedoColor: Color3;
  55538. /**
  55539. * AKA Specular Color in other nomenclature.
  55540. */
  55541. protected _reflectivityColor: Color3;
  55542. /**
  55543. * The color applied when light is reflected from a material.
  55544. */
  55545. protected _reflectionColor: Color3;
  55546. /**
  55547. * The color applied when light is emitted from a material.
  55548. */
  55549. protected _emissiveColor: Color3;
  55550. /**
  55551. * AKA Glossiness in other nomenclature.
  55552. */
  55553. protected _microSurface: number;
  55554. /**
  55555. * Specifies that the material will use the light map as a show map.
  55556. */
  55557. protected _useLightmapAsShadowmap: boolean;
  55558. /**
  55559. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  55560. * makes the reflect vector face the model (under horizon).
  55561. */
  55562. protected _useHorizonOcclusion: boolean;
  55563. /**
  55564. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  55565. * too much the area relying on ambient texture to define their ambient occlusion.
  55566. */
  55567. protected _useRadianceOcclusion: boolean;
  55568. /**
  55569. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  55570. */
  55571. protected _useAlphaFromAlbedoTexture: boolean;
  55572. /**
  55573. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  55574. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  55575. */
  55576. protected _useSpecularOverAlpha: boolean;
  55577. /**
  55578. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  55579. */
  55580. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  55581. /**
  55582. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  55583. */
  55584. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  55585. /**
  55586. * Specifies if the metallic texture contains the roughness information in its green channel.
  55587. */
  55588. protected _useRoughnessFromMetallicTextureGreen: boolean;
  55589. /**
  55590. * Specifies if the metallic texture contains the metallness information in its blue channel.
  55591. */
  55592. protected _useMetallnessFromMetallicTextureBlue: boolean;
  55593. /**
  55594. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  55595. */
  55596. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  55597. /**
  55598. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  55599. */
  55600. protected _useAmbientInGrayScale: boolean;
  55601. /**
  55602. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  55603. * The material will try to infer what glossiness each pixel should be.
  55604. */
  55605. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  55606. /**
  55607. * Defines the falloff type used in this material.
  55608. * It by default is Physical.
  55609. */
  55610. protected _lightFalloff: number;
  55611. /**
  55612. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  55613. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  55614. */
  55615. protected _useRadianceOverAlpha: boolean;
  55616. /**
  55617. * Allows using an object space normal map (instead of tangent space).
  55618. */
  55619. protected _useObjectSpaceNormalMap: boolean;
  55620. /**
  55621. * Allows using the bump map in parallax mode.
  55622. */
  55623. protected _useParallax: boolean;
  55624. /**
  55625. * Allows using the bump map in parallax occlusion mode.
  55626. */
  55627. protected _useParallaxOcclusion: boolean;
  55628. /**
  55629. * Controls the scale bias of the parallax mode.
  55630. */
  55631. protected _parallaxScaleBias: number;
  55632. /**
  55633. * If sets to true, disables all the lights affecting the material.
  55634. */
  55635. protected _disableLighting: boolean;
  55636. /**
  55637. * Number of Simultaneous lights allowed on the material.
  55638. */
  55639. protected _maxSimultaneousLights: number;
  55640. /**
  55641. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55642. */
  55643. protected _invertNormalMapX: boolean;
  55644. /**
  55645. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55646. */
  55647. protected _invertNormalMapY: boolean;
  55648. /**
  55649. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55650. */
  55651. protected _twoSidedLighting: boolean;
  55652. /**
  55653. * Defines the alpha limits in alpha test mode.
  55654. */
  55655. protected _alphaCutOff: number;
  55656. /**
  55657. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  55658. */
  55659. protected _forceAlphaTest: boolean;
  55660. /**
  55661. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55662. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  55663. */
  55664. protected _useAlphaFresnel: boolean;
  55665. /**
  55666. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  55667. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  55668. */
  55669. protected _useLinearAlphaFresnel: boolean;
  55670. /**
  55671. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  55672. * from cos thetav and roughness:
  55673. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  55674. */
  55675. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  55676. /**
  55677. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  55678. */
  55679. protected _forceIrradianceInFragment: boolean;
  55680. private _realTimeFiltering;
  55681. /**
  55682. * Enables realtime filtering on the texture.
  55683. */
  55684. get realTimeFiltering(): boolean;
  55685. set realTimeFiltering(b: boolean);
  55686. private _realTimeFilteringQuality;
  55687. /**
  55688. * Quality switch for realtime filtering
  55689. */
  55690. get realTimeFilteringQuality(): number;
  55691. set realTimeFilteringQuality(n: number);
  55692. /**
  55693. * Should this material render to several textures at once
  55694. */
  55695. get shouldRenderToMRT(): boolean;
  55696. /**
  55697. * Force normal to face away from face.
  55698. */
  55699. protected _forceNormalForward: boolean;
  55700. /**
  55701. * Enables specular anti aliasing in the PBR shader.
  55702. * It will both interacts on the Geometry for analytical and IBL lighting.
  55703. * It also prefilter the roughness map based on the bump values.
  55704. */
  55705. protected _enableSpecularAntiAliasing: boolean;
  55706. /**
  55707. * Default configuration related to image processing available in the PBR Material.
  55708. */
  55709. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55710. /**
  55711. * Keep track of the image processing observer to allow dispose and replace.
  55712. */
  55713. private _imageProcessingObserver;
  55714. /**
  55715. * Attaches a new image processing configuration to the PBR Material.
  55716. * @param configuration
  55717. */
  55718. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55719. /**
  55720. * Stores the available render targets.
  55721. */
  55722. private _renderTargets;
  55723. /**
  55724. * Sets the global ambient color for the material used in lighting calculations.
  55725. */
  55726. private _globalAmbientColor;
  55727. /**
  55728. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  55729. */
  55730. private _useLogarithmicDepth;
  55731. /**
  55732. * If set to true, no lighting calculations will be applied.
  55733. */
  55734. private _unlit;
  55735. private _debugMode;
  55736. /**
  55737. * @hidden
  55738. * This is reserved for the inspector.
  55739. * Defines the material debug mode.
  55740. * It helps seeing only some components of the material while troubleshooting.
  55741. */
  55742. debugMode: number;
  55743. /**
  55744. * @hidden
  55745. * This is reserved for the inspector.
  55746. * Specify from where on screen the debug mode should start.
  55747. * The value goes from -1 (full screen) to 1 (not visible)
  55748. * It helps with side by side comparison against the final render
  55749. * This defaults to -1
  55750. */
  55751. private debugLimit;
  55752. /**
  55753. * @hidden
  55754. * This is reserved for the inspector.
  55755. * As the default viewing range might not be enough (if the ambient is really small for instance)
  55756. * You can use the factor to better multiply the final value.
  55757. */
  55758. private debugFactor;
  55759. /**
  55760. * Defines the clear coat layer parameters for the material.
  55761. */
  55762. readonly clearCoat: PBRClearCoatConfiguration;
  55763. /**
  55764. * Defines the anisotropic parameters for the material.
  55765. */
  55766. readonly anisotropy: PBRAnisotropicConfiguration;
  55767. /**
  55768. * Defines the BRDF parameters for the material.
  55769. */
  55770. readonly brdf: PBRBRDFConfiguration;
  55771. /**
  55772. * Defines the Sheen parameters for the material.
  55773. */
  55774. readonly sheen: PBRSheenConfiguration;
  55775. /**
  55776. * Defines the SubSurface parameters for the material.
  55777. */
  55778. readonly subSurface: PBRSubSurfaceConfiguration;
  55779. /**
  55780. * Defines the detail map parameters for the material.
  55781. */
  55782. readonly detailMap: DetailMapConfiguration;
  55783. protected _rebuildInParallel: boolean;
  55784. /**
  55785. * Instantiates a new PBRMaterial instance.
  55786. *
  55787. * @param name The material name
  55788. * @param scene The scene the material will be use in.
  55789. */
  55790. constructor(name: string, scene: Scene);
  55791. /**
  55792. * Gets a boolean indicating that current material needs to register RTT
  55793. */
  55794. get hasRenderTargetTextures(): boolean;
  55795. /**
  55796. * Gets the name of the material class.
  55797. */
  55798. getClassName(): string;
  55799. /**
  55800. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55801. */
  55802. get useLogarithmicDepth(): boolean;
  55803. /**
  55804. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  55805. */
  55806. set useLogarithmicDepth(value: boolean);
  55807. /**
  55808. * Returns true if alpha blending should be disabled.
  55809. */
  55810. protected get _disableAlphaBlending(): boolean;
  55811. /**
  55812. * Specifies whether or not this material should be rendered in alpha blend mode.
  55813. */
  55814. needAlphaBlending(): boolean;
  55815. /**
  55816. * Specifies whether or not this material should be rendered in alpha test mode.
  55817. */
  55818. needAlphaTesting(): boolean;
  55819. /**
  55820. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  55821. */
  55822. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  55823. /**
  55824. * Gets the texture used for the alpha test.
  55825. */
  55826. getAlphaTestTexture(): Nullable<BaseTexture>;
  55827. /**
  55828. * Specifies that the submesh is ready to be used.
  55829. * @param mesh - BJS mesh.
  55830. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  55831. * @param useInstances - Specifies that instances should be used.
  55832. * @returns - boolean indicating that the submesh is ready or not.
  55833. */
  55834. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55835. /**
  55836. * Specifies if the material uses metallic roughness workflow.
  55837. * @returns boolean specifiying if the material uses metallic roughness workflow.
  55838. */
  55839. isMetallicWorkflow(): boolean;
  55840. private _prepareEffect;
  55841. private _prepareDefines;
  55842. /**
  55843. * Force shader compilation
  55844. */
  55845. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  55846. /**
  55847. * Initializes the uniform buffer layout for the shader.
  55848. */
  55849. buildUniformLayout(): void;
  55850. /**
  55851. * Unbinds the material from the mesh
  55852. */
  55853. unbind(): void;
  55854. /**
  55855. * Binds the submesh data.
  55856. * @param world - The world matrix.
  55857. * @param mesh - The BJS mesh.
  55858. * @param subMesh - A submesh of the BJS mesh.
  55859. */
  55860. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55861. /**
  55862. * Returns the animatable textures.
  55863. * @returns - Array of animatable textures.
  55864. */
  55865. getAnimatables(): IAnimatable[];
  55866. /**
  55867. * Returns the texture used for reflections.
  55868. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  55869. */
  55870. private _getReflectionTexture;
  55871. /**
  55872. * Returns an array of the actively used textures.
  55873. * @returns - Array of BaseTextures
  55874. */
  55875. getActiveTextures(): BaseTexture[];
  55876. /**
  55877. * Checks to see if a texture is used in the material.
  55878. * @param texture - Base texture to use.
  55879. * @returns - Boolean specifying if a texture is used in the material.
  55880. */
  55881. hasTexture(texture: BaseTexture): boolean;
  55882. /**
  55883. * Disposes the resources of the material.
  55884. * @param forceDisposeEffect - Forces the disposal of effects.
  55885. * @param forceDisposeTextures - Forces the disposal of all textures.
  55886. */
  55887. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55888. }
  55889. }
  55890. declare module BABYLON {
  55891. /**
  55892. * The Physically based material of BJS.
  55893. *
  55894. * This offers the main features of a standard PBR material.
  55895. * For more information, please refer to the documentation :
  55896. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55897. */
  55898. export class PBRMaterial extends PBRBaseMaterial {
  55899. /**
  55900. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55901. */
  55902. static readonly PBRMATERIAL_OPAQUE: number;
  55903. /**
  55904. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55905. */
  55906. static readonly PBRMATERIAL_ALPHATEST: number;
  55907. /**
  55908. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55909. */
  55910. static readonly PBRMATERIAL_ALPHABLEND: number;
  55911. /**
  55912. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55913. * They are also discarded below the alpha cutoff threshold to improve performances.
  55914. */
  55915. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55916. /**
  55917. * Defines the default value of how much AO map is occluding the analytical lights
  55918. * (point spot...).
  55919. */
  55920. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55921. /**
  55922. * Intensity of the direct lights e.g. the four lights available in your scene.
  55923. * This impacts both the direct diffuse and specular highlights.
  55924. */
  55925. directIntensity: number;
  55926. /**
  55927. * Intensity of the emissive part of the material.
  55928. * This helps controlling the emissive effect without modifying the emissive color.
  55929. */
  55930. emissiveIntensity: number;
  55931. /**
  55932. * Intensity of the environment e.g. how much the environment will light the object
  55933. * either through harmonics for rough material or through the refelction for shiny ones.
  55934. */
  55935. environmentIntensity: number;
  55936. /**
  55937. * This is a special control allowing the reduction of the specular highlights coming from the
  55938. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55939. */
  55940. specularIntensity: number;
  55941. /**
  55942. * Debug Control allowing disabling the bump map on this material.
  55943. */
  55944. disableBumpMap: boolean;
  55945. /**
  55946. * AKA Diffuse Texture in standard nomenclature.
  55947. */
  55948. albedoTexture: BaseTexture;
  55949. /**
  55950. * AKA Occlusion Texture in other nomenclature.
  55951. */
  55952. ambientTexture: BaseTexture;
  55953. /**
  55954. * AKA Occlusion Texture Intensity in other nomenclature.
  55955. */
  55956. ambientTextureStrength: number;
  55957. /**
  55958. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55959. * 1 means it completely occludes it
  55960. * 0 mean it has no impact
  55961. */
  55962. ambientTextureImpactOnAnalyticalLights: number;
  55963. /**
  55964. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  55965. */
  55966. opacityTexture: BaseTexture;
  55967. /**
  55968. * Stores the reflection values in a texture.
  55969. */
  55970. reflectionTexture: Nullable<BaseTexture>;
  55971. /**
  55972. * Stores the emissive values in a texture.
  55973. */
  55974. emissiveTexture: BaseTexture;
  55975. /**
  55976. * AKA Specular texture in other nomenclature.
  55977. */
  55978. reflectivityTexture: BaseTexture;
  55979. /**
  55980. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55981. */
  55982. metallicTexture: BaseTexture;
  55983. /**
  55984. * Specifies the metallic scalar of the metallic/roughness workflow.
  55985. * Can also be used to scale the metalness values of the metallic texture.
  55986. */
  55987. metallic: Nullable<number>;
  55988. /**
  55989. * Specifies the roughness scalar of the metallic/roughness workflow.
  55990. * Can also be used to scale the roughness values of the metallic texture.
  55991. */
  55992. roughness: Nullable<number>;
  55993. /**
  55994. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55995. * By default the indexOfrefraction is used to compute F0;
  55996. *
  55997. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55998. *
  55999. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56000. * F90 = metallicReflectanceColor;
  56001. */
  56002. metallicF0Factor: number;
  56003. /**
  56004. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56005. * By default the F90 is always 1;
  56006. *
  56007. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56008. *
  56009. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56010. * F90 = metallicReflectanceColor;
  56011. */
  56012. metallicReflectanceColor: Color3;
  56013. /**
  56014. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56015. * This is multiply against the scalar values defined in the material.
  56016. */
  56017. metallicReflectanceTexture: Nullable<BaseTexture>;
  56018. /**
  56019. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56020. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56021. */
  56022. microSurfaceTexture: BaseTexture;
  56023. /**
  56024. * Stores surface normal data used to displace a mesh in a texture.
  56025. */
  56026. bumpTexture: BaseTexture;
  56027. /**
  56028. * Stores the pre-calculated light information of a mesh in a texture.
  56029. */
  56030. lightmapTexture: BaseTexture;
  56031. /**
  56032. * Stores the refracted light information in a texture.
  56033. */
  56034. get refractionTexture(): Nullable<BaseTexture>;
  56035. set refractionTexture(value: Nullable<BaseTexture>);
  56036. /**
  56037. * The color of a material in ambient lighting.
  56038. */
  56039. ambientColor: Color3;
  56040. /**
  56041. * AKA Diffuse Color in other nomenclature.
  56042. */
  56043. albedoColor: Color3;
  56044. /**
  56045. * AKA Specular Color in other nomenclature.
  56046. */
  56047. reflectivityColor: Color3;
  56048. /**
  56049. * The color reflected from the material.
  56050. */
  56051. reflectionColor: Color3;
  56052. /**
  56053. * The color emitted from the material.
  56054. */
  56055. emissiveColor: Color3;
  56056. /**
  56057. * AKA Glossiness in other nomenclature.
  56058. */
  56059. microSurface: number;
  56060. /**
  56061. * Index of refraction of the material base layer.
  56062. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56063. *
  56064. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56065. *
  56066. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56067. */
  56068. get indexOfRefraction(): number;
  56069. set indexOfRefraction(value: number);
  56070. /**
  56071. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56072. */
  56073. get invertRefractionY(): boolean;
  56074. set invertRefractionY(value: boolean);
  56075. /**
  56076. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56077. * Materials half opaque for instance using refraction could benefit from this control.
  56078. */
  56079. get linkRefractionWithTransparency(): boolean;
  56080. set linkRefractionWithTransparency(value: boolean);
  56081. /**
  56082. * If true, the light map contains occlusion information instead of lighting info.
  56083. */
  56084. useLightmapAsShadowmap: boolean;
  56085. /**
  56086. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56087. */
  56088. useAlphaFromAlbedoTexture: boolean;
  56089. /**
  56090. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56091. */
  56092. forceAlphaTest: boolean;
  56093. /**
  56094. * Defines the alpha limits in alpha test mode.
  56095. */
  56096. alphaCutOff: number;
  56097. /**
  56098. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56099. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56100. */
  56101. useSpecularOverAlpha: boolean;
  56102. /**
  56103. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56104. */
  56105. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56106. /**
  56107. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56108. */
  56109. useRoughnessFromMetallicTextureAlpha: boolean;
  56110. /**
  56111. * Specifies if the metallic texture contains the roughness information in its green channel.
  56112. */
  56113. useRoughnessFromMetallicTextureGreen: boolean;
  56114. /**
  56115. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56116. */
  56117. useMetallnessFromMetallicTextureBlue: boolean;
  56118. /**
  56119. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56120. */
  56121. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56122. /**
  56123. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56124. */
  56125. useAmbientInGrayScale: boolean;
  56126. /**
  56127. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56128. * The material will try to infer what glossiness each pixel should be.
  56129. */
  56130. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56131. /**
  56132. * BJS is using an harcoded light falloff based on a manually sets up range.
  56133. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56134. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56135. */
  56136. get usePhysicalLightFalloff(): boolean;
  56137. /**
  56138. * BJS is using an harcoded light falloff based on a manually sets up range.
  56139. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56140. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56141. */
  56142. set usePhysicalLightFalloff(value: boolean);
  56143. /**
  56144. * In order to support the falloff compatibility with gltf, a special mode has been added
  56145. * to reproduce the gltf light falloff.
  56146. */
  56147. get useGLTFLightFalloff(): boolean;
  56148. /**
  56149. * In order to support the falloff compatibility with gltf, a special mode has been added
  56150. * to reproduce the gltf light falloff.
  56151. */
  56152. set useGLTFLightFalloff(value: boolean);
  56153. /**
  56154. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56155. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56156. */
  56157. useRadianceOverAlpha: boolean;
  56158. /**
  56159. * Allows using an object space normal map (instead of tangent space).
  56160. */
  56161. useObjectSpaceNormalMap: boolean;
  56162. /**
  56163. * Allows using the bump map in parallax mode.
  56164. */
  56165. useParallax: boolean;
  56166. /**
  56167. * Allows using the bump map in parallax occlusion mode.
  56168. */
  56169. useParallaxOcclusion: boolean;
  56170. /**
  56171. * Controls the scale bias of the parallax mode.
  56172. */
  56173. parallaxScaleBias: number;
  56174. /**
  56175. * If sets to true, disables all the lights affecting the material.
  56176. */
  56177. disableLighting: boolean;
  56178. /**
  56179. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56180. */
  56181. forceIrradianceInFragment: boolean;
  56182. /**
  56183. * Number of Simultaneous lights allowed on the material.
  56184. */
  56185. maxSimultaneousLights: number;
  56186. /**
  56187. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56188. */
  56189. invertNormalMapX: boolean;
  56190. /**
  56191. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56192. */
  56193. invertNormalMapY: boolean;
  56194. /**
  56195. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56196. */
  56197. twoSidedLighting: boolean;
  56198. /**
  56199. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56200. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56201. */
  56202. useAlphaFresnel: boolean;
  56203. /**
  56204. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56205. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56206. */
  56207. useLinearAlphaFresnel: boolean;
  56208. /**
  56209. * Let user defines the brdf lookup texture used for IBL.
  56210. * A default 8bit version is embedded but you could point at :
  56211. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56212. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56213. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56214. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56215. */
  56216. environmentBRDFTexture: Nullable<BaseTexture>;
  56217. /**
  56218. * Force normal to face away from face.
  56219. */
  56220. forceNormalForward: boolean;
  56221. /**
  56222. * Enables specular anti aliasing in the PBR shader.
  56223. * It will both interacts on the Geometry for analytical and IBL lighting.
  56224. * It also prefilter the roughness map based on the bump values.
  56225. */
  56226. enableSpecularAntiAliasing: boolean;
  56227. /**
  56228. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56229. * makes the reflect vector face the model (under horizon).
  56230. */
  56231. useHorizonOcclusion: boolean;
  56232. /**
  56233. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56234. * too much the area relying on ambient texture to define their ambient occlusion.
  56235. */
  56236. useRadianceOcclusion: boolean;
  56237. /**
  56238. * If set to true, no lighting calculations will be applied.
  56239. */
  56240. unlit: boolean;
  56241. /**
  56242. * Gets the image processing configuration used either in this material.
  56243. */
  56244. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56245. /**
  56246. * Sets the Default image processing configuration used either in the this material.
  56247. *
  56248. * If sets to null, the scene one is in use.
  56249. */
  56250. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56251. /**
  56252. * Gets wether the color curves effect is enabled.
  56253. */
  56254. get cameraColorCurvesEnabled(): boolean;
  56255. /**
  56256. * Sets wether the color curves effect is enabled.
  56257. */
  56258. set cameraColorCurvesEnabled(value: boolean);
  56259. /**
  56260. * Gets wether the color grading effect is enabled.
  56261. */
  56262. get cameraColorGradingEnabled(): boolean;
  56263. /**
  56264. * Gets wether the color grading effect is enabled.
  56265. */
  56266. set cameraColorGradingEnabled(value: boolean);
  56267. /**
  56268. * Gets wether tonemapping is enabled or not.
  56269. */
  56270. get cameraToneMappingEnabled(): boolean;
  56271. /**
  56272. * Sets wether tonemapping is enabled or not
  56273. */
  56274. set cameraToneMappingEnabled(value: boolean);
  56275. /**
  56276. * The camera exposure used on this material.
  56277. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56278. * This corresponds to a photographic exposure.
  56279. */
  56280. get cameraExposure(): number;
  56281. /**
  56282. * The camera exposure used on this material.
  56283. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56284. * This corresponds to a photographic exposure.
  56285. */
  56286. set cameraExposure(value: number);
  56287. /**
  56288. * Gets The camera contrast used on this material.
  56289. */
  56290. get cameraContrast(): number;
  56291. /**
  56292. * Sets The camera contrast used on this material.
  56293. */
  56294. set cameraContrast(value: number);
  56295. /**
  56296. * Gets the Color Grading 2D Lookup Texture.
  56297. */
  56298. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56299. /**
  56300. * Sets the Color Grading 2D Lookup Texture.
  56301. */
  56302. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56303. /**
  56304. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56305. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56306. * 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;
  56307. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56308. */
  56309. get cameraColorCurves(): Nullable<ColorCurves>;
  56310. /**
  56311. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56312. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56313. * 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;
  56314. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56315. */
  56316. set cameraColorCurves(value: Nullable<ColorCurves>);
  56317. /**
  56318. * Instantiates a new PBRMaterial instance.
  56319. *
  56320. * @param name The material name
  56321. * @param scene The scene the material will be use in.
  56322. */
  56323. constructor(name: string, scene: Scene);
  56324. /**
  56325. * Returns the name of this material class.
  56326. */
  56327. getClassName(): string;
  56328. /**
  56329. * Makes a duplicate of the current material.
  56330. * @param name - name to use for the new material.
  56331. */
  56332. clone(name: string): PBRMaterial;
  56333. /**
  56334. * Serializes this PBR Material.
  56335. * @returns - An object with the serialized material.
  56336. */
  56337. serialize(): any;
  56338. /**
  56339. * Parses a PBR Material from a serialized object.
  56340. * @param source - Serialized object.
  56341. * @param scene - BJS scene instance.
  56342. * @param rootUrl - url for the scene object
  56343. * @returns - PBRMaterial
  56344. */
  56345. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56346. }
  56347. }
  56348. declare module BABYLON {
  56349. /**
  56350. * Direct draw surface info
  56351. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56352. */
  56353. export interface DDSInfo {
  56354. /**
  56355. * Width of the texture
  56356. */
  56357. width: number;
  56358. /**
  56359. * Width of the texture
  56360. */
  56361. height: number;
  56362. /**
  56363. * Number of Mipmaps for the texture
  56364. * @see https://en.wikipedia.org/wiki/Mipmap
  56365. */
  56366. mipmapCount: number;
  56367. /**
  56368. * If the textures format is a known fourCC format
  56369. * @see https://www.fourcc.org/
  56370. */
  56371. isFourCC: boolean;
  56372. /**
  56373. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56374. */
  56375. isRGB: boolean;
  56376. /**
  56377. * If the texture is a lumincance format
  56378. */
  56379. isLuminance: boolean;
  56380. /**
  56381. * If this is a cube texture
  56382. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56383. */
  56384. isCube: boolean;
  56385. /**
  56386. * If the texture is a compressed format eg. FOURCC_DXT1
  56387. */
  56388. isCompressed: boolean;
  56389. /**
  56390. * The dxgiFormat of the texture
  56391. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56392. */
  56393. dxgiFormat: number;
  56394. /**
  56395. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56396. */
  56397. textureType: number;
  56398. /**
  56399. * Sphericle polynomial created for the dds texture
  56400. */
  56401. sphericalPolynomial?: SphericalPolynomial;
  56402. }
  56403. /**
  56404. * Class used to provide DDS decompression tools
  56405. */
  56406. export class DDSTools {
  56407. /**
  56408. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56409. */
  56410. static StoreLODInAlphaChannel: boolean;
  56411. /**
  56412. * Gets DDS information from an array buffer
  56413. * @param data defines the array buffer view to read data from
  56414. * @returns the DDS information
  56415. */
  56416. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56417. private static _FloatView;
  56418. private static _Int32View;
  56419. private static _ToHalfFloat;
  56420. private static _FromHalfFloat;
  56421. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56422. private static _GetHalfFloatRGBAArrayBuffer;
  56423. private static _GetFloatRGBAArrayBuffer;
  56424. private static _GetFloatAsUIntRGBAArrayBuffer;
  56425. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56426. private static _GetRGBAArrayBuffer;
  56427. private static _ExtractLongWordOrder;
  56428. private static _GetRGBArrayBuffer;
  56429. private static _GetLuminanceArrayBuffer;
  56430. /**
  56431. * Uploads DDS Levels to a Babylon Texture
  56432. * @hidden
  56433. */
  56434. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56435. }
  56436. interface ThinEngine {
  56437. /**
  56438. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56439. * @param rootUrl defines the url where the file to load is located
  56440. * @param scene defines the current scene
  56441. * @param lodScale defines scale to apply to the mip map selection
  56442. * @param lodOffset defines offset to apply to the mip map selection
  56443. * @param onLoad defines an optional callback raised when the texture is loaded
  56444. * @param onError defines an optional callback raised if there is an issue to load the texture
  56445. * @param format defines the format of the data
  56446. * @param forcedExtension defines the extension to use to pick the right loader
  56447. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56448. * @returns the cube texture as an InternalTexture
  56449. */
  56450. 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;
  56451. }
  56452. }
  56453. declare module BABYLON {
  56454. /**
  56455. * Implementation of the DDS Texture Loader.
  56456. * @hidden
  56457. */
  56458. export class _DDSTextureLoader implements IInternalTextureLoader {
  56459. /**
  56460. * Defines wether the loader supports cascade loading the different faces.
  56461. */
  56462. readonly supportCascades: boolean;
  56463. /**
  56464. * This returns if the loader support the current file information.
  56465. * @param extension defines the file extension of the file being loaded
  56466. * @returns true if the loader can load the specified file
  56467. */
  56468. canLoad(extension: string): boolean;
  56469. /**
  56470. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56471. * @param data contains the texture data
  56472. * @param texture defines the BabylonJS internal texture
  56473. * @param createPolynomials will be true if polynomials have been requested
  56474. * @param onLoad defines the callback to trigger once the texture is ready
  56475. * @param onError defines the callback to trigger in case of error
  56476. */
  56477. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56478. /**
  56479. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56480. * @param data contains the texture data
  56481. * @param texture defines the BabylonJS internal texture
  56482. * @param callback defines the method to call once ready to upload
  56483. */
  56484. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56485. }
  56486. }
  56487. declare module BABYLON {
  56488. /**
  56489. * Implementation of the ENV Texture Loader.
  56490. * @hidden
  56491. */
  56492. export class _ENVTextureLoader implements IInternalTextureLoader {
  56493. /**
  56494. * Defines wether the loader supports cascade loading the different faces.
  56495. */
  56496. readonly supportCascades: boolean;
  56497. /**
  56498. * This returns if the loader support the current file information.
  56499. * @param extension defines the file extension of the file being loaded
  56500. * @returns true if the loader can load the specified file
  56501. */
  56502. canLoad(extension: string): boolean;
  56503. /**
  56504. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56505. * @param data contains the texture data
  56506. * @param texture defines the BabylonJS internal texture
  56507. * @param createPolynomials will be true if polynomials have been requested
  56508. * @param onLoad defines the callback to trigger once the texture is ready
  56509. * @param onError defines the callback to trigger in case of error
  56510. */
  56511. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56512. /**
  56513. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56514. * @param data contains the texture data
  56515. * @param texture defines the BabylonJS internal texture
  56516. * @param callback defines the method to call once ready to upload
  56517. */
  56518. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56519. }
  56520. }
  56521. declare module BABYLON {
  56522. /**
  56523. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56524. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56525. */
  56526. export class KhronosTextureContainer {
  56527. /** contents of the KTX container file */
  56528. data: ArrayBufferView;
  56529. private static HEADER_LEN;
  56530. private static COMPRESSED_2D;
  56531. private static COMPRESSED_3D;
  56532. private static TEX_2D;
  56533. private static TEX_3D;
  56534. /**
  56535. * Gets the openGL type
  56536. */
  56537. glType: number;
  56538. /**
  56539. * Gets the openGL type size
  56540. */
  56541. glTypeSize: number;
  56542. /**
  56543. * Gets the openGL format
  56544. */
  56545. glFormat: number;
  56546. /**
  56547. * Gets the openGL internal format
  56548. */
  56549. glInternalFormat: number;
  56550. /**
  56551. * Gets the base internal format
  56552. */
  56553. glBaseInternalFormat: number;
  56554. /**
  56555. * Gets image width in pixel
  56556. */
  56557. pixelWidth: number;
  56558. /**
  56559. * Gets image height in pixel
  56560. */
  56561. pixelHeight: number;
  56562. /**
  56563. * Gets image depth in pixels
  56564. */
  56565. pixelDepth: number;
  56566. /**
  56567. * Gets the number of array elements
  56568. */
  56569. numberOfArrayElements: number;
  56570. /**
  56571. * Gets the number of faces
  56572. */
  56573. numberOfFaces: number;
  56574. /**
  56575. * Gets the number of mipmap levels
  56576. */
  56577. numberOfMipmapLevels: number;
  56578. /**
  56579. * Gets the bytes of key value data
  56580. */
  56581. bytesOfKeyValueData: number;
  56582. /**
  56583. * Gets the load type
  56584. */
  56585. loadType: number;
  56586. /**
  56587. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  56588. */
  56589. isInvalid: boolean;
  56590. /**
  56591. * Creates a new KhronosTextureContainer
  56592. * @param data contents of the KTX container file
  56593. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  56594. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  56595. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  56596. */
  56597. constructor(
  56598. /** contents of the KTX container file */
  56599. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  56600. /**
  56601. * Uploads KTX content to a Babylon Texture.
  56602. * It is assumed that the texture has already been created & is currently bound
  56603. * @hidden
  56604. */
  56605. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  56606. private _upload2DCompressedLevels;
  56607. /**
  56608. * Checks if the given data starts with a KTX file identifier.
  56609. * @param data the data to check
  56610. * @returns true if the data is a KTX file or false otherwise
  56611. */
  56612. static IsValid(data: ArrayBufferView): boolean;
  56613. }
  56614. }
  56615. declare module BABYLON {
  56616. /**
  56617. * Class for loading KTX2 files
  56618. * !!! Experimental Extension Subject to Changes !!!
  56619. * @hidden
  56620. */
  56621. export class KhronosTextureContainer2 {
  56622. private static _ModulePromise;
  56623. private static _TranscodeFormat;
  56624. constructor(engine: ThinEngine);
  56625. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  56626. private _determineTranscodeFormat;
  56627. /**
  56628. * Checks if the given data starts with a KTX2 file identifier.
  56629. * @param data the data to check
  56630. * @returns true if the data is a KTX2 file or false otherwise
  56631. */
  56632. static IsValid(data: ArrayBufferView): boolean;
  56633. }
  56634. }
  56635. declare module BABYLON {
  56636. /**
  56637. * Implementation of the KTX Texture Loader.
  56638. * @hidden
  56639. */
  56640. export class _KTXTextureLoader implements IInternalTextureLoader {
  56641. /**
  56642. * Defines wether the loader supports cascade loading the different faces.
  56643. */
  56644. readonly supportCascades: boolean;
  56645. /**
  56646. * This returns if the loader support the current file information.
  56647. * @param extension defines the file extension of the file being loaded
  56648. * @param mimeType defines the optional mime type of the file being loaded
  56649. * @returns true if the loader can load the specified file
  56650. */
  56651. canLoad(extension: string, mimeType?: string): boolean;
  56652. /**
  56653. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56654. * @param data contains the texture data
  56655. * @param texture defines the BabylonJS internal texture
  56656. * @param createPolynomials will be true if polynomials have been requested
  56657. * @param onLoad defines the callback to trigger once the texture is ready
  56658. * @param onError defines the callback to trigger in case of error
  56659. */
  56660. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56661. /**
  56662. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56663. * @param data contains the texture data
  56664. * @param texture defines the BabylonJS internal texture
  56665. * @param callback defines the method to call once ready to upload
  56666. */
  56667. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  56668. }
  56669. }
  56670. declare module BABYLON {
  56671. /** @hidden */
  56672. export var _forceSceneHelpersToBundle: boolean;
  56673. interface Scene {
  56674. /**
  56675. * Creates a default light for the scene.
  56676. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  56677. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  56678. */
  56679. createDefaultLight(replace?: boolean): void;
  56680. /**
  56681. * Creates a default camera for the scene.
  56682. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  56683. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56684. * @param replace has default false, when true replaces the active camera in the scene
  56685. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  56686. */
  56687. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56688. /**
  56689. * Creates a default camera and a default light.
  56690. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  56691. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  56692. * @param replace has the default false, when true replaces the active camera/light in the scene
  56693. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  56694. */
  56695. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  56696. /**
  56697. * Creates a new sky box
  56698. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  56699. * @param environmentTexture defines the texture to use as environment texture
  56700. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  56701. * @param scale defines the overall scale of the skybox
  56702. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  56703. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  56704. * @returns a new mesh holding the sky box
  56705. */
  56706. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  56707. /**
  56708. * Creates a new environment
  56709. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  56710. * @param options defines the options you can use to configure the environment
  56711. * @returns the new EnvironmentHelper
  56712. */
  56713. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  56714. /**
  56715. * Creates a new VREXperienceHelper
  56716. * @see https://doc.babylonjs.com/how_to/webvr_helper
  56717. * @param webVROptions defines the options used to create the new VREXperienceHelper
  56718. * @returns a new VREXperienceHelper
  56719. */
  56720. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  56721. /**
  56722. * Creates a new WebXRDefaultExperience
  56723. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  56724. * @param options experience options
  56725. * @returns a promise for a new WebXRDefaultExperience
  56726. */
  56727. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56728. }
  56729. }
  56730. declare module BABYLON {
  56731. /**
  56732. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  56733. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  56734. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  56735. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56736. */
  56737. export class VideoDome extends TransformNode {
  56738. /**
  56739. * Define the video source as a Monoscopic panoramic 360 video.
  56740. */
  56741. static readonly MODE_MONOSCOPIC: number;
  56742. /**
  56743. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56744. */
  56745. static readonly MODE_TOPBOTTOM: number;
  56746. /**
  56747. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56748. */
  56749. static readonly MODE_SIDEBYSIDE: number;
  56750. private _halfDome;
  56751. private _useDirectMapping;
  56752. /**
  56753. * The video texture being displayed on the sphere
  56754. */
  56755. protected _videoTexture: VideoTexture;
  56756. /**
  56757. * Gets the video texture being displayed on the sphere
  56758. */
  56759. get videoTexture(): VideoTexture;
  56760. /**
  56761. * The skybox material
  56762. */
  56763. protected _material: BackgroundMaterial;
  56764. /**
  56765. * The surface used for the video dome
  56766. */
  56767. protected _mesh: Mesh;
  56768. /**
  56769. * Gets the mesh used for the video dome.
  56770. */
  56771. get mesh(): Mesh;
  56772. /**
  56773. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  56774. */
  56775. private _halfDomeMask;
  56776. /**
  56777. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56778. * Also see the options.resolution property.
  56779. */
  56780. get fovMultiplier(): number;
  56781. set fovMultiplier(value: number);
  56782. private _videoMode;
  56783. /**
  56784. * Gets or set the current video mode for the video. It can be:
  56785. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  56786. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  56787. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  56788. */
  56789. get videoMode(): number;
  56790. set videoMode(value: number);
  56791. /**
  56792. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  56793. *
  56794. */
  56795. get halfDome(): boolean;
  56796. /**
  56797. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  56798. */
  56799. set halfDome(enabled: boolean);
  56800. /**
  56801. * Oberserver used in Stereoscopic VR Mode.
  56802. */
  56803. private _onBeforeCameraRenderObserver;
  56804. /**
  56805. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  56806. * @param name Element's name, child elements will append suffixes for their own names.
  56807. * @param urlsOrVideo defines the url(s) or the video element to use
  56808. * @param options An object containing optional or exposed sub element properties
  56809. */
  56810. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  56811. resolution?: number;
  56812. clickToPlay?: boolean;
  56813. autoPlay?: boolean;
  56814. loop?: boolean;
  56815. size?: number;
  56816. poster?: string;
  56817. faceForward?: boolean;
  56818. useDirectMapping?: boolean;
  56819. halfDomeMode?: boolean;
  56820. }, scene: Scene);
  56821. private _changeVideoMode;
  56822. /**
  56823. * Releases resources associated with this node.
  56824. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56825. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56826. */
  56827. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56828. }
  56829. }
  56830. declare module BABYLON {
  56831. /**
  56832. * This class can be used to get instrumentation data from a Babylon engine
  56833. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56834. */
  56835. export class EngineInstrumentation implements IDisposable {
  56836. /**
  56837. * Define the instrumented engine.
  56838. */
  56839. engine: Engine;
  56840. private _captureGPUFrameTime;
  56841. private _gpuFrameTimeToken;
  56842. private _gpuFrameTime;
  56843. private _captureShaderCompilationTime;
  56844. private _shaderCompilationTime;
  56845. private _onBeginFrameObserver;
  56846. private _onEndFrameObserver;
  56847. private _onBeforeShaderCompilationObserver;
  56848. private _onAfterShaderCompilationObserver;
  56849. /**
  56850. * Gets the perf counter used for GPU frame time
  56851. */
  56852. get gpuFrameTimeCounter(): PerfCounter;
  56853. /**
  56854. * Gets the GPU frame time capture status
  56855. */
  56856. get captureGPUFrameTime(): boolean;
  56857. /**
  56858. * Enable or disable the GPU frame time capture
  56859. */
  56860. set captureGPUFrameTime(value: boolean);
  56861. /**
  56862. * Gets the perf counter used for shader compilation time
  56863. */
  56864. get shaderCompilationTimeCounter(): PerfCounter;
  56865. /**
  56866. * Gets the shader compilation time capture status
  56867. */
  56868. get captureShaderCompilationTime(): boolean;
  56869. /**
  56870. * Enable or disable the shader compilation time capture
  56871. */
  56872. set captureShaderCompilationTime(value: boolean);
  56873. /**
  56874. * Instantiates a new engine instrumentation.
  56875. * This class can be used to get instrumentation data from a Babylon engine
  56876. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  56877. * @param engine Defines the engine to instrument
  56878. */
  56879. constructor(
  56880. /**
  56881. * Define the instrumented engine.
  56882. */
  56883. engine: Engine);
  56884. /**
  56885. * Dispose and release associated resources.
  56886. */
  56887. dispose(): void;
  56888. }
  56889. }
  56890. declare module BABYLON {
  56891. /**
  56892. * This class can be used to get instrumentation data from a Babylon engine
  56893. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  56894. */
  56895. export class SceneInstrumentation implements IDisposable {
  56896. /**
  56897. * Defines the scene to instrument
  56898. */
  56899. scene: Scene;
  56900. private _captureActiveMeshesEvaluationTime;
  56901. private _activeMeshesEvaluationTime;
  56902. private _captureRenderTargetsRenderTime;
  56903. private _renderTargetsRenderTime;
  56904. private _captureFrameTime;
  56905. private _frameTime;
  56906. private _captureRenderTime;
  56907. private _renderTime;
  56908. private _captureInterFrameTime;
  56909. private _interFrameTime;
  56910. private _captureParticlesRenderTime;
  56911. private _particlesRenderTime;
  56912. private _captureSpritesRenderTime;
  56913. private _spritesRenderTime;
  56914. private _capturePhysicsTime;
  56915. private _physicsTime;
  56916. private _captureAnimationsTime;
  56917. private _animationsTime;
  56918. private _captureCameraRenderTime;
  56919. private _cameraRenderTime;
  56920. private _onBeforeActiveMeshesEvaluationObserver;
  56921. private _onAfterActiveMeshesEvaluationObserver;
  56922. private _onBeforeRenderTargetsRenderObserver;
  56923. private _onAfterRenderTargetsRenderObserver;
  56924. private _onAfterRenderObserver;
  56925. private _onBeforeDrawPhaseObserver;
  56926. private _onAfterDrawPhaseObserver;
  56927. private _onBeforeAnimationsObserver;
  56928. private _onBeforeParticlesRenderingObserver;
  56929. private _onAfterParticlesRenderingObserver;
  56930. private _onBeforeSpritesRenderingObserver;
  56931. private _onAfterSpritesRenderingObserver;
  56932. private _onBeforePhysicsObserver;
  56933. private _onAfterPhysicsObserver;
  56934. private _onAfterAnimationsObserver;
  56935. private _onBeforeCameraRenderObserver;
  56936. private _onAfterCameraRenderObserver;
  56937. /**
  56938. * Gets the perf counter used for active meshes evaluation time
  56939. */
  56940. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  56941. /**
  56942. * Gets the active meshes evaluation time capture status
  56943. */
  56944. get captureActiveMeshesEvaluationTime(): boolean;
  56945. /**
  56946. * Enable or disable the active meshes evaluation time capture
  56947. */
  56948. set captureActiveMeshesEvaluationTime(value: boolean);
  56949. /**
  56950. * Gets the perf counter used for render targets render time
  56951. */
  56952. get renderTargetsRenderTimeCounter(): PerfCounter;
  56953. /**
  56954. * Gets the render targets render time capture status
  56955. */
  56956. get captureRenderTargetsRenderTime(): boolean;
  56957. /**
  56958. * Enable or disable the render targets render time capture
  56959. */
  56960. set captureRenderTargetsRenderTime(value: boolean);
  56961. /**
  56962. * Gets the perf counter used for particles render time
  56963. */
  56964. get particlesRenderTimeCounter(): PerfCounter;
  56965. /**
  56966. * Gets the particles render time capture status
  56967. */
  56968. get captureParticlesRenderTime(): boolean;
  56969. /**
  56970. * Enable or disable the particles render time capture
  56971. */
  56972. set captureParticlesRenderTime(value: boolean);
  56973. /**
  56974. * Gets the perf counter used for sprites render time
  56975. */
  56976. get spritesRenderTimeCounter(): PerfCounter;
  56977. /**
  56978. * Gets the sprites render time capture status
  56979. */
  56980. get captureSpritesRenderTime(): boolean;
  56981. /**
  56982. * Enable or disable the sprites render time capture
  56983. */
  56984. set captureSpritesRenderTime(value: boolean);
  56985. /**
  56986. * Gets the perf counter used for physics time
  56987. */
  56988. get physicsTimeCounter(): PerfCounter;
  56989. /**
  56990. * Gets the physics time capture status
  56991. */
  56992. get capturePhysicsTime(): boolean;
  56993. /**
  56994. * Enable or disable the physics time capture
  56995. */
  56996. set capturePhysicsTime(value: boolean);
  56997. /**
  56998. * Gets the perf counter used for animations time
  56999. */
  57000. get animationsTimeCounter(): PerfCounter;
  57001. /**
  57002. * Gets the animations time capture status
  57003. */
  57004. get captureAnimationsTime(): boolean;
  57005. /**
  57006. * Enable or disable the animations time capture
  57007. */
  57008. set captureAnimationsTime(value: boolean);
  57009. /**
  57010. * Gets the perf counter used for frame time capture
  57011. */
  57012. get frameTimeCounter(): PerfCounter;
  57013. /**
  57014. * Gets the frame time capture status
  57015. */
  57016. get captureFrameTime(): boolean;
  57017. /**
  57018. * Enable or disable the frame time capture
  57019. */
  57020. set captureFrameTime(value: boolean);
  57021. /**
  57022. * Gets the perf counter used for inter-frames time capture
  57023. */
  57024. get interFrameTimeCounter(): PerfCounter;
  57025. /**
  57026. * Gets the inter-frames time capture status
  57027. */
  57028. get captureInterFrameTime(): boolean;
  57029. /**
  57030. * Enable or disable the inter-frames time capture
  57031. */
  57032. set captureInterFrameTime(value: boolean);
  57033. /**
  57034. * Gets the perf counter used for render time capture
  57035. */
  57036. get renderTimeCounter(): PerfCounter;
  57037. /**
  57038. * Gets the render time capture status
  57039. */
  57040. get captureRenderTime(): boolean;
  57041. /**
  57042. * Enable or disable the render time capture
  57043. */
  57044. set captureRenderTime(value: boolean);
  57045. /**
  57046. * Gets the perf counter used for camera render time capture
  57047. */
  57048. get cameraRenderTimeCounter(): PerfCounter;
  57049. /**
  57050. * Gets the camera render time capture status
  57051. */
  57052. get captureCameraRenderTime(): boolean;
  57053. /**
  57054. * Enable or disable the camera render time capture
  57055. */
  57056. set captureCameraRenderTime(value: boolean);
  57057. /**
  57058. * Gets the perf counter used for draw calls
  57059. */
  57060. get drawCallsCounter(): PerfCounter;
  57061. /**
  57062. * Instantiates a new scene instrumentation.
  57063. * This class can be used to get instrumentation data from a Babylon engine
  57064. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57065. * @param scene Defines the scene to instrument
  57066. */
  57067. constructor(
  57068. /**
  57069. * Defines the scene to instrument
  57070. */
  57071. scene: Scene);
  57072. /**
  57073. * Dispose and release associated resources.
  57074. */
  57075. dispose(): void;
  57076. }
  57077. }
  57078. declare module BABYLON {
  57079. /** @hidden */
  57080. export var glowMapGenerationPixelShader: {
  57081. name: string;
  57082. shader: string;
  57083. };
  57084. }
  57085. declare module BABYLON {
  57086. /** @hidden */
  57087. export var glowMapGenerationVertexShader: {
  57088. name: string;
  57089. shader: string;
  57090. };
  57091. }
  57092. declare module BABYLON {
  57093. /**
  57094. * Effect layer options. This helps customizing the behaviour
  57095. * of the effect layer.
  57096. */
  57097. export interface IEffectLayerOptions {
  57098. /**
  57099. * Multiplication factor apply to the canvas size to compute the render target size
  57100. * used to generated the objects (the smaller the faster).
  57101. */
  57102. mainTextureRatio: number;
  57103. /**
  57104. * Enforces a fixed size texture to ensure effect stability across devices.
  57105. */
  57106. mainTextureFixedSize?: number;
  57107. /**
  57108. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57109. */
  57110. alphaBlendingMode: number;
  57111. /**
  57112. * The camera attached to the layer.
  57113. */
  57114. camera: Nullable<Camera>;
  57115. /**
  57116. * The rendering group to draw the layer in.
  57117. */
  57118. renderingGroupId: number;
  57119. }
  57120. /**
  57121. * The effect layer Helps adding post process effect blended with the main pass.
  57122. *
  57123. * This can be for instance use to generate glow or higlight effects on the scene.
  57124. *
  57125. * The effect layer class can not be used directly and is intented to inherited from to be
  57126. * customized per effects.
  57127. */
  57128. export abstract class EffectLayer {
  57129. private _vertexBuffers;
  57130. private _indexBuffer;
  57131. private _cachedDefines;
  57132. private _effectLayerMapGenerationEffect;
  57133. private _effectLayerOptions;
  57134. private _mergeEffect;
  57135. protected _scene: Scene;
  57136. protected _engine: Engine;
  57137. protected _maxSize: number;
  57138. protected _mainTextureDesiredSize: ISize;
  57139. protected _mainTexture: RenderTargetTexture;
  57140. protected _shouldRender: boolean;
  57141. protected _postProcesses: PostProcess[];
  57142. protected _textures: BaseTexture[];
  57143. protected _emissiveTextureAndColor: {
  57144. texture: Nullable<BaseTexture>;
  57145. color: Color4;
  57146. };
  57147. /**
  57148. * The name of the layer
  57149. */
  57150. name: string;
  57151. /**
  57152. * The clear color of the texture used to generate the glow map.
  57153. */
  57154. neutralColor: Color4;
  57155. /**
  57156. * Specifies whether the highlight layer is enabled or not.
  57157. */
  57158. isEnabled: boolean;
  57159. /**
  57160. * Gets the camera attached to the layer.
  57161. */
  57162. get camera(): Nullable<Camera>;
  57163. /**
  57164. * Gets the rendering group id the layer should render in.
  57165. */
  57166. get renderingGroupId(): number;
  57167. set renderingGroupId(renderingGroupId: number);
  57168. /**
  57169. * An event triggered when the effect layer has been disposed.
  57170. */
  57171. onDisposeObservable: Observable<EffectLayer>;
  57172. /**
  57173. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57174. */
  57175. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57176. /**
  57177. * An event triggered when the generated texture is being merged in the scene.
  57178. */
  57179. onBeforeComposeObservable: Observable<EffectLayer>;
  57180. /**
  57181. * An event triggered when the mesh is rendered into the effect render target.
  57182. */
  57183. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57184. /**
  57185. * An event triggered after the mesh has been rendered into the effect render target.
  57186. */
  57187. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57188. /**
  57189. * An event triggered when the generated texture has been merged in the scene.
  57190. */
  57191. onAfterComposeObservable: Observable<EffectLayer>;
  57192. /**
  57193. * An event triggered when the efffect layer changes its size.
  57194. */
  57195. onSizeChangedObservable: Observable<EffectLayer>;
  57196. /** @hidden */
  57197. static _SceneComponentInitialization: (scene: Scene) => void;
  57198. /**
  57199. * Instantiates a new effect Layer and references it in the scene.
  57200. * @param name The name of the layer
  57201. * @param scene The scene to use the layer in
  57202. */
  57203. constructor(
  57204. /** The Friendly of the effect in the scene */
  57205. name: string, scene: Scene);
  57206. /**
  57207. * Get the effect name of the layer.
  57208. * @return The effect name
  57209. */
  57210. abstract getEffectName(): string;
  57211. /**
  57212. * Checks for the readiness of the element composing the layer.
  57213. * @param subMesh the mesh to check for
  57214. * @param useInstances specify whether or not to use instances to render the mesh
  57215. * @return true if ready otherwise, false
  57216. */
  57217. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57218. /**
  57219. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57220. * @returns true if the effect requires stencil during the main canvas render pass.
  57221. */
  57222. abstract needStencil(): boolean;
  57223. /**
  57224. * Create the merge effect. This is the shader use to blit the information back
  57225. * to the main canvas at the end of the scene rendering.
  57226. * @returns The effect containing the shader used to merge the effect on the main canvas
  57227. */
  57228. protected abstract _createMergeEffect(): Effect;
  57229. /**
  57230. * Creates the render target textures and post processes used in the effect layer.
  57231. */
  57232. protected abstract _createTextureAndPostProcesses(): void;
  57233. /**
  57234. * Implementation specific of rendering the generating effect on the main canvas.
  57235. * @param effect The effect used to render through
  57236. */
  57237. protected abstract _internalRender(effect: Effect): void;
  57238. /**
  57239. * Sets the required values for both the emissive texture and and the main color.
  57240. */
  57241. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57242. /**
  57243. * Free any resources and references associated to a mesh.
  57244. * Internal use
  57245. * @param mesh The mesh to free.
  57246. */
  57247. abstract _disposeMesh(mesh: Mesh): void;
  57248. /**
  57249. * Serializes this layer (Glow or Highlight for example)
  57250. * @returns a serialized layer object
  57251. */
  57252. abstract serialize?(): any;
  57253. /**
  57254. * Initializes the effect layer with the required options.
  57255. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57256. */
  57257. protected _init(options: Partial<IEffectLayerOptions>): void;
  57258. /**
  57259. * Generates the index buffer of the full screen quad blending to the main canvas.
  57260. */
  57261. private _generateIndexBuffer;
  57262. /**
  57263. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57264. */
  57265. private _generateVertexBuffer;
  57266. /**
  57267. * Sets the main texture desired size which is the closest power of two
  57268. * of the engine canvas size.
  57269. */
  57270. private _setMainTextureSize;
  57271. /**
  57272. * Creates the main texture for the effect layer.
  57273. */
  57274. protected _createMainTexture(): void;
  57275. /**
  57276. * Adds specific effects defines.
  57277. * @param defines The defines to add specifics to.
  57278. */
  57279. protected _addCustomEffectDefines(defines: string[]): void;
  57280. /**
  57281. * Checks for the readiness of the element composing the layer.
  57282. * @param subMesh the mesh to check for
  57283. * @param useInstances specify whether or not to use instances to render the mesh
  57284. * @param emissiveTexture the associated emissive texture used to generate the glow
  57285. * @return true if ready otherwise, false
  57286. */
  57287. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57288. /**
  57289. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57290. */
  57291. render(): void;
  57292. /**
  57293. * Determine if a given mesh will be used in the current effect.
  57294. * @param mesh mesh to test
  57295. * @returns true if the mesh will be used
  57296. */
  57297. hasMesh(mesh: AbstractMesh): boolean;
  57298. /**
  57299. * Returns true if the layer contains information to display, otherwise false.
  57300. * @returns true if the glow layer should be rendered
  57301. */
  57302. shouldRender(): boolean;
  57303. /**
  57304. * Returns true if the mesh should render, otherwise false.
  57305. * @param mesh The mesh to render
  57306. * @returns true if it should render otherwise false
  57307. */
  57308. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57309. /**
  57310. * Returns true if the mesh can be rendered, otherwise false.
  57311. * @param mesh The mesh to render
  57312. * @param material The material used on the mesh
  57313. * @returns true if it can be rendered otherwise false
  57314. */
  57315. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57316. /**
  57317. * Returns true if the mesh should render, otherwise false.
  57318. * @param mesh The mesh to render
  57319. * @returns true if it should render otherwise false
  57320. */
  57321. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57322. /**
  57323. * Renders the submesh passed in parameter to the generation map.
  57324. */
  57325. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57326. /**
  57327. * Defines whether the current material of the mesh should be use to render the effect.
  57328. * @param mesh defines the current mesh to render
  57329. */
  57330. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57331. /**
  57332. * Rebuild the required buffers.
  57333. * @hidden Internal use only.
  57334. */
  57335. _rebuild(): void;
  57336. /**
  57337. * Dispose only the render target textures and post process.
  57338. */
  57339. private _disposeTextureAndPostProcesses;
  57340. /**
  57341. * Dispose the highlight layer and free resources.
  57342. */
  57343. dispose(): void;
  57344. /**
  57345. * Gets the class name of the effect layer
  57346. * @returns the string with the class name of the effect layer
  57347. */
  57348. getClassName(): string;
  57349. /**
  57350. * Creates an effect layer from parsed effect layer data
  57351. * @param parsedEffectLayer defines effect layer data
  57352. * @param scene defines the current scene
  57353. * @param rootUrl defines the root URL containing the effect layer information
  57354. * @returns a parsed effect Layer
  57355. */
  57356. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57357. }
  57358. }
  57359. declare module BABYLON {
  57360. interface AbstractScene {
  57361. /**
  57362. * The list of effect layers (highlights/glow) added to the scene
  57363. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57364. * @see https://doc.babylonjs.com/how_to/glow_layer
  57365. */
  57366. effectLayers: Array<EffectLayer>;
  57367. /**
  57368. * Removes the given effect layer from this scene.
  57369. * @param toRemove defines the effect layer to remove
  57370. * @returns the index of the removed effect layer
  57371. */
  57372. removeEffectLayer(toRemove: EffectLayer): number;
  57373. /**
  57374. * Adds the given effect layer to this scene
  57375. * @param newEffectLayer defines the effect layer to add
  57376. */
  57377. addEffectLayer(newEffectLayer: EffectLayer): void;
  57378. }
  57379. /**
  57380. * Defines the layer scene component responsible to manage any effect layers
  57381. * in a given scene.
  57382. */
  57383. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57384. /**
  57385. * The component name helpfull to identify the component in the list of scene components.
  57386. */
  57387. readonly name: string;
  57388. /**
  57389. * The scene the component belongs to.
  57390. */
  57391. scene: Scene;
  57392. private _engine;
  57393. private _renderEffects;
  57394. private _needStencil;
  57395. private _previousStencilState;
  57396. /**
  57397. * Creates a new instance of the component for the given scene
  57398. * @param scene Defines the scene to register the component in
  57399. */
  57400. constructor(scene: Scene);
  57401. /**
  57402. * Registers the component in a given scene
  57403. */
  57404. register(): void;
  57405. /**
  57406. * Rebuilds the elements related to this component in case of
  57407. * context lost for instance.
  57408. */
  57409. rebuild(): void;
  57410. /**
  57411. * Serializes the component data to the specified json object
  57412. * @param serializationObject The object to serialize to
  57413. */
  57414. serialize(serializationObject: any): void;
  57415. /**
  57416. * Adds all the elements from the container to the scene
  57417. * @param container the container holding the elements
  57418. */
  57419. addFromContainer(container: AbstractScene): void;
  57420. /**
  57421. * Removes all the elements in the container from the scene
  57422. * @param container contains the elements to remove
  57423. * @param dispose if the removed element should be disposed (default: false)
  57424. */
  57425. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57426. /**
  57427. * Disposes the component and the associated ressources.
  57428. */
  57429. dispose(): void;
  57430. private _isReadyForMesh;
  57431. private _renderMainTexture;
  57432. private _setStencil;
  57433. private _setStencilBack;
  57434. private _draw;
  57435. private _drawCamera;
  57436. private _drawRenderingGroup;
  57437. }
  57438. }
  57439. declare module BABYLON {
  57440. /** @hidden */
  57441. export var glowMapMergePixelShader: {
  57442. name: string;
  57443. shader: string;
  57444. };
  57445. }
  57446. declare module BABYLON {
  57447. /** @hidden */
  57448. export var glowMapMergeVertexShader: {
  57449. name: string;
  57450. shader: string;
  57451. };
  57452. }
  57453. declare module BABYLON {
  57454. interface AbstractScene {
  57455. /**
  57456. * Return a the first highlight layer of the scene with a given name.
  57457. * @param name The name of the highlight layer to look for.
  57458. * @return The highlight layer if found otherwise null.
  57459. */
  57460. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57461. }
  57462. /**
  57463. * Glow layer options. This helps customizing the behaviour
  57464. * of the glow layer.
  57465. */
  57466. export interface IGlowLayerOptions {
  57467. /**
  57468. * Multiplication factor apply to the canvas size to compute the render target size
  57469. * used to generated the glowing objects (the smaller the faster).
  57470. */
  57471. mainTextureRatio: number;
  57472. /**
  57473. * Enforces a fixed size texture to ensure resize independant blur.
  57474. */
  57475. mainTextureFixedSize?: number;
  57476. /**
  57477. * How big is the kernel of the blur texture.
  57478. */
  57479. blurKernelSize: number;
  57480. /**
  57481. * The camera attached to the layer.
  57482. */
  57483. camera: Nullable<Camera>;
  57484. /**
  57485. * Enable MSAA by chosing the number of samples.
  57486. */
  57487. mainTextureSamples?: number;
  57488. /**
  57489. * The rendering group to draw the layer in.
  57490. */
  57491. renderingGroupId: number;
  57492. }
  57493. /**
  57494. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57495. *
  57496. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57497. *
  57498. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57499. */
  57500. export class GlowLayer extends EffectLayer {
  57501. /**
  57502. * Effect Name of the layer.
  57503. */
  57504. static readonly EffectName: string;
  57505. /**
  57506. * The default blur kernel size used for the glow.
  57507. */
  57508. static DefaultBlurKernelSize: number;
  57509. /**
  57510. * The default texture size ratio used for the glow.
  57511. */
  57512. static DefaultTextureRatio: number;
  57513. /**
  57514. * Sets the kernel size of the blur.
  57515. */
  57516. set blurKernelSize(value: number);
  57517. /**
  57518. * Gets the kernel size of the blur.
  57519. */
  57520. get blurKernelSize(): number;
  57521. /**
  57522. * Sets the glow intensity.
  57523. */
  57524. set intensity(value: number);
  57525. /**
  57526. * Gets the glow intensity.
  57527. */
  57528. get intensity(): number;
  57529. private _options;
  57530. private _intensity;
  57531. private _horizontalBlurPostprocess1;
  57532. private _verticalBlurPostprocess1;
  57533. private _horizontalBlurPostprocess2;
  57534. private _verticalBlurPostprocess2;
  57535. private _blurTexture1;
  57536. private _blurTexture2;
  57537. private _postProcesses1;
  57538. private _postProcesses2;
  57539. private _includedOnlyMeshes;
  57540. private _excludedMeshes;
  57541. private _meshesUsingTheirOwnMaterials;
  57542. /**
  57543. * Callback used to let the user override the color selection on a per mesh basis
  57544. */
  57545. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  57546. /**
  57547. * Callback used to let the user override the texture selection on a per mesh basis
  57548. */
  57549. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  57550. /**
  57551. * Instantiates a new glow Layer and references it to the scene.
  57552. * @param name The name of the layer
  57553. * @param scene The scene to use the layer in
  57554. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  57555. */
  57556. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  57557. /**
  57558. * Get the effect name of the layer.
  57559. * @return The effect name
  57560. */
  57561. getEffectName(): string;
  57562. /**
  57563. * Create the merge effect. This is the shader use to blit the information back
  57564. * to the main canvas at the end of the scene rendering.
  57565. */
  57566. protected _createMergeEffect(): Effect;
  57567. /**
  57568. * Creates the render target textures and post processes used in the glow layer.
  57569. */
  57570. protected _createTextureAndPostProcesses(): void;
  57571. /**
  57572. * Checks for the readiness of the element composing the layer.
  57573. * @param subMesh the mesh to check for
  57574. * @param useInstances specify wether or not to use instances to render the mesh
  57575. * @param emissiveTexture the associated emissive texture used to generate the glow
  57576. * @return true if ready otherwise, false
  57577. */
  57578. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57579. /**
  57580. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57581. */
  57582. needStencil(): boolean;
  57583. /**
  57584. * Returns true if the mesh can be rendered, otherwise false.
  57585. * @param mesh The mesh to render
  57586. * @param material The material used on the mesh
  57587. * @returns true if it can be rendered otherwise false
  57588. */
  57589. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57590. /**
  57591. * Implementation specific of rendering the generating effect on the main canvas.
  57592. * @param effect The effect used to render through
  57593. */
  57594. protected _internalRender(effect: Effect): void;
  57595. /**
  57596. * Sets the required values for both the emissive texture and and the main color.
  57597. */
  57598. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57599. /**
  57600. * Returns true if the mesh should render, otherwise false.
  57601. * @param mesh The mesh to render
  57602. * @returns true if it should render otherwise false
  57603. */
  57604. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57605. /**
  57606. * Adds specific effects defines.
  57607. * @param defines The defines to add specifics to.
  57608. */
  57609. protected _addCustomEffectDefines(defines: string[]): void;
  57610. /**
  57611. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  57612. * @param mesh The mesh to exclude from the glow layer
  57613. */
  57614. addExcludedMesh(mesh: Mesh): void;
  57615. /**
  57616. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  57617. * @param mesh The mesh to remove
  57618. */
  57619. removeExcludedMesh(mesh: Mesh): void;
  57620. /**
  57621. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  57622. * @param mesh The mesh to include in the glow layer
  57623. */
  57624. addIncludedOnlyMesh(mesh: Mesh): void;
  57625. /**
  57626. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  57627. * @param mesh The mesh to remove
  57628. */
  57629. removeIncludedOnlyMesh(mesh: Mesh): void;
  57630. /**
  57631. * Determine if a given mesh will be used in the glow layer
  57632. * @param mesh The mesh to test
  57633. * @returns true if the mesh will be highlighted by the current glow layer
  57634. */
  57635. hasMesh(mesh: AbstractMesh): boolean;
  57636. /**
  57637. * Defines whether the current material of the mesh should be use to render the effect.
  57638. * @param mesh defines the current mesh to render
  57639. */
  57640. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57641. /**
  57642. * Add a mesh to be rendered through its own material and not with emissive only.
  57643. * @param mesh The mesh for which we need to use its material
  57644. */
  57645. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  57646. /**
  57647. * Remove a mesh from being rendered through its own material and not with emissive only.
  57648. * @param mesh The mesh for which we need to not use its material
  57649. */
  57650. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  57651. /**
  57652. * Free any resources and references associated to a mesh.
  57653. * Internal use
  57654. * @param mesh The mesh to free.
  57655. * @hidden
  57656. */
  57657. _disposeMesh(mesh: Mesh): void;
  57658. /**
  57659. * Gets the class name of the effect layer
  57660. * @returns the string with the class name of the effect layer
  57661. */
  57662. getClassName(): string;
  57663. /**
  57664. * Serializes this glow layer
  57665. * @returns a serialized glow layer object
  57666. */
  57667. serialize(): any;
  57668. /**
  57669. * Creates a Glow Layer from parsed glow layer data
  57670. * @param parsedGlowLayer defines glow layer data
  57671. * @param scene defines the current scene
  57672. * @param rootUrl defines the root URL containing the glow layer information
  57673. * @returns a parsed Glow Layer
  57674. */
  57675. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  57676. }
  57677. }
  57678. declare module BABYLON {
  57679. /** @hidden */
  57680. export var glowBlurPostProcessPixelShader: {
  57681. name: string;
  57682. shader: string;
  57683. };
  57684. }
  57685. declare module BABYLON {
  57686. interface AbstractScene {
  57687. /**
  57688. * Return a the first highlight layer of the scene with a given name.
  57689. * @param name The name of the highlight layer to look for.
  57690. * @return The highlight layer if found otherwise null.
  57691. */
  57692. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  57693. }
  57694. /**
  57695. * Highlight layer options. This helps customizing the behaviour
  57696. * of the highlight layer.
  57697. */
  57698. export interface IHighlightLayerOptions {
  57699. /**
  57700. * Multiplication factor apply to the canvas size to compute the render target size
  57701. * used to generated the glowing objects (the smaller the faster).
  57702. */
  57703. mainTextureRatio: number;
  57704. /**
  57705. * Enforces a fixed size texture to ensure resize independant blur.
  57706. */
  57707. mainTextureFixedSize?: number;
  57708. /**
  57709. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  57710. * of the picture to blur (the smaller the faster).
  57711. */
  57712. blurTextureSizeRatio: number;
  57713. /**
  57714. * How big in texel of the blur texture is the vertical blur.
  57715. */
  57716. blurVerticalSize: number;
  57717. /**
  57718. * How big in texel of the blur texture is the horizontal blur.
  57719. */
  57720. blurHorizontalSize: number;
  57721. /**
  57722. * Alpha blending mode used to apply the blur. Default is combine.
  57723. */
  57724. alphaBlendingMode: number;
  57725. /**
  57726. * The camera attached to the layer.
  57727. */
  57728. camera: Nullable<Camera>;
  57729. /**
  57730. * Should we display highlight as a solid stroke?
  57731. */
  57732. isStroke?: boolean;
  57733. /**
  57734. * The rendering group to draw the layer in.
  57735. */
  57736. renderingGroupId: number;
  57737. }
  57738. /**
  57739. * The highlight layer Helps adding a glow effect around a mesh.
  57740. *
  57741. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  57742. * glowy meshes to your scene.
  57743. *
  57744. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  57745. */
  57746. export class HighlightLayer extends EffectLayer {
  57747. name: string;
  57748. /**
  57749. * Effect Name of the highlight layer.
  57750. */
  57751. static readonly EffectName: string;
  57752. /**
  57753. * The neutral color used during the preparation of the glow effect.
  57754. * This is black by default as the blend operation is a blend operation.
  57755. */
  57756. static NeutralColor: Color4;
  57757. /**
  57758. * Stencil value used for glowing meshes.
  57759. */
  57760. static GlowingMeshStencilReference: number;
  57761. /**
  57762. * Stencil value used for the other meshes in the scene.
  57763. */
  57764. static NormalMeshStencilReference: number;
  57765. /**
  57766. * Specifies whether or not the inner glow is ACTIVE in the layer.
  57767. */
  57768. innerGlow: boolean;
  57769. /**
  57770. * Specifies whether or not the outer glow is ACTIVE in the layer.
  57771. */
  57772. outerGlow: boolean;
  57773. /**
  57774. * Specifies the horizontal size of the blur.
  57775. */
  57776. set blurHorizontalSize(value: number);
  57777. /**
  57778. * Specifies the vertical size of the blur.
  57779. */
  57780. set blurVerticalSize(value: number);
  57781. /**
  57782. * Gets the horizontal size of the blur.
  57783. */
  57784. get blurHorizontalSize(): number;
  57785. /**
  57786. * Gets the vertical size of the blur.
  57787. */
  57788. get blurVerticalSize(): number;
  57789. /**
  57790. * An event triggered when the highlight layer is being blurred.
  57791. */
  57792. onBeforeBlurObservable: Observable<HighlightLayer>;
  57793. /**
  57794. * An event triggered when the highlight layer has been blurred.
  57795. */
  57796. onAfterBlurObservable: Observable<HighlightLayer>;
  57797. private _instanceGlowingMeshStencilReference;
  57798. private _options;
  57799. private _downSamplePostprocess;
  57800. private _horizontalBlurPostprocess;
  57801. private _verticalBlurPostprocess;
  57802. private _blurTexture;
  57803. private _meshes;
  57804. private _excludedMeshes;
  57805. /**
  57806. * Instantiates a new highlight Layer and references it to the scene..
  57807. * @param name The name of the layer
  57808. * @param scene The scene to use the layer in
  57809. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  57810. */
  57811. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  57812. /**
  57813. * Get the effect name of the layer.
  57814. * @return The effect name
  57815. */
  57816. getEffectName(): string;
  57817. /**
  57818. * Create the merge effect. This is the shader use to blit the information back
  57819. * to the main canvas at the end of the scene rendering.
  57820. */
  57821. protected _createMergeEffect(): Effect;
  57822. /**
  57823. * Creates the render target textures and post processes used in the highlight layer.
  57824. */
  57825. protected _createTextureAndPostProcesses(): void;
  57826. /**
  57827. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  57828. */
  57829. needStencil(): boolean;
  57830. /**
  57831. * Checks for the readiness of the element composing the layer.
  57832. * @param subMesh the mesh to check for
  57833. * @param useInstances specify wether or not to use instances to render the mesh
  57834. * @param emissiveTexture the associated emissive texture used to generate the glow
  57835. * @return true if ready otherwise, false
  57836. */
  57837. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57838. /**
  57839. * Implementation specific of rendering the generating effect on the main canvas.
  57840. * @param effect The effect used to render through
  57841. */
  57842. protected _internalRender(effect: Effect): void;
  57843. /**
  57844. * Returns true if the layer contains information to display, otherwise false.
  57845. */
  57846. shouldRender(): boolean;
  57847. /**
  57848. * Returns true if the mesh should render, otherwise false.
  57849. * @param mesh The mesh to render
  57850. * @returns true if it should render otherwise false
  57851. */
  57852. protected _shouldRenderMesh(mesh: Mesh): boolean;
  57853. /**
  57854. * Returns true if the mesh can be rendered, otherwise false.
  57855. * @param mesh The mesh to render
  57856. * @param material The material used on the mesh
  57857. * @returns true if it can be rendered otherwise false
  57858. */
  57859. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57860. /**
  57861. * Adds specific effects defines.
  57862. * @param defines The defines to add specifics to.
  57863. */
  57864. protected _addCustomEffectDefines(defines: string[]): void;
  57865. /**
  57866. * Sets the required values for both the emissive texture and and the main color.
  57867. */
  57868. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57869. /**
  57870. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  57871. * @param mesh The mesh to exclude from the highlight layer
  57872. */
  57873. addExcludedMesh(mesh: Mesh): void;
  57874. /**
  57875. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  57876. * @param mesh The mesh to highlight
  57877. */
  57878. removeExcludedMesh(mesh: Mesh): void;
  57879. /**
  57880. * Determine if a given mesh will be highlighted by the current HighlightLayer
  57881. * @param mesh mesh to test
  57882. * @returns true if the mesh will be highlighted by the current HighlightLayer
  57883. */
  57884. hasMesh(mesh: AbstractMesh): boolean;
  57885. /**
  57886. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  57887. * @param mesh The mesh to highlight
  57888. * @param color The color of the highlight
  57889. * @param glowEmissiveOnly Extract the glow from the emissive texture
  57890. */
  57891. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  57892. /**
  57893. * Remove a mesh from the highlight layer in order to make it stop glowing.
  57894. * @param mesh The mesh to highlight
  57895. */
  57896. removeMesh(mesh: Mesh): void;
  57897. /**
  57898. * Remove all the meshes currently referenced in the highlight layer
  57899. */
  57900. removeAllMeshes(): void;
  57901. /**
  57902. * Force the stencil to the normal expected value for none glowing parts
  57903. */
  57904. private _defaultStencilReference;
  57905. /**
  57906. * Free any resources and references associated to a mesh.
  57907. * Internal use
  57908. * @param mesh The mesh to free.
  57909. * @hidden
  57910. */
  57911. _disposeMesh(mesh: Mesh): void;
  57912. /**
  57913. * Dispose the highlight layer and free resources.
  57914. */
  57915. dispose(): void;
  57916. /**
  57917. * Gets the class name of the effect layer
  57918. * @returns the string with the class name of the effect layer
  57919. */
  57920. getClassName(): string;
  57921. /**
  57922. * Serializes this Highlight layer
  57923. * @returns a serialized Highlight layer object
  57924. */
  57925. serialize(): any;
  57926. /**
  57927. * Creates a Highlight layer from parsed Highlight layer data
  57928. * @param parsedHightlightLayer defines the Highlight layer data
  57929. * @param scene defines the current scene
  57930. * @param rootUrl defines the root URL containing the Highlight layer information
  57931. * @returns a parsed Highlight layer
  57932. */
  57933. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  57934. }
  57935. }
  57936. declare module BABYLON {
  57937. interface AbstractScene {
  57938. /**
  57939. * The list of layers (background and foreground) of the scene
  57940. */
  57941. layers: Array<Layer>;
  57942. }
  57943. /**
  57944. * Defines the layer scene component responsible to manage any layers
  57945. * in a given scene.
  57946. */
  57947. export class LayerSceneComponent implements ISceneComponent {
  57948. /**
  57949. * The component name helpfull to identify the component in the list of scene components.
  57950. */
  57951. readonly name: string;
  57952. /**
  57953. * The scene the component belongs to.
  57954. */
  57955. scene: Scene;
  57956. private _engine;
  57957. /**
  57958. * Creates a new instance of the component for the given scene
  57959. * @param scene Defines the scene to register the component in
  57960. */
  57961. constructor(scene: Scene);
  57962. /**
  57963. * Registers the component in a given scene
  57964. */
  57965. register(): void;
  57966. /**
  57967. * Rebuilds the elements related to this component in case of
  57968. * context lost for instance.
  57969. */
  57970. rebuild(): void;
  57971. /**
  57972. * Disposes the component and the associated ressources.
  57973. */
  57974. dispose(): void;
  57975. private _draw;
  57976. private _drawCameraPredicate;
  57977. private _drawCameraBackground;
  57978. private _drawCameraForeground;
  57979. private _drawRenderTargetPredicate;
  57980. private _drawRenderTargetBackground;
  57981. private _drawRenderTargetForeground;
  57982. /**
  57983. * Adds all the elements from the container to the scene
  57984. * @param container the container holding the elements
  57985. */
  57986. addFromContainer(container: AbstractScene): void;
  57987. /**
  57988. * Removes all the elements in the container from the scene
  57989. * @param container contains the elements to remove
  57990. * @param dispose if the removed element should be disposed (default: false)
  57991. */
  57992. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57993. }
  57994. }
  57995. declare module BABYLON {
  57996. /** @hidden */
  57997. export var layerPixelShader: {
  57998. name: string;
  57999. shader: string;
  58000. };
  58001. }
  58002. declare module BABYLON {
  58003. /** @hidden */
  58004. export var layerVertexShader: {
  58005. name: string;
  58006. shader: string;
  58007. };
  58008. }
  58009. declare module BABYLON {
  58010. /**
  58011. * This represents a full screen 2d layer.
  58012. * This can be useful to display a picture in the background of your scene for instance.
  58013. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58014. */
  58015. export class Layer {
  58016. /**
  58017. * Define the name of the layer.
  58018. */
  58019. name: string;
  58020. /**
  58021. * Define the texture the layer should display.
  58022. */
  58023. texture: Nullable<Texture>;
  58024. /**
  58025. * Is the layer in background or foreground.
  58026. */
  58027. isBackground: boolean;
  58028. /**
  58029. * Define the color of the layer (instead of texture).
  58030. */
  58031. color: Color4;
  58032. /**
  58033. * Define the scale of the layer in order to zoom in out of the texture.
  58034. */
  58035. scale: Vector2;
  58036. /**
  58037. * Define an offset for the layer in order to shift the texture.
  58038. */
  58039. offset: Vector2;
  58040. /**
  58041. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58042. */
  58043. alphaBlendingMode: number;
  58044. /**
  58045. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58046. * Alpha test will not mix with the background color in case of transparency.
  58047. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58048. */
  58049. alphaTest: boolean;
  58050. /**
  58051. * Define a mask to restrict the layer to only some of the scene cameras.
  58052. */
  58053. layerMask: number;
  58054. /**
  58055. * Define the list of render target the layer is visible into.
  58056. */
  58057. renderTargetTextures: RenderTargetTexture[];
  58058. /**
  58059. * Define if the layer is only used in renderTarget or if it also
  58060. * renders in the main frame buffer of the canvas.
  58061. */
  58062. renderOnlyInRenderTargetTextures: boolean;
  58063. private _scene;
  58064. private _vertexBuffers;
  58065. private _indexBuffer;
  58066. private _effect;
  58067. private _previousDefines;
  58068. /**
  58069. * An event triggered when the layer is disposed.
  58070. */
  58071. onDisposeObservable: Observable<Layer>;
  58072. private _onDisposeObserver;
  58073. /**
  58074. * Back compatibility with callback before the onDisposeObservable existed.
  58075. * The set callback will be triggered when the layer has been disposed.
  58076. */
  58077. set onDispose(callback: () => void);
  58078. /**
  58079. * An event triggered before rendering the scene
  58080. */
  58081. onBeforeRenderObservable: Observable<Layer>;
  58082. private _onBeforeRenderObserver;
  58083. /**
  58084. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58085. * The set callback will be triggered just before rendering the layer.
  58086. */
  58087. set onBeforeRender(callback: () => void);
  58088. /**
  58089. * An event triggered after rendering the scene
  58090. */
  58091. onAfterRenderObservable: Observable<Layer>;
  58092. private _onAfterRenderObserver;
  58093. /**
  58094. * Back compatibility with callback before the onAfterRenderObservable existed.
  58095. * The set callback will be triggered just after rendering the layer.
  58096. */
  58097. set onAfterRender(callback: () => void);
  58098. /**
  58099. * Instantiates a new layer.
  58100. * This represents a full screen 2d layer.
  58101. * This can be useful to display a picture in the background of your scene for instance.
  58102. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58103. * @param name Define the name of the layer in the scene
  58104. * @param imgUrl Define the url of the texture to display in the layer
  58105. * @param scene Define the scene the layer belongs to
  58106. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58107. * @param color Defines a color for the layer
  58108. */
  58109. constructor(
  58110. /**
  58111. * Define the name of the layer.
  58112. */
  58113. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58114. private _createIndexBuffer;
  58115. /** @hidden */
  58116. _rebuild(): void;
  58117. /**
  58118. * Renders the layer in the scene.
  58119. */
  58120. render(): void;
  58121. /**
  58122. * Disposes and releases the associated ressources.
  58123. */
  58124. dispose(): void;
  58125. }
  58126. }
  58127. declare module BABYLON {
  58128. /** @hidden */
  58129. export var lensFlarePixelShader: {
  58130. name: string;
  58131. shader: string;
  58132. };
  58133. }
  58134. declare module BABYLON {
  58135. /** @hidden */
  58136. export var lensFlareVertexShader: {
  58137. name: string;
  58138. shader: string;
  58139. };
  58140. }
  58141. declare module BABYLON {
  58142. /**
  58143. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58144. * It is usually composed of several `lensFlare`.
  58145. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58146. */
  58147. export class LensFlareSystem {
  58148. /**
  58149. * Define the name of the lens flare system
  58150. */
  58151. name: string;
  58152. /**
  58153. * List of lens flares used in this system.
  58154. */
  58155. lensFlares: LensFlare[];
  58156. /**
  58157. * Define a limit from the border the lens flare can be visible.
  58158. */
  58159. borderLimit: number;
  58160. /**
  58161. * Define a viewport border we do not want to see the lens flare in.
  58162. */
  58163. viewportBorder: number;
  58164. /**
  58165. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58166. */
  58167. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58168. /**
  58169. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58170. */
  58171. layerMask: number;
  58172. /**
  58173. * Define the id of the lens flare system in the scene.
  58174. * (equal to name by default)
  58175. */
  58176. id: string;
  58177. private _scene;
  58178. private _emitter;
  58179. private _vertexBuffers;
  58180. private _indexBuffer;
  58181. private _effect;
  58182. private _positionX;
  58183. private _positionY;
  58184. private _isEnabled;
  58185. /** @hidden */
  58186. static _SceneComponentInitialization: (scene: Scene) => void;
  58187. /**
  58188. * Instantiates a lens flare system.
  58189. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58190. * It is usually composed of several `lensFlare`.
  58191. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58192. * @param name Define the name of the lens flare system in the scene
  58193. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58194. * @param scene Define the scene the lens flare system belongs to
  58195. */
  58196. constructor(
  58197. /**
  58198. * Define the name of the lens flare system
  58199. */
  58200. name: string, emitter: any, scene: Scene);
  58201. /**
  58202. * Define if the lens flare system is enabled.
  58203. */
  58204. get isEnabled(): boolean;
  58205. set isEnabled(value: boolean);
  58206. /**
  58207. * Get the scene the effects belongs to.
  58208. * @returns the scene holding the lens flare system
  58209. */
  58210. getScene(): Scene;
  58211. /**
  58212. * Get the emitter of the lens flare system.
  58213. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58214. * @returns the emitter of the lens flare system
  58215. */
  58216. getEmitter(): any;
  58217. /**
  58218. * Set the emitter of the lens flare system.
  58219. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58220. * @param newEmitter Define the new emitter of the system
  58221. */
  58222. setEmitter(newEmitter: any): void;
  58223. /**
  58224. * Get the lens flare system emitter position.
  58225. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58226. * @returns the position
  58227. */
  58228. getEmitterPosition(): Vector3;
  58229. /**
  58230. * @hidden
  58231. */
  58232. computeEffectivePosition(globalViewport: Viewport): boolean;
  58233. /** @hidden */
  58234. _isVisible(): boolean;
  58235. /**
  58236. * @hidden
  58237. */
  58238. render(): boolean;
  58239. /**
  58240. * Dispose and release the lens flare with its associated resources.
  58241. */
  58242. dispose(): void;
  58243. /**
  58244. * Parse a lens flare system from a JSON repressentation
  58245. * @param parsedLensFlareSystem Define the JSON to parse
  58246. * @param scene Define the scene the parsed system should be instantiated in
  58247. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58248. * @returns the parsed system
  58249. */
  58250. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58251. /**
  58252. * Serialize the current Lens Flare System into a JSON representation.
  58253. * @returns the serialized JSON
  58254. */
  58255. serialize(): any;
  58256. }
  58257. }
  58258. declare module BABYLON {
  58259. /**
  58260. * This represents one of the lens effect in a `lensFlareSystem`.
  58261. * It controls one of the indiviual texture used in the effect.
  58262. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58263. */
  58264. export class LensFlare {
  58265. /**
  58266. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58267. */
  58268. size: number;
  58269. /**
  58270. * 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.
  58271. */
  58272. position: number;
  58273. /**
  58274. * Define the lens color.
  58275. */
  58276. color: Color3;
  58277. /**
  58278. * Define the lens texture.
  58279. */
  58280. texture: Nullable<Texture>;
  58281. /**
  58282. * Define the alpha mode to render this particular lens.
  58283. */
  58284. alphaMode: number;
  58285. private _system;
  58286. /**
  58287. * Creates a new Lens Flare.
  58288. * This represents one of the lens effect in a `lensFlareSystem`.
  58289. * It controls one of the indiviual texture used in the effect.
  58290. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58291. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58292. * @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.
  58293. * @param color Define the lens color
  58294. * @param imgUrl Define the lens texture url
  58295. * @param system Define the `lensFlareSystem` this flare is part of
  58296. * @returns The newly created Lens Flare
  58297. */
  58298. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58299. /**
  58300. * Instantiates a new Lens Flare.
  58301. * This represents one of the lens effect in a `lensFlareSystem`.
  58302. * It controls one of the indiviual texture used in the effect.
  58303. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58304. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58305. * @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.
  58306. * @param color Define the lens color
  58307. * @param imgUrl Define the lens texture url
  58308. * @param system Define the `lensFlareSystem` this flare is part of
  58309. */
  58310. constructor(
  58311. /**
  58312. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58313. */
  58314. size: number,
  58315. /**
  58316. * 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.
  58317. */
  58318. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58319. /**
  58320. * Dispose and release the lens flare with its associated resources.
  58321. */
  58322. dispose(): void;
  58323. }
  58324. }
  58325. declare module BABYLON {
  58326. interface AbstractScene {
  58327. /**
  58328. * The list of lens flare system added to the scene
  58329. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58330. */
  58331. lensFlareSystems: Array<LensFlareSystem>;
  58332. /**
  58333. * Removes the given lens flare system from this scene.
  58334. * @param toRemove The lens flare system to remove
  58335. * @returns The index of the removed lens flare system
  58336. */
  58337. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58338. /**
  58339. * Adds the given lens flare system to this scene
  58340. * @param newLensFlareSystem The lens flare system to add
  58341. */
  58342. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58343. /**
  58344. * Gets a lens flare system using its name
  58345. * @param name defines the name to look for
  58346. * @returns the lens flare system or null if not found
  58347. */
  58348. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58349. /**
  58350. * Gets a lens flare system using its id
  58351. * @param id defines the id to look for
  58352. * @returns the lens flare system or null if not found
  58353. */
  58354. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58355. }
  58356. /**
  58357. * Defines the lens flare scene component responsible to manage any lens flares
  58358. * in a given scene.
  58359. */
  58360. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58361. /**
  58362. * The component name helpfull to identify the component in the list of scene components.
  58363. */
  58364. readonly name: string;
  58365. /**
  58366. * The scene the component belongs to.
  58367. */
  58368. scene: Scene;
  58369. /**
  58370. * Creates a new instance of the component for the given scene
  58371. * @param scene Defines the scene to register the component in
  58372. */
  58373. constructor(scene: Scene);
  58374. /**
  58375. * Registers the component in a given scene
  58376. */
  58377. register(): void;
  58378. /**
  58379. * Rebuilds the elements related to this component in case of
  58380. * context lost for instance.
  58381. */
  58382. rebuild(): void;
  58383. /**
  58384. * Adds all the elements from the container to the scene
  58385. * @param container the container holding the elements
  58386. */
  58387. addFromContainer(container: AbstractScene): void;
  58388. /**
  58389. * Removes all the elements in the container from the scene
  58390. * @param container contains the elements to remove
  58391. * @param dispose if the removed element should be disposed (default: false)
  58392. */
  58393. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58394. /**
  58395. * Serializes the component data to the specified json object
  58396. * @param serializationObject The object to serialize to
  58397. */
  58398. serialize(serializationObject: any): void;
  58399. /**
  58400. * Disposes the component and the associated ressources.
  58401. */
  58402. dispose(): void;
  58403. private _draw;
  58404. }
  58405. }
  58406. declare module BABYLON {
  58407. /** @hidden */
  58408. export var depthPixelShader: {
  58409. name: string;
  58410. shader: string;
  58411. };
  58412. }
  58413. declare module BABYLON {
  58414. /** @hidden */
  58415. export var depthVertexShader: {
  58416. name: string;
  58417. shader: string;
  58418. };
  58419. }
  58420. declare module BABYLON {
  58421. /**
  58422. * This represents a depth renderer in Babylon.
  58423. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58424. */
  58425. export class DepthRenderer {
  58426. private _scene;
  58427. private _depthMap;
  58428. private _effect;
  58429. private readonly _storeNonLinearDepth;
  58430. private readonly _clearColor;
  58431. /** Get if the depth renderer is using packed depth or not */
  58432. readonly isPacked: boolean;
  58433. private _cachedDefines;
  58434. private _camera;
  58435. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58436. enabled: boolean;
  58437. /**
  58438. * Specifiess that the depth renderer will only be used within
  58439. * the camera it is created for.
  58440. * This can help forcing its rendering during the camera processing.
  58441. */
  58442. useOnlyInActiveCamera: boolean;
  58443. /** @hidden */
  58444. static _SceneComponentInitialization: (scene: Scene) => void;
  58445. /**
  58446. * Instantiates a depth renderer
  58447. * @param scene The scene the renderer belongs to
  58448. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58449. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58450. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58451. */
  58452. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58453. /**
  58454. * Creates the depth rendering effect and checks if the effect is ready.
  58455. * @param subMesh The submesh to be used to render the depth map of
  58456. * @param useInstances If multiple world instances should be used
  58457. * @returns if the depth renderer is ready to render the depth map
  58458. */
  58459. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58460. /**
  58461. * Gets the texture which the depth map will be written to.
  58462. * @returns The depth map texture
  58463. */
  58464. getDepthMap(): RenderTargetTexture;
  58465. /**
  58466. * Disposes of the depth renderer.
  58467. */
  58468. dispose(): void;
  58469. }
  58470. }
  58471. declare module BABYLON {
  58472. /** @hidden */
  58473. export var minmaxReduxPixelShader: {
  58474. name: string;
  58475. shader: string;
  58476. };
  58477. }
  58478. declare module BABYLON {
  58479. /**
  58480. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58481. * and maximum values from all values of the texture.
  58482. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58483. * The source values are read from the red channel of the texture.
  58484. */
  58485. export class MinMaxReducer {
  58486. /**
  58487. * Observable triggered when the computation has been performed
  58488. */
  58489. onAfterReductionPerformed: Observable<{
  58490. min: number;
  58491. max: number;
  58492. }>;
  58493. protected _camera: Camera;
  58494. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58495. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58496. protected _postProcessManager: PostProcessManager;
  58497. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58498. protected _forceFullscreenViewport: boolean;
  58499. /**
  58500. * Creates a min/max reducer
  58501. * @param camera The camera to use for the post processes
  58502. */
  58503. constructor(camera: Camera);
  58504. /**
  58505. * Gets the texture used to read the values from.
  58506. */
  58507. get sourceTexture(): Nullable<RenderTargetTexture>;
  58508. /**
  58509. * Sets the source texture to read the values from.
  58510. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58511. * because in such textures '1' value must not be taken into account to compute the maximum
  58512. * as this value is used to clear the texture.
  58513. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58514. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58515. * @param depthRedux Indicates if the texture is a depth texture or not
  58516. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58517. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58518. */
  58519. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58520. /**
  58521. * Defines the refresh rate of the computation.
  58522. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58523. */
  58524. get refreshRate(): number;
  58525. set refreshRate(value: number);
  58526. protected _activated: boolean;
  58527. /**
  58528. * Gets the activation status of the reducer
  58529. */
  58530. get activated(): boolean;
  58531. /**
  58532. * Activates the reduction computation.
  58533. * When activated, the observers registered in onAfterReductionPerformed are
  58534. * called after the compuation is performed
  58535. */
  58536. activate(): void;
  58537. /**
  58538. * Deactivates the reduction computation.
  58539. */
  58540. deactivate(): void;
  58541. /**
  58542. * Disposes the min/max reducer
  58543. * @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.
  58544. */
  58545. dispose(disposeAll?: boolean): void;
  58546. }
  58547. }
  58548. declare module BABYLON {
  58549. /**
  58550. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  58551. */
  58552. export class DepthReducer extends MinMaxReducer {
  58553. private _depthRenderer;
  58554. private _depthRendererId;
  58555. /**
  58556. * Gets the depth renderer used for the computation.
  58557. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  58558. */
  58559. get depthRenderer(): Nullable<DepthRenderer>;
  58560. /**
  58561. * Creates a depth reducer
  58562. * @param camera The camera used to render the depth texture
  58563. */
  58564. constructor(camera: Camera);
  58565. /**
  58566. * Sets the depth renderer to use to generate the depth map
  58567. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  58568. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  58569. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58570. */
  58571. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  58572. /** @hidden */
  58573. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58574. /**
  58575. * Activates the reduction computation.
  58576. * When activated, the observers registered in onAfterReductionPerformed are
  58577. * called after the compuation is performed
  58578. */
  58579. activate(): void;
  58580. /**
  58581. * Deactivates the reduction computation.
  58582. */
  58583. deactivate(): void;
  58584. /**
  58585. * Disposes the depth reducer
  58586. * @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.
  58587. */
  58588. dispose(disposeAll?: boolean): void;
  58589. }
  58590. }
  58591. declare module BABYLON {
  58592. /**
  58593. * A CSM implementation allowing casting shadows on large scenes.
  58594. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58595. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  58596. */
  58597. export class CascadedShadowGenerator extends ShadowGenerator {
  58598. private static readonly frustumCornersNDCSpace;
  58599. /**
  58600. * Name of the CSM class
  58601. */
  58602. static CLASSNAME: string;
  58603. /**
  58604. * Defines the default number of cascades used by the CSM.
  58605. */
  58606. static readonly DEFAULT_CASCADES_COUNT: number;
  58607. /**
  58608. * Defines the minimum number of cascades used by the CSM.
  58609. */
  58610. static readonly MIN_CASCADES_COUNT: number;
  58611. /**
  58612. * Defines the maximum number of cascades used by the CSM.
  58613. */
  58614. static readonly MAX_CASCADES_COUNT: number;
  58615. protected _validateFilter(filter: number): number;
  58616. /**
  58617. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  58618. */
  58619. penumbraDarkness: number;
  58620. private _numCascades;
  58621. /**
  58622. * Gets or set the number of cascades used by the CSM.
  58623. */
  58624. get numCascades(): number;
  58625. set numCascades(value: number);
  58626. /**
  58627. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  58628. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  58629. */
  58630. stabilizeCascades: boolean;
  58631. private _freezeShadowCastersBoundingInfo;
  58632. private _freezeShadowCastersBoundingInfoObservable;
  58633. /**
  58634. * Enables or disables the shadow casters bounding info computation.
  58635. * If your shadow casters don't move, you can disable this feature.
  58636. * If it is enabled, the bounding box computation is done every frame.
  58637. */
  58638. get freezeShadowCastersBoundingInfo(): boolean;
  58639. set freezeShadowCastersBoundingInfo(freeze: boolean);
  58640. private _scbiMin;
  58641. private _scbiMax;
  58642. protected _computeShadowCastersBoundingInfo(): void;
  58643. protected _shadowCastersBoundingInfo: BoundingInfo;
  58644. /**
  58645. * Gets or sets the shadow casters bounding info.
  58646. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  58647. * so that the system won't overwrite the bounds you provide
  58648. */
  58649. get shadowCastersBoundingInfo(): BoundingInfo;
  58650. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  58651. protected _breaksAreDirty: boolean;
  58652. protected _minDistance: number;
  58653. protected _maxDistance: number;
  58654. /**
  58655. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  58656. *
  58657. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  58658. * If you don't know these values, simply leave them to their defaults and don't call this function.
  58659. * @param min minimal distance for the breaks (default to 0.)
  58660. * @param max maximal distance for the breaks (default to 1.)
  58661. */
  58662. setMinMaxDistance(min: number, max: number): void;
  58663. /** Gets the minimal distance used in the cascade break computation */
  58664. get minDistance(): number;
  58665. /** Gets the maximal distance used in the cascade break computation */
  58666. get maxDistance(): number;
  58667. /**
  58668. * Gets the class name of that object
  58669. * @returns "CascadedShadowGenerator"
  58670. */
  58671. getClassName(): string;
  58672. private _cascadeMinExtents;
  58673. private _cascadeMaxExtents;
  58674. /**
  58675. * Gets a cascade minimum extents
  58676. * @param cascadeIndex index of the cascade
  58677. * @returns the minimum cascade extents
  58678. */
  58679. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  58680. /**
  58681. * Gets a cascade maximum extents
  58682. * @param cascadeIndex index of the cascade
  58683. * @returns the maximum cascade extents
  58684. */
  58685. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  58686. private _cascades;
  58687. private _currentLayer;
  58688. private _viewSpaceFrustumsZ;
  58689. private _viewMatrices;
  58690. private _projectionMatrices;
  58691. private _transformMatrices;
  58692. private _transformMatricesAsArray;
  58693. private _frustumLengths;
  58694. private _lightSizeUVCorrection;
  58695. private _depthCorrection;
  58696. private _frustumCornersWorldSpace;
  58697. private _frustumCenter;
  58698. private _shadowCameraPos;
  58699. private _shadowMaxZ;
  58700. /**
  58701. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  58702. * It defaults to camera.maxZ
  58703. */
  58704. get shadowMaxZ(): number;
  58705. /**
  58706. * Sets the shadow max z distance.
  58707. */
  58708. set shadowMaxZ(value: number);
  58709. protected _debug: boolean;
  58710. /**
  58711. * Gets or sets the debug flag.
  58712. * When enabled, the cascades are materialized by different colors on the screen.
  58713. */
  58714. get debug(): boolean;
  58715. set debug(dbg: boolean);
  58716. private _depthClamp;
  58717. /**
  58718. * Gets or sets the depth clamping value.
  58719. *
  58720. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  58721. * to account for the shadow casters far away.
  58722. *
  58723. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  58724. */
  58725. get depthClamp(): boolean;
  58726. set depthClamp(value: boolean);
  58727. private _cascadeBlendPercentage;
  58728. /**
  58729. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  58730. * It defaults to 0.1 (10% blending).
  58731. */
  58732. get cascadeBlendPercentage(): number;
  58733. set cascadeBlendPercentage(value: number);
  58734. private _lambda;
  58735. /**
  58736. * Gets or set the lambda parameter.
  58737. * This parameter is used to split the camera frustum and create the cascades.
  58738. * 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.
  58739. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  58740. */
  58741. get lambda(): number;
  58742. set lambda(value: number);
  58743. /**
  58744. * Gets the view matrix corresponding to a given cascade
  58745. * @param cascadeNum cascade to retrieve the view matrix from
  58746. * @returns the cascade view matrix
  58747. */
  58748. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  58749. /**
  58750. * Gets the projection matrix corresponding to a given cascade
  58751. * @param cascadeNum cascade to retrieve the projection matrix from
  58752. * @returns the cascade projection matrix
  58753. */
  58754. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  58755. /**
  58756. * Gets the transformation matrix corresponding to a given cascade
  58757. * @param cascadeNum cascade to retrieve the transformation matrix from
  58758. * @returns the cascade transformation matrix
  58759. */
  58760. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  58761. private _depthRenderer;
  58762. /**
  58763. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  58764. *
  58765. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  58766. *
  58767. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  58768. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  58769. * @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
  58770. */
  58771. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  58772. private _depthReducer;
  58773. private _autoCalcDepthBounds;
  58774. /**
  58775. * Gets or sets the autoCalcDepthBounds property.
  58776. *
  58777. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  58778. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  58779. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  58780. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  58781. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  58782. */
  58783. get autoCalcDepthBounds(): boolean;
  58784. set autoCalcDepthBounds(value: boolean);
  58785. /**
  58786. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  58787. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58788. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  58789. * for setting the refresh rate on the renderer yourself!
  58790. */
  58791. get autoCalcDepthBoundsRefreshRate(): number;
  58792. set autoCalcDepthBoundsRefreshRate(value: number);
  58793. /**
  58794. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  58795. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  58796. * you change the camera near/far planes!
  58797. */
  58798. splitFrustum(): void;
  58799. private _splitFrustum;
  58800. private _computeMatrices;
  58801. private _computeFrustumInWorldSpace;
  58802. private _computeCascadeFrustum;
  58803. /**
  58804. * Support test.
  58805. */
  58806. static get IsSupported(): boolean;
  58807. /** @hidden */
  58808. static _SceneComponentInitialization: (scene: Scene) => void;
  58809. /**
  58810. * Creates a Cascaded Shadow Generator object.
  58811. * A ShadowGenerator is the required tool to use the shadows.
  58812. * Each directional light casting shadows needs to use its own ShadowGenerator.
  58813. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  58814. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  58815. * @param light The directional light object generating the shadows.
  58816. * @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.
  58817. */
  58818. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  58819. protected _initializeGenerator(): void;
  58820. protected _createTargetRenderTexture(): void;
  58821. protected _initializeShadowMap(): void;
  58822. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  58823. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  58824. /**
  58825. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  58826. * @param defines Defines of the material we want to update
  58827. * @param lightIndex Index of the light in the enabled light list of the material
  58828. */
  58829. prepareDefines(defines: any, lightIndex: number): void;
  58830. /**
  58831. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  58832. * defined in the generator but impacting the effect).
  58833. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  58834. * @param effect The effect we are binfing the information for
  58835. */
  58836. bindShadowLight(lightIndex: string, effect: Effect): void;
  58837. /**
  58838. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  58839. * (eq to view projection * shadow projection matrices)
  58840. * @returns The transform matrix used to create the shadow map
  58841. */
  58842. getTransformMatrix(): Matrix;
  58843. /**
  58844. * Disposes the ShadowGenerator.
  58845. * Returns nothing.
  58846. */
  58847. dispose(): void;
  58848. /**
  58849. * Serializes the shadow generator setup to a json object.
  58850. * @returns The serialized JSON object
  58851. */
  58852. serialize(): any;
  58853. /**
  58854. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  58855. * @param parsedShadowGenerator The JSON object to parse
  58856. * @param scene The scene to create the shadow map for
  58857. * @returns The parsed shadow generator
  58858. */
  58859. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  58860. }
  58861. }
  58862. declare module BABYLON {
  58863. /**
  58864. * Defines the shadow generator component responsible to manage any shadow generators
  58865. * in a given scene.
  58866. */
  58867. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  58868. /**
  58869. * The component name helpfull to identify the component in the list of scene components.
  58870. */
  58871. readonly name: string;
  58872. /**
  58873. * The scene the component belongs to.
  58874. */
  58875. scene: Scene;
  58876. /**
  58877. * Creates a new instance of the component for the given scene
  58878. * @param scene Defines the scene to register the component in
  58879. */
  58880. constructor(scene: Scene);
  58881. /**
  58882. * Registers the component in a given scene
  58883. */
  58884. register(): void;
  58885. /**
  58886. * Rebuilds the elements related to this component in case of
  58887. * context lost for instance.
  58888. */
  58889. rebuild(): void;
  58890. /**
  58891. * Serializes the component data to the specified json object
  58892. * @param serializationObject The object to serialize to
  58893. */
  58894. serialize(serializationObject: any): void;
  58895. /**
  58896. * Adds all the elements from the container to the scene
  58897. * @param container the container holding the elements
  58898. */
  58899. addFromContainer(container: AbstractScene): void;
  58900. /**
  58901. * Removes all the elements in the container from the scene
  58902. * @param container contains the elements to remove
  58903. * @param dispose if the removed element should be disposed (default: false)
  58904. */
  58905. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58906. /**
  58907. * Rebuilds the elements related to this component in case of
  58908. * context lost for instance.
  58909. */
  58910. dispose(): void;
  58911. private _gatherRenderTargets;
  58912. }
  58913. }
  58914. declare module BABYLON {
  58915. /**
  58916. * A point light is a light defined by an unique point in world space.
  58917. * The light is emitted in every direction from this point.
  58918. * A good example of a point light is a standard light bulb.
  58919. * Documentation: https://doc.babylonjs.com/babylon101/lights
  58920. */
  58921. export class PointLight extends ShadowLight {
  58922. private _shadowAngle;
  58923. /**
  58924. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58925. * This specifies what angle the shadow will use to be created.
  58926. *
  58927. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58928. */
  58929. get shadowAngle(): number;
  58930. /**
  58931. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58932. * This specifies what angle the shadow will use to be created.
  58933. *
  58934. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  58935. */
  58936. set shadowAngle(value: number);
  58937. /**
  58938. * Gets the direction if it has been set.
  58939. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58940. */
  58941. get direction(): Vector3;
  58942. /**
  58943. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  58944. */
  58945. set direction(value: Vector3);
  58946. /**
  58947. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  58948. * A PointLight emits the light in every direction.
  58949. * It can cast shadows.
  58950. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  58951. * ```javascript
  58952. * var pointLight = new PointLight("pl", camera.position, scene);
  58953. * ```
  58954. * Documentation : https://doc.babylonjs.com/babylon101/lights
  58955. * @param name The light friendly name
  58956. * @param position The position of the point light in the scene
  58957. * @param scene The scene the lights belongs to
  58958. */
  58959. constructor(name: string, position: Vector3, scene: Scene);
  58960. /**
  58961. * Returns the string "PointLight"
  58962. * @returns the class name
  58963. */
  58964. getClassName(): string;
  58965. /**
  58966. * Returns the integer 0.
  58967. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  58968. */
  58969. getTypeID(): number;
  58970. /**
  58971. * Specifies wether or not the shadowmap should be a cube texture.
  58972. * @returns true if the shadowmap needs to be a cube texture.
  58973. */
  58974. needCube(): boolean;
  58975. /**
  58976. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  58977. * @param faceIndex The index of the face we are computed the direction to generate shadow
  58978. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  58979. */
  58980. getShadowDirection(faceIndex?: number): Vector3;
  58981. /**
  58982. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  58983. * - fov = PI / 2
  58984. * - aspect ratio : 1.0
  58985. * - z-near and far equal to the active camera minZ and maxZ.
  58986. * Returns the PointLight.
  58987. */
  58988. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  58989. protected _buildUniformLayout(): void;
  58990. /**
  58991. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  58992. * @param effect The effect to update
  58993. * @param lightIndex The index of the light in the effect to update
  58994. * @returns The point light
  58995. */
  58996. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  58997. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  58998. /**
  58999. * Prepares the list of defines specific to the light type.
  59000. * @param defines the list of defines
  59001. * @param lightIndex defines the index of the light for the effect
  59002. */
  59003. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59004. }
  59005. }
  59006. declare module BABYLON {
  59007. /**
  59008. * Header information of HDR texture files.
  59009. */
  59010. export interface HDRInfo {
  59011. /**
  59012. * The height of the texture in pixels.
  59013. */
  59014. height: number;
  59015. /**
  59016. * The width of the texture in pixels.
  59017. */
  59018. width: number;
  59019. /**
  59020. * The index of the beginning of the data in the binary file.
  59021. */
  59022. dataPosition: number;
  59023. }
  59024. /**
  59025. * This groups tools to convert HDR texture to native colors array.
  59026. */
  59027. export class HDRTools {
  59028. private static Ldexp;
  59029. private static Rgbe2float;
  59030. private static readStringLine;
  59031. /**
  59032. * Reads header information from an RGBE texture stored in a native array.
  59033. * More information on this format are available here:
  59034. * https://en.wikipedia.org/wiki/RGBE_image_format
  59035. *
  59036. * @param uint8array The binary file stored in native array.
  59037. * @return The header information.
  59038. */
  59039. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59040. /**
  59041. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59042. * This RGBE texture needs to store the information as a panorama.
  59043. *
  59044. * More information on this format are available here:
  59045. * https://en.wikipedia.org/wiki/RGBE_image_format
  59046. *
  59047. * @param buffer The binary file stored in an array buffer.
  59048. * @param size The expected size of the extracted cubemap.
  59049. * @return The Cube Map information.
  59050. */
  59051. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59052. /**
  59053. * Returns the pixels data extracted from an RGBE texture.
  59054. * This pixels will be stored left to right up to down in the R G B order in one array.
  59055. *
  59056. * More information on this format are available here:
  59057. * https://en.wikipedia.org/wiki/RGBE_image_format
  59058. *
  59059. * @param uint8array The binary file stored in an array buffer.
  59060. * @param hdrInfo The header information of the file.
  59061. * @return The pixels data in RGB right to left up to down order.
  59062. */
  59063. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59064. private static RGBE_ReadPixels_RLE;
  59065. }
  59066. }
  59067. declare module BABYLON {
  59068. /**
  59069. * Effect Render Options
  59070. */
  59071. export interface IEffectRendererOptions {
  59072. /**
  59073. * Defines the vertices positions.
  59074. */
  59075. positions?: number[];
  59076. /**
  59077. * Defines the indices.
  59078. */
  59079. indices?: number[];
  59080. }
  59081. /**
  59082. * Helper class to render one or more effects.
  59083. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59084. */
  59085. export class EffectRenderer {
  59086. private engine;
  59087. private static _DefaultOptions;
  59088. private _vertexBuffers;
  59089. private _indexBuffer;
  59090. private _fullscreenViewport;
  59091. /**
  59092. * Creates an effect renderer
  59093. * @param engine the engine to use for rendering
  59094. * @param options defines the options of the effect renderer
  59095. */
  59096. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59097. /**
  59098. * Sets the current viewport in normalized coordinates 0-1
  59099. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59100. */
  59101. setViewport(viewport?: Viewport): void;
  59102. /**
  59103. * Binds the embedded attributes buffer to the effect.
  59104. * @param effect Defines the effect to bind the attributes for
  59105. */
  59106. bindBuffers(effect: Effect): void;
  59107. /**
  59108. * Sets the current effect wrapper to use during draw.
  59109. * The effect needs to be ready before calling this api.
  59110. * This also sets the default full screen position attribute.
  59111. * @param effectWrapper Defines the effect to draw with
  59112. */
  59113. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59114. /**
  59115. * Restores engine states
  59116. */
  59117. restoreStates(): void;
  59118. /**
  59119. * Draws a full screen quad.
  59120. */
  59121. draw(): void;
  59122. private isRenderTargetTexture;
  59123. /**
  59124. * renders one or more effects to a specified texture
  59125. * @param effectWrapper the effect to renderer
  59126. * @param outputTexture texture to draw to, if null it will render to the screen.
  59127. */
  59128. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59129. /**
  59130. * Disposes of the effect renderer
  59131. */
  59132. dispose(): void;
  59133. }
  59134. /**
  59135. * Options to create an EffectWrapper
  59136. */
  59137. interface EffectWrapperCreationOptions {
  59138. /**
  59139. * Engine to use to create the effect
  59140. */
  59141. engine: ThinEngine;
  59142. /**
  59143. * Fragment shader for the effect
  59144. */
  59145. fragmentShader: string;
  59146. /**
  59147. * Use the shader store instead of direct source code
  59148. */
  59149. useShaderStore?: boolean;
  59150. /**
  59151. * Vertex shader for the effect
  59152. */
  59153. vertexShader?: string;
  59154. /**
  59155. * Attributes to use in the shader
  59156. */
  59157. attributeNames?: Array<string>;
  59158. /**
  59159. * Uniforms to use in the shader
  59160. */
  59161. uniformNames?: Array<string>;
  59162. /**
  59163. * Texture sampler names to use in the shader
  59164. */
  59165. samplerNames?: Array<string>;
  59166. /**
  59167. * Defines to use in the shader
  59168. */
  59169. defines?: Array<string>;
  59170. /**
  59171. * Callback when effect is compiled
  59172. */
  59173. onCompiled?: Nullable<(effect: Effect) => void>;
  59174. /**
  59175. * The friendly name of the effect displayed in Spector.
  59176. */
  59177. name?: string;
  59178. }
  59179. /**
  59180. * Wraps an effect to be used for rendering
  59181. */
  59182. export class EffectWrapper {
  59183. /**
  59184. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59185. */
  59186. onApplyObservable: Observable<{}>;
  59187. /**
  59188. * The underlying effect
  59189. */
  59190. effect: Effect;
  59191. /**
  59192. * Creates an effect to be renderer
  59193. * @param creationOptions options to create the effect
  59194. */
  59195. constructor(creationOptions: EffectWrapperCreationOptions);
  59196. /**
  59197. * Disposes of the effect wrapper
  59198. */
  59199. dispose(): void;
  59200. }
  59201. }
  59202. declare module BABYLON {
  59203. /** @hidden */
  59204. export var hdrFilteringVertexShader: {
  59205. name: string;
  59206. shader: string;
  59207. };
  59208. }
  59209. declare module BABYLON {
  59210. /** @hidden */
  59211. export var hdrFilteringPixelShader: {
  59212. name: string;
  59213. shader: string;
  59214. };
  59215. }
  59216. declare module BABYLON {
  59217. /**
  59218. * Options for texture filtering
  59219. */
  59220. interface IHDRFilteringOptions {
  59221. /**
  59222. * Scales pixel intensity for the input HDR map.
  59223. */
  59224. hdrScale?: number;
  59225. /**
  59226. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59227. */
  59228. quality?: number;
  59229. }
  59230. /**
  59231. * Filters HDR maps to get correct renderings of PBR reflections
  59232. */
  59233. export class HDRFiltering {
  59234. private _engine;
  59235. private _effectRenderer;
  59236. private _effectWrapper;
  59237. private _lodGenerationOffset;
  59238. private _lodGenerationScale;
  59239. /**
  59240. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59241. * you care about baking speed.
  59242. */
  59243. quality: number;
  59244. /**
  59245. * Scales pixel intensity for the input HDR map.
  59246. */
  59247. hdrScale: number;
  59248. /**
  59249. * Instantiates HDR filter for reflection maps
  59250. *
  59251. * @param engine Thin engine
  59252. * @param options Options
  59253. */
  59254. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59255. private _createRenderTarget;
  59256. private _prefilterInternal;
  59257. private _createEffect;
  59258. /**
  59259. * Get a value indicating if the filter is ready to be used
  59260. * @param texture Texture to filter
  59261. * @returns true if the filter is ready
  59262. */
  59263. isReady(texture: BaseTexture): boolean;
  59264. /**
  59265. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59266. * Prefiltering will be invoked at the end of next rendering pass.
  59267. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59268. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59269. * @param texture Texture to filter
  59270. * @param onFinished Callback when filtering is done
  59271. * @return Promise called when prefiltering is done
  59272. */
  59273. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59274. }
  59275. }
  59276. declare module BABYLON {
  59277. /**
  59278. * This represents a texture coming from an HDR input.
  59279. *
  59280. * The only supported format is currently panorama picture stored in RGBE format.
  59281. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59282. */
  59283. export class HDRCubeTexture extends BaseTexture {
  59284. private static _facesMapping;
  59285. private _generateHarmonics;
  59286. private _noMipmap;
  59287. private _prefilterOnLoad;
  59288. private _textureMatrix;
  59289. private _size;
  59290. private _onLoad;
  59291. private _onError;
  59292. /**
  59293. * The texture URL.
  59294. */
  59295. url: string;
  59296. /**
  59297. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59298. */
  59299. coordinatesMode: number;
  59300. protected _isBlocking: boolean;
  59301. /**
  59302. * Sets wether or not the texture is blocking during loading.
  59303. */
  59304. set isBlocking(value: boolean);
  59305. /**
  59306. * Gets wether or not the texture is blocking during loading.
  59307. */
  59308. get isBlocking(): boolean;
  59309. protected _rotationY: number;
  59310. /**
  59311. * Sets texture matrix rotation angle around Y axis in radians.
  59312. */
  59313. set rotationY(value: number);
  59314. /**
  59315. * Gets texture matrix rotation angle around Y axis radians.
  59316. */
  59317. get rotationY(): number;
  59318. /**
  59319. * Gets or sets the center of the bounding box associated with the cube texture
  59320. * It must define where the camera used to render the texture was set
  59321. */
  59322. boundingBoxPosition: Vector3;
  59323. private _boundingBoxSize;
  59324. /**
  59325. * Gets or sets the size of the bounding box associated with the cube texture
  59326. * When defined, the cubemap will switch to local mode
  59327. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59328. * @example https://www.babylonjs-playground.com/#RNASML
  59329. */
  59330. set boundingBoxSize(value: Vector3);
  59331. get boundingBoxSize(): Vector3;
  59332. /**
  59333. * Instantiates an HDRTexture from the following parameters.
  59334. *
  59335. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59336. * @param sceneOrEngine The scene or engine the texture will be used in
  59337. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59338. * @param noMipmap Forces to not generate the mipmap if true
  59339. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59340. * @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)
  59341. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59342. */
  59343. 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>);
  59344. /**
  59345. * Get the current class name of the texture useful for serialization or dynamic coding.
  59346. * @returns "HDRCubeTexture"
  59347. */
  59348. getClassName(): string;
  59349. /**
  59350. * Occurs when the file is raw .hdr file.
  59351. */
  59352. private loadTexture;
  59353. clone(): HDRCubeTexture;
  59354. delayLoad(): void;
  59355. /**
  59356. * Get the texture reflection matrix used to rotate/transform the reflection.
  59357. * @returns the reflection matrix
  59358. */
  59359. getReflectionTextureMatrix(): Matrix;
  59360. /**
  59361. * Set the texture reflection matrix used to rotate/transform the reflection.
  59362. * @param value Define the reflection matrix to set
  59363. */
  59364. setReflectionTextureMatrix(value: Matrix): void;
  59365. /**
  59366. * Parses a JSON representation of an HDR Texture in order to create the texture
  59367. * @param parsedTexture Define the JSON representation
  59368. * @param scene Define the scene the texture should be created in
  59369. * @param rootUrl Define the root url in case we need to load relative dependencies
  59370. * @returns the newly created texture after parsing
  59371. */
  59372. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59373. serialize(): any;
  59374. }
  59375. }
  59376. declare module BABYLON {
  59377. /**
  59378. * Class used to control physics engine
  59379. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59380. */
  59381. export class PhysicsEngine implements IPhysicsEngine {
  59382. private _physicsPlugin;
  59383. /**
  59384. * Global value used to control the smallest number supported by the simulation
  59385. */
  59386. static Epsilon: number;
  59387. private _impostors;
  59388. private _joints;
  59389. private _subTimeStep;
  59390. /**
  59391. * Gets the gravity vector used by the simulation
  59392. */
  59393. gravity: Vector3;
  59394. /**
  59395. * Factory used to create the default physics plugin.
  59396. * @returns The default physics plugin
  59397. */
  59398. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59399. /**
  59400. * Creates a new Physics Engine
  59401. * @param gravity defines the gravity vector used by the simulation
  59402. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59403. */
  59404. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59405. /**
  59406. * Sets the gravity vector used by the simulation
  59407. * @param gravity defines the gravity vector to use
  59408. */
  59409. setGravity(gravity: Vector3): void;
  59410. /**
  59411. * Set the time step of the physics engine.
  59412. * Default is 1/60.
  59413. * To slow it down, enter 1/600 for example.
  59414. * To speed it up, 1/30
  59415. * @param newTimeStep defines the new timestep to apply to this world.
  59416. */
  59417. setTimeStep(newTimeStep?: number): void;
  59418. /**
  59419. * Get the time step of the physics engine.
  59420. * @returns the current time step
  59421. */
  59422. getTimeStep(): number;
  59423. /**
  59424. * Set the sub time step of the physics engine.
  59425. * Default is 0 meaning there is no sub steps
  59426. * To increase physics resolution precision, set a small value (like 1 ms)
  59427. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59428. */
  59429. setSubTimeStep(subTimeStep?: number): void;
  59430. /**
  59431. * Get the sub time step of the physics engine.
  59432. * @returns the current sub time step
  59433. */
  59434. getSubTimeStep(): number;
  59435. /**
  59436. * Release all resources
  59437. */
  59438. dispose(): void;
  59439. /**
  59440. * Gets the name of the current physics plugin
  59441. * @returns the name of the plugin
  59442. */
  59443. getPhysicsPluginName(): string;
  59444. /**
  59445. * Adding a new impostor for the impostor tracking.
  59446. * This will be done by the impostor itself.
  59447. * @param impostor the impostor to add
  59448. */
  59449. addImpostor(impostor: PhysicsImpostor): void;
  59450. /**
  59451. * Remove an impostor from the engine.
  59452. * This impostor and its mesh will not longer be updated by the physics engine.
  59453. * @param impostor the impostor to remove
  59454. */
  59455. removeImpostor(impostor: PhysicsImpostor): void;
  59456. /**
  59457. * Add a joint to the physics engine
  59458. * @param mainImpostor defines the main impostor to which the joint is added.
  59459. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59460. * @param joint defines the joint that will connect both impostors.
  59461. */
  59462. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59463. /**
  59464. * Removes a joint from the simulation
  59465. * @param mainImpostor defines the impostor used with the joint
  59466. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59467. * @param joint defines the joint to remove
  59468. */
  59469. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59470. /**
  59471. * Called by the scene. No need to call it.
  59472. * @param delta defines the timespam between frames
  59473. */
  59474. _step(delta: number): void;
  59475. /**
  59476. * Gets the current plugin used to run the simulation
  59477. * @returns current plugin
  59478. */
  59479. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59480. /**
  59481. * Gets the list of physic impostors
  59482. * @returns an array of PhysicsImpostor
  59483. */
  59484. getImpostors(): Array<PhysicsImpostor>;
  59485. /**
  59486. * Gets the impostor for a physics enabled object
  59487. * @param object defines the object impersonated by the impostor
  59488. * @returns the PhysicsImpostor or null if not found
  59489. */
  59490. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59491. /**
  59492. * Gets the impostor for a physics body object
  59493. * @param body defines physics body used by the impostor
  59494. * @returns the PhysicsImpostor or null if not found
  59495. */
  59496. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59497. /**
  59498. * Does a raycast in the physics world
  59499. * @param from when should the ray start?
  59500. * @param to when should the ray end?
  59501. * @returns PhysicsRaycastResult
  59502. */
  59503. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59504. }
  59505. }
  59506. declare module BABYLON {
  59507. /** @hidden */
  59508. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59509. private _useDeltaForWorldStep;
  59510. world: any;
  59511. name: string;
  59512. private _physicsMaterials;
  59513. private _fixedTimeStep;
  59514. private _cannonRaycastResult;
  59515. private _raycastResult;
  59516. private _physicsBodysToRemoveAfterStep;
  59517. private _firstFrame;
  59518. BJSCANNON: any;
  59519. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59520. setGravity(gravity: Vector3): void;
  59521. setTimeStep(timeStep: number): void;
  59522. getTimeStep(): number;
  59523. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59524. private _removeMarkedPhysicsBodiesFromWorld;
  59525. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59526. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59527. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59528. private _processChildMeshes;
  59529. removePhysicsBody(impostor: PhysicsImpostor): void;
  59530. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59531. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59532. private _addMaterial;
  59533. private _checkWithEpsilon;
  59534. private _createShape;
  59535. private _createHeightmap;
  59536. private _minus90X;
  59537. private _plus90X;
  59538. private _tmpPosition;
  59539. private _tmpDeltaPosition;
  59540. private _tmpUnityRotation;
  59541. private _updatePhysicsBodyTransformation;
  59542. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59543. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59544. isSupported(): boolean;
  59545. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59546. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59547. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59548. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59549. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59550. getBodyMass(impostor: PhysicsImpostor): number;
  59551. getBodyFriction(impostor: PhysicsImpostor): number;
  59552. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59553. getBodyRestitution(impostor: PhysicsImpostor): number;
  59554. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59555. sleepBody(impostor: PhysicsImpostor): void;
  59556. wakeUpBody(impostor: PhysicsImpostor): void;
  59557. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  59558. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  59559. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  59560. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59561. getRadius(impostor: PhysicsImpostor): number;
  59562. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59563. dispose(): void;
  59564. private _extendNamespace;
  59565. /**
  59566. * Does a raycast in the physics world
  59567. * @param from when should the ray start?
  59568. * @param to when should the ray end?
  59569. * @returns PhysicsRaycastResult
  59570. */
  59571. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59572. }
  59573. }
  59574. declare module BABYLON {
  59575. /** @hidden */
  59576. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  59577. private _useDeltaForWorldStep;
  59578. world: any;
  59579. name: string;
  59580. BJSOIMO: any;
  59581. private _raycastResult;
  59582. private _fixedTimeStep;
  59583. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  59584. setGravity(gravity: Vector3): void;
  59585. setTimeStep(timeStep: number): void;
  59586. getTimeStep(): number;
  59587. private _tmpImpostorsArray;
  59588. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59589. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59590. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59591. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59592. private _tmpPositionVector;
  59593. removePhysicsBody(impostor: PhysicsImpostor): void;
  59594. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59595. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59596. isSupported(): boolean;
  59597. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59598. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59599. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59600. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59601. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59602. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59603. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59604. getBodyMass(impostor: PhysicsImpostor): number;
  59605. getBodyFriction(impostor: PhysicsImpostor): number;
  59606. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59607. getBodyRestitution(impostor: PhysicsImpostor): number;
  59608. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  59609. sleepBody(impostor: PhysicsImpostor): void;
  59610. wakeUpBody(impostor: PhysicsImpostor): void;
  59611. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  59612. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  59613. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  59614. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  59615. getRadius(impostor: PhysicsImpostor): number;
  59616. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  59617. dispose(): void;
  59618. /**
  59619. * Does a raycast in the physics world
  59620. * @param from when should the ray start?
  59621. * @param to when should the ray end?
  59622. * @returns PhysicsRaycastResult
  59623. */
  59624. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59625. }
  59626. }
  59627. declare module BABYLON {
  59628. /**
  59629. * Class containing static functions to help procedurally build meshes
  59630. */
  59631. export class RibbonBuilder {
  59632. /**
  59633. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59634. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59635. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59636. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59637. * * 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
  59638. * * 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
  59639. * * 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
  59640. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59641. * * 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
  59642. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59643. * * 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
  59644. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59645. * * 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
  59646. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59648. * @param name defines the name of the mesh
  59649. * @param options defines the options used to create the mesh
  59650. * @param scene defines the hosting scene
  59651. * @returns the ribbon mesh
  59652. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59653. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59654. */
  59655. static CreateRibbon(name: string, options: {
  59656. pathArray: Vector3[][];
  59657. closeArray?: boolean;
  59658. closePath?: boolean;
  59659. offset?: number;
  59660. updatable?: boolean;
  59661. sideOrientation?: number;
  59662. frontUVs?: Vector4;
  59663. backUVs?: Vector4;
  59664. instance?: Mesh;
  59665. invertUV?: boolean;
  59666. uvs?: Vector2[];
  59667. colors?: Color4[];
  59668. }, scene?: Nullable<Scene>): Mesh;
  59669. }
  59670. }
  59671. declare module BABYLON {
  59672. /**
  59673. * Class containing static functions to help procedurally build meshes
  59674. */
  59675. export class ShapeBuilder {
  59676. /**
  59677. * 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.
  59678. * * 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.
  59679. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59680. * * 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.
  59681. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59682. * * 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
  59683. * * 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
  59684. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59686. * * 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
  59687. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59689. * @param name defines the name of the mesh
  59690. * @param options defines the options used to create the mesh
  59691. * @param scene defines the hosting scene
  59692. * @returns the extruded shape mesh
  59693. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59694. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59695. */
  59696. static ExtrudeShape(name: string, options: {
  59697. shape: Vector3[];
  59698. path: Vector3[];
  59699. scale?: number;
  59700. rotation?: number;
  59701. cap?: number;
  59702. updatable?: boolean;
  59703. sideOrientation?: number;
  59704. frontUVs?: Vector4;
  59705. backUVs?: Vector4;
  59706. instance?: Mesh;
  59707. invertUV?: boolean;
  59708. }, scene?: Nullable<Scene>): Mesh;
  59709. /**
  59710. * Creates an custom extruded shape mesh.
  59711. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59712. * * 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.
  59713. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59714. * * 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
  59715. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59716. * * 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
  59717. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59718. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59719. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59720. * * 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
  59721. * * 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
  59722. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59724. * * 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
  59725. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59727. * @param name defines the name of the mesh
  59728. * @param options defines the options used to create the mesh
  59729. * @param scene defines the hosting scene
  59730. * @returns the custom extruded shape mesh
  59731. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59732. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59734. */
  59735. static ExtrudeShapeCustom(name: string, options: {
  59736. shape: Vector3[];
  59737. path: Vector3[];
  59738. scaleFunction?: any;
  59739. rotationFunction?: any;
  59740. ribbonCloseArray?: boolean;
  59741. ribbonClosePath?: boolean;
  59742. cap?: number;
  59743. updatable?: boolean;
  59744. sideOrientation?: number;
  59745. frontUVs?: Vector4;
  59746. backUVs?: Vector4;
  59747. instance?: Mesh;
  59748. invertUV?: boolean;
  59749. }, scene?: Nullable<Scene>): Mesh;
  59750. private static _ExtrudeShapeGeneric;
  59751. }
  59752. }
  59753. declare module BABYLON {
  59754. /**
  59755. * AmmoJS Physics plugin
  59756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59757. * @see https://github.com/kripken/ammo.js/
  59758. */
  59759. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  59760. private _useDeltaForWorldStep;
  59761. /**
  59762. * Reference to the Ammo library
  59763. */
  59764. bjsAMMO: any;
  59765. /**
  59766. * Created ammoJS world which physics bodies are added to
  59767. */
  59768. world: any;
  59769. /**
  59770. * Name of the plugin
  59771. */
  59772. name: string;
  59773. private _timeStep;
  59774. private _fixedTimeStep;
  59775. private _maxSteps;
  59776. private _tmpQuaternion;
  59777. private _tmpAmmoTransform;
  59778. private _tmpAmmoQuaternion;
  59779. private _tmpAmmoConcreteContactResultCallback;
  59780. private _collisionConfiguration;
  59781. private _dispatcher;
  59782. private _overlappingPairCache;
  59783. private _solver;
  59784. private _softBodySolver;
  59785. private _tmpAmmoVectorA;
  59786. private _tmpAmmoVectorB;
  59787. private _tmpAmmoVectorC;
  59788. private _tmpAmmoVectorD;
  59789. private _tmpContactCallbackResult;
  59790. private _tmpAmmoVectorRCA;
  59791. private _tmpAmmoVectorRCB;
  59792. private _raycastResult;
  59793. private static readonly DISABLE_COLLISION_FLAG;
  59794. private static readonly KINEMATIC_FLAG;
  59795. private static readonly DISABLE_DEACTIVATION_FLAG;
  59796. /**
  59797. * Initializes the ammoJS plugin
  59798. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  59799. * @param ammoInjection can be used to inject your own ammo reference
  59800. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  59801. */
  59802. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  59803. /**
  59804. * Sets the gravity of the physics world (m/(s^2))
  59805. * @param gravity Gravity to set
  59806. */
  59807. setGravity(gravity: Vector3): void;
  59808. /**
  59809. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  59810. * @param timeStep timestep to use in seconds
  59811. */
  59812. setTimeStep(timeStep: number): void;
  59813. /**
  59814. * 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)
  59815. * @param fixedTimeStep fixedTimeStep to use in seconds
  59816. */
  59817. setFixedTimeStep(fixedTimeStep: number): void;
  59818. /**
  59819. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  59820. * @param maxSteps the maximum number of steps by the physics engine per frame
  59821. */
  59822. setMaxSteps(maxSteps: number): void;
  59823. /**
  59824. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  59825. * @returns the current timestep in seconds
  59826. */
  59827. getTimeStep(): number;
  59828. /**
  59829. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  59830. */
  59831. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  59832. private _isImpostorInContact;
  59833. private _isImpostorPairInContact;
  59834. private _stepSimulation;
  59835. /**
  59836. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  59837. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  59838. * After the step the babylon meshes are set to the position of the physics imposters
  59839. * @param delta amount of time to step forward
  59840. * @param impostors array of imposters to update before/after the step
  59841. */
  59842. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59843. /**
  59844. * Update babylon mesh to match physics world object
  59845. * @param impostor imposter to match
  59846. */
  59847. private _afterSoftStep;
  59848. /**
  59849. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59850. * @param impostor imposter to match
  59851. */
  59852. private _ropeStep;
  59853. /**
  59854. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  59855. * @param impostor imposter to match
  59856. */
  59857. private _softbodyOrClothStep;
  59858. private _tmpMatrix;
  59859. /**
  59860. * Applies an impulse on the imposter
  59861. * @param impostor imposter to apply impulse to
  59862. * @param force amount of force to be applied to the imposter
  59863. * @param contactPoint the location to apply the impulse on the imposter
  59864. */
  59865. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59866. /**
  59867. * Applies a force on the imposter
  59868. * @param impostor imposter to apply force
  59869. * @param force amount of force to be applied to the imposter
  59870. * @param contactPoint the location to apply the force on the imposter
  59871. */
  59872. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59873. /**
  59874. * Creates a physics body using the plugin
  59875. * @param impostor the imposter to create the physics body on
  59876. */
  59877. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59878. /**
  59879. * Removes the physics body from the imposter and disposes of the body's memory
  59880. * @param impostor imposter to remove the physics body from
  59881. */
  59882. removePhysicsBody(impostor: PhysicsImpostor): void;
  59883. /**
  59884. * Generates a joint
  59885. * @param impostorJoint the imposter joint to create the joint with
  59886. */
  59887. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59888. /**
  59889. * Removes a joint
  59890. * @param impostorJoint the imposter joint to remove the joint from
  59891. */
  59892. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59893. private _addMeshVerts;
  59894. /**
  59895. * Initialise the soft body vertices to match its object's (mesh) vertices
  59896. * Softbody vertices (nodes) are in world space and to match this
  59897. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  59898. * @param impostor to create the softbody for
  59899. */
  59900. private _softVertexData;
  59901. /**
  59902. * Create an impostor's soft body
  59903. * @param impostor to create the softbody for
  59904. */
  59905. private _createSoftbody;
  59906. /**
  59907. * Create cloth for an impostor
  59908. * @param impostor to create the softbody for
  59909. */
  59910. private _createCloth;
  59911. /**
  59912. * Create rope for an impostor
  59913. * @param impostor to create the softbody for
  59914. */
  59915. private _createRope;
  59916. /**
  59917. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  59918. * @param impostor to create the custom physics shape for
  59919. */
  59920. private _createCustom;
  59921. private _addHullVerts;
  59922. private _createShape;
  59923. /**
  59924. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  59925. * @param impostor imposter containing the physics body and babylon object
  59926. */
  59927. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59928. /**
  59929. * Sets the babylon object's position/rotation from the physics body's position/rotation
  59930. * @param impostor imposter containing the physics body and babylon object
  59931. * @param newPosition new position
  59932. * @param newRotation new rotation
  59933. */
  59934. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59935. /**
  59936. * If this plugin is supported
  59937. * @returns true if its supported
  59938. */
  59939. isSupported(): boolean;
  59940. /**
  59941. * Sets the linear velocity of the physics body
  59942. * @param impostor imposter to set the velocity on
  59943. * @param velocity velocity to set
  59944. */
  59945. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59946. /**
  59947. * Sets the angular velocity of the physics body
  59948. * @param impostor imposter to set the velocity on
  59949. * @param velocity velocity to set
  59950. */
  59951. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  59952. /**
  59953. * gets the linear velocity
  59954. * @param impostor imposter to get linear velocity from
  59955. * @returns linear velocity
  59956. */
  59957. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59958. /**
  59959. * gets the angular velocity
  59960. * @param impostor imposter to get angular velocity from
  59961. * @returns angular velocity
  59962. */
  59963. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  59964. /**
  59965. * Sets the mass of physics body
  59966. * @param impostor imposter to set the mass on
  59967. * @param mass mass to set
  59968. */
  59969. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  59970. /**
  59971. * Gets the mass of the physics body
  59972. * @param impostor imposter to get the mass from
  59973. * @returns mass
  59974. */
  59975. getBodyMass(impostor: PhysicsImpostor): number;
  59976. /**
  59977. * Gets friction of the impostor
  59978. * @param impostor impostor to get friction from
  59979. * @returns friction value
  59980. */
  59981. getBodyFriction(impostor: PhysicsImpostor): number;
  59982. /**
  59983. * Sets friction of the impostor
  59984. * @param impostor impostor to set friction on
  59985. * @param friction friction value
  59986. */
  59987. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  59988. /**
  59989. * Gets restitution of the impostor
  59990. * @param impostor impostor to get restitution from
  59991. * @returns restitution value
  59992. */
  59993. getBodyRestitution(impostor: PhysicsImpostor): number;
  59994. /**
  59995. * Sets resitution of the impostor
  59996. * @param impostor impostor to set resitution on
  59997. * @param restitution resitution value
  59998. */
  59999. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60000. /**
  60001. * Gets pressure inside the impostor
  60002. * @param impostor impostor to get pressure from
  60003. * @returns pressure value
  60004. */
  60005. getBodyPressure(impostor: PhysicsImpostor): number;
  60006. /**
  60007. * Sets pressure inside a soft body impostor
  60008. * Cloth and rope must remain 0 pressure
  60009. * @param impostor impostor to set pressure on
  60010. * @param pressure pressure value
  60011. */
  60012. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60013. /**
  60014. * Gets stiffness of the impostor
  60015. * @param impostor impostor to get stiffness from
  60016. * @returns pressure value
  60017. */
  60018. getBodyStiffness(impostor: PhysicsImpostor): number;
  60019. /**
  60020. * Sets stiffness of the impostor
  60021. * @param impostor impostor to set stiffness on
  60022. * @param stiffness stiffness value from 0 to 1
  60023. */
  60024. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60025. /**
  60026. * Gets velocityIterations of the impostor
  60027. * @param impostor impostor to get velocity iterations from
  60028. * @returns velocityIterations value
  60029. */
  60030. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60031. /**
  60032. * Sets velocityIterations of the impostor
  60033. * @param impostor impostor to set velocity iterations on
  60034. * @param velocityIterations velocityIterations value
  60035. */
  60036. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60037. /**
  60038. * Gets positionIterations of the impostor
  60039. * @param impostor impostor to get position iterations from
  60040. * @returns positionIterations value
  60041. */
  60042. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60043. /**
  60044. * Sets positionIterations of the impostor
  60045. * @param impostor impostor to set position on
  60046. * @param positionIterations positionIterations value
  60047. */
  60048. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60049. /**
  60050. * Append an anchor to a cloth object
  60051. * @param impostor is the cloth impostor to add anchor to
  60052. * @param otherImpostor is the rigid impostor to anchor to
  60053. * @param width ratio across width from 0 to 1
  60054. * @param height ratio up height from 0 to 1
  60055. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60056. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60057. */
  60058. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60059. /**
  60060. * Append an hook to a rope object
  60061. * @param impostor is the rope impostor to add hook to
  60062. * @param otherImpostor is the rigid impostor to hook to
  60063. * @param length ratio along the rope from 0 to 1
  60064. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60065. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60066. */
  60067. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60068. /**
  60069. * Sleeps the physics body and stops it from being active
  60070. * @param impostor impostor to sleep
  60071. */
  60072. sleepBody(impostor: PhysicsImpostor): void;
  60073. /**
  60074. * Activates the physics body
  60075. * @param impostor impostor to activate
  60076. */
  60077. wakeUpBody(impostor: PhysicsImpostor): void;
  60078. /**
  60079. * Updates the distance parameters of the joint
  60080. * @param joint joint to update
  60081. * @param maxDistance maximum distance of the joint
  60082. * @param minDistance minimum distance of the joint
  60083. */
  60084. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60085. /**
  60086. * Sets a motor on the joint
  60087. * @param joint joint to set motor on
  60088. * @param speed speed of the motor
  60089. * @param maxForce maximum force of the motor
  60090. * @param motorIndex index of the motor
  60091. */
  60092. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60093. /**
  60094. * Sets the motors limit
  60095. * @param joint joint to set limit on
  60096. * @param upperLimit upper limit
  60097. * @param lowerLimit lower limit
  60098. */
  60099. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60100. /**
  60101. * Syncs the position and rotation of a mesh with the impostor
  60102. * @param mesh mesh to sync
  60103. * @param impostor impostor to update the mesh with
  60104. */
  60105. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60106. /**
  60107. * Gets the radius of the impostor
  60108. * @param impostor impostor to get radius from
  60109. * @returns the radius
  60110. */
  60111. getRadius(impostor: PhysicsImpostor): number;
  60112. /**
  60113. * Gets the box size of the impostor
  60114. * @param impostor impostor to get box size from
  60115. * @param result the resulting box size
  60116. */
  60117. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60118. /**
  60119. * Disposes of the impostor
  60120. */
  60121. dispose(): void;
  60122. /**
  60123. * Does a raycast in the physics world
  60124. * @param from when should the ray start?
  60125. * @param to when should the ray end?
  60126. * @returns PhysicsRaycastResult
  60127. */
  60128. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60129. }
  60130. }
  60131. declare module BABYLON {
  60132. interface AbstractScene {
  60133. /**
  60134. * The list of reflection probes added to the scene
  60135. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60136. */
  60137. reflectionProbes: Array<ReflectionProbe>;
  60138. /**
  60139. * Removes the given reflection probe from this scene.
  60140. * @param toRemove The reflection probe to remove
  60141. * @returns The index of the removed reflection probe
  60142. */
  60143. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60144. /**
  60145. * Adds the given reflection probe to this scene.
  60146. * @param newReflectionProbe The reflection probe to add
  60147. */
  60148. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60149. }
  60150. /**
  60151. * Class used to generate realtime reflection / refraction cube textures
  60152. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60153. */
  60154. export class ReflectionProbe {
  60155. /** defines the name of the probe */
  60156. name: string;
  60157. private _scene;
  60158. private _renderTargetTexture;
  60159. private _projectionMatrix;
  60160. private _viewMatrix;
  60161. private _target;
  60162. private _add;
  60163. private _attachedMesh;
  60164. private _invertYAxis;
  60165. /** Gets or sets probe position (center of the cube map) */
  60166. position: Vector3;
  60167. /**
  60168. * Creates a new reflection probe
  60169. * @param name defines the name of the probe
  60170. * @param size defines the texture resolution (for each face)
  60171. * @param scene defines the hosting scene
  60172. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60173. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60174. */
  60175. constructor(
  60176. /** defines the name of the probe */
  60177. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60178. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60179. get samples(): number;
  60180. set samples(value: number);
  60181. /** Gets or sets the refresh rate to use (on every frame by default) */
  60182. get refreshRate(): number;
  60183. set refreshRate(value: number);
  60184. /**
  60185. * Gets the hosting scene
  60186. * @returns a Scene
  60187. */
  60188. getScene(): Scene;
  60189. /** Gets the internal CubeTexture used to render to */
  60190. get cubeTexture(): RenderTargetTexture;
  60191. /** Gets the list of meshes to render */
  60192. get renderList(): Nullable<AbstractMesh[]>;
  60193. /**
  60194. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60195. * @param mesh defines the mesh to attach to
  60196. */
  60197. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60198. /**
  60199. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60200. * @param renderingGroupId The rendering group id corresponding to its index
  60201. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60202. */
  60203. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60204. /**
  60205. * Clean all associated resources
  60206. */
  60207. dispose(): void;
  60208. /**
  60209. * Converts the reflection probe information to a readable string for debug purpose.
  60210. * @param fullDetails Supports for multiple levels of logging within scene loading
  60211. * @returns the human readable reflection probe info
  60212. */
  60213. toString(fullDetails?: boolean): string;
  60214. /**
  60215. * Get the class name of the relfection probe.
  60216. * @returns "ReflectionProbe"
  60217. */
  60218. getClassName(): string;
  60219. /**
  60220. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60221. * @returns The JSON representation of the texture
  60222. */
  60223. serialize(): any;
  60224. /**
  60225. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60226. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60227. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60228. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60229. * @returns The parsed reflection probe if successful
  60230. */
  60231. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60232. }
  60233. }
  60234. declare module BABYLON {
  60235. /** @hidden */
  60236. export var _BabylonLoaderRegistered: boolean;
  60237. /**
  60238. * Helps setting up some configuration for the babylon file loader.
  60239. */
  60240. export class BabylonFileLoaderConfiguration {
  60241. /**
  60242. * The loader does not allow injecting custom physix engine into the plugins.
  60243. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60244. * So you could set this variable to your engine import to make it work.
  60245. */
  60246. static LoaderInjectedPhysicsEngine: any;
  60247. }
  60248. }
  60249. declare module BABYLON {
  60250. /**
  60251. * The Physically based simple base material of BJS.
  60252. *
  60253. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60254. * It is used as the base class for both the specGloss and metalRough conventions.
  60255. */
  60256. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60257. /**
  60258. * Number of Simultaneous lights allowed on the material.
  60259. */
  60260. maxSimultaneousLights: number;
  60261. /**
  60262. * If sets to true, disables all the lights affecting the material.
  60263. */
  60264. disableLighting: boolean;
  60265. /**
  60266. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60267. */
  60268. environmentTexture: BaseTexture;
  60269. /**
  60270. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60271. */
  60272. invertNormalMapX: boolean;
  60273. /**
  60274. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60275. */
  60276. invertNormalMapY: boolean;
  60277. /**
  60278. * Normal map used in the model.
  60279. */
  60280. normalTexture: BaseTexture;
  60281. /**
  60282. * Emissivie color used to self-illuminate the model.
  60283. */
  60284. emissiveColor: Color3;
  60285. /**
  60286. * Emissivie texture used to self-illuminate the model.
  60287. */
  60288. emissiveTexture: BaseTexture;
  60289. /**
  60290. * Occlusion Channel Strenght.
  60291. */
  60292. occlusionStrength: number;
  60293. /**
  60294. * Occlusion Texture of the material (adding extra occlusion effects).
  60295. */
  60296. occlusionTexture: BaseTexture;
  60297. /**
  60298. * Defines the alpha limits in alpha test mode.
  60299. */
  60300. alphaCutOff: number;
  60301. /**
  60302. * Gets the current double sided mode.
  60303. */
  60304. get doubleSided(): boolean;
  60305. /**
  60306. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60307. */
  60308. set doubleSided(value: boolean);
  60309. /**
  60310. * Stores the pre-calculated light information of a mesh in a texture.
  60311. */
  60312. lightmapTexture: BaseTexture;
  60313. /**
  60314. * If true, the light map contains occlusion information instead of lighting info.
  60315. */
  60316. useLightmapAsShadowmap: boolean;
  60317. /**
  60318. * Instantiates a new PBRMaterial instance.
  60319. *
  60320. * @param name The material name
  60321. * @param scene The scene the material will be use in.
  60322. */
  60323. constructor(name: string, scene: Scene);
  60324. getClassName(): string;
  60325. }
  60326. }
  60327. declare module BABYLON {
  60328. /**
  60329. * The PBR material of BJS following the metal roughness convention.
  60330. *
  60331. * This fits to the PBR convention in the GLTF definition:
  60332. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60333. */
  60334. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60335. /**
  60336. * The base color has two different interpretations depending on the value of metalness.
  60337. * When the material is a metal, the base color is the specific measured reflectance value
  60338. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60339. * of the material.
  60340. */
  60341. baseColor: Color3;
  60342. /**
  60343. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60344. * well as opacity information in the alpha channel.
  60345. */
  60346. baseTexture: BaseTexture;
  60347. /**
  60348. * Specifies the metallic scalar value of the material.
  60349. * Can also be used to scale the metalness values of the metallic texture.
  60350. */
  60351. metallic: number;
  60352. /**
  60353. * Specifies the roughness scalar value of the material.
  60354. * Can also be used to scale the roughness values of the metallic texture.
  60355. */
  60356. roughness: number;
  60357. /**
  60358. * Texture containing both the metallic value in the B channel and the
  60359. * roughness value in the G channel to keep better precision.
  60360. */
  60361. metallicRoughnessTexture: BaseTexture;
  60362. /**
  60363. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60364. *
  60365. * @param name The material name
  60366. * @param scene The scene the material will be use in.
  60367. */
  60368. constructor(name: string, scene: Scene);
  60369. /**
  60370. * Return the currrent class name of the material.
  60371. */
  60372. getClassName(): string;
  60373. /**
  60374. * Makes a duplicate of the current material.
  60375. * @param name - name to use for the new material.
  60376. */
  60377. clone(name: string): PBRMetallicRoughnessMaterial;
  60378. /**
  60379. * Serialize the material to a parsable JSON object.
  60380. */
  60381. serialize(): any;
  60382. /**
  60383. * Parses a JSON object correponding to the serialize function.
  60384. */
  60385. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60386. }
  60387. }
  60388. declare module BABYLON {
  60389. /**
  60390. * The PBR material of BJS following the specular glossiness convention.
  60391. *
  60392. * This fits to the PBR convention in the GLTF definition:
  60393. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60394. */
  60395. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60396. /**
  60397. * Specifies the diffuse color of the material.
  60398. */
  60399. diffuseColor: Color3;
  60400. /**
  60401. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60402. * channel.
  60403. */
  60404. diffuseTexture: BaseTexture;
  60405. /**
  60406. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60407. */
  60408. specularColor: Color3;
  60409. /**
  60410. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60411. */
  60412. glossiness: number;
  60413. /**
  60414. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60415. */
  60416. specularGlossinessTexture: BaseTexture;
  60417. /**
  60418. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60419. *
  60420. * @param name The material name
  60421. * @param scene The scene the material will be use in.
  60422. */
  60423. constructor(name: string, scene: Scene);
  60424. /**
  60425. * Return the currrent class name of the material.
  60426. */
  60427. getClassName(): string;
  60428. /**
  60429. * Makes a duplicate of the current material.
  60430. * @param name - name to use for the new material.
  60431. */
  60432. clone(name: string): PBRSpecularGlossinessMaterial;
  60433. /**
  60434. * Serialize the material to a parsable JSON object.
  60435. */
  60436. serialize(): any;
  60437. /**
  60438. * Parses a JSON object correponding to the serialize function.
  60439. */
  60440. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60441. }
  60442. }
  60443. declare module BABYLON {
  60444. /**
  60445. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60446. * It can help converting any input color in a desired output one. This can then be used to create effects
  60447. * from sepia, black and white to sixties or futuristic rendering...
  60448. *
  60449. * The only supported format is currently 3dl.
  60450. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60451. */
  60452. export class ColorGradingTexture extends BaseTexture {
  60453. /**
  60454. * The texture URL.
  60455. */
  60456. url: string;
  60457. /**
  60458. * Empty line regex stored for GC.
  60459. */
  60460. private static _noneEmptyLineRegex;
  60461. private _textureMatrix;
  60462. private _onLoad;
  60463. /**
  60464. * Instantiates a ColorGradingTexture from the following parameters.
  60465. *
  60466. * @param url The location of the color gradind data (currently only supporting 3dl)
  60467. * @param sceneOrEngine The scene or engine the texture will be used in
  60468. * @param onLoad defines a callback triggered when the texture has been loaded
  60469. */
  60470. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60471. /**
  60472. * Fires the onload event from the constructor if requested.
  60473. */
  60474. private _triggerOnLoad;
  60475. /**
  60476. * Returns the texture matrix used in most of the material.
  60477. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60478. */
  60479. getTextureMatrix(): Matrix;
  60480. /**
  60481. * Occurs when the file being loaded is a .3dl LUT file.
  60482. */
  60483. private load3dlTexture;
  60484. /**
  60485. * Starts the loading process of the texture.
  60486. */
  60487. private loadTexture;
  60488. /**
  60489. * Clones the color gradind texture.
  60490. */
  60491. clone(): ColorGradingTexture;
  60492. /**
  60493. * Called during delayed load for textures.
  60494. */
  60495. delayLoad(): void;
  60496. /**
  60497. * Parses a color grading texture serialized by Babylon.
  60498. * @param parsedTexture The texture information being parsedTexture
  60499. * @param scene The scene to load the texture in
  60500. * @param rootUrl The root url of the data assets to load
  60501. * @return A color gradind texture
  60502. */
  60503. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60504. /**
  60505. * Serializes the LUT texture to json format.
  60506. */
  60507. serialize(): any;
  60508. }
  60509. }
  60510. declare module BABYLON {
  60511. /**
  60512. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60513. */
  60514. export class EquiRectangularCubeTexture extends BaseTexture {
  60515. /** The six faces of the cube. */
  60516. private static _FacesMapping;
  60517. private _noMipmap;
  60518. private _onLoad;
  60519. private _onError;
  60520. /** The size of the cubemap. */
  60521. private _size;
  60522. /** The buffer of the image. */
  60523. private _buffer;
  60524. /** The width of the input image. */
  60525. private _width;
  60526. /** The height of the input image. */
  60527. private _height;
  60528. /** The URL to the image. */
  60529. url: string;
  60530. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60531. coordinatesMode: number;
  60532. /**
  60533. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60534. * @param url The location of the image
  60535. * @param scene The scene the texture will be used in
  60536. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60537. * @param noMipmap Forces to not generate the mipmap if true
  60538. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60539. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60540. * @param onLoad — defines a callback called when texture is loaded
  60541. * @param onError — defines a callback called if there is an error
  60542. */
  60543. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60544. /**
  60545. * Load the image data, by putting the image on a canvas and extracting its buffer.
  60546. */
  60547. private loadImage;
  60548. /**
  60549. * Convert the image buffer into a cubemap and create a CubeTexture.
  60550. */
  60551. private loadTexture;
  60552. /**
  60553. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  60554. * @param buffer The ArrayBuffer that should be converted.
  60555. * @returns The buffer as Float32Array.
  60556. */
  60557. private getFloat32ArrayFromArrayBuffer;
  60558. /**
  60559. * Get the current class name of the texture useful for serialization or dynamic coding.
  60560. * @returns "EquiRectangularCubeTexture"
  60561. */
  60562. getClassName(): string;
  60563. /**
  60564. * Create a clone of the current EquiRectangularCubeTexture and return it.
  60565. * @returns A clone of the current EquiRectangularCubeTexture.
  60566. */
  60567. clone(): EquiRectangularCubeTexture;
  60568. }
  60569. }
  60570. declare module BABYLON {
  60571. /**
  60572. * Defines the options related to the creation of an HtmlElementTexture
  60573. */
  60574. export interface IHtmlElementTextureOptions {
  60575. /**
  60576. * Defines wether mip maps should be created or not.
  60577. */
  60578. generateMipMaps?: boolean;
  60579. /**
  60580. * Defines the sampling mode of the texture.
  60581. */
  60582. samplingMode?: number;
  60583. /**
  60584. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  60585. */
  60586. engine: Nullable<ThinEngine>;
  60587. /**
  60588. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  60589. */
  60590. scene: Nullable<Scene>;
  60591. }
  60592. /**
  60593. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  60594. * To be as efficient as possible depending on your constraints nothing aside the first upload
  60595. * is automatically managed.
  60596. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  60597. * in your application.
  60598. *
  60599. * As the update is not automatic, you need to call them manually.
  60600. */
  60601. export class HtmlElementTexture extends BaseTexture {
  60602. /**
  60603. * The texture URL.
  60604. */
  60605. element: HTMLVideoElement | HTMLCanvasElement;
  60606. private static readonly DefaultOptions;
  60607. private _textureMatrix;
  60608. private _isVideo;
  60609. private _generateMipMaps;
  60610. private _samplingMode;
  60611. /**
  60612. * Instantiates a HtmlElementTexture from the following parameters.
  60613. *
  60614. * @param name Defines the name of the texture
  60615. * @param element Defines the video or canvas the texture is filled with
  60616. * @param options Defines the other none mandatory texture creation options
  60617. */
  60618. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  60619. private _createInternalTexture;
  60620. /**
  60621. * Returns the texture matrix used in most of the material.
  60622. */
  60623. getTextureMatrix(): Matrix;
  60624. /**
  60625. * Updates the content of the texture.
  60626. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  60627. */
  60628. update(invertY?: Nullable<boolean>): void;
  60629. }
  60630. }
  60631. declare module BABYLON {
  60632. /**
  60633. * Based on jsTGALoader - Javascript loader for TGA file
  60634. * By Vincent Thibault
  60635. * @see http://blog.robrowser.com/javascript-tga-loader.html
  60636. */
  60637. export class TGATools {
  60638. private static _TYPE_INDEXED;
  60639. private static _TYPE_RGB;
  60640. private static _TYPE_GREY;
  60641. private static _TYPE_RLE_INDEXED;
  60642. private static _TYPE_RLE_RGB;
  60643. private static _TYPE_RLE_GREY;
  60644. private static _ORIGIN_MASK;
  60645. private static _ORIGIN_SHIFT;
  60646. private static _ORIGIN_BL;
  60647. private static _ORIGIN_BR;
  60648. private static _ORIGIN_UL;
  60649. private static _ORIGIN_UR;
  60650. /**
  60651. * Gets the header of a TGA file
  60652. * @param data defines the TGA data
  60653. * @returns the header
  60654. */
  60655. static GetTGAHeader(data: Uint8Array): any;
  60656. /**
  60657. * Uploads TGA content to a Babylon Texture
  60658. * @hidden
  60659. */
  60660. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  60661. /** @hidden */
  60662. 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;
  60663. /** @hidden */
  60664. 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;
  60665. /** @hidden */
  60666. 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;
  60667. /** @hidden */
  60668. 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;
  60669. /** @hidden */
  60670. 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;
  60671. /** @hidden */
  60672. 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;
  60673. }
  60674. }
  60675. declare module BABYLON {
  60676. /**
  60677. * Implementation of the TGA Texture Loader.
  60678. * @hidden
  60679. */
  60680. export class _TGATextureLoader implements IInternalTextureLoader {
  60681. /**
  60682. * Defines wether the loader supports cascade loading the different faces.
  60683. */
  60684. readonly supportCascades: boolean;
  60685. /**
  60686. * This returns if the loader support the current file information.
  60687. * @param extension defines the file extension of the file being loaded
  60688. * @returns true if the loader can load the specified file
  60689. */
  60690. canLoad(extension: string): boolean;
  60691. /**
  60692. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60693. * @param data contains the texture data
  60694. * @param texture defines the BabylonJS internal texture
  60695. * @param createPolynomials will be true if polynomials have been requested
  60696. * @param onLoad defines the callback to trigger once the texture is ready
  60697. * @param onError defines the callback to trigger in case of error
  60698. */
  60699. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60700. /**
  60701. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60702. * @param data contains the texture data
  60703. * @param texture defines the BabylonJS internal texture
  60704. * @param callback defines the method to call once ready to upload
  60705. */
  60706. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60707. }
  60708. }
  60709. declare module BABYLON {
  60710. /**
  60711. * Info about the .basis files
  60712. */
  60713. class BasisFileInfo {
  60714. /**
  60715. * If the file has alpha
  60716. */
  60717. hasAlpha: boolean;
  60718. /**
  60719. * Info about each image of the basis file
  60720. */
  60721. images: Array<{
  60722. levels: Array<{
  60723. width: number;
  60724. height: number;
  60725. transcodedPixels: ArrayBufferView;
  60726. }>;
  60727. }>;
  60728. }
  60729. /**
  60730. * Result of transcoding a basis file
  60731. */
  60732. class TranscodeResult {
  60733. /**
  60734. * Info about the .basis file
  60735. */
  60736. fileInfo: BasisFileInfo;
  60737. /**
  60738. * Format to use when loading the file
  60739. */
  60740. format: number;
  60741. }
  60742. /**
  60743. * Configuration options for the Basis transcoder
  60744. */
  60745. export class BasisTranscodeConfiguration {
  60746. /**
  60747. * Supported compression formats used to determine the supported output format of the transcoder
  60748. */
  60749. supportedCompressionFormats?: {
  60750. /**
  60751. * etc1 compression format
  60752. */
  60753. etc1?: boolean;
  60754. /**
  60755. * s3tc compression format
  60756. */
  60757. s3tc?: boolean;
  60758. /**
  60759. * pvrtc compression format
  60760. */
  60761. pvrtc?: boolean;
  60762. /**
  60763. * etc2 compression format
  60764. */
  60765. etc2?: boolean;
  60766. };
  60767. /**
  60768. * If mipmap levels should be loaded for transcoded images (Default: true)
  60769. */
  60770. loadMipmapLevels?: boolean;
  60771. /**
  60772. * Index of a single image to load (Default: all images)
  60773. */
  60774. loadSingleImage?: number;
  60775. }
  60776. /**
  60777. * Used to load .Basis files
  60778. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  60779. */
  60780. export class BasisTools {
  60781. private static _IgnoreSupportedFormats;
  60782. /**
  60783. * URL to use when loading the basis transcoder
  60784. */
  60785. static JSModuleURL: string;
  60786. /**
  60787. * URL to use when loading the wasm module for the transcoder
  60788. */
  60789. static WasmModuleURL: string;
  60790. /**
  60791. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  60792. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  60793. * @returns internal format corresponding to the Basis format
  60794. */
  60795. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  60796. private static _WorkerPromise;
  60797. private static _Worker;
  60798. private static _actionId;
  60799. private static _CreateWorkerAsync;
  60800. /**
  60801. * Transcodes a loaded image file to compressed pixel data
  60802. * @param data image data to transcode
  60803. * @param config configuration options for the transcoding
  60804. * @returns a promise resulting in the transcoded image
  60805. */
  60806. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  60807. /**
  60808. * Loads a texture from the transcode result
  60809. * @param texture texture load to
  60810. * @param transcodeResult the result of transcoding the basis file to load from
  60811. */
  60812. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  60813. }
  60814. }
  60815. declare module BABYLON {
  60816. /**
  60817. * Loader for .basis file format
  60818. */
  60819. export class _BasisTextureLoader implements IInternalTextureLoader {
  60820. /**
  60821. * Defines whether the loader supports cascade loading the different faces.
  60822. */
  60823. readonly supportCascades: boolean;
  60824. /**
  60825. * This returns if the loader support the current file information.
  60826. * @param extension defines the file extension of the file being loaded
  60827. * @returns true if the loader can load the specified file
  60828. */
  60829. canLoad(extension: string): boolean;
  60830. /**
  60831. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60832. * @param data contains the texture data
  60833. * @param texture defines the BabylonJS internal texture
  60834. * @param createPolynomials will be true if polynomials have been requested
  60835. * @param onLoad defines the callback to trigger once the texture is ready
  60836. * @param onError defines the callback to trigger in case of error
  60837. */
  60838. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60839. /**
  60840. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60841. * @param data contains the texture data
  60842. * @param texture defines the BabylonJS internal texture
  60843. * @param callback defines the method to call once ready to upload
  60844. */
  60845. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60846. }
  60847. }
  60848. declare module BABYLON {
  60849. /**
  60850. * Defines the basic options interface of a TexturePacker Frame
  60851. */
  60852. export interface ITexturePackerFrame {
  60853. /**
  60854. * The frame ID
  60855. */
  60856. id: number;
  60857. /**
  60858. * The frames Scale
  60859. */
  60860. scale: Vector2;
  60861. /**
  60862. * The Frames offset
  60863. */
  60864. offset: Vector2;
  60865. }
  60866. /**
  60867. * This is a support class for frame Data on texture packer sets.
  60868. */
  60869. export class TexturePackerFrame implements ITexturePackerFrame {
  60870. /**
  60871. * The frame ID
  60872. */
  60873. id: number;
  60874. /**
  60875. * The frames Scale
  60876. */
  60877. scale: Vector2;
  60878. /**
  60879. * The Frames offset
  60880. */
  60881. offset: Vector2;
  60882. /**
  60883. * Initializes a texture package frame.
  60884. * @param id The numerical frame identifier
  60885. * @param scale Scalar Vector2 for UV frame
  60886. * @param offset Vector2 for the frame position in UV units.
  60887. * @returns TexturePackerFrame
  60888. */
  60889. constructor(id: number, scale: Vector2, offset: Vector2);
  60890. }
  60891. }
  60892. declare module BABYLON {
  60893. /**
  60894. * Defines the basic options interface of a TexturePacker
  60895. */
  60896. export interface ITexturePackerOptions {
  60897. /**
  60898. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  60899. */
  60900. map?: string[];
  60901. /**
  60902. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60903. */
  60904. uvsIn?: string;
  60905. /**
  60906. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  60907. */
  60908. uvsOut?: string;
  60909. /**
  60910. * number representing the layout style. Defaults to LAYOUT_STRIP
  60911. */
  60912. layout?: number;
  60913. /**
  60914. * number of columns if using custom column count layout(2). This defaults to 4.
  60915. */
  60916. colnum?: number;
  60917. /**
  60918. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  60919. */
  60920. updateInputMeshes?: boolean;
  60921. /**
  60922. * boolean flag to dispose all the source textures. Defaults to true.
  60923. */
  60924. disposeSources?: boolean;
  60925. /**
  60926. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  60927. */
  60928. fillBlanks?: boolean;
  60929. /**
  60930. * string value representing the context fill style color. Defaults to 'black'.
  60931. */
  60932. customFillColor?: string;
  60933. /**
  60934. * Width and Height Value of each Frame in the TexturePacker Sets
  60935. */
  60936. frameSize?: number;
  60937. /**
  60938. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  60939. */
  60940. paddingRatio?: number;
  60941. /**
  60942. * Number that declares the fill method for the padding gutter.
  60943. */
  60944. paddingMode?: number;
  60945. /**
  60946. * If in SUBUV_COLOR padding mode what color to use.
  60947. */
  60948. paddingColor?: Color3 | Color4;
  60949. }
  60950. /**
  60951. * Defines the basic interface of a TexturePacker JSON File
  60952. */
  60953. export interface ITexturePackerJSON {
  60954. /**
  60955. * The frame ID
  60956. */
  60957. name: string;
  60958. /**
  60959. * The base64 channel data
  60960. */
  60961. sets: any;
  60962. /**
  60963. * The options of the Packer
  60964. */
  60965. options: ITexturePackerOptions;
  60966. /**
  60967. * The frame data of the Packer
  60968. */
  60969. frames: Array<number>;
  60970. }
  60971. /**
  60972. * This is a support class that generates a series of packed texture sets.
  60973. * @see https://doc.babylonjs.com/babylon101/materials
  60974. */
  60975. export class TexturePacker {
  60976. /** Packer Layout Constant 0 */
  60977. static readonly LAYOUT_STRIP: number;
  60978. /** Packer Layout Constant 1 */
  60979. static readonly LAYOUT_POWER2: number;
  60980. /** Packer Layout Constant 2 */
  60981. static readonly LAYOUT_COLNUM: number;
  60982. /** Packer Layout Constant 0 */
  60983. static readonly SUBUV_WRAP: number;
  60984. /** Packer Layout Constant 1 */
  60985. static readonly SUBUV_EXTEND: number;
  60986. /** Packer Layout Constant 2 */
  60987. static readonly SUBUV_COLOR: number;
  60988. /** The Name of the Texture Package */
  60989. name: string;
  60990. /** The scene scope of the TexturePacker */
  60991. scene: Scene;
  60992. /** The Meshes to target */
  60993. meshes: AbstractMesh[];
  60994. /** Arguments passed with the Constructor */
  60995. options: ITexturePackerOptions;
  60996. /** The promise that is started upon initialization */
  60997. promise: Nullable<Promise<TexturePacker | string>>;
  60998. /** The Container object for the channel sets that are generated */
  60999. sets: object;
  61000. /** The Container array for the frames that are generated */
  61001. frames: TexturePackerFrame[];
  61002. /** The expected number of textures the system is parsing. */
  61003. private _expecting;
  61004. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61005. private _paddingValue;
  61006. /**
  61007. * Initializes a texture package series from an array of meshes or a single mesh.
  61008. * @param name The name of the package
  61009. * @param meshes The target meshes to compose the package from
  61010. * @param options The arguments that texture packer should follow while building.
  61011. * @param scene The scene which the textures are scoped to.
  61012. * @returns TexturePacker
  61013. */
  61014. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61015. /**
  61016. * Starts the package process
  61017. * @param resolve The promises resolution function
  61018. * @returns TexturePacker
  61019. */
  61020. private _createFrames;
  61021. /**
  61022. * Calculates the Size of the Channel Sets
  61023. * @returns Vector2
  61024. */
  61025. private _calculateSize;
  61026. /**
  61027. * Calculates the UV data for the frames.
  61028. * @param baseSize the base frameSize
  61029. * @param padding the base frame padding
  61030. * @param dtSize size of the Dynamic Texture for that channel
  61031. * @param dtUnits is 1/dtSize
  61032. * @param update flag to update the input meshes
  61033. */
  61034. private _calculateMeshUVFrames;
  61035. /**
  61036. * Calculates the frames Offset.
  61037. * @param index of the frame
  61038. * @returns Vector2
  61039. */
  61040. private _getFrameOffset;
  61041. /**
  61042. * Updates a Mesh to the frame data
  61043. * @param mesh that is the target
  61044. * @param frameID or the frame index
  61045. */
  61046. private _updateMeshUV;
  61047. /**
  61048. * Updates a Meshes materials to use the texture packer channels
  61049. * @param m is the mesh to target
  61050. * @param force all channels on the packer to be set.
  61051. */
  61052. private _updateTextureReferences;
  61053. /**
  61054. * Public method to set a Mesh to a frame
  61055. * @param m that is the target
  61056. * @param frameID or the frame index
  61057. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61058. */
  61059. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61060. /**
  61061. * Starts the async promise to compile the texture packer.
  61062. * @returns Promise<void>
  61063. */
  61064. processAsync(): Promise<void>;
  61065. /**
  61066. * Disposes all textures associated with this packer
  61067. */
  61068. dispose(): void;
  61069. /**
  61070. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61071. * @param imageType is the image type to use.
  61072. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61073. */
  61074. download(imageType?: string, quality?: number): void;
  61075. /**
  61076. * Public method to load a texturePacker JSON file.
  61077. * @param data of the JSON file in string format.
  61078. */
  61079. updateFromJSON(data: string): void;
  61080. }
  61081. }
  61082. declare module BABYLON {
  61083. /**
  61084. * 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.
  61085. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61086. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61087. */
  61088. export class CustomProceduralTexture extends ProceduralTexture {
  61089. private _animate;
  61090. private _time;
  61091. private _config;
  61092. private _texturePath;
  61093. /**
  61094. * Instantiates a new Custom Procedural Texture.
  61095. * 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.
  61096. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61097. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61098. * @param name Define the name of the texture
  61099. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61100. * @param size Define the size of the texture to create
  61101. * @param scene Define the scene the texture belongs to
  61102. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61103. * @param generateMipMaps Define if the texture should creates mip maps or not
  61104. */
  61105. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61106. private _loadJson;
  61107. /**
  61108. * Is the texture ready to be used ? (rendered at least once)
  61109. * @returns true if ready, otherwise, false.
  61110. */
  61111. isReady(): boolean;
  61112. /**
  61113. * Render the texture to its associated render target.
  61114. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61115. */
  61116. render(useCameraPostProcess?: boolean): void;
  61117. /**
  61118. * Update the list of dependant textures samplers in the shader.
  61119. */
  61120. updateTextures(): void;
  61121. /**
  61122. * Update the uniform values of the procedural texture in the shader.
  61123. */
  61124. updateShaderUniforms(): void;
  61125. /**
  61126. * Define if the texture animates or not.
  61127. */
  61128. get animate(): boolean;
  61129. set animate(value: boolean);
  61130. }
  61131. }
  61132. declare module BABYLON {
  61133. /** @hidden */
  61134. export var noisePixelShader: {
  61135. name: string;
  61136. shader: string;
  61137. };
  61138. }
  61139. declare module BABYLON {
  61140. /**
  61141. * Class used to generate noise procedural textures
  61142. */
  61143. export class NoiseProceduralTexture extends ProceduralTexture {
  61144. private _time;
  61145. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61146. brightness: number;
  61147. /** Defines the number of octaves to process */
  61148. octaves: number;
  61149. /** Defines the level of persistence (0.8 by default) */
  61150. persistence: number;
  61151. /** Gets or sets animation speed factor (default is 1) */
  61152. animationSpeedFactor: number;
  61153. /**
  61154. * Creates a new NoiseProceduralTexture
  61155. * @param name defines the name fo the texture
  61156. * @param size defines the size of the texture (default is 256)
  61157. * @param scene defines the hosting scene
  61158. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61159. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61160. */
  61161. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61162. private _updateShaderUniforms;
  61163. protected _getDefines(): string;
  61164. /** Generate the current state of the procedural texture */
  61165. render(useCameraPostProcess?: boolean): void;
  61166. /**
  61167. * Serializes this noise procedural texture
  61168. * @returns a serialized noise procedural texture object
  61169. */
  61170. serialize(): any;
  61171. /**
  61172. * Clone the texture.
  61173. * @returns the cloned texture
  61174. */
  61175. clone(): NoiseProceduralTexture;
  61176. /**
  61177. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61178. * @param parsedTexture defines parsed texture data
  61179. * @param scene defines the current scene
  61180. * @param rootUrl defines the root URL containing noise procedural texture information
  61181. * @returns a parsed NoiseProceduralTexture
  61182. */
  61183. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61184. }
  61185. }
  61186. declare module BABYLON {
  61187. /**
  61188. * Raw cube texture where the raw buffers are passed in
  61189. */
  61190. export class RawCubeTexture extends CubeTexture {
  61191. /**
  61192. * Creates a cube texture where the raw buffers are passed in.
  61193. * @param scene defines the scene the texture is attached to
  61194. * @param data defines the array of data to use to create each face
  61195. * @param size defines the size of the textures
  61196. * @param format defines the format of the data
  61197. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61198. * @param generateMipMaps defines if the engine should generate the mip levels
  61199. * @param invertY defines if data must be stored with Y axis inverted
  61200. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61201. * @param compression defines the compression used (null by default)
  61202. */
  61203. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61204. /**
  61205. * Updates the raw cube texture.
  61206. * @param data defines the data to store
  61207. * @param format defines the data format
  61208. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61209. * @param invertY defines if data must be stored with Y axis inverted
  61210. * @param compression defines the compression used (null by default)
  61211. * @param level defines which level of the texture to update
  61212. */
  61213. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61214. /**
  61215. * Updates a raw cube texture with RGBD encoded data.
  61216. * @param data defines the array of data [mipmap][face] to use to create each face
  61217. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61218. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61219. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61220. * @returns a promsie that resolves when the operation is complete
  61221. */
  61222. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61223. /**
  61224. * Clones the raw cube texture.
  61225. * @return a new cube texture
  61226. */
  61227. clone(): CubeTexture;
  61228. /** @hidden */
  61229. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61230. }
  61231. }
  61232. declare module BABYLON {
  61233. /**
  61234. * Class used to store 2D array textures containing user data
  61235. */
  61236. export class RawTexture2DArray extends Texture {
  61237. /** Gets or sets the texture format to use */
  61238. format: number;
  61239. /**
  61240. * Create a new RawTexture2DArray
  61241. * @param data defines the data of the texture
  61242. * @param width defines the width of the texture
  61243. * @param height defines the height of the texture
  61244. * @param depth defines the number of layers of the texture
  61245. * @param format defines the texture format to use
  61246. * @param scene defines the hosting scene
  61247. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61248. * @param invertY defines if texture must be stored with Y axis inverted
  61249. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61250. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61251. */
  61252. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61253. /** Gets or sets the texture format to use */
  61254. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61255. /**
  61256. * Update the texture with new data
  61257. * @param data defines the data to store in the texture
  61258. */
  61259. update(data: ArrayBufferView): void;
  61260. }
  61261. }
  61262. declare module BABYLON {
  61263. /**
  61264. * Class used to store 3D textures containing user data
  61265. */
  61266. export class RawTexture3D extends Texture {
  61267. /** Gets or sets the texture format to use */
  61268. format: number;
  61269. /**
  61270. * Create a new RawTexture3D
  61271. * @param data defines the data of the texture
  61272. * @param width defines the width of the texture
  61273. * @param height defines the height of the texture
  61274. * @param depth defines the depth of the texture
  61275. * @param format defines the texture format to use
  61276. * @param scene defines the hosting scene
  61277. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61278. * @param invertY defines if texture must be stored with Y axis inverted
  61279. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61280. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61281. */
  61282. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61283. /** Gets or sets the texture format to use */
  61284. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61285. /**
  61286. * Update the texture with new data
  61287. * @param data defines the data to store in the texture
  61288. */
  61289. update(data: ArrayBufferView): void;
  61290. }
  61291. }
  61292. declare module BABYLON {
  61293. /**
  61294. * Creates a refraction texture used by refraction channel of the standard material.
  61295. * It is like a mirror but to see through a material.
  61296. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61297. */
  61298. export class RefractionTexture extends RenderTargetTexture {
  61299. /**
  61300. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61301. * 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.
  61302. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61303. */
  61304. refractionPlane: Plane;
  61305. /**
  61306. * Define how deep under the surface we should see.
  61307. */
  61308. depth: number;
  61309. /**
  61310. * Creates a refraction texture used by refraction channel of the standard material.
  61311. * It is like a mirror but to see through a material.
  61312. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61313. * @param name Define the texture name
  61314. * @param size Define the size of the underlying texture
  61315. * @param scene Define the scene the refraction belongs to
  61316. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61317. */
  61318. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61319. /**
  61320. * Clone the refraction texture.
  61321. * @returns the cloned texture
  61322. */
  61323. clone(): RefractionTexture;
  61324. /**
  61325. * Serialize the texture to a JSON representation you could use in Parse later on
  61326. * @returns the serialized JSON representation
  61327. */
  61328. serialize(): any;
  61329. }
  61330. }
  61331. declare module BABYLON {
  61332. /**
  61333. * Block used to add support for vertex skinning (bones)
  61334. */
  61335. export class BonesBlock extends NodeMaterialBlock {
  61336. /**
  61337. * Creates a new BonesBlock
  61338. * @param name defines the block name
  61339. */
  61340. constructor(name: string);
  61341. /**
  61342. * Initialize the block and prepare the context for build
  61343. * @param state defines the state that will be used for the build
  61344. */
  61345. initialize(state: NodeMaterialBuildState): void;
  61346. /**
  61347. * Gets the current class name
  61348. * @returns the class name
  61349. */
  61350. getClassName(): string;
  61351. /**
  61352. * Gets the matrix indices input component
  61353. */
  61354. get matricesIndices(): NodeMaterialConnectionPoint;
  61355. /**
  61356. * Gets the matrix weights input component
  61357. */
  61358. get matricesWeights(): NodeMaterialConnectionPoint;
  61359. /**
  61360. * Gets the extra matrix indices input component
  61361. */
  61362. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61363. /**
  61364. * Gets the extra matrix weights input component
  61365. */
  61366. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61367. /**
  61368. * Gets the world input component
  61369. */
  61370. get world(): NodeMaterialConnectionPoint;
  61371. /**
  61372. * Gets the output component
  61373. */
  61374. get output(): NodeMaterialConnectionPoint;
  61375. autoConfigure(material: NodeMaterial): void;
  61376. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61377. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61378. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61379. protected _buildBlock(state: NodeMaterialBuildState): this;
  61380. }
  61381. }
  61382. declare module BABYLON {
  61383. /**
  61384. * Block used to add support for instances
  61385. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61386. */
  61387. export class InstancesBlock extends NodeMaterialBlock {
  61388. /**
  61389. * Creates a new InstancesBlock
  61390. * @param name defines the block name
  61391. */
  61392. constructor(name: string);
  61393. /**
  61394. * Gets the current class name
  61395. * @returns the class name
  61396. */
  61397. getClassName(): string;
  61398. /**
  61399. * Gets the first world row input component
  61400. */
  61401. get world0(): NodeMaterialConnectionPoint;
  61402. /**
  61403. * Gets the second world row input component
  61404. */
  61405. get world1(): NodeMaterialConnectionPoint;
  61406. /**
  61407. * Gets the third world row input component
  61408. */
  61409. get world2(): NodeMaterialConnectionPoint;
  61410. /**
  61411. * Gets the forth world row input component
  61412. */
  61413. get world3(): NodeMaterialConnectionPoint;
  61414. /**
  61415. * Gets the world input component
  61416. */
  61417. get world(): NodeMaterialConnectionPoint;
  61418. /**
  61419. * Gets the output component
  61420. */
  61421. get output(): NodeMaterialConnectionPoint;
  61422. /**
  61423. * Gets the isntanceID component
  61424. */
  61425. get instanceID(): NodeMaterialConnectionPoint;
  61426. autoConfigure(material: NodeMaterial): void;
  61427. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61428. protected _buildBlock(state: NodeMaterialBuildState): this;
  61429. }
  61430. }
  61431. declare module BABYLON {
  61432. /**
  61433. * Block used to add morph targets support to vertex shader
  61434. */
  61435. export class MorphTargetsBlock extends NodeMaterialBlock {
  61436. private _repeatableContentAnchor;
  61437. /**
  61438. * Create a new MorphTargetsBlock
  61439. * @param name defines the block name
  61440. */
  61441. constructor(name: string);
  61442. /**
  61443. * Gets the current class name
  61444. * @returns the class name
  61445. */
  61446. getClassName(): string;
  61447. /**
  61448. * Gets the position input component
  61449. */
  61450. get position(): NodeMaterialConnectionPoint;
  61451. /**
  61452. * Gets the normal input component
  61453. */
  61454. get normal(): NodeMaterialConnectionPoint;
  61455. /**
  61456. * Gets the tangent input component
  61457. */
  61458. get tangent(): NodeMaterialConnectionPoint;
  61459. /**
  61460. * Gets the tangent input component
  61461. */
  61462. get uv(): NodeMaterialConnectionPoint;
  61463. /**
  61464. * Gets the position output component
  61465. */
  61466. get positionOutput(): NodeMaterialConnectionPoint;
  61467. /**
  61468. * Gets the normal output component
  61469. */
  61470. get normalOutput(): NodeMaterialConnectionPoint;
  61471. /**
  61472. * Gets the tangent output component
  61473. */
  61474. get tangentOutput(): NodeMaterialConnectionPoint;
  61475. /**
  61476. * Gets the tangent output component
  61477. */
  61478. get uvOutput(): NodeMaterialConnectionPoint;
  61479. initialize(state: NodeMaterialBuildState): void;
  61480. autoConfigure(material: NodeMaterial): void;
  61481. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61482. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61483. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61484. protected _buildBlock(state: NodeMaterialBuildState): this;
  61485. }
  61486. }
  61487. declare module BABYLON {
  61488. /**
  61489. * Block used to get data information from a light
  61490. */
  61491. export class LightInformationBlock extends NodeMaterialBlock {
  61492. private _lightDataUniformName;
  61493. private _lightColorUniformName;
  61494. private _lightTypeDefineName;
  61495. /**
  61496. * Gets or sets the light associated with this block
  61497. */
  61498. light: Nullable<Light>;
  61499. /**
  61500. * Creates a new LightInformationBlock
  61501. * @param name defines the block name
  61502. */
  61503. constructor(name: string);
  61504. /**
  61505. * Gets the current class name
  61506. * @returns the class name
  61507. */
  61508. getClassName(): string;
  61509. /**
  61510. * Gets the world position input component
  61511. */
  61512. get worldPosition(): NodeMaterialConnectionPoint;
  61513. /**
  61514. * Gets the direction output component
  61515. */
  61516. get direction(): NodeMaterialConnectionPoint;
  61517. /**
  61518. * Gets the direction output component
  61519. */
  61520. get color(): NodeMaterialConnectionPoint;
  61521. /**
  61522. * Gets the direction output component
  61523. */
  61524. get intensity(): NodeMaterialConnectionPoint;
  61525. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61526. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61527. protected _buildBlock(state: NodeMaterialBuildState): this;
  61528. serialize(): any;
  61529. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61530. }
  61531. }
  61532. declare module BABYLON {
  61533. /**
  61534. * Block used to add image processing support to fragment shader
  61535. */
  61536. export class ImageProcessingBlock extends NodeMaterialBlock {
  61537. /**
  61538. * Create a new ImageProcessingBlock
  61539. * @param name defines the block name
  61540. */
  61541. constructor(name: string);
  61542. /**
  61543. * Gets the current class name
  61544. * @returns the class name
  61545. */
  61546. getClassName(): string;
  61547. /**
  61548. * Gets the color input component
  61549. */
  61550. get color(): NodeMaterialConnectionPoint;
  61551. /**
  61552. * Gets the output component
  61553. */
  61554. get output(): NodeMaterialConnectionPoint;
  61555. /**
  61556. * Initialize the block and prepare the context for build
  61557. * @param state defines the state that will be used for the build
  61558. */
  61559. initialize(state: NodeMaterialBuildState): void;
  61560. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61562. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61563. protected _buildBlock(state: NodeMaterialBuildState): this;
  61564. }
  61565. }
  61566. declare module BABYLON {
  61567. /**
  61568. * Block used to pertub normals based on a normal map
  61569. */
  61570. export class PerturbNormalBlock extends NodeMaterialBlock {
  61571. private _tangentSpaceParameterName;
  61572. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61573. invertX: boolean;
  61574. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61575. invertY: boolean;
  61576. /**
  61577. * Create a new PerturbNormalBlock
  61578. * @param name defines the block name
  61579. */
  61580. constructor(name: string);
  61581. /**
  61582. * Gets the current class name
  61583. * @returns the class name
  61584. */
  61585. getClassName(): string;
  61586. /**
  61587. * Gets the world position input component
  61588. */
  61589. get worldPosition(): NodeMaterialConnectionPoint;
  61590. /**
  61591. * Gets the world normal input component
  61592. */
  61593. get worldNormal(): NodeMaterialConnectionPoint;
  61594. /**
  61595. * Gets the world tangent input component
  61596. */
  61597. get worldTangent(): NodeMaterialConnectionPoint;
  61598. /**
  61599. * Gets the uv input component
  61600. */
  61601. get uv(): NodeMaterialConnectionPoint;
  61602. /**
  61603. * Gets the normal map color input component
  61604. */
  61605. get normalMapColor(): NodeMaterialConnectionPoint;
  61606. /**
  61607. * Gets the strength input component
  61608. */
  61609. get strength(): NodeMaterialConnectionPoint;
  61610. /**
  61611. * Gets the output component
  61612. */
  61613. get output(): NodeMaterialConnectionPoint;
  61614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61615. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61616. autoConfigure(material: NodeMaterial): void;
  61617. protected _buildBlock(state: NodeMaterialBuildState): this;
  61618. protected _dumpPropertiesCode(): string;
  61619. serialize(): any;
  61620. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61621. }
  61622. }
  61623. declare module BABYLON {
  61624. /**
  61625. * Block used to discard a pixel if a value is smaller than a cutoff
  61626. */
  61627. export class DiscardBlock extends NodeMaterialBlock {
  61628. /**
  61629. * Create a new DiscardBlock
  61630. * @param name defines the block name
  61631. */
  61632. constructor(name: string);
  61633. /**
  61634. * Gets the current class name
  61635. * @returns the class name
  61636. */
  61637. getClassName(): string;
  61638. /**
  61639. * Gets the color input component
  61640. */
  61641. get value(): NodeMaterialConnectionPoint;
  61642. /**
  61643. * Gets the cutoff input component
  61644. */
  61645. get cutoff(): NodeMaterialConnectionPoint;
  61646. protected _buildBlock(state: NodeMaterialBuildState): this;
  61647. }
  61648. }
  61649. declare module BABYLON {
  61650. /**
  61651. * Block used to test if the fragment shader is front facing
  61652. */
  61653. export class FrontFacingBlock extends NodeMaterialBlock {
  61654. /**
  61655. * Creates a new FrontFacingBlock
  61656. * @param name defines the block name
  61657. */
  61658. constructor(name: string);
  61659. /**
  61660. * Gets the current class name
  61661. * @returns the class name
  61662. */
  61663. getClassName(): string;
  61664. /**
  61665. * Gets the output component
  61666. */
  61667. get output(): NodeMaterialConnectionPoint;
  61668. protected _buildBlock(state: NodeMaterialBuildState): this;
  61669. }
  61670. }
  61671. declare module BABYLON {
  61672. /**
  61673. * Block used to get the derivative value on x and y of a given input
  61674. */
  61675. export class DerivativeBlock extends NodeMaterialBlock {
  61676. /**
  61677. * Create a new DerivativeBlock
  61678. * @param name defines the block name
  61679. */
  61680. constructor(name: string);
  61681. /**
  61682. * Gets the current class name
  61683. * @returns the class name
  61684. */
  61685. getClassName(): string;
  61686. /**
  61687. * Gets the input component
  61688. */
  61689. get input(): NodeMaterialConnectionPoint;
  61690. /**
  61691. * Gets the derivative output on x
  61692. */
  61693. get dx(): NodeMaterialConnectionPoint;
  61694. /**
  61695. * Gets the derivative output on y
  61696. */
  61697. get dy(): NodeMaterialConnectionPoint;
  61698. protected _buildBlock(state: NodeMaterialBuildState): this;
  61699. }
  61700. }
  61701. declare module BABYLON {
  61702. /**
  61703. * Block used to make gl_FragCoord available
  61704. */
  61705. export class FragCoordBlock extends NodeMaterialBlock {
  61706. /**
  61707. * Creates a new FragCoordBlock
  61708. * @param name defines the block name
  61709. */
  61710. constructor(name: string);
  61711. /**
  61712. * Gets the current class name
  61713. * @returns the class name
  61714. */
  61715. getClassName(): string;
  61716. /**
  61717. * Gets the xy component
  61718. */
  61719. get xy(): NodeMaterialConnectionPoint;
  61720. /**
  61721. * Gets the xyz component
  61722. */
  61723. get xyz(): NodeMaterialConnectionPoint;
  61724. /**
  61725. * Gets the xyzw component
  61726. */
  61727. get xyzw(): NodeMaterialConnectionPoint;
  61728. /**
  61729. * Gets the x component
  61730. */
  61731. get x(): NodeMaterialConnectionPoint;
  61732. /**
  61733. * Gets the y component
  61734. */
  61735. get y(): NodeMaterialConnectionPoint;
  61736. /**
  61737. * Gets the z component
  61738. */
  61739. get z(): NodeMaterialConnectionPoint;
  61740. /**
  61741. * Gets the w component
  61742. */
  61743. get output(): NodeMaterialConnectionPoint;
  61744. protected writeOutputs(state: NodeMaterialBuildState): string;
  61745. protected _buildBlock(state: NodeMaterialBuildState): this;
  61746. }
  61747. }
  61748. declare module BABYLON {
  61749. /**
  61750. * Block used to get the screen sizes
  61751. */
  61752. export class ScreenSizeBlock extends NodeMaterialBlock {
  61753. private _varName;
  61754. private _scene;
  61755. /**
  61756. * Creates a new ScreenSizeBlock
  61757. * @param name defines the block name
  61758. */
  61759. constructor(name: string);
  61760. /**
  61761. * Gets the current class name
  61762. * @returns the class name
  61763. */
  61764. getClassName(): string;
  61765. /**
  61766. * Gets the xy component
  61767. */
  61768. get xy(): NodeMaterialConnectionPoint;
  61769. /**
  61770. * Gets the x component
  61771. */
  61772. get x(): NodeMaterialConnectionPoint;
  61773. /**
  61774. * Gets the y component
  61775. */
  61776. get y(): NodeMaterialConnectionPoint;
  61777. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61778. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  61779. protected _buildBlock(state: NodeMaterialBuildState): this;
  61780. }
  61781. }
  61782. declare module BABYLON {
  61783. /**
  61784. * Block used to add support for scene fog
  61785. */
  61786. export class FogBlock extends NodeMaterialBlock {
  61787. private _fogDistanceName;
  61788. private _fogParameters;
  61789. /**
  61790. * Create a new FogBlock
  61791. * @param name defines the block name
  61792. */
  61793. constructor(name: string);
  61794. /**
  61795. * Gets the current class name
  61796. * @returns the class name
  61797. */
  61798. getClassName(): string;
  61799. /**
  61800. * Gets the world position input component
  61801. */
  61802. get worldPosition(): NodeMaterialConnectionPoint;
  61803. /**
  61804. * Gets the view input component
  61805. */
  61806. get view(): NodeMaterialConnectionPoint;
  61807. /**
  61808. * Gets the color input component
  61809. */
  61810. get input(): NodeMaterialConnectionPoint;
  61811. /**
  61812. * Gets the fog color input component
  61813. */
  61814. get fogColor(): NodeMaterialConnectionPoint;
  61815. /**
  61816. * Gets the output component
  61817. */
  61818. get output(): NodeMaterialConnectionPoint;
  61819. autoConfigure(material: NodeMaterial): void;
  61820. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61821. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61822. protected _buildBlock(state: NodeMaterialBuildState): this;
  61823. }
  61824. }
  61825. declare module BABYLON {
  61826. /**
  61827. * Block used to add light in the fragment shader
  61828. */
  61829. export class LightBlock extends NodeMaterialBlock {
  61830. private _lightId;
  61831. /**
  61832. * Gets or sets the light associated with this block
  61833. */
  61834. light: Nullable<Light>;
  61835. /**
  61836. * Create a new LightBlock
  61837. * @param name defines the block name
  61838. */
  61839. constructor(name: string);
  61840. /**
  61841. * Gets the current class name
  61842. * @returns the class name
  61843. */
  61844. getClassName(): string;
  61845. /**
  61846. * Gets the world position input component
  61847. */
  61848. get worldPosition(): NodeMaterialConnectionPoint;
  61849. /**
  61850. * Gets the world normal input component
  61851. */
  61852. get worldNormal(): NodeMaterialConnectionPoint;
  61853. /**
  61854. * Gets the camera (or eye) position component
  61855. */
  61856. get cameraPosition(): NodeMaterialConnectionPoint;
  61857. /**
  61858. * Gets the glossiness component
  61859. */
  61860. get glossiness(): NodeMaterialConnectionPoint;
  61861. /**
  61862. * Gets the glossinness power component
  61863. */
  61864. get glossPower(): NodeMaterialConnectionPoint;
  61865. /**
  61866. * Gets the diffuse color component
  61867. */
  61868. get diffuseColor(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the specular color component
  61871. */
  61872. get specularColor(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the diffuse output component
  61875. */
  61876. get diffuseOutput(): NodeMaterialConnectionPoint;
  61877. /**
  61878. * Gets the specular output component
  61879. */
  61880. get specularOutput(): NodeMaterialConnectionPoint;
  61881. /**
  61882. * Gets the shadow output component
  61883. */
  61884. get shadow(): NodeMaterialConnectionPoint;
  61885. autoConfigure(material: NodeMaterial): void;
  61886. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61887. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61888. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61889. private _injectVertexCode;
  61890. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61891. serialize(): any;
  61892. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61893. }
  61894. }
  61895. declare module BABYLON {
  61896. /**
  61897. * Block used to read a reflection texture from a sampler
  61898. */
  61899. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  61900. /**
  61901. * Create a new ReflectionTextureBlock
  61902. * @param name defines the block name
  61903. */
  61904. constructor(name: string);
  61905. /**
  61906. * Gets the current class name
  61907. * @returns the class name
  61908. */
  61909. getClassName(): string;
  61910. /**
  61911. * Gets the world position input component
  61912. */
  61913. get position(): NodeMaterialConnectionPoint;
  61914. /**
  61915. * Gets the world position input component
  61916. */
  61917. get worldPosition(): NodeMaterialConnectionPoint;
  61918. /**
  61919. * Gets the world normal input component
  61920. */
  61921. get worldNormal(): NodeMaterialConnectionPoint;
  61922. /**
  61923. * Gets the world input component
  61924. */
  61925. get world(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the camera (or eye) position component
  61928. */
  61929. get cameraPosition(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the view input component
  61932. */
  61933. get view(): NodeMaterialConnectionPoint;
  61934. /**
  61935. * Gets the rgb output component
  61936. */
  61937. get rgb(): NodeMaterialConnectionPoint;
  61938. /**
  61939. * Gets the rgba output component
  61940. */
  61941. get rgba(): NodeMaterialConnectionPoint;
  61942. /**
  61943. * Gets the r output component
  61944. */
  61945. get r(): NodeMaterialConnectionPoint;
  61946. /**
  61947. * Gets the g output component
  61948. */
  61949. get g(): NodeMaterialConnectionPoint;
  61950. /**
  61951. * Gets the b output component
  61952. */
  61953. get b(): NodeMaterialConnectionPoint;
  61954. /**
  61955. * Gets the a output component
  61956. */
  61957. get a(): NodeMaterialConnectionPoint;
  61958. autoConfigure(material: NodeMaterial): void;
  61959. protected _buildBlock(state: NodeMaterialBuildState): this;
  61960. }
  61961. }
  61962. declare module BABYLON {
  61963. /**
  61964. * Block used to add 2 vectors
  61965. */
  61966. export class AddBlock extends NodeMaterialBlock {
  61967. /**
  61968. * Creates a new AddBlock
  61969. * @param name defines the block name
  61970. */
  61971. constructor(name: string);
  61972. /**
  61973. * Gets the current class name
  61974. * @returns the class name
  61975. */
  61976. getClassName(): string;
  61977. /**
  61978. * Gets the left operand input component
  61979. */
  61980. get left(): NodeMaterialConnectionPoint;
  61981. /**
  61982. * Gets the right operand input component
  61983. */
  61984. get right(): NodeMaterialConnectionPoint;
  61985. /**
  61986. * Gets the output component
  61987. */
  61988. get output(): NodeMaterialConnectionPoint;
  61989. protected _buildBlock(state: NodeMaterialBuildState): this;
  61990. }
  61991. }
  61992. declare module BABYLON {
  61993. /**
  61994. * Block used to scale a vector by a float
  61995. */
  61996. export class ScaleBlock extends NodeMaterialBlock {
  61997. /**
  61998. * Creates a new ScaleBlock
  61999. * @param name defines the block name
  62000. */
  62001. constructor(name: string);
  62002. /**
  62003. * Gets the current class name
  62004. * @returns the class name
  62005. */
  62006. getClassName(): string;
  62007. /**
  62008. * Gets the input component
  62009. */
  62010. get input(): NodeMaterialConnectionPoint;
  62011. /**
  62012. * Gets the factor input component
  62013. */
  62014. get factor(): NodeMaterialConnectionPoint;
  62015. /**
  62016. * Gets the output component
  62017. */
  62018. get output(): NodeMaterialConnectionPoint;
  62019. protected _buildBlock(state: NodeMaterialBuildState): this;
  62020. }
  62021. }
  62022. declare module BABYLON {
  62023. /**
  62024. * Block used to clamp a float
  62025. */
  62026. export class ClampBlock extends NodeMaterialBlock {
  62027. /** Gets or sets the minimum range */
  62028. minimum: number;
  62029. /** Gets or sets the maximum range */
  62030. maximum: number;
  62031. /**
  62032. * Creates a new ClampBlock
  62033. * @param name defines the block name
  62034. */
  62035. constructor(name: string);
  62036. /**
  62037. * Gets the current class name
  62038. * @returns the class name
  62039. */
  62040. getClassName(): string;
  62041. /**
  62042. * Gets the value input component
  62043. */
  62044. get value(): NodeMaterialConnectionPoint;
  62045. /**
  62046. * Gets the output component
  62047. */
  62048. get output(): NodeMaterialConnectionPoint;
  62049. protected _buildBlock(state: NodeMaterialBuildState): this;
  62050. protected _dumpPropertiesCode(): string;
  62051. serialize(): any;
  62052. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62053. }
  62054. }
  62055. declare module BABYLON {
  62056. /**
  62057. * Block used to apply a cross product between 2 vectors
  62058. */
  62059. export class CrossBlock extends NodeMaterialBlock {
  62060. /**
  62061. * Creates a new CrossBlock
  62062. * @param name defines the block name
  62063. */
  62064. constructor(name: string);
  62065. /**
  62066. * Gets the current class name
  62067. * @returns the class name
  62068. */
  62069. getClassName(): string;
  62070. /**
  62071. * Gets the left operand input component
  62072. */
  62073. get left(): NodeMaterialConnectionPoint;
  62074. /**
  62075. * Gets the right operand input component
  62076. */
  62077. get right(): NodeMaterialConnectionPoint;
  62078. /**
  62079. * Gets the output component
  62080. */
  62081. get output(): NodeMaterialConnectionPoint;
  62082. protected _buildBlock(state: NodeMaterialBuildState): this;
  62083. }
  62084. }
  62085. declare module BABYLON {
  62086. /**
  62087. * Block used to apply a dot product between 2 vectors
  62088. */
  62089. export class DotBlock extends NodeMaterialBlock {
  62090. /**
  62091. * Creates a new DotBlock
  62092. * @param name defines the block name
  62093. */
  62094. constructor(name: string);
  62095. /**
  62096. * Gets the current class name
  62097. * @returns the class name
  62098. */
  62099. getClassName(): string;
  62100. /**
  62101. * Gets the left operand input component
  62102. */
  62103. get left(): NodeMaterialConnectionPoint;
  62104. /**
  62105. * Gets the right operand input component
  62106. */
  62107. get right(): NodeMaterialConnectionPoint;
  62108. /**
  62109. * Gets the output component
  62110. */
  62111. get output(): NodeMaterialConnectionPoint;
  62112. protected _buildBlock(state: NodeMaterialBuildState): this;
  62113. }
  62114. }
  62115. declare module BABYLON {
  62116. /**
  62117. * Block used to normalize a vector
  62118. */
  62119. export class NormalizeBlock extends NodeMaterialBlock {
  62120. /**
  62121. * Creates a new NormalizeBlock
  62122. * @param name defines the block name
  62123. */
  62124. constructor(name: string);
  62125. /**
  62126. * Gets the current class name
  62127. * @returns the class name
  62128. */
  62129. getClassName(): string;
  62130. /**
  62131. * Gets the input component
  62132. */
  62133. get input(): NodeMaterialConnectionPoint;
  62134. /**
  62135. * Gets the output component
  62136. */
  62137. get output(): NodeMaterialConnectionPoint;
  62138. protected _buildBlock(state: NodeMaterialBuildState): this;
  62139. }
  62140. }
  62141. declare module BABYLON {
  62142. /**
  62143. * Operations supported by the Trigonometry block
  62144. */
  62145. export enum TrigonometryBlockOperations {
  62146. /** Cos */
  62147. Cos = 0,
  62148. /** Sin */
  62149. Sin = 1,
  62150. /** Abs */
  62151. Abs = 2,
  62152. /** Exp */
  62153. Exp = 3,
  62154. /** Exp2 */
  62155. Exp2 = 4,
  62156. /** Round */
  62157. Round = 5,
  62158. /** Floor */
  62159. Floor = 6,
  62160. /** Ceiling */
  62161. Ceiling = 7,
  62162. /** Square root */
  62163. Sqrt = 8,
  62164. /** Log */
  62165. Log = 9,
  62166. /** Tangent */
  62167. Tan = 10,
  62168. /** Arc tangent */
  62169. ArcTan = 11,
  62170. /** Arc cosinus */
  62171. ArcCos = 12,
  62172. /** Arc sinus */
  62173. ArcSin = 13,
  62174. /** Fraction */
  62175. Fract = 14,
  62176. /** Sign */
  62177. Sign = 15,
  62178. /** To radians (from degrees) */
  62179. Radians = 16,
  62180. /** To degrees (from radians) */
  62181. Degrees = 17
  62182. }
  62183. /**
  62184. * Block used to apply trigonometry operation to floats
  62185. */
  62186. export class TrigonometryBlock extends NodeMaterialBlock {
  62187. /**
  62188. * Gets or sets the operation applied by the block
  62189. */
  62190. operation: TrigonometryBlockOperations;
  62191. /**
  62192. * Creates a new TrigonometryBlock
  62193. * @param name defines the block name
  62194. */
  62195. constructor(name: string);
  62196. /**
  62197. * Gets the current class name
  62198. * @returns the class name
  62199. */
  62200. getClassName(): string;
  62201. /**
  62202. * Gets the input component
  62203. */
  62204. get input(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the output component
  62207. */
  62208. get output(): NodeMaterialConnectionPoint;
  62209. protected _buildBlock(state: NodeMaterialBuildState): this;
  62210. serialize(): any;
  62211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62212. protected _dumpPropertiesCode(): string;
  62213. }
  62214. }
  62215. declare module BABYLON {
  62216. /**
  62217. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62218. */
  62219. export class ColorMergerBlock extends NodeMaterialBlock {
  62220. /**
  62221. * Create a new ColorMergerBlock
  62222. * @param name defines the block name
  62223. */
  62224. constructor(name: string);
  62225. /**
  62226. * Gets the current class name
  62227. * @returns the class name
  62228. */
  62229. getClassName(): string;
  62230. /**
  62231. * Gets the rgb component (input)
  62232. */
  62233. get rgbIn(): NodeMaterialConnectionPoint;
  62234. /**
  62235. * Gets the r component (input)
  62236. */
  62237. get r(): NodeMaterialConnectionPoint;
  62238. /**
  62239. * Gets the g component (input)
  62240. */
  62241. get g(): NodeMaterialConnectionPoint;
  62242. /**
  62243. * Gets the b component (input)
  62244. */
  62245. get b(): NodeMaterialConnectionPoint;
  62246. /**
  62247. * Gets the a component (input)
  62248. */
  62249. get a(): NodeMaterialConnectionPoint;
  62250. /**
  62251. * Gets the rgba component (output)
  62252. */
  62253. get rgba(): NodeMaterialConnectionPoint;
  62254. /**
  62255. * Gets the rgb component (output)
  62256. */
  62257. get rgbOut(): NodeMaterialConnectionPoint;
  62258. /**
  62259. * Gets the rgb component (output)
  62260. * @deprecated Please use rgbOut instead.
  62261. */
  62262. get rgb(): NodeMaterialConnectionPoint;
  62263. protected _buildBlock(state: NodeMaterialBuildState): this;
  62264. }
  62265. }
  62266. declare module BABYLON {
  62267. /**
  62268. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62269. */
  62270. export class VectorSplitterBlock extends NodeMaterialBlock {
  62271. /**
  62272. * Create a new VectorSplitterBlock
  62273. * @param name defines the block name
  62274. */
  62275. constructor(name: string);
  62276. /**
  62277. * Gets the current class name
  62278. * @returns the class name
  62279. */
  62280. getClassName(): string;
  62281. /**
  62282. * Gets the xyzw component (input)
  62283. */
  62284. get xyzw(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the xyz component (input)
  62287. */
  62288. get xyzIn(): NodeMaterialConnectionPoint;
  62289. /**
  62290. * Gets the xy component (input)
  62291. */
  62292. get xyIn(): NodeMaterialConnectionPoint;
  62293. /**
  62294. * Gets the xyz component (output)
  62295. */
  62296. get xyzOut(): NodeMaterialConnectionPoint;
  62297. /**
  62298. * Gets the xy component (output)
  62299. */
  62300. get xyOut(): NodeMaterialConnectionPoint;
  62301. /**
  62302. * Gets the x component (output)
  62303. */
  62304. get x(): NodeMaterialConnectionPoint;
  62305. /**
  62306. * Gets the y component (output)
  62307. */
  62308. get y(): NodeMaterialConnectionPoint;
  62309. /**
  62310. * Gets the z component (output)
  62311. */
  62312. get z(): NodeMaterialConnectionPoint;
  62313. /**
  62314. * Gets the w component (output)
  62315. */
  62316. get w(): NodeMaterialConnectionPoint;
  62317. protected _inputRename(name: string): string;
  62318. protected _outputRename(name: string): string;
  62319. protected _buildBlock(state: NodeMaterialBuildState): this;
  62320. }
  62321. }
  62322. declare module BABYLON {
  62323. /**
  62324. * Block used to lerp between 2 values
  62325. */
  62326. export class LerpBlock extends NodeMaterialBlock {
  62327. /**
  62328. * Creates a new LerpBlock
  62329. * @param name defines the block name
  62330. */
  62331. constructor(name: string);
  62332. /**
  62333. * Gets the current class name
  62334. * @returns the class name
  62335. */
  62336. getClassName(): string;
  62337. /**
  62338. * Gets the left operand input component
  62339. */
  62340. get left(): NodeMaterialConnectionPoint;
  62341. /**
  62342. * Gets the right operand input component
  62343. */
  62344. get right(): NodeMaterialConnectionPoint;
  62345. /**
  62346. * Gets the gradient operand input component
  62347. */
  62348. get gradient(): NodeMaterialConnectionPoint;
  62349. /**
  62350. * Gets the output component
  62351. */
  62352. get output(): NodeMaterialConnectionPoint;
  62353. protected _buildBlock(state: NodeMaterialBuildState): this;
  62354. }
  62355. }
  62356. declare module BABYLON {
  62357. /**
  62358. * Block used to divide 2 vectors
  62359. */
  62360. export class DivideBlock extends NodeMaterialBlock {
  62361. /**
  62362. * Creates a new DivideBlock
  62363. * @param name defines the block name
  62364. */
  62365. constructor(name: string);
  62366. /**
  62367. * Gets the current class name
  62368. * @returns the class name
  62369. */
  62370. getClassName(): string;
  62371. /**
  62372. * Gets the left operand input component
  62373. */
  62374. get left(): NodeMaterialConnectionPoint;
  62375. /**
  62376. * Gets the right operand input component
  62377. */
  62378. get right(): NodeMaterialConnectionPoint;
  62379. /**
  62380. * Gets the output component
  62381. */
  62382. get output(): NodeMaterialConnectionPoint;
  62383. protected _buildBlock(state: NodeMaterialBuildState): this;
  62384. }
  62385. }
  62386. declare module BABYLON {
  62387. /**
  62388. * Block used to subtract 2 vectors
  62389. */
  62390. export class SubtractBlock extends NodeMaterialBlock {
  62391. /**
  62392. * Creates a new SubtractBlock
  62393. * @param name defines the block name
  62394. */
  62395. constructor(name: string);
  62396. /**
  62397. * Gets the current class name
  62398. * @returns the class name
  62399. */
  62400. getClassName(): string;
  62401. /**
  62402. * Gets the left operand input component
  62403. */
  62404. get left(): NodeMaterialConnectionPoint;
  62405. /**
  62406. * Gets the right operand input component
  62407. */
  62408. get right(): NodeMaterialConnectionPoint;
  62409. /**
  62410. * Gets the output component
  62411. */
  62412. get output(): NodeMaterialConnectionPoint;
  62413. protected _buildBlock(state: NodeMaterialBuildState): this;
  62414. }
  62415. }
  62416. declare module BABYLON {
  62417. /**
  62418. * Block used to step a value
  62419. */
  62420. export class StepBlock extends NodeMaterialBlock {
  62421. /**
  62422. * Creates a new StepBlock
  62423. * @param name defines the block name
  62424. */
  62425. constructor(name: string);
  62426. /**
  62427. * Gets the current class name
  62428. * @returns the class name
  62429. */
  62430. getClassName(): string;
  62431. /**
  62432. * Gets the value operand input component
  62433. */
  62434. get value(): NodeMaterialConnectionPoint;
  62435. /**
  62436. * Gets the edge operand input component
  62437. */
  62438. get edge(): NodeMaterialConnectionPoint;
  62439. /**
  62440. * Gets the output component
  62441. */
  62442. get output(): NodeMaterialConnectionPoint;
  62443. protected _buildBlock(state: NodeMaterialBuildState): this;
  62444. }
  62445. }
  62446. declare module BABYLON {
  62447. /**
  62448. * Block used to get the opposite (1 - x) of a value
  62449. */
  62450. export class OneMinusBlock extends NodeMaterialBlock {
  62451. /**
  62452. * Creates a new OneMinusBlock
  62453. * @param name defines the block name
  62454. */
  62455. constructor(name: string);
  62456. /**
  62457. * Gets the current class name
  62458. * @returns the class name
  62459. */
  62460. getClassName(): string;
  62461. /**
  62462. * Gets the input component
  62463. */
  62464. get input(): NodeMaterialConnectionPoint;
  62465. /**
  62466. * Gets the output component
  62467. */
  62468. get output(): NodeMaterialConnectionPoint;
  62469. protected _buildBlock(state: NodeMaterialBuildState): this;
  62470. }
  62471. }
  62472. declare module BABYLON {
  62473. /**
  62474. * Block used to get the view direction
  62475. */
  62476. export class ViewDirectionBlock extends NodeMaterialBlock {
  62477. /**
  62478. * Creates a new ViewDirectionBlock
  62479. * @param name defines the block name
  62480. */
  62481. constructor(name: string);
  62482. /**
  62483. * Gets the current class name
  62484. * @returns the class name
  62485. */
  62486. getClassName(): string;
  62487. /**
  62488. * Gets the world position component
  62489. */
  62490. get worldPosition(): NodeMaterialConnectionPoint;
  62491. /**
  62492. * Gets the camera position component
  62493. */
  62494. get cameraPosition(): NodeMaterialConnectionPoint;
  62495. /**
  62496. * Gets the output component
  62497. */
  62498. get output(): NodeMaterialConnectionPoint;
  62499. autoConfigure(material: NodeMaterial): void;
  62500. protected _buildBlock(state: NodeMaterialBuildState): this;
  62501. }
  62502. }
  62503. declare module BABYLON {
  62504. /**
  62505. * Block used to compute fresnel value
  62506. */
  62507. export class FresnelBlock extends NodeMaterialBlock {
  62508. /**
  62509. * Create a new FresnelBlock
  62510. * @param name defines the block name
  62511. */
  62512. constructor(name: string);
  62513. /**
  62514. * Gets the current class name
  62515. * @returns the class name
  62516. */
  62517. getClassName(): string;
  62518. /**
  62519. * Gets the world normal input component
  62520. */
  62521. get worldNormal(): NodeMaterialConnectionPoint;
  62522. /**
  62523. * Gets the view direction input component
  62524. */
  62525. get viewDirection(): NodeMaterialConnectionPoint;
  62526. /**
  62527. * Gets the bias input component
  62528. */
  62529. get bias(): NodeMaterialConnectionPoint;
  62530. /**
  62531. * Gets the camera (or eye) position component
  62532. */
  62533. get power(): NodeMaterialConnectionPoint;
  62534. /**
  62535. * Gets the fresnel output component
  62536. */
  62537. get fresnel(): NodeMaterialConnectionPoint;
  62538. autoConfigure(material: NodeMaterial): void;
  62539. protected _buildBlock(state: NodeMaterialBuildState): this;
  62540. }
  62541. }
  62542. declare module BABYLON {
  62543. /**
  62544. * Block used to get the max of 2 values
  62545. */
  62546. export class MaxBlock extends NodeMaterialBlock {
  62547. /**
  62548. * Creates a new MaxBlock
  62549. * @param name defines the block name
  62550. */
  62551. constructor(name: string);
  62552. /**
  62553. * Gets the current class name
  62554. * @returns the class name
  62555. */
  62556. getClassName(): string;
  62557. /**
  62558. * Gets the left operand input component
  62559. */
  62560. get left(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the right operand input component
  62563. */
  62564. get right(): NodeMaterialConnectionPoint;
  62565. /**
  62566. * Gets the output component
  62567. */
  62568. get output(): NodeMaterialConnectionPoint;
  62569. protected _buildBlock(state: NodeMaterialBuildState): this;
  62570. }
  62571. }
  62572. declare module BABYLON {
  62573. /**
  62574. * Block used to get the min of 2 values
  62575. */
  62576. export class MinBlock extends NodeMaterialBlock {
  62577. /**
  62578. * Creates a new MinBlock
  62579. * @param name defines the block name
  62580. */
  62581. constructor(name: string);
  62582. /**
  62583. * Gets the current class name
  62584. * @returns the class name
  62585. */
  62586. getClassName(): string;
  62587. /**
  62588. * Gets the left operand input component
  62589. */
  62590. get left(): NodeMaterialConnectionPoint;
  62591. /**
  62592. * Gets the right operand input component
  62593. */
  62594. get right(): NodeMaterialConnectionPoint;
  62595. /**
  62596. * Gets the output component
  62597. */
  62598. get output(): NodeMaterialConnectionPoint;
  62599. protected _buildBlock(state: NodeMaterialBuildState): this;
  62600. }
  62601. }
  62602. declare module BABYLON {
  62603. /**
  62604. * Block used to get the distance between 2 values
  62605. */
  62606. export class DistanceBlock extends NodeMaterialBlock {
  62607. /**
  62608. * Creates a new DistanceBlock
  62609. * @param name defines the block name
  62610. */
  62611. constructor(name: string);
  62612. /**
  62613. * Gets the current class name
  62614. * @returns the class name
  62615. */
  62616. getClassName(): string;
  62617. /**
  62618. * Gets the left operand input component
  62619. */
  62620. get left(): NodeMaterialConnectionPoint;
  62621. /**
  62622. * Gets the right operand input component
  62623. */
  62624. get right(): NodeMaterialConnectionPoint;
  62625. /**
  62626. * Gets the output component
  62627. */
  62628. get output(): NodeMaterialConnectionPoint;
  62629. protected _buildBlock(state: NodeMaterialBuildState): this;
  62630. }
  62631. }
  62632. declare module BABYLON {
  62633. /**
  62634. * Block used to get the length of a vector
  62635. */
  62636. export class LengthBlock extends NodeMaterialBlock {
  62637. /**
  62638. * Creates a new LengthBlock
  62639. * @param name defines the block name
  62640. */
  62641. constructor(name: string);
  62642. /**
  62643. * Gets the current class name
  62644. * @returns the class name
  62645. */
  62646. getClassName(): string;
  62647. /**
  62648. * Gets the value input component
  62649. */
  62650. get value(): NodeMaterialConnectionPoint;
  62651. /**
  62652. * Gets the output component
  62653. */
  62654. get output(): NodeMaterialConnectionPoint;
  62655. protected _buildBlock(state: NodeMaterialBuildState): this;
  62656. }
  62657. }
  62658. declare module BABYLON {
  62659. /**
  62660. * Block used to get negative version of a value (i.e. x * -1)
  62661. */
  62662. export class NegateBlock extends NodeMaterialBlock {
  62663. /**
  62664. * Creates a new NegateBlock
  62665. * @param name defines the block name
  62666. */
  62667. constructor(name: string);
  62668. /**
  62669. * Gets the current class name
  62670. * @returns the class name
  62671. */
  62672. getClassName(): string;
  62673. /**
  62674. * Gets the value input component
  62675. */
  62676. get value(): NodeMaterialConnectionPoint;
  62677. /**
  62678. * Gets the output component
  62679. */
  62680. get output(): NodeMaterialConnectionPoint;
  62681. protected _buildBlock(state: NodeMaterialBuildState): this;
  62682. }
  62683. }
  62684. declare module BABYLON {
  62685. /**
  62686. * Block used to get the value of the first parameter raised to the power of the second
  62687. */
  62688. export class PowBlock extends NodeMaterialBlock {
  62689. /**
  62690. * Creates a new PowBlock
  62691. * @param name defines the block name
  62692. */
  62693. constructor(name: string);
  62694. /**
  62695. * Gets the current class name
  62696. * @returns the class name
  62697. */
  62698. getClassName(): string;
  62699. /**
  62700. * Gets the value operand input component
  62701. */
  62702. get value(): NodeMaterialConnectionPoint;
  62703. /**
  62704. * Gets the power operand input component
  62705. */
  62706. get power(): NodeMaterialConnectionPoint;
  62707. /**
  62708. * Gets the output component
  62709. */
  62710. get output(): NodeMaterialConnectionPoint;
  62711. protected _buildBlock(state: NodeMaterialBuildState): this;
  62712. }
  62713. }
  62714. declare module BABYLON {
  62715. /**
  62716. * Block used to get a random number
  62717. */
  62718. export class RandomNumberBlock extends NodeMaterialBlock {
  62719. /**
  62720. * Creates a new RandomNumberBlock
  62721. * @param name defines the block name
  62722. */
  62723. constructor(name: string);
  62724. /**
  62725. * Gets the current class name
  62726. * @returns the class name
  62727. */
  62728. getClassName(): string;
  62729. /**
  62730. * Gets the seed input component
  62731. */
  62732. get seed(): NodeMaterialConnectionPoint;
  62733. /**
  62734. * Gets the output component
  62735. */
  62736. get output(): NodeMaterialConnectionPoint;
  62737. protected _buildBlock(state: NodeMaterialBuildState): this;
  62738. }
  62739. }
  62740. declare module BABYLON {
  62741. /**
  62742. * Block used to compute arc tangent of 2 values
  62743. */
  62744. export class ArcTan2Block extends NodeMaterialBlock {
  62745. /**
  62746. * Creates a new ArcTan2Block
  62747. * @param name defines the block name
  62748. */
  62749. constructor(name: string);
  62750. /**
  62751. * Gets the current class name
  62752. * @returns the class name
  62753. */
  62754. getClassName(): string;
  62755. /**
  62756. * Gets the x operand input component
  62757. */
  62758. get x(): NodeMaterialConnectionPoint;
  62759. /**
  62760. * Gets the y operand input component
  62761. */
  62762. get y(): NodeMaterialConnectionPoint;
  62763. /**
  62764. * Gets the output component
  62765. */
  62766. get output(): NodeMaterialConnectionPoint;
  62767. protected _buildBlock(state: NodeMaterialBuildState): this;
  62768. }
  62769. }
  62770. declare module BABYLON {
  62771. /**
  62772. * Block used to smooth step a value
  62773. */
  62774. export class SmoothStepBlock extends NodeMaterialBlock {
  62775. /**
  62776. * Creates a new SmoothStepBlock
  62777. * @param name defines the block name
  62778. */
  62779. constructor(name: string);
  62780. /**
  62781. * Gets the current class name
  62782. * @returns the class name
  62783. */
  62784. getClassName(): string;
  62785. /**
  62786. * Gets the value operand input component
  62787. */
  62788. get value(): NodeMaterialConnectionPoint;
  62789. /**
  62790. * Gets the first edge operand input component
  62791. */
  62792. get edge0(): NodeMaterialConnectionPoint;
  62793. /**
  62794. * Gets the second edge operand input component
  62795. */
  62796. get edge1(): NodeMaterialConnectionPoint;
  62797. /**
  62798. * Gets the output component
  62799. */
  62800. get output(): NodeMaterialConnectionPoint;
  62801. protected _buildBlock(state: NodeMaterialBuildState): this;
  62802. }
  62803. }
  62804. declare module BABYLON {
  62805. /**
  62806. * Block used to get the reciprocal (1 / x) of a value
  62807. */
  62808. export class ReciprocalBlock extends NodeMaterialBlock {
  62809. /**
  62810. * Creates a new ReciprocalBlock
  62811. * @param name defines the block name
  62812. */
  62813. constructor(name: string);
  62814. /**
  62815. * Gets the current class name
  62816. * @returns the class name
  62817. */
  62818. getClassName(): string;
  62819. /**
  62820. * Gets the input component
  62821. */
  62822. get input(): NodeMaterialConnectionPoint;
  62823. /**
  62824. * Gets the output component
  62825. */
  62826. get output(): NodeMaterialConnectionPoint;
  62827. protected _buildBlock(state: NodeMaterialBuildState): this;
  62828. }
  62829. }
  62830. declare module BABYLON {
  62831. /**
  62832. * Block used to replace a color by another one
  62833. */
  62834. export class ReplaceColorBlock extends NodeMaterialBlock {
  62835. /**
  62836. * Creates a new ReplaceColorBlock
  62837. * @param name defines the block name
  62838. */
  62839. constructor(name: string);
  62840. /**
  62841. * Gets the current class name
  62842. * @returns the class name
  62843. */
  62844. getClassName(): string;
  62845. /**
  62846. * Gets the value input component
  62847. */
  62848. get value(): NodeMaterialConnectionPoint;
  62849. /**
  62850. * Gets the reference input component
  62851. */
  62852. get reference(): NodeMaterialConnectionPoint;
  62853. /**
  62854. * Gets the distance input component
  62855. */
  62856. get distance(): NodeMaterialConnectionPoint;
  62857. /**
  62858. * Gets the replacement input component
  62859. */
  62860. get replacement(): NodeMaterialConnectionPoint;
  62861. /**
  62862. * Gets the output component
  62863. */
  62864. get output(): NodeMaterialConnectionPoint;
  62865. protected _buildBlock(state: NodeMaterialBuildState): this;
  62866. }
  62867. }
  62868. declare module BABYLON {
  62869. /**
  62870. * Block used to posterize a value
  62871. * @see https://en.wikipedia.org/wiki/Posterization
  62872. */
  62873. export class PosterizeBlock extends NodeMaterialBlock {
  62874. /**
  62875. * Creates a new PosterizeBlock
  62876. * @param name defines the block name
  62877. */
  62878. constructor(name: string);
  62879. /**
  62880. * Gets the current class name
  62881. * @returns the class name
  62882. */
  62883. getClassName(): string;
  62884. /**
  62885. * Gets the value input component
  62886. */
  62887. get value(): NodeMaterialConnectionPoint;
  62888. /**
  62889. * Gets the steps input component
  62890. */
  62891. get steps(): NodeMaterialConnectionPoint;
  62892. /**
  62893. * Gets the output component
  62894. */
  62895. get output(): NodeMaterialConnectionPoint;
  62896. protected _buildBlock(state: NodeMaterialBuildState): this;
  62897. }
  62898. }
  62899. declare module BABYLON {
  62900. /**
  62901. * Operations supported by the Wave block
  62902. */
  62903. export enum WaveBlockKind {
  62904. /** SawTooth */
  62905. SawTooth = 0,
  62906. /** Square */
  62907. Square = 1,
  62908. /** Triangle */
  62909. Triangle = 2
  62910. }
  62911. /**
  62912. * Block used to apply wave operation to floats
  62913. */
  62914. export class WaveBlock extends NodeMaterialBlock {
  62915. /**
  62916. * Gets or sets the kibnd of wave to be applied by the block
  62917. */
  62918. kind: WaveBlockKind;
  62919. /**
  62920. * Creates a new WaveBlock
  62921. * @param name defines the block name
  62922. */
  62923. constructor(name: string);
  62924. /**
  62925. * Gets the current class name
  62926. * @returns the class name
  62927. */
  62928. getClassName(): string;
  62929. /**
  62930. * Gets the input component
  62931. */
  62932. get input(): NodeMaterialConnectionPoint;
  62933. /**
  62934. * Gets the output component
  62935. */
  62936. get output(): NodeMaterialConnectionPoint;
  62937. protected _buildBlock(state: NodeMaterialBuildState): this;
  62938. serialize(): any;
  62939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62940. }
  62941. }
  62942. declare module BABYLON {
  62943. /**
  62944. * Class used to store a color step for the GradientBlock
  62945. */
  62946. export class GradientBlockColorStep {
  62947. /**
  62948. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62949. */
  62950. step: number;
  62951. /**
  62952. * Gets or sets the color associated with this step
  62953. */
  62954. color: Color3;
  62955. /**
  62956. * Creates a new GradientBlockColorStep
  62957. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62958. * @param color defines the color associated with this step
  62959. */
  62960. constructor(
  62961. /**
  62962. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62963. */
  62964. step: number,
  62965. /**
  62966. * Gets or sets the color associated with this step
  62967. */
  62968. color: Color3);
  62969. }
  62970. /**
  62971. * Block used to return a color from a gradient based on an input value between 0 and 1
  62972. */
  62973. export class GradientBlock extends NodeMaterialBlock {
  62974. /**
  62975. * Gets or sets the list of color steps
  62976. */
  62977. colorSteps: GradientBlockColorStep[];
  62978. /**
  62979. * Creates a new GradientBlock
  62980. * @param name defines the block name
  62981. */
  62982. constructor(name: string);
  62983. /**
  62984. * Gets the current class name
  62985. * @returns the class name
  62986. */
  62987. getClassName(): string;
  62988. /**
  62989. * Gets the gradient input component
  62990. */
  62991. get gradient(): NodeMaterialConnectionPoint;
  62992. /**
  62993. * Gets the output component
  62994. */
  62995. get output(): NodeMaterialConnectionPoint;
  62996. private _writeColorConstant;
  62997. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62998. serialize(): any;
  62999. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63000. protected _dumpPropertiesCode(): string;
  63001. }
  63002. }
  63003. declare module BABYLON {
  63004. /**
  63005. * Block used to normalize lerp between 2 values
  63006. */
  63007. export class NLerpBlock extends NodeMaterialBlock {
  63008. /**
  63009. * Creates a new NLerpBlock
  63010. * @param name defines the block name
  63011. */
  63012. constructor(name: string);
  63013. /**
  63014. * Gets the current class name
  63015. * @returns the class name
  63016. */
  63017. getClassName(): string;
  63018. /**
  63019. * Gets the left operand input component
  63020. */
  63021. get left(): NodeMaterialConnectionPoint;
  63022. /**
  63023. * Gets the right operand input component
  63024. */
  63025. get right(): NodeMaterialConnectionPoint;
  63026. /**
  63027. * Gets the gradient operand input component
  63028. */
  63029. get gradient(): NodeMaterialConnectionPoint;
  63030. /**
  63031. * Gets the output component
  63032. */
  63033. get output(): NodeMaterialConnectionPoint;
  63034. protected _buildBlock(state: NodeMaterialBuildState): this;
  63035. }
  63036. }
  63037. declare module BABYLON {
  63038. /**
  63039. * block used to Generate a Worley Noise 3D Noise Pattern
  63040. */
  63041. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63042. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63043. manhattanDistance: boolean;
  63044. /**
  63045. * Creates a new WorleyNoise3DBlock
  63046. * @param name defines the block name
  63047. */
  63048. constructor(name: string);
  63049. /**
  63050. * Gets the current class name
  63051. * @returns the class name
  63052. */
  63053. getClassName(): string;
  63054. /**
  63055. * Gets the seed input component
  63056. */
  63057. get seed(): NodeMaterialConnectionPoint;
  63058. /**
  63059. * Gets the jitter input component
  63060. */
  63061. get jitter(): NodeMaterialConnectionPoint;
  63062. /**
  63063. * Gets the output component
  63064. */
  63065. get output(): NodeMaterialConnectionPoint;
  63066. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63067. /**
  63068. * Exposes the properties to the UI?
  63069. */
  63070. protected _dumpPropertiesCode(): string;
  63071. /**
  63072. * Exposes the properties to the Seralize?
  63073. */
  63074. serialize(): any;
  63075. /**
  63076. * Exposes the properties to the deseralize?
  63077. */
  63078. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63079. }
  63080. }
  63081. declare module BABYLON {
  63082. /**
  63083. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63084. */
  63085. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63086. /**
  63087. * Creates a new SimplexPerlin3DBlock
  63088. * @param name defines the block name
  63089. */
  63090. constructor(name: string);
  63091. /**
  63092. * Gets the current class name
  63093. * @returns the class name
  63094. */
  63095. getClassName(): string;
  63096. /**
  63097. * Gets the seed operand input component
  63098. */
  63099. get seed(): NodeMaterialConnectionPoint;
  63100. /**
  63101. * Gets the output component
  63102. */
  63103. get output(): NodeMaterialConnectionPoint;
  63104. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63105. }
  63106. }
  63107. declare module BABYLON {
  63108. /**
  63109. * Block used to blend normals
  63110. */
  63111. export class NormalBlendBlock extends NodeMaterialBlock {
  63112. /**
  63113. * Creates a new NormalBlendBlock
  63114. * @param name defines the block name
  63115. */
  63116. constructor(name: string);
  63117. /**
  63118. * Gets the current class name
  63119. * @returns the class name
  63120. */
  63121. getClassName(): string;
  63122. /**
  63123. * Gets the first input component
  63124. */
  63125. get normalMap0(): NodeMaterialConnectionPoint;
  63126. /**
  63127. * Gets the second input component
  63128. */
  63129. get normalMap1(): NodeMaterialConnectionPoint;
  63130. /**
  63131. * Gets the output component
  63132. */
  63133. get output(): NodeMaterialConnectionPoint;
  63134. protected _buildBlock(state: NodeMaterialBuildState): this;
  63135. }
  63136. }
  63137. declare module BABYLON {
  63138. /**
  63139. * Block used to rotate a 2d vector by a given angle
  63140. */
  63141. export class Rotate2dBlock extends NodeMaterialBlock {
  63142. /**
  63143. * Creates a new Rotate2dBlock
  63144. * @param name defines the block name
  63145. */
  63146. constructor(name: string);
  63147. /**
  63148. * Gets the current class name
  63149. * @returns the class name
  63150. */
  63151. getClassName(): string;
  63152. /**
  63153. * Gets the input vector
  63154. */
  63155. get input(): NodeMaterialConnectionPoint;
  63156. /**
  63157. * Gets the input angle
  63158. */
  63159. get angle(): NodeMaterialConnectionPoint;
  63160. /**
  63161. * Gets the output component
  63162. */
  63163. get output(): NodeMaterialConnectionPoint;
  63164. autoConfigure(material: NodeMaterial): void;
  63165. protected _buildBlock(state: NodeMaterialBuildState): this;
  63166. }
  63167. }
  63168. declare module BABYLON {
  63169. /**
  63170. * Block used to get the reflected vector from a direction and a normal
  63171. */
  63172. export class ReflectBlock extends NodeMaterialBlock {
  63173. /**
  63174. * Creates a new ReflectBlock
  63175. * @param name defines the block name
  63176. */
  63177. constructor(name: string);
  63178. /**
  63179. * Gets the current class name
  63180. * @returns the class name
  63181. */
  63182. getClassName(): string;
  63183. /**
  63184. * Gets the incident component
  63185. */
  63186. get incident(): NodeMaterialConnectionPoint;
  63187. /**
  63188. * Gets the normal component
  63189. */
  63190. get normal(): NodeMaterialConnectionPoint;
  63191. /**
  63192. * Gets the output component
  63193. */
  63194. get output(): NodeMaterialConnectionPoint;
  63195. protected _buildBlock(state: NodeMaterialBuildState): this;
  63196. }
  63197. }
  63198. declare module BABYLON {
  63199. /**
  63200. * Block used to get the refracted vector from a direction and a normal
  63201. */
  63202. export class RefractBlock extends NodeMaterialBlock {
  63203. /**
  63204. * Creates a new RefractBlock
  63205. * @param name defines the block name
  63206. */
  63207. constructor(name: string);
  63208. /**
  63209. * Gets the current class name
  63210. * @returns the class name
  63211. */
  63212. getClassName(): string;
  63213. /**
  63214. * Gets the incident component
  63215. */
  63216. get incident(): NodeMaterialConnectionPoint;
  63217. /**
  63218. * Gets the normal component
  63219. */
  63220. get normal(): NodeMaterialConnectionPoint;
  63221. /**
  63222. * Gets the index of refraction component
  63223. */
  63224. get ior(): NodeMaterialConnectionPoint;
  63225. /**
  63226. * Gets the output component
  63227. */
  63228. get output(): NodeMaterialConnectionPoint;
  63229. protected _buildBlock(state: NodeMaterialBuildState): this;
  63230. }
  63231. }
  63232. declare module BABYLON {
  63233. /**
  63234. * Block used to desaturate a color
  63235. */
  63236. export class DesaturateBlock extends NodeMaterialBlock {
  63237. /**
  63238. * Creates a new DesaturateBlock
  63239. * @param name defines the block name
  63240. */
  63241. constructor(name: string);
  63242. /**
  63243. * Gets the current class name
  63244. * @returns the class name
  63245. */
  63246. getClassName(): string;
  63247. /**
  63248. * Gets the color operand input component
  63249. */
  63250. get color(): NodeMaterialConnectionPoint;
  63251. /**
  63252. * Gets the level operand input component
  63253. */
  63254. get level(): NodeMaterialConnectionPoint;
  63255. /**
  63256. * Gets the output component
  63257. */
  63258. get output(): NodeMaterialConnectionPoint;
  63259. protected _buildBlock(state: NodeMaterialBuildState): this;
  63260. }
  63261. }
  63262. declare module BABYLON {
  63263. /**
  63264. * Block used to implement the ambient occlusion module of the PBR material
  63265. */
  63266. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63267. /**
  63268. * Create a new AmbientOcclusionBlock
  63269. * @param name defines the block name
  63270. */
  63271. constructor(name: string);
  63272. /**
  63273. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63274. */
  63275. useAmbientInGrayScale: boolean;
  63276. /**
  63277. * Initialize the block and prepare the context for build
  63278. * @param state defines the state that will be used for the build
  63279. */
  63280. initialize(state: NodeMaterialBuildState): void;
  63281. /**
  63282. * Gets the current class name
  63283. * @returns the class name
  63284. */
  63285. getClassName(): string;
  63286. /**
  63287. * Gets the texture input component
  63288. */
  63289. get texture(): NodeMaterialConnectionPoint;
  63290. /**
  63291. * Gets the texture intensity component
  63292. */
  63293. get intensity(): NodeMaterialConnectionPoint;
  63294. /**
  63295. * Gets the direct light intensity input component
  63296. */
  63297. get directLightIntensity(): NodeMaterialConnectionPoint;
  63298. /**
  63299. * Gets the ambient occlusion object output component
  63300. */
  63301. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63302. /**
  63303. * Gets the main code of the block (fragment side)
  63304. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63305. * @returns the shader code
  63306. */
  63307. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63308. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63309. protected _buildBlock(state: NodeMaterialBuildState): this;
  63310. protected _dumpPropertiesCode(): string;
  63311. serialize(): any;
  63312. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63313. }
  63314. }
  63315. declare module BABYLON {
  63316. /**
  63317. * Block used to implement the reflection module of the PBR material
  63318. */
  63319. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63320. /** @hidden */
  63321. _defineLODReflectionAlpha: string;
  63322. /** @hidden */
  63323. _defineLinearSpecularReflection: string;
  63324. private _vEnvironmentIrradianceName;
  63325. /** @hidden */
  63326. _vReflectionMicrosurfaceInfosName: string;
  63327. /** @hidden */
  63328. _vReflectionInfosName: string;
  63329. /** @hidden */
  63330. _vReflectionFilteringInfoName: string;
  63331. private _scene;
  63332. /**
  63333. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63334. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63335. * It's less burden on the user side in the editor part.
  63336. */
  63337. /** @hidden */
  63338. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63339. /** @hidden */
  63340. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63341. /** @hidden */
  63342. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63343. /**
  63344. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63345. * diffuse part of the IBL.
  63346. */
  63347. useSphericalHarmonics: boolean;
  63348. /**
  63349. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63350. */
  63351. forceIrradianceInFragment: boolean;
  63352. /**
  63353. * Create a new ReflectionBlock
  63354. * @param name defines the block name
  63355. */
  63356. constructor(name: string);
  63357. /**
  63358. * Gets the current class name
  63359. * @returns the class name
  63360. */
  63361. getClassName(): string;
  63362. /**
  63363. * Gets the position input component
  63364. */
  63365. get position(): NodeMaterialConnectionPoint;
  63366. /**
  63367. * Gets the world position input component
  63368. */
  63369. get worldPosition(): NodeMaterialConnectionPoint;
  63370. /**
  63371. * Gets the world normal input component
  63372. */
  63373. get worldNormal(): NodeMaterialConnectionPoint;
  63374. /**
  63375. * Gets the world input component
  63376. */
  63377. get world(): NodeMaterialConnectionPoint;
  63378. /**
  63379. * Gets the camera (or eye) position component
  63380. */
  63381. get cameraPosition(): NodeMaterialConnectionPoint;
  63382. /**
  63383. * Gets the view input component
  63384. */
  63385. get view(): NodeMaterialConnectionPoint;
  63386. /**
  63387. * Gets the color input component
  63388. */
  63389. get color(): NodeMaterialConnectionPoint;
  63390. /**
  63391. * Gets the reflection object output component
  63392. */
  63393. get reflection(): NodeMaterialConnectionPoint;
  63394. /**
  63395. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63396. */
  63397. get hasTexture(): boolean;
  63398. /**
  63399. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63400. */
  63401. get reflectionColor(): string;
  63402. protected _getTexture(): Nullable<BaseTexture>;
  63403. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63404. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63405. /**
  63406. * Gets the code to inject in the vertex shader
  63407. * @param state current state of the node material building
  63408. * @returns the shader code
  63409. */
  63410. handleVertexSide(state: NodeMaterialBuildState): string;
  63411. /**
  63412. * Gets the main code of the block (fragment side)
  63413. * @param state current state of the node material building
  63414. * @param normalVarName name of the existing variable corresponding to the normal
  63415. * @returns the shader code
  63416. */
  63417. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63418. protected _buildBlock(state: NodeMaterialBuildState): this;
  63419. protected _dumpPropertiesCode(): string;
  63420. serialize(): any;
  63421. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63422. }
  63423. }
  63424. declare module BABYLON {
  63425. /**
  63426. * Block used to implement the sheen module of the PBR material
  63427. */
  63428. export class SheenBlock extends NodeMaterialBlock {
  63429. /**
  63430. * Create a new SheenBlock
  63431. * @param name defines the block name
  63432. */
  63433. constructor(name: string);
  63434. /**
  63435. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63436. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63437. * making it easier to setup and tweak the effect
  63438. */
  63439. albedoScaling: boolean;
  63440. /**
  63441. * Defines if the sheen is linked to the sheen color.
  63442. */
  63443. linkSheenWithAlbedo: boolean;
  63444. /**
  63445. * Initialize the block and prepare the context for build
  63446. * @param state defines the state that will be used for the build
  63447. */
  63448. initialize(state: NodeMaterialBuildState): void;
  63449. /**
  63450. * Gets the current class name
  63451. * @returns the class name
  63452. */
  63453. getClassName(): string;
  63454. /**
  63455. * Gets the intensity input component
  63456. */
  63457. get intensity(): NodeMaterialConnectionPoint;
  63458. /**
  63459. * Gets the color input component
  63460. */
  63461. get color(): NodeMaterialConnectionPoint;
  63462. /**
  63463. * Gets the roughness input component
  63464. */
  63465. get roughness(): NodeMaterialConnectionPoint;
  63466. /**
  63467. * Gets the sheen object output component
  63468. */
  63469. get sheen(): NodeMaterialConnectionPoint;
  63470. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63471. /**
  63472. * Gets the main code of the block (fragment side)
  63473. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63474. * @returns the shader code
  63475. */
  63476. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63477. protected _buildBlock(state: NodeMaterialBuildState): this;
  63478. protected _dumpPropertiesCode(): string;
  63479. serialize(): any;
  63480. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63481. }
  63482. }
  63483. declare module BABYLON {
  63484. /**
  63485. * Block used to implement the reflectivity module of the PBR material
  63486. */
  63487. export class ReflectivityBlock extends NodeMaterialBlock {
  63488. private _metallicReflectanceColor;
  63489. private _metallicF0Factor;
  63490. /** @hidden */
  63491. _vMetallicReflectanceFactorsName: string;
  63492. /**
  63493. * The property below is set by the main PBR block prior to calling methods of this class.
  63494. */
  63495. /** @hidden */
  63496. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63497. /**
  63498. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63499. */
  63500. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63501. /**
  63502. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63503. */
  63504. useMetallnessFromMetallicTextureBlue: boolean;
  63505. /**
  63506. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63507. */
  63508. useRoughnessFromMetallicTextureAlpha: boolean;
  63509. /**
  63510. * Specifies if the metallic texture contains the roughness information in its green channel.
  63511. */
  63512. useRoughnessFromMetallicTextureGreen: boolean;
  63513. /**
  63514. * Create a new ReflectivityBlock
  63515. * @param name defines the block name
  63516. */
  63517. constructor(name: string);
  63518. /**
  63519. * Initialize the block and prepare the context for build
  63520. * @param state defines the state that will be used for the build
  63521. */
  63522. initialize(state: NodeMaterialBuildState): void;
  63523. /**
  63524. * Gets the current class name
  63525. * @returns the class name
  63526. */
  63527. getClassName(): string;
  63528. /**
  63529. * Gets the metallic input component
  63530. */
  63531. get metallic(): NodeMaterialConnectionPoint;
  63532. /**
  63533. * Gets the roughness input component
  63534. */
  63535. get roughness(): NodeMaterialConnectionPoint;
  63536. /**
  63537. * Gets the texture input component
  63538. */
  63539. get texture(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the reflectivity object output component
  63542. */
  63543. get reflectivity(): NodeMaterialConnectionPoint;
  63544. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63545. /**
  63546. * Gets the main code of the block (fragment side)
  63547. * @param state current state of the node material building
  63548. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  63549. * @returns the shader code
  63550. */
  63551. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  63552. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63553. protected _buildBlock(state: NodeMaterialBuildState): this;
  63554. protected _dumpPropertiesCode(): string;
  63555. serialize(): any;
  63556. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63557. }
  63558. }
  63559. declare module BABYLON {
  63560. /**
  63561. * Block used to implement the anisotropy module of the PBR material
  63562. */
  63563. export class AnisotropyBlock extends NodeMaterialBlock {
  63564. /**
  63565. * The two properties below are set by the main PBR block prior to calling methods of this class.
  63566. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63567. * It's less burden on the user side in the editor part.
  63568. */
  63569. /** @hidden */
  63570. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63571. /** @hidden */
  63572. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63573. /**
  63574. * Create a new AnisotropyBlock
  63575. * @param name defines the block name
  63576. */
  63577. constructor(name: string);
  63578. /**
  63579. * Initialize the block and prepare the context for build
  63580. * @param state defines the state that will be used for the build
  63581. */
  63582. initialize(state: NodeMaterialBuildState): void;
  63583. /**
  63584. * Gets the current class name
  63585. * @returns the class name
  63586. */
  63587. getClassName(): string;
  63588. /**
  63589. * Gets the intensity input component
  63590. */
  63591. get intensity(): NodeMaterialConnectionPoint;
  63592. /**
  63593. * Gets the direction input component
  63594. */
  63595. get direction(): NodeMaterialConnectionPoint;
  63596. /**
  63597. * Gets the texture input component
  63598. */
  63599. get texture(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the uv input component
  63602. */
  63603. get uv(): NodeMaterialConnectionPoint;
  63604. /**
  63605. * Gets the worldTangent input component
  63606. */
  63607. get worldTangent(): NodeMaterialConnectionPoint;
  63608. /**
  63609. * Gets the anisotropy object output component
  63610. */
  63611. get anisotropy(): NodeMaterialConnectionPoint;
  63612. private _generateTBNSpace;
  63613. /**
  63614. * Gets the main code of the block (fragment side)
  63615. * @param state current state of the node material building
  63616. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63617. * @returns the shader code
  63618. */
  63619. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  63620. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63621. protected _buildBlock(state: NodeMaterialBuildState): this;
  63622. }
  63623. }
  63624. declare module BABYLON {
  63625. /**
  63626. * Block used to implement the clear coat module of the PBR material
  63627. */
  63628. export class ClearCoatBlock extends NodeMaterialBlock {
  63629. private _scene;
  63630. /**
  63631. * Create a new ClearCoatBlock
  63632. * @param name defines the block name
  63633. */
  63634. constructor(name: string);
  63635. /**
  63636. * Initialize the block and prepare the context for build
  63637. * @param state defines the state that will be used for the build
  63638. */
  63639. initialize(state: NodeMaterialBuildState): void;
  63640. /**
  63641. * Gets the current class name
  63642. * @returns the class name
  63643. */
  63644. getClassName(): string;
  63645. /**
  63646. * Gets the intensity input component
  63647. */
  63648. get intensity(): NodeMaterialConnectionPoint;
  63649. /**
  63650. * Gets the roughness input component
  63651. */
  63652. get roughness(): NodeMaterialConnectionPoint;
  63653. /**
  63654. * Gets the ior input component
  63655. */
  63656. get ior(): NodeMaterialConnectionPoint;
  63657. /**
  63658. * Gets the texture input component
  63659. */
  63660. get texture(): NodeMaterialConnectionPoint;
  63661. /**
  63662. * Gets the bump texture input component
  63663. */
  63664. get bumpTexture(): NodeMaterialConnectionPoint;
  63665. /**
  63666. * Gets the uv input component
  63667. */
  63668. get uv(): NodeMaterialConnectionPoint;
  63669. /**
  63670. * Gets the tint color input component
  63671. */
  63672. get tintColor(): NodeMaterialConnectionPoint;
  63673. /**
  63674. * Gets the tint "at distance" input component
  63675. */
  63676. get tintAtDistance(): NodeMaterialConnectionPoint;
  63677. /**
  63678. * Gets the tint thickness input component
  63679. */
  63680. get tintThickness(): NodeMaterialConnectionPoint;
  63681. /**
  63682. * Gets the world tangent input component
  63683. */
  63684. get worldTangent(): NodeMaterialConnectionPoint;
  63685. /**
  63686. * Gets the clear coat object output component
  63687. */
  63688. get clearcoat(): NodeMaterialConnectionPoint;
  63689. autoConfigure(material: NodeMaterial): void;
  63690. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63691. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63692. private _generateTBNSpace;
  63693. /**
  63694. * Gets the main code of the block (fragment side)
  63695. * @param state current state of the node material building
  63696. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  63697. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63698. * @param worldPosVarName name of the variable holding the world position
  63699. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  63700. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  63701. * @param worldNormalVarName name of the variable holding the world normal
  63702. * @returns the shader code
  63703. */
  63704. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  63705. protected _buildBlock(state: NodeMaterialBuildState): this;
  63706. }
  63707. }
  63708. declare module BABYLON {
  63709. /**
  63710. * Block used to implement the sub surface module of the PBR material
  63711. */
  63712. export class SubSurfaceBlock extends NodeMaterialBlock {
  63713. /**
  63714. * Create a new SubSurfaceBlock
  63715. * @param name defines the block name
  63716. */
  63717. constructor(name: string);
  63718. /**
  63719. * Stores the intensity of the different subsurface effects in the thickness texture.
  63720. * * the green channel is the translucency intensity.
  63721. * * the blue channel is the scattering intensity.
  63722. * * the alpha channel is the refraction intensity.
  63723. */
  63724. useMaskFromThicknessTexture: boolean;
  63725. /**
  63726. * Initialize the block and prepare the context for build
  63727. * @param state defines the state that will be used for the build
  63728. */
  63729. initialize(state: NodeMaterialBuildState): void;
  63730. /**
  63731. * Gets the current class name
  63732. * @returns the class name
  63733. */
  63734. getClassName(): string;
  63735. /**
  63736. * Gets the min thickness input component
  63737. */
  63738. get minThickness(): NodeMaterialConnectionPoint;
  63739. /**
  63740. * Gets the max thickness input component
  63741. */
  63742. get maxThickness(): NodeMaterialConnectionPoint;
  63743. /**
  63744. * Gets the thickness texture component
  63745. */
  63746. get thicknessTexture(): NodeMaterialConnectionPoint;
  63747. /**
  63748. * Gets the tint color input component
  63749. */
  63750. get tintColor(): NodeMaterialConnectionPoint;
  63751. /**
  63752. * Gets the translucency intensity input component
  63753. */
  63754. get translucencyIntensity(): NodeMaterialConnectionPoint;
  63755. /**
  63756. * Gets the translucency diffusion distance input component
  63757. */
  63758. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  63759. /**
  63760. * Gets the refraction object parameters
  63761. */
  63762. get refraction(): NodeMaterialConnectionPoint;
  63763. /**
  63764. * Gets the sub surface object output component
  63765. */
  63766. get subsurface(): NodeMaterialConnectionPoint;
  63767. autoConfigure(material: NodeMaterial): void;
  63768. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63769. /**
  63770. * Gets the main code of the block (fragment side)
  63771. * @param state current state of the node material building
  63772. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  63773. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63774. * @param worldPosVarName name of the variable holding the world position
  63775. * @returns the shader code
  63776. */
  63777. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  63778. protected _buildBlock(state: NodeMaterialBuildState): this;
  63779. }
  63780. }
  63781. declare module BABYLON {
  63782. /**
  63783. * Block used to implement the PBR metallic/roughness model
  63784. */
  63785. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  63786. /**
  63787. * Gets or sets the light associated with this block
  63788. */
  63789. light: Nullable<Light>;
  63790. private _lightId;
  63791. private _scene;
  63792. private _environmentBRDFTexture;
  63793. private _environmentBrdfSamplerName;
  63794. private _vNormalWName;
  63795. private _invertNormalName;
  63796. /**
  63797. * Create a new ReflectionBlock
  63798. * @param name defines the block name
  63799. */
  63800. constructor(name: string);
  63801. /**
  63802. * Intensity of the direct lights e.g. the four lights available in your scene.
  63803. * This impacts both the direct diffuse and specular highlights.
  63804. */
  63805. directIntensity: number;
  63806. /**
  63807. * Intensity of the environment e.g. how much the environment will light the object
  63808. * either through harmonics for rough material or through the refelction for shiny ones.
  63809. */
  63810. environmentIntensity: number;
  63811. /**
  63812. * This is a special control allowing the reduction of the specular highlights coming from the
  63813. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  63814. */
  63815. specularIntensity: number;
  63816. /**
  63817. * Defines the falloff type used in this material.
  63818. * It by default is Physical.
  63819. */
  63820. lightFalloff: number;
  63821. /**
  63822. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  63823. */
  63824. useAlphaFromAlbedoTexture: boolean;
  63825. /**
  63826. * Specifies that alpha test should be used
  63827. */
  63828. useAlphaTest: boolean;
  63829. /**
  63830. * Defines the alpha limits in alpha test mode.
  63831. */
  63832. alphaTestCutoff: number;
  63833. /**
  63834. * Specifies that alpha blending should be used
  63835. */
  63836. useAlphaBlending: boolean;
  63837. /**
  63838. * Defines if the alpha value should be determined via the rgb values.
  63839. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  63840. */
  63841. opacityRGB: boolean;
  63842. /**
  63843. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  63844. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  63845. */
  63846. useRadianceOverAlpha: boolean;
  63847. /**
  63848. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  63849. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  63850. */
  63851. useSpecularOverAlpha: boolean;
  63852. /**
  63853. * Enables specular anti aliasing in the PBR shader.
  63854. * It will both interacts on the Geometry for analytical and IBL lighting.
  63855. * It also prefilter the roughness map based on the bump values.
  63856. */
  63857. enableSpecularAntiAliasing: boolean;
  63858. /**
  63859. * Enables realtime filtering on the texture.
  63860. */
  63861. realTimeFiltering: boolean;
  63862. /**
  63863. * Quality switch for realtime filtering
  63864. */
  63865. realTimeFilteringQuality: number;
  63866. /**
  63867. * Defines if the material uses energy conservation.
  63868. */
  63869. useEnergyConservation: boolean;
  63870. /**
  63871. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  63872. * too much the area relying on ambient texture to define their ambient occlusion.
  63873. */
  63874. useRadianceOcclusion: boolean;
  63875. /**
  63876. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  63877. * makes the reflect vector face the model (under horizon).
  63878. */
  63879. useHorizonOcclusion: boolean;
  63880. /**
  63881. * If set to true, no lighting calculations will be applied.
  63882. */
  63883. unlit: boolean;
  63884. /**
  63885. * Force normal to face away from face.
  63886. */
  63887. forceNormalForward: boolean;
  63888. /**
  63889. * Defines the material debug mode.
  63890. * It helps seeing only some components of the material while troubleshooting.
  63891. */
  63892. debugMode: number;
  63893. /**
  63894. * Specify from where on screen the debug mode should start.
  63895. * The value goes from -1 (full screen) to 1 (not visible)
  63896. * It helps with side by side comparison against the final render
  63897. * This defaults to 0
  63898. */
  63899. debugLimit: number;
  63900. /**
  63901. * As the default viewing range might not be enough (if the ambient is really small for instance)
  63902. * You can use the factor to better multiply the final value.
  63903. */
  63904. debugFactor: number;
  63905. /**
  63906. * Initialize the block and prepare the context for build
  63907. * @param state defines the state that will be used for the build
  63908. */
  63909. initialize(state: NodeMaterialBuildState): void;
  63910. /**
  63911. * Gets the current class name
  63912. * @returns the class name
  63913. */
  63914. getClassName(): string;
  63915. /**
  63916. * Gets the world position input component
  63917. */
  63918. get worldPosition(): NodeMaterialConnectionPoint;
  63919. /**
  63920. * Gets the world normal input component
  63921. */
  63922. get worldNormal(): NodeMaterialConnectionPoint;
  63923. /**
  63924. * Gets the perturbed normal input component
  63925. */
  63926. get perturbedNormal(): NodeMaterialConnectionPoint;
  63927. /**
  63928. * Gets the camera position input component
  63929. */
  63930. get cameraPosition(): NodeMaterialConnectionPoint;
  63931. /**
  63932. * Gets the base color input component
  63933. */
  63934. get baseColor(): NodeMaterialConnectionPoint;
  63935. /**
  63936. * Gets the opacity texture input component
  63937. */
  63938. get opacityTexture(): NodeMaterialConnectionPoint;
  63939. /**
  63940. * Gets the ambient color input component
  63941. */
  63942. get ambientColor(): NodeMaterialConnectionPoint;
  63943. /**
  63944. * Gets the reflectivity object parameters
  63945. */
  63946. get reflectivity(): NodeMaterialConnectionPoint;
  63947. /**
  63948. * Gets the ambient occlusion object parameters
  63949. */
  63950. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63951. /**
  63952. * Gets the reflection object parameters
  63953. */
  63954. get reflection(): NodeMaterialConnectionPoint;
  63955. /**
  63956. * Gets the sheen object parameters
  63957. */
  63958. get sheen(): NodeMaterialConnectionPoint;
  63959. /**
  63960. * Gets the clear coat object parameters
  63961. */
  63962. get clearcoat(): NodeMaterialConnectionPoint;
  63963. /**
  63964. * Gets the sub surface object parameters
  63965. */
  63966. get subsurface(): NodeMaterialConnectionPoint;
  63967. /**
  63968. * Gets the anisotropy object parameters
  63969. */
  63970. get anisotropy(): NodeMaterialConnectionPoint;
  63971. /**
  63972. * Gets the ambient output component
  63973. */
  63974. get ambient(): NodeMaterialConnectionPoint;
  63975. /**
  63976. * Gets the diffuse output component
  63977. */
  63978. get diffuse(): NodeMaterialConnectionPoint;
  63979. /**
  63980. * Gets the specular output component
  63981. */
  63982. get specular(): NodeMaterialConnectionPoint;
  63983. /**
  63984. * Gets the sheen output component
  63985. */
  63986. get sheenDir(): NodeMaterialConnectionPoint;
  63987. /**
  63988. * Gets the clear coat output component
  63989. */
  63990. get clearcoatDir(): NodeMaterialConnectionPoint;
  63991. /**
  63992. * Gets the indirect diffuse output component
  63993. */
  63994. get diffuseIndirect(): NodeMaterialConnectionPoint;
  63995. /**
  63996. * Gets the indirect specular output component
  63997. */
  63998. get specularIndirect(): NodeMaterialConnectionPoint;
  63999. /**
  64000. * Gets the indirect sheen output component
  64001. */
  64002. get sheenIndirect(): NodeMaterialConnectionPoint;
  64003. /**
  64004. * Gets the indirect clear coat output component
  64005. */
  64006. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64007. /**
  64008. * Gets the refraction output component
  64009. */
  64010. get refraction(): NodeMaterialConnectionPoint;
  64011. /**
  64012. * Gets the global lighting output component
  64013. */
  64014. get lighting(): NodeMaterialConnectionPoint;
  64015. /**
  64016. * Gets the shadow output component
  64017. */
  64018. get shadow(): NodeMaterialConnectionPoint;
  64019. /**
  64020. * Gets the alpha output component
  64021. */
  64022. get alpha(): NodeMaterialConnectionPoint;
  64023. autoConfigure(material: NodeMaterial): void;
  64024. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64025. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64027. private _injectVertexCode;
  64028. /**
  64029. * Gets the code corresponding to the albedo/opacity module
  64030. * @returns the shader code
  64031. */
  64032. getAlbedoOpacityCode(): string;
  64033. protected _buildBlock(state: NodeMaterialBuildState): this;
  64034. protected _dumpPropertiesCode(): string;
  64035. serialize(): any;
  64036. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64037. }
  64038. }
  64039. declare module BABYLON {
  64040. /**
  64041. * Block used to compute value of one parameter modulo another
  64042. */
  64043. export class ModBlock extends NodeMaterialBlock {
  64044. /**
  64045. * Creates a new ModBlock
  64046. * @param name defines the block name
  64047. */
  64048. constructor(name: string);
  64049. /**
  64050. * Gets the current class name
  64051. * @returns the class name
  64052. */
  64053. getClassName(): string;
  64054. /**
  64055. * Gets the left operand input component
  64056. */
  64057. get left(): NodeMaterialConnectionPoint;
  64058. /**
  64059. * Gets the right operand input component
  64060. */
  64061. get right(): NodeMaterialConnectionPoint;
  64062. /**
  64063. * Gets the output component
  64064. */
  64065. get output(): NodeMaterialConnectionPoint;
  64066. protected _buildBlock(state: NodeMaterialBuildState): this;
  64067. }
  64068. }
  64069. declare module BABYLON {
  64070. /**
  64071. * Helper class to push actions to a pool of workers.
  64072. */
  64073. export class WorkerPool implements IDisposable {
  64074. private _workerInfos;
  64075. private _pendingActions;
  64076. /**
  64077. * Constructor
  64078. * @param workers Array of workers to use for actions
  64079. */
  64080. constructor(workers: Array<Worker>);
  64081. /**
  64082. * Terminates all workers and clears any pending actions.
  64083. */
  64084. dispose(): void;
  64085. /**
  64086. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64087. * pended until a worker has completed its action.
  64088. * @param action The action to perform. Call onComplete when the action is complete.
  64089. */
  64090. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64091. private _execute;
  64092. }
  64093. }
  64094. declare module BABYLON {
  64095. /**
  64096. * Configuration for Draco compression
  64097. */
  64098. export interface IDracoCompressionConfiguration {
  64099. /**
  64100. * Configuration for the decoder.
  64101. */
  64102. decoder: {
  64103. /**
  64104. * The url to the WebAssembly module.
  64105. */
  64106. wasmUrl?: string;
  64107. /**
  64108. * The url to the WebAssembly binary.
  64109. */
  64110. wasmBinaryUrl?: string;
  64111. /**
  64112. * The url to the fallback JavaScript module.
  64113. */
  64114. fallbackUrl?: string;
  64115. };
  64116. }
  64117. /**
  64118. * Draco compression (https://google.github.io/draco/)
  64119. *
  64120. * This class wraps the Draco module.
  64121. *
  64122. * **Encoder**
  64123. *
  64124. * The encoder is not currently implemented.
  64125. *
  64126. * **Decoder**
  64127. *
  64128. * 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.
  64129. *
  64130. * To update the configuration, use the following code:
  64131. * ```javascript
  64132. * DracoCompression.Configuration = {
  64133. * decoder: {
  64134. * wasmUrl: "<url to the WebAssembly library>",
  64135. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64136. * fallbackUrl: "<url to the fallback JavaScript library>",
  64137. * }
  64138. * };
  64139. * ```
  64140. *
  64141. * 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.
  64142. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64143. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64144. *
  64145. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64146. * ```javascript
  64147. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64148. * ```
  64149. *
  64150. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64151. */
  64152. export class DracoCompression implements IDisposable {
  64153. private _workerPoolPromise?;
  64154. private _decoderModulePromise?;
  64155. /**
  64156. * The configuration. Defaults to the following urls:
  64157. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64158. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64159. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64160. */
  64161. static Configuration: IDracoCompressionConfiguration;
  64162. /**
  64163. * Returns true if the decoder configuration is available.
  64164. */
  64165. static get DecoderAvailable(): boolean;
  64166. /**
  64167. * Default number of workers to create when creating the draco compression object.
  64168. */
  64169. static DefaultNumWorkers: number;
  64170. private static GetDefaultNumWorkers;
  64171. private static _Default;
  64172. /**
  64173. * Default instance for the draco compression object.
  64174. */
  64175. static get Default(): DracoCompression;
  64176. /**
  64177. * Constructor
  64178. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64179. */
  64180. constructor(numWorkers?: number);
  64181. /**
  64182. * Stop all async operations and release resources.
  64183. */
  64184. dispose(): void;
  64185. /**
  64186. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64187. * @returns a promise that resolves when ready
  64188. */
  64189. whenReadyAsync(): Promise<void>;
  64190. /**
  64191. * Decode Draco compressed mesh data to vertex data.
  64192. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64193. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64194. * @returns A promise that resolves with the decoded vertex data
  64195. */
  64196. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64197. [kind: string]: number;
  64198. }): Promise<VertexData>;
  64199. }
  64200. }
  64201. declare module BABYLON {
  64202. /**
  64203. * Class for building Constructive Solid Geometry
  64204. */
  64205. export class CSG {
  64206. private polygons;
  64207. /**
  64208. * The world matrix
  64209. */
  64210. matrix: Matrix;
  64211. /**
  64212. * Stores the position
  64213. */
  64214. position: Vector3;
  64215. /**
  64216. * Stores the rotation
  64217. */
  64218. rotation: Vector3;
  64219. /**
  64220. * Stores the rotation quaternion
  64221. */
  64222. rotationQuaternion: Nullable<Quaternion>;
  64223. /**
  64224. * Stores the scaling vector
  64225. */
  64226. scaling: Vector3;
  64227. /**
  64228. * Convert the Mesh to CSG
  64229. * @param mesh The Mesh to convert to CSG
  64230. * @returns A new CSG from the Mesh
  64231. */
  64232. static FromMesh(mesh: Mesh): CSG;
  64233. /**
  64234. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64235. * @param polygons Polygons used to construct a CSG solid
  64236. */
  64237. private static FromPolygons;
  64238. /**
  64239. * Clones, or makes a deep copy, of the CSG
  64240. * @returns A new CSG
  64241. */
  64242. clone(): CSG;
  64243. /**
  64244. * Unions this CSG with another CSG
  64245. * @param csg The CSG to union against this CSG
  64246. * @returns The unioned CSG
  64247. */
  64248. union(csg: CSG): CSG;
  64249. /**
  64250. * Unions this CSG with another CSG in place
  64251. * @param csg The CSG to union against this CSG
  64252. */
  64253. unionInPlace(csg: CSG): void;
  64254. /**
  64255. * Subtracts this CSG with another CSG
  64256. * @param csg The CSG to subtract against this CSG
  64257. * @returns A new CSG
  64258. */
  64259. subtract(csg: CSG): CSG;
  64260. /**
  64261. * Subtracts this CSG with another CSG in place
  64262. * @param csg The CSG to subtact against this CSG
  64263. */
  64264. subtractInPlace(csg: CSG): void;
  64265. /**
  64266. * Intersect this CSG with another CSG
  64267. * @param csg The CSG to intersect against this CSG
  64268. * @returns A new CSG
  64269. */
  64270. intersect(csg: CSG): CSG;
  64271. /**
  64272. * Intersects this CSG with another CSG in place
  64273. * @param csg The CSG to intersect against this CSG
  64274. */
  64275. intersectInPlace(csg: CSG): void;
  64276. /**
  64277. * Return a new CSG solid with solid and empty space switched. This solid is
  64278. * not modified.
  64279. * @returns A new CSG solid with solid and empty space switched
  64280. */
  64281. inverse(): CSG;
  64282. /**
  64283. * Inverses the CSG in place
  64284. */
  64285. inverseInPlace(): void;
  64286. /**
  64287. * This is used to keep meshes transformations so they can be restored
  64288. * when we build back a Babylon Mesh
  64289. * NB : All CSG operations are performed in world coordinates
  64290. * @param csg The CSG to copy the transform attributes from
  64291. * @returns This CSG
  64292. */
  64293. copyTransformAttributes(csg: CSG): CSG;
  64294. /**
  64295. * Build Raw mesh from CSG
  64296. * Coordinates here are in world space
  64297. * @param name The name of the mesh geometry
  64298. * @param scene The Scene
  64299. * @param keepSubMeshes Specifies if the submeshes should be kept
  64300. * @returns A new Mesh
  64301. */
  64302. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64303. /**
  64304. * Build Mesh from CSG taking material and transforms into account
  64305. * @param name The name of the Mesh
  64306. * @param material The material of the Mesh
  64307. * @param scene The Scene
  64308. * @param keepSubMeshes Specifies if submeshes should be kept
  64309. * @returns The new Mesh
  64310. */
  64311. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64312. }
  64313. }
  64314. declare module BABYLON {
  64315. /**
  64316. * Class used to create a trail following a mesh
  64317. */
  64318. export class TrailMesh extends Mesh {
  64319. private _generator;
  64320. private _autoStart;
  64321. private _running;
  64322. private _diameter;
  64323. private _length;
  64324. private _sectionPolygonPointsCount;
  64325. private _sectionVectors;
  64326. private _sectionNormalVectors;
  64327. private _beforeRenderObserver;
  64328. /**
  64329. * @constructor
  64330. * @param name The value used by scene.getMeshByName() to do a lookup.
  64331. * @param generator The mesh or transform node to generate a trail.
  64332. * @param scene The scene to add this mesh to.
  64333. * @param diameter Diameter of trailing mesh. Default is 1.
  64334. * @param length Length of trailing mesh. Default is 60.
  64335. * @param autoStart Automatically start trailing mesh. Default true.
  64336. */
  64337. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64338. /**
  64339. * "TrailMesh"
  64340. * @returns "TrailMesh"
  64341. */
  64342. getClassName(): string;
  64343. private _createMesh;
  64344. /**
  64345. * Start trailing mesh.
  64346. */
  64347. start(): void;
  64348. /**
  64349. * Stop trailing mesh.
  64350. */
  64351. stop(): void;
  64352. /**
  64353. * Update trailing mesh geometry.
  64354. */
  64355. update(): void;
  64356. /**
  64357. * Returns a new TrailMesh object.
  64358. * @param name is a string, the name given to the new mesh
  64359. * @param newGenerator use new generator object for cloned trail mesh
  64360. * @returns a new mesh
  64361. */
  64362. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64363. /**
  64364. * Serializes this trail mesh
  64365. * @param serializationObject object to write serialization to
  64366. */
  64367. serialize(serializationObject: any): void;
  64368. /**
  64369. * Parses a serialized trail mesh
  64370. * @param parsedMesh the serialized mesh
  64371. * @param scene the scene to create the trail mesh in
  64372. * @returns the created trail mesh
  64373. */
  64374. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64375. }
  64376. }
  64377. declare module BABYLON {
  64378. /**
  64379. * Class containing static functions to help procedurally build meshes
  64380. */
  64381. export class TiledBoxBuilder {
  64382. /**
  64383. * Creates a box mesh
  64384. * 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)
  64385. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64387. * * 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
  64388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64389. * @param name defines the name of the mesh
  64390. * @param options defines the options used to create the mesh
  64391. * @param scene defines the hosting scene
  64392. * @returns the box mesh
  64393. */
  64394. static CreateTiledBox(name: string, options: {
  64395. pattern?: number;
  64396. width?: number;
  64397. height?: number;
  64398. depth?: number;
  64399. tileSize?: number;
  64400. tileWidth?: number;
  64401. tileHeight?: number;
  64402. alignHorizontal?: number;
  64403. alignVertical?: number;
  64404. faceUV?: Vector4[];
  64405. faceColors?: Color4[];
  64406. sideOrientation?: number;
  64407. updatable?: boolean;
  64408. }, scene?: Nullable<Scene>): Mesh;
  64409. }
  64410. }
  64411. declare module BABYLON {
  64412. /**
  64413. * Class containing static functions to help procedurally build meshes
  64414. */
  64415. export class TorusKnotBuilder {
  64416. /**
  64417. * Creates a torus knot mesh
  64418. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64419. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64420. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64421. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64423. * * 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
  64424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64425. * @param name defines the name of the mesh
  64426. * @param options defines the options used to create the mesh
  64427. * @param scene defines the hosting scene
  64428. * @returns the torus knot mesh
  64429. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64430. */
  64431. static CreateTorusKnot(name: string, options: {
  64432. radius?: number;
  64433. tube?: number;
  64434. radialSegments?: number;
  64435. tubularSegments?: number;
  64436. p?: number;
  64437. q?: number;
  64438. updatable?: boolean;
  64439. sideOrientation?: number;
  64440. frontUVs?: Vector4;
  64441. backUVs?: Vector4;
  64442. }, scene: any): Mesh;
  64443. }
  64444. }
  64445. declare module BABYLON {
  64446. /**
  64447. * Polygon
  64448. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64449. */
  64450. export class Polygon {
  64451. /**
  64452. * Creates a rectangle
  64453. * @param xmin bottom X coord
  64454. * @param ymin bottom Y coord
  64455. * @param xmax top X coord
  64456. * @param ymax top Y coord
  64457. * @returns points that make the resulting rectation
  64458. */
  64459. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64460. /**
  64461. * Creates a circle
  64462. * @param radius radius of circle
  64463. * @param cx scale in x
  64464. * @param cy scale in y
  64465. * @param numberOfSides number of sides that make up the circle
  64466. * @returns points that make the resulting circle
  64467. */
  64468. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64469. /**
  64470. * Creates a polygon from input string
  64471. * @param input Input polygon data
  64472. * @returns the parsed points
  64473. */
  64474. static Parse(input: string): Vector2[];
  64475. /**
  64476. * Starts building a polygon from x and y coordinates
  64477. * @param x x coordinate
  64478. * @param y y coordinate
  64479. * @returns the started path2
  64480. */
  64481. static StartingAt(x: number, y: number): Path2;
  64482. }
  64483. /**
  64484. * Builds a polygon
  64485. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64486. */
  64487. export class PolygonMeshBuilder {
  64488. private _points;
  64489. private _outlinepoints;
  64490. private _holes;
  64491. private _name;
  64492. private _scene;
  64493. private _epoints;
  64494. private _eholes;
  64495. private _addToepoint;
  64496. /**
  64497. * Babylon reference to the earcut plugin.
  64498. */
  64499. bjsEarcut: any;
  64500. /**
  64501. * Creates a PolygonMeshBuilder
  64502. * @param name name of the builder
  64503. * @param contours Path of the polygon
  64504. * @param scene scene to add to when creating the mesh
  64505. * @param earcutInjection can be used to inject your own earcut reference
  64506. */
  64507. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64508. /**
  64509. * Adds a whole within the polygon
  64510. * @param hole Array of points defining the hole
  64511. * @returns this
  64512. */
  64513. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64514. /**
  64515. * Creates the polygon
  64516. * @param updatable If the mesh should be updatable
  64517. * @param depth The depth of the mesh created
  64518. * @returns the created mesh
  64519. */
  64520. build(updatable?: boolean, depth?: number): Mesh;
  64521. /**
  64522. * Creates the polygon
  64523. * @param depth The depth of the mesh created
  64524. * @returns the created VertexData
  64525. */
  64526. buildVertexData(depth?: number): VertexData;
  64527. /**
  64528. * Adds a side to the polygon
  64529. * @param positions points that make the polygon
  64530. * @param normals normals of the polygon
  64531. * @param uvs uvs of the polygon
  64532. * @param indices indices of the polygon
  64533. * @param bounds bounds of the polygon
  64534. * @param points points of the polygon
  64535. * @param depth depth of the polygon
  64536. * @param flip flip of the polygon
  64537. */
  64538. private addSide;
  64539. }
  64540. }
  64541. declare module BABYLON {
  64542. /**
  64543. * Class containing static functions to help procedurally build meshes
  64544. */
  64545. export class PolygonBuilder {
  64546. /**
  64547. * Creates a polygon mesh
  64548. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64549. * * 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
  64550. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64551. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64552. * * 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)
  64553. * * Remember you can only change the shape positions, not their number when updating a polygon
  64554. * @param name defines the name of the mesh
  64555. * @param options defines the options used to create the mesh
  64556. * @param scene defines the hosting scene
  64557. * @param earcutInjection can be used to inject your own earcut reference
  64558. * @returns the polygon mesh
  64559. */
  64560. static CreatePolygon(name: string, options: {
  64561. shape: Vector3[];
  64562. holes?: Vector3[][];
  64563. depth?: number;
  64564. faceUV?: Vector4[];
  64565. faceColors?: Color4[];
  64566. updatable?: boolean;
  64567. sideOrientation?: number;
  64568. frontUVs?: Vector4;
  64569. backUVs?: Vector4;
  64570. wrap?: boolean;
  64571. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64572. /**
  64573. * Creates an extruded polygon mesh, with depth in the Y direction.
  64574. * * 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)
  64575. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64576. * @param name defines the name of the mesh
  64577. * @param options defines the options used to create the mesh
  64578. * @param scene defines the hosting scene
  64579. * @param earcutInjection can be used to inject your own earcut reference
  64580. * @returns the polygon mesh
  64581. */
  64582. static ExtrudePolygon(name: string, options: {
  64583. shape: Vector3[];
  64584. holes?: Vector3[][];
  64585. depth?: number;
  64586. faceUV?: Vector4[];
  64587. faceColors?: Color4[];
  64588. updatable?: boolean;
  64589. sideOrientation?: number;
  64590. frontUVs?: Vector4;
  64591. backUVs?: Vector4;
  64592. wrap?: boolean;
  64593. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64594. }
  64595. }
  64596. declare module BABYLON {
  64597. /**
  64598. * Class containing static functions to help procedurally build meshes
  64599. */
  64600. export class LatheBuilder {
  64601. /**
  64602. * Creates lathe mesh.
  64603. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64604. * * 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
  64605. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64606. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64607. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64608. * * 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
  64609. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64610. * * 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
  64611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64612. * * 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
  64613. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64615. * @param name defines the name of the mesh
  64616. * @param options defines the options used to create the mesh
  64617. * @param scene defines the hosting scene
  64618. * @returns the lathe mesh
  64619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64620. */
  64621. static CreateLathe(name: string, options: {
  64622. shape: Vector3[];
  64623. radius?: number;
  64624. tessellation?: number;
  64625. clip?: number;
  64626. arc?: number;
  64627. closed?: boolean;
  64628. updatable?: boolean;
  64629. sideOrientation?: number;
  64630. frontUVs?: Vector4;
  64631. backUVs?: Vector4;
  64632. cap?: number;
  64633. invertUV?: boolean;
  64634. }, scene?: Nullable<Scene>): Mesh;
  64635. }
  64636. }
  64637. declare module BABYLON {
  64638. /**
  64639. * Class containing static functions to help procedurally build meshes
  64640. */
  64641. export class TiledPlaneBuilder {
  64642. /**
  64643. * Creates a tiled plane mesh
  64644. * * The parameter `pattern` will, depending on value, do nothing or
  64645. * * * flip (reflect about central vertical) alternate tiles across and up
  64646. * * * flip every tile on alternate rows
  64647. * * * rotate (180 degs) alternate tiles across and up
  64648. * * * rotate every tile on alternate rows
  64649. * * * flip and rotate alternate tiles across and up
  64650. * * * flip and rotate every tile on alternate rows
  64651. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64652. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64653. * * 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
  64654. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64655. * * 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)
  64656. * * 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)
  64657. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64658. * @param name defines the name of the mesh
  64659. * @param options defines the options used to create the mesh
  64660. * @param scene defines the hosting scene
  64661. * @returns the box mesh
  64662. */
  64663. static CreateTiledPlane(name: string, options: {
  64664. pattern?: number;
  64665. tileSize?: number;
  64666. tileWidth?: number;
  64667. tileHeight?: number;
  64668. size?: number;
  64669. width?: number;
  64670. height?: number;
  64671. alignHorizontal?: number;
  64672. alignVertical?: number;
  64673. sideOrientation?: number;
  64674. frontUVs?: Vector4;
  64675. backUVs?: Vector4;
  64676. updatable?: boolean;
  64677. }, scene?: Nullable<Scene>): Mesh;
  64678. }
  64679. }
  64680. declare module BABYLON {
  64681. /**
  64682. * Class containing static functions to help procedurally build meshes
  64683. */
  64684. export class TubeBuilder {
  64685. /**
  64686. * Creates a tube mesh.
  64687. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64688. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64689. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64690. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64691. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64692. * * 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)
  64693. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64694. * * 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
  64695. * * 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
  64696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64697. * * 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
  64698. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64700. * @param name defines the name of the mesh
  64701. * @param options defines the options used to create the mesh
  64702. * @param scene defines the hosting scene
  64703. * @returns the tube mesh
  64704. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64705. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64706. */
  64707. static CreateTube(name: string, options: {
  64708. path: Vector3[];
  64709. radius?: number;
  64710. tessellation?: number;
  64711. radiusFunction?: {
  64712. (i: number, distance: number): number;
  64713. };
  64714. cap?: number;
  64715. arc?: number;
  64716. updatable?: boolean;
  64717. sideOrientation?: number;
  64718. frontUVs?: Vector4;
  64719. backUVs?: Vector4;
  64720. instance?: Mesh;
  64721. invertUV?: boolean;
  64722. }, scene?: Nullable<Scene>): Mesh;
  64723. }
  64724. }
  64725. declare module BABYLON {
  64726. /**
  64727. * Class containing static functions to help procedurally build meshes
  64728. */
  64729. export class IcoSphereBuilder {
  64730. /**
  64731. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64732. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64733. * * 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`)
  64734. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64735. * * 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
  64736. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64737. * * 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
  64738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64739. * @param name defines the name of the mesh
  64740. * @param options defines the options used to create the mesh
  64741. * @param scene defines the hosting scene
  64742. * @returns the icosahedron mesh
  64743. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64744. */
  64745. static CreateIcoSphere(name: string, options: {
  64746. radius?: number;
  64747. radiusX?: number;
  64748. radiusY?: number;
  64749. radiusZ?: number;
  64750. flat?: boolean;
  64751. subdivisions?: number;
  64752. sideOrientation?: number;
  64753. frontUVs?: Vector4;
  64754. backUVs?: Vector4;
  64755. updatable?: boolean;
  64756. }, scene?: Nullable<Scene>): Mesh;
  64757. }
  64758. }
  64759. declare module BABYLON {
  64760. /**
  64761. * Class containing static functions to help procedurally build meshes
  64762. */
  64763. export class DecalBuilder {
  64764. /**
  64765. * Creates a decal mesh.
  64766. * 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
  64767. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64768. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64769. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64770. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64771. * @param name defines the name of the mesh
  64772. * @param sourceMesh defines the mesh where the decal must be applied
  64773. * @param options defines the options used to create the mesh
  64774. * @param scene defines the hosting scene
  64775. * @returns the decal mesh
  64776. * @see https://doc.babylonjs.com/how_to/decals
  64777. */
  64778. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64779. position?: Vector3;
  64780. normal?: Vector3;
  64781. size?: Vector3;
  64782. angle?: number;
  64783. }): Mesh;
  64784. }
  64785. }
  64786. declare module BABYLON {
  64787. /**
  64788. * Class containing static functions to help procedurally build meshes
  64789. */
  64790. export class MeshBuilder {
  64791. /**
  64792. * Creates a box mesh
  64793. * * The parameter `size` sets the size (float) of each box side (default 1)
  64794. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64795. * * 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)
  64796. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64798. * * 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
  64799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64800. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64801. * @param name defines the name of the mesh
  64802. * @param options defines the options used to create the mesh
  64803. * @param scene defines the hosting scene
  64804. * @returns the box mesh
  64805. */
  64806. static CreateBox(name: string, options: {
  64807. size?: number;
  64808. width?: number;
  64809. height?: number;
  64810. depth?: number;
  64811. faceUV?: Vector4[];
  64812. faceColors?: Color4[];
  64813. sideOrientation?: number;
  64814. frontUVs?: Vector4;
  64815. backUVs?: Vector4;
  64816. wrap?: boolean;
  64817. topBaseAt?: number;
  64818. bottomBaseAt?: number;
  64819. updatable?: boolean;
  64820. }, scene?: Nullable<Scene>): Mesh;
  64821. /**
  64822. * Creates a tiled box mesh
  64823. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64825. * @param name defines the name of the mesh
  64826. * @param options defines the options used to create the mesh
  64827. * @param scene defines the hosting scene
  64828. * @returns the tiled box mesh
  64829. */
  64830. static CreateTiledBox(name: string, options: {
  64831. pattern?: number;
  64832. size?: number;
  64833. width?: number;
  64834. height?: number;
  64835. depth: number;
  64836. tileSize?: number;
  64837. tileWidth?: number;
  64838. tileHeight?: number;
  64839. faceUV?: Vector4[];
  64840. faceColors?: Color4[];
  64841. alignHorizontal?: number;
  64842. alignVertical?: number;
  64843. sideOrientation?: number;
  64844. updatable?: boolean;
  64845. }, scene?: Nullable<Scene>): Mesh;
  64846. /**
  64847. * Creates a sphere mesh
  64848. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64849. * * 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`)
  64850. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64851. * * 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
  64852. * * 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)
  64853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64854. * * 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
  64855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64856. * @param name defines the name of the mesh
  64857. * @param options defines the options used to create the mesh
  64858. * @param scene defines the hosting scene
  64859. * @returns the sphere mesh
  64860. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64861. */
  64862. static CreateSphere(name: string, options: {
  64863. segments?: number;
  64864. diameter?: number;
  64865. diameterX?: number;
  64866. diameterY?: number;
  64867. diameterZ?: number;
  64868. arc?: number;
  64869. slice?: number;
  64870. sideOrientation?: number;
  64871. frontUVs?: Vector4;
  64872. backUVs?: Vector4;
  64873. updatable?: boolean;
  64874. }, scene?: Nullable<Scene>): Mesh;
  64875. /**
  64876. * Creates a plane polygonal mesh. By default, this is a disc
  64877. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64878. * * 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
  64879. * * 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
  64880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64881. * * 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
  64882. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64883. * @param name defines the name of the mesh
  64884. * @param options defines the options used to create the mesh
  64885. * @param scene defines the hosting scene
  64886. * @returns the plane polygonal mesh
  64887. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64888. */
  64889. static CreateDisc(name: string, options: {
  64890. radius?: number;
  64891. tessellation?: number;
  64892. arc?: number;
  64893. updatable?: boolean;
  64894. sideOrientation?: number;
  64895. frontUVs?: Vector4;
  64896. backUVs?: Vector4;
  64897. }, scene?: Nullable<Scene>): Mesh;
  64898. /**
  64899. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64900. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64901. * * 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`)
  64902. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64903. * * 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
  64904. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64905. * * 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
  64906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64907. * @param name defines the name of the mesh
  64908. * @param options defines the options used to create the mesh
  64909. * @param scene defines the hosting scene
  64910. * @returns the icosahedron mesh
  64911. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64912. */
  64913. static CreateIcoSphere(name: string, options: {
  64914. radius?: number;
  64915. radiusX?: number;
  64916. radiusY?: number;
  64917. radiusZ?: number;
  64918. flat?: boolean;
  64919. subdivisions?: number;
  64920. sideOrientation?: number;
  64921. frontUVs?: Vector4;
  64922. backUVs?: Vector4;
  64923. updatable?: boolean;
  64924. }, scene?: Nullable<Scene>): Mesh;
  64925. /**
  64926. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64927. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64928. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64929. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64930. * * 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
  64931. * * 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
  64932. * * 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
  64933. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64934. * * 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
  64935. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64936. * * 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
  64937. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64938. * * 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
  64939. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64941. * @param name defines the name of the mesh
  64942. * @param options defines the options used to create the mesh
  64943. * @param scene defines the hosting scene
  64944. * @returns the ribbon mesh
  64945. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64946. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64947. */
  64948. static CreateRibbon(name: string, options: {
  64949. pathArray: Vector3[][];
  64950. closeArray?: boolean;
  64951. closePath?: boolean;
  64952. offset?: number;
  64953. updatable?: boolean;
  64954. sideOrientation?: number;
  64955. frontUVs?: Vector4;
  64956. backUVs?: Vector4;
  64957. instance?: Mesh;
  64958. invertUV?: boolean;
  64959. uvs?: Vector2[];
  64960. colors?: Color4[];
  64961. }, scene?: Nullable<Scene>): Mesh;
  64962. /**
  64963. * Creates a cylinder or a cone mesh
  64964. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64965. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64966. * * 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.
  64967. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64968. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64969. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64970. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64971. * * 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).
  64972. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64973. * * 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).
  64974. * * 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
  64975. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64976. * * 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
  64977. * * 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.
  64978. * * If `enclose` is false, a ring surface is one element.
  64979. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64980. * * 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
  64981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64982. * * 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
  64983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64984. * @param name defines the name of the mesh
  64985. * @param options defines the options used to create the mesh
  64986. * @param scene defines the hosting scene
  64987. * @returns the cylinder mesh
  64988. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64989. */
  64990. static CreateCylinder(name: string, options: {
  64991. height?: number;
  64992. diameterTop?: number;
  64993. diameterBottom?: number;
  64994. diameter?: number;
  64995. tessellation?: number;
  64996. subdivisions?: number;
  64997. arc?: number;
  64998. faceColors?: Color4[];
  64999. faceUV?: Vector4[];
  65000. updatable?: boolean;
  65001. hasRings?: boolean;
  65002. enclose?: boolean;
  65003. cap?: number;
  65004. sideOrientation?: number;
  65005. frontUVs?: Vector4;
  65006. backUVs?: Vector4;
  65007. }, scene?: Nullable<Scene>): Mesh;
  65008. /**
  65009. * Creates a torus mesh
  65010. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65011. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65012. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65014. * * 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
  65015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65016. * @param name defines the name of the mesh
  65017. * @param options defines the options used to create the mesh
  65018. * @param scene defines the hosting scene
  65019. * @returns the torus mesh
  65020. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65021. */
  65022. static CreateTorus(name: string, options: {
  65023. diameter?: number;
  65024. thickness?: number;
  65025. tessellation?: number;
  65026. updatable?: boolean;
  65027. sideOrientation?: number;
  65028. frontUVs?: Vector4;
  65029. backUVs?: Vector4;
  65030. }, scene?: Nullable<Scene>): Mesh;
  65031. /**
  65032. * Creates a torus knot mesh
  65033. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65034. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65035. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65036. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65038. * * 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
  65039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65040. * @param name defines the name of the mesh
  65041. * @param options defines the options used to create the mesh
  65042. * @param scene defines the hosting scene
  65043. * @returns the torus knot mesh
  65044. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65045. */
  65046. static CreateTorusKnot(name: string, options: {
  65047. radius?: number;
  65048. tube?: number;
  65049. radialSegments?: number;
  65050. tubularSegments?: number;
  65051. p?: number;
  65052. q?: number;
  65053. updatable?: boolean;
  65054. sideOrientation?: number;
  65055. frontUVs?: Vector4;
  65056. backUVs?: Vector4;
  65057. }, scene?: Nullable<Scene>): Mesh;
  65058. /**
  65059. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65060. * * 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
  65061. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65062. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65063. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65064. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65065. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65066. * * 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
  65067. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65069. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65070. * @param name defines the name of the new line system
  65071. * @param options defines the options used to create the line system
  65072. * @param scene defines the hosting scene
  65073. * @returns a new line system mesh
  65074. */
  65075. static CreateLineSystem(name: string, options: {
  65076. lines: Vector3[][];
  65077. updatable?: boolean;
  65078. instance?: Nullable<LinesMesh>;
  65079. colors?: Nullable<Color4[][]>;
  65080. useVertexAlpha?: boolean;
  65081. }, scene: Nullable<Scene>): LinesMesh;
  65082. /**
  65083. * Creates a line mesh
  65084. * 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
  65085. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65086. * * The parameter `points` is an array successive Vector3
  65087. * * 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
  65088. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65089. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65090. * * When updating an instance, remember that only point positions can change, not the number of points
  65091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65093. * @param name defines the name of the new line system
  65094. * @param options defines the options used to create the line system
  65095. * @param scene defines the hosting scene
  65096. * @returns a new line mesh
  65097. */
  65098. static CreateLines(name: string, options: {
  65099. points: Vector3[];
  65100. updatable?: boolean;
  65101. instance?: Nullable<LinesMesh>;
  65102. colors?: Color4[];
  65103. useVertexAlpha?: boolean;
  65104. }, scene?: Nullable<Scene>): LinesMesh;
  65105. /**
  65106. * Creates a dashed line mesh
  65107. * * 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
  65108. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65109. * * The parameter `points` is an array successive Vector3
  65110. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65111. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65112. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65113. * * 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
  65114. * * When updating an instance, remember that only point positions can change, not the number of points
  65115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65116. * @param name defines the name of the mesh
  65117. * @param options defines the options used to create the mesh
  65118. * @param scene defines the hosting scene
  65119. * @returns the dashed line mesh
  65120. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65121. */
  65122. static CreateDashedLines(name: string, options: {
  65123. points: Vector3[];
  65124. dashSize?: number;
  65125. gapSize?: number;
  65126. dashNb?: number;
  65127. updatable?: boolean;
  65128. instance?: LinesMesh;
  65129. }, scene?: Nullable<Scene>): LinesMesh;
  65130. /**
  65131. * 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.
  65132. * * 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.
  65133. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65134. * * 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.
  65135. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65136. * * 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
  65137. * * 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
  65138. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65140. * * 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
  65141. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65142. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65143. * @param name defines the name of the mesh
  65144. * @param options defines the options used to create the mesh
  65145. * @param scene defines the hosting scene
  65146. * @returns the extruded shape mesh
  65147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65149. */
  65150. static ExtrudeShape(name: string, options: {
  65151. shape: Vector3[];
  65152. path: Vector3[];
  65153. scale?: number;
  65154. rotation?: number;
  65155. cap?: number;
  65156. updatable?: boolean;
  65157. sideOrientation?: number;
  65158. frontUVs?: Vector4;
  65159. backUVs?: Vector4;
  65160. instance?: Mesh;
  65161. invertUV?: boolean;
  65162. }, scene?: Nullable<Scene>): Mesh;
  65163. /**
  65164. * Creates an custom extruded shape mesh.
  65165. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65166. * * 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.
  65167. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65168. * * 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
  65169. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65170. * * 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
  65171. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65172. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65173. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65174. * * 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
  65175. * * 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
  65176. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65177. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65178. * * 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
  65179. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65181. * @param name defines the name of the mesh
  65182. * @param options defines the options used to create the mesh
  65183. * @param scene defines the hosting scene
  65184. * @returns the custom extruded shape mesh
  65185. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65186. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65188. */
  65189. static ExtrudeShapeCustom(name: string, options: {
  65190. shape: Vector3[];
  65191. path: Vector3[];
  65192. scaleFunction?: any;
  65193. rotationFunction?: any;
  65194. ribbonCloseArray?: boolean;
  65195. ribbonClosePath?: boolean;
  65196. cap?: number;
  65197. updatable?: boolean;
  65198. sideOrientation?: number;
  65199. frontUVs?: Vector4;
  65200. backUVs?: Vector4;
  65201. instance?: Mesh;
  65202. invertUV?: boolean;
  65203. }, scene?: Nullable<Scene>): Mesh;
  65204. /**
  65205. * Creates lathe mesh.
  65206. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65207. * * 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
  65208. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65209. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65210. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65211. * * 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
  65212. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65213. * * 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
  65214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65215. * * 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
  65216. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65217. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65218. * @param name defines the name of the mesh
  65219. * @param options defines the options used to create the mesh
  65220. * @param scene defines the hosting scene
  65221. * @returns the lathe mesh
  65222. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65223. */
  65224. static CreateLathe(name: string, options: {
  65225. shape: Vector3[];
  65226. radius?: number;
  65227. tessellation?: number;
  65228. clip?: number;
  65229. arc?: number;
  65230. closed?: boolean;
  65231. updatable?: boolean;
  65232. sideOrientation?: number;
  65233. frontUVs?: Vector4;
  65234. backUVs?: Vector4;
  65235. cap?: number;
  65236. invertUV?: boolean;
  65237. }, scene?: Nullable<Scene>): Mesh;
  65238. /**
  65239. * Creates a tiled plane mesh
  65240. * * You can set a limited pattern arrangement with the tiles
  65241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65242. * * 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
  65243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65244. * @param name defines the name of the mesh
  65245. * @param options defines the options used to create the mesh
  65246. * @param scene defines the hosting scene
  65247. * @returns the plane mesh
  65248. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65249. */
  65250. static CreateTiledPlane(name: string, options: {
  65251. pattern?: number;
  65252. tileSize?: number;
  65253. tileWidth?: number;
  65254. tileHeight?: number;
  65255. size?: number;
  65256. width?: number;
  65257. height?: number;
  65258. alignHorizontal?: number;
  65259. alignVertical?: number;
  65260. sideOrientation?: number;
  65261. frontUVs?: Vector4;
  65262. backUVs?: Vector4;
  65263. updatable?: boolean;
  65264. }, scene?: Nullable<Scene>): Mesh;
  65265. /**
  65266. * Creates a plane mesh
  65267. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65268. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65269. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65270. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65271. * * 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
  65272. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65273. * @param name defines the name of the mesh
  65274. * @param options defines the options used to create the mesh
  65275. * @param scene defines the hosting scene
  65276. * @returns the plane mesh
  65277. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65278. */
  65279. static CreatePlane(name: string, options: {
  65280. size?: number;
  65281. width?: number;
  65282. height?: number;
  65283. sideOrientation?: number;
  65284. frontUVs?: Vector4;
  65285. backUVs?: Vector4;
  65286. updatable?: boolean;
  65287. sourcePlane?: Plane;
  65288. }, scene?: Nullable<Scene>): Mesh;
  65289. /**
  65290. * Creates a ground mesh
  65291. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65292. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65294. * @param name defines the name of the mesh
  65295. * @param options defines the options used to create the mesh
  65296. * @param scene defines the hosting scene
  65297. * @returns the ground mesh
  65298. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65299. */
  65300. static CreateGround(name: string, options: {
  65301. width?: number;
  65302. height?: number;
  65303. subdivisions?: number;
  65304. subdivisionsX?: number;
  65305. subdivisionsY?: number;
  65306. updatable?: boolean;
  65307. }, scene?: Nullable<Scene>): Mesh;
  65308. /**
  65309. * Creates a tiled ground mesh
  65310. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65311. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65312. * * 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
  65313. * * 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
  65314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65315. * @param name defines the name of the mesh
  65316. * @param options defines the options used to create the mesh
  65317. * @param scene defines the hosting scene
  65318. * @returns the tiled ground mesh
  65319. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65320. */
  65321. static CreateTiledGround(name: string, options: {
  65322. xmin: number;
  65323. zmin: number;
  65324. xmax: number;
  65325. zmax: number;
  65326. subdivisions?: {
  65327. w: number;
  65328. h: number;
  65329. };
  65330. precision?: {
  65331. w: number;
  65332. h: number;
  65333. };
  65334. updatable?: boolean;
  65335. }, scene?: Nullable<Scene>): Mesh;
  65336. /**
  65337. * Creates a ground mesh from a height map
  65338. * * The parameter `url` sets the URL of the height map image resource.
  65339. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65340. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65341. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65342. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65343. * * 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.
  65344. * * 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).
  65345. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65347. * @param name defines the name of the mesh
  65348. * @param url defines the url to the height map
  65349. * @param options defines the options used to create the mesh
  65350. * @param scene defines the hosting scene
  65351. * @returns the ground mesh
  65352. * @see https://doc.babylonjs.com/babylon101/height_map
  65353. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65354. */
  65355. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65356. width?: number;
  65357. height?: number;
  65358. subdivisions?: number;
  65359. minHeight?: number;
  65360. maxHeight?: number;
  65361. colorFilter?: Color3;
  65362. alphaFilter?: number;
  65363. updatable?: boolean;
  65364. onReady?: (mesh: GroundMesh) => void;
  65365. }, scene?: Nullable<Scene>): GroundMesh;
  65366. /**
  65367. * Creates a polygon mesh
  65368. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65369. * * 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
  65370. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65372. * * 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)
  65373. * * Remember you can only change the shape positions, not their number when updating a polygon
  65374. * @param name defines the name of the mesh
  65375. * @param options defines the options used to create the mesh
  65376. * @param scene defines the hosting scene
  65377. * @param earcutInjection can be used to inject your own earcut reference
  65378. * @returns the polygon mesh
  65379. */
  65380. static CreatePolygon(name: string, options: {
  65381. shape: Vector3[];
  65382. holes?: Vector3[][];
  65383. depth?: number;
  65384. faceUV?: Vector4[];
  65385. faceColors?: Color4[];
  65386. updatable?: boolean;
  65387. sideOrientation?: number;
  65388. frontUVs?: Vector4;
  65389. backUVs?: Vector4;
  65390. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65391. /**
  65392. * Creates an extruded polygon mesh, with depth in the Y direction.
  65393. * * 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)
  65394. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65395. * @param name defines the name of the mesh
  65396. * @param options defines the options used to create the mesh
  65397. * @param scene defines the hosting scene
  65398. * @param earcutInjection can be used to inject your own earcut reference
  65399. * @returns the polygon mesh
  65400. */
  65401. static ExtrudePolygon(name: string, options: {
  65402. shape: Vector3[];
  65403. holes?: Vector3[][];
  65404. depth?: number;
  65405. faceUV?: Vector4[];
  65406. faceColors?: Color4[];
  65407. updatable?: boolean;
  65408. sideOrientation?: number;
  65409. frontUVs?: Vector4;
  65410. backUVs?: Vector4;
  65411. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65412. /**
  65413. * Creates a tube mesh.
  65414. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65415. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65416. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65417. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65418. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65419. * * 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)
  65420. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65421. * * 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
  65422. * * 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
  65423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65424. * * 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
  65425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65426. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65427. * @param name defines the name of the mesh
  65428. * @param options defines the options used to create the mesh
  65429. * @param scene defines the hosting scene
  65430. * @returns the tube mesh
  65431. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65432. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65433. */
  65434. static CreateTube(name: string, options: {
  65435. path: Vector3[];
  65436. radius?: number;
  65437. tessellation?: number;
  65438. radiusFunction?: {
  65439. (i: number, distance: number): number;
  65440. };
  65441. cap?: number;
  65442. arc?: number;
  65443. updatable?: boolean;
  65444. sideOrientation?: number;
  65445. frontUVs?: Vector4;
  65446. backUVs?: Vector4;
  65447. instance?: Mesh;
  65448. invertUV?: boolean;
  65449. }, scene?: Nullable<Scene>): Mesh;
  65450. /**
  65451. * Creates a polyhedron mesh
  65452. * * 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
  65453. * * The parameter `size` (positive float, default 1) sets the polygon size
  65454. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65455. * * 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`
  65456. * * 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
  65457. * * 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)`)
  65458. * * 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
  65459. * * 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
  65460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65461. * * 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
  65462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65463. * @param name defines the name of the mesh
  65464. * @param options defines the options used to create the mesh
  65465. * @param scene defines the hosting scene
  65466. * @returns the polyhedron mesh
  65467. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65468. */
  65469. static CreatePolyhedron(name: string, options: {
  65470. type?: number;
  65471. size?: number;
  65472. sizeX?: number;
  65473. sizeY?: number;
  65474. sizeZ?: number;
  65475. custom?: any;
  65476. faceUV?: Vector4[];
  65477. faceColors?: Color4[];
  65478. flat?: boolean;
  65479. updatable?: boolean;
  65480. sideOrientation?: number;
  65481. frontUVs?: Vector4;
  65482. backUVs?: Vector4;
  65483. }, scene?: Nullable<Scene>): Mesh;
  65484. /**
  65485. * Creates a decal mesh.
  65486. * 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
  65487. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65488. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65489. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65490. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65491. * @param name defines the name of the mesh
  65492. * @param sourceMesh defines the mesh where the decal must be applied
  65493. * @param options defines the options used to create the mesh
  65494. * @param scene defines the hosting scene
  65495. * @returns the decal mesh
  65496. * @see https://doc.babylonjs.com/how_to/decals
  65497. */
  65498. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65499. position?: Vector3;
  65500. normal?: Vector3;
  65501. size?: Vector3;
  65502. angle?: number;
  65503. }): Mesh;
  65504. }
  65505. }
  65506. declare module BABYLON {
  65507. /**
  65508. * A simplifier interface for future simplification implementations
  65509. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65510. */
  65511. export interface ISimplifier {
  65512. /**
  65513. * Simplification of a given mesh according to the given settings.
  65514. * Since this requires computation, it is assumed that the function runs async.
  65515. * @param settings The settings of the simplification, including quality and distance
  65516. * @param successCallback A callback that will be called after the mesh was simplified.
  65517. * @param errorCallback in case of an error, this callback will be called. optional.
  65518. */
  65519. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65520. }
  65521. /**
  65522. * Expected simplification settings.
  65523. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65524. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65525. */
  65526. export interface ISimplificationSettings {
  65527. /**
  65528. * Gets or sets the expected quality
  65529. */
  65530. quality: number;
  65531. /**
  65532. * Gets or sets the distance when this optimized version should be used
  65533. */
  65534. distance: number;
  65535. /**
  65536. * Gets an already optimized mesh
  65537. */
  65538. optimizeMesh?: boolean;
  65539. }
  65540. /**
  65541. * Class used to specify simplification options
  65542. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65543. */
  65544. export class SimplificationSettings implements ISimplificationSettings {
  65545. /** expected quality */
  65546. quality: number;
  65547. /** distance when this optimized version should be used */
  65548. distance: number;
  65549. /** already optimized mesh */
  65550. optimizeMesh?: boolean | undefined;
  65551. /**
  65552. * Creates a SimplificationSettings
  65553. * @param quality expected quality
  65554. * @param distance distance when this optimized version should be used
  65555. * @param optimizeMesh already optimized mesh
  65556. */
  65557. constructor(
  65558. /** expected quality */
  65559. quality: number,
  65560. /** distance when this optimized version should be used */
  65561. distance: number,
  65562. /** already optimized mesh */
  65563. optimizeMesh?: boolean | undefined);
  65564. }
  65565. /**
  65566. * Interface used to define a simplification task
  65567. */
  65568. export interface ISimplificationTask {
  65569. /**
  65570. * Array of settings
  65571. */
  65572. settings: Array<ISimplificationSettings>;
  65573. /**
  65574. * Simplification type
  65575. */
  65576. simplificationType: SimplificationType;
  65577. /**
  65578. * Mesh to simplify
  65579. */
  65580. mesh: Mesh;
  65581. /**
  65582. * Callback called on success
  65583. */
  65584. successCallback?: () => void;
  65585. /**
  65586. * Defines if parallel processing can be used
  65587. */
  65588. parallelProcessing: boolean;
  65589. }
  65590. /**
  65591. * Queue used to order the simplification tasks
  65592. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65593. */
  65594. export class SimplificationQueue {
  65595. private _simplificationArray;
  65596. /**
  65597. * Gets a boolean indicating that the process is still running
  65598. */
  65599. running: boolean;
  65600. /**
  65601. * Creates a new queue
  65602. */
  65603. constructor();
  65604. /**
  65605. * Adds a new simplification task
  65606. * @param task defines a task to add
  65607. */
  65608. addTask(task: ISimplificationTask): void;
  65609. /**
  65610. * Execute next task
  65611. */
  65612. executeNext(): void;
  65613. /**
  65614. * Execute a simplification task
  65615. * @param task defines the task to run
  65616. */
  65617. runSimplification(task: ISimplificationTask): void;
  65618. private getSimplifier;
  65619. }
  65620. /**
  65621. * The implemented types of simplification
  65622. * At the moment only Quadratic Error Decimation is implemented
  65623. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65624. */
  65625. export enum SimplificationType {
  65626. /** Quadratic error decimation */
  65627. QUADRATIC = 0
  65628. }
  65629. /**
  65630. * An implementation of the Quadratic Error simplification algorithm.
  65631. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65632. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65633. * @author RaananW
  65634. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65635. */
  65636. export class QuadraticErrorSimplification implements ISimplifier {
  65637. private _mesh;
  65638. private triangles;
  65639. private vertices;
  65640. private references;
  65641. private _reconstructedMesh;
  65642. /** Gets or sets the number pf sync interations */
  65643. syncIterations: number;
  65644. /** Gets or sets the aggressiveness of the simplifier */
  65645. aggressiveness: number;
  65646. /** Gets or sets the number of allowed iterations for decimation */
  65647. decimationIterations: number;
  65648. /** Gets or sets the espilon to use for bounding box computation */
  65649. boundingBoxEpsilon: number;
  65650. /**
  65651. * Creates a new QuadraticErrorSimplification
  65652. * @param _mesh defines the target mesh
  65653. */
  65654. constructor(_mesh: Mesh);
  65655. /**
  65656. * Simplification of a given mesh according to the given settings.
  65657. * Since this requires computation, it is assumed that the function runs async.
  65658. * @param settings The settings of the simplification, including quality and distance
  65659. * @param successCallback A callback that will be called after the mesh was simplified.
  65660. */
  65661. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65662. private runDecimation;
  65663. private initWithMesh;
  65664. private init;
  65665. private reconstructMesh;
  65666. private initDecimatedMesh;
  65667. private isFlipped;
  65668. private updateTriangles;
  65669. private identifyBorder;
  65670. private updateMesh;
  65671. private vertexError;
  65672. private calculateError;
  65673. }
  65674. }
  65675. declare module BABYLON {
  65676. interface Scene {
  65677. /** @hidden (Backing field) */
  65678. _simplificationQueue: SimplificationQueue;
  65679. /**
  65680. * Gets or sets the simplification queue attached to the scene
  65681. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65682. */
  65683. simplificationQueue: SimplificationQueue;
  65684. }
  65685. interface Mesh {
  65686. /**
  65687. * Simplify the mesh according to the given array of settings.
  65688. * Function will return immediately and will simplify async
  65689. * @param settings a collection of simplification settings
  65690. * @param parallelProcessing should all levels calculate parallel or one after the other
  65691. * @param simplificationType the type of simplification to run
  65692. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65693. * @returns the current mesh
  65694. */
  65695. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65696. }
  65697. /**
  65698. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65699. * created in a scene
  65700. */
  65701. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65702. /**
  65703. * The component name helpfull to identify the component in the list of scene components.
  65704. */
  65705. readonly name: string;
  65706. /**
  65707. * The scene the component belongs to.
  65708. */
  65709. scene: Scene;
  65710. /**
  65711. * Creates a new instance of the component for the given scene
  65712. * @param scene Defines the scene to register the component in
  65713. */
  65714. constructor(scene: Scene);
  65715. /**
  65716. * Registers the component in a given scene
  65717. */
  65718. register(): void;
  65719. /**
  65720. * Rebuilds the elements related to this component in case of
  65721. * context lost for instance.
  65722. */
  65723. rebuild(): void;
  65724. /**
  65725. * Disposes the component and the associated ressources
  65726. */
  65727. dispose(): void;
  65728. private _beforeCameraUpdate;
  65729. }
  65730. }
  65731. declare module BABYLON {
  65732. interface Mesh {
  65733. /**
  65734. * Creates a new thin instance
  65735. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  65736. * @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
  65737. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  65738. */
  65739. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  65740. /**
  65741. * Adds the transformation (matrix) of the current mesh as a thin instance
  65742. * @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
  65743. * @returns the thin instance index number
  65744. */
  65745. thinInstanceAddSelf(refresh: boolean): number;
  65746. /**
  65747. * Registers a custom attribute to be used with thin instances
  65748. * @param kind name of the attribute
  65749. * @param stride size in floats of the attribute
  65750. */
  65751. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  65752. /**
  65753. * Sets the matrix of a thin instance
  65754. * @param index index of the thin instance
  65755. * @param matrix matrix to set
  65756. * @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
  65757. */
  65758. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  65759. /**
  65760. * Sets the value of a custom attribute for a thin instance
  65761. * @param kind name of the attribute
  65762. * @param index index of the thin instance
  65763. * @param value value to set
  65764. * @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
  65765. */
  65766. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  65767. /**
  65768. * 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.
  65769. */
  65770. thinInstanceCount: number;
  65771. /**
  65772. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  65773. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  65774. * @param buffer buffer to set
  65775. * @param stride size in floats of each value of the buffer
  65776. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  65777. */
  65778. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  65779. /**
  65780. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  65781. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  65782. */
  65783. thinInstanceBufferUpdated(kind: string): void;
  65784. /**
  65785. * Refreshes the bounding info, taking into account all the thin instances defined
  65786. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  65787. */
  65788. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  65789. /** @hidden */
  65790. _thinInstanceInitializeUserStorage(): void;
  65791. /** @hidden */
  65792. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  65793. /** @hidden */
  65794. _userThinInstanceBuffersStorage: {
  65795. data: {
  65796. [key: string]: Float32Array;
  65797. };
  65798. sizes: {
  65799. [key: string]: number;
  65800. };
  65801. vertexBuffers: {
  65802. [key: string]: Nullable<VertexBuffer>;
  65803. };
  65804. strides: {
  65805. [key: string]: number;
  65806. };
  65807. };
  65808. }
  65809. }
  65810. declare module BABYLON {
  65811. /**
  65812. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65813. */
  65814. export interface INavigationEnginePlugin {
  65815. /**
  65816. * plugin name
  65817. */
  65818. name: string;
  65819. /**
  65820. * Creates a navigation mesh
  65821. * @param meshes array of all the geometry used to compute the navigatio mesh
  65822. * @param parameters bunch of parameters used to filter geometry
  65823. */
  65824. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65825. /**
  65826. * Create a navigation mesh debug mesh
  65827. * @param scene is where the mesh will be added
  65828. * @returns debug display mesh
  65829. */
  65830. createDebugNavMesh(scene: Scene): Mesh;
  65831. /**
  65832. * Get a navigation mesh constrained position, closest to the parameter position
  65833. * @param position world position
  65834. * @returns the closest point to position constrained by the navigation mesh
  65835. */
  65836. getClosestPoint(position: Vector3): Vector3;
  65837. /**
  65838. * Get a navigation mesh constrained position, closest to the parameter position
  65839. * @param position world position
  65840. * @param result output the closest point to position constrained by the navigation mesh
  65841. */
  65842. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65843. /**
  65844. * Get a navigation mesh constrained position, within a particular radius
  65845. * @param position world position
  65846. * @param maxRadius the maximum distance to the constrained world position
  65847. * @returns the closest point to position constrained by the navigation mesh
  65848. */
  65849. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65850. /**
  65851. * Get a navigation mesh constrained position, within a particular radius
  65852. * @param position world position
  65853. * @param maxRadius the maximum distance to the constrained world position
  65854. * @param result output the closest point to position constrained by the navigation mesh
  65855. */
  65856. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65857. /**
  65858. * Compute the final position from a segment made of destination-position
  65859. * @param position world position
  65860. * @param destination world position
  65861. * @returns the resulting point along the navmesh
  65862. */
  65863. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65864. /**
  65865. * Compute the final position from a segment made of destination-position
  65866. * @param position world position
  65867. * @param destination world position
  65868. * @param result output the resulting point along the navmesh
  65869. */
  65870. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65871. /**
  65872. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65873. * @param start world position
  65874. * @param end world position
  65875. * @returns array containing world position composing the path
  65876. */
  65877. computePath(start: Vector3, end: Vector3): Vector3[];
  65878. /**
  65879. * If this plugin is supported
  65880. * @returns true if plugin is supported
  65881. */
  65882. isSupported(): boolean;
  65883. /**
  65884. * Create a new Crowd so you can add agents
  65885. * @param maxAgents the maximum agent count in the crowd
  65886. * @param maxAgentRadius the maximum radius an agent can have
  65887. * @param scene to attach the crowd to
  65888. * @returns the crowd you can add agents to
  65889. */
  65890. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65891. /**
  65892. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65893. * The queries will try to find a solution within those bounds
  65894. * default is (1,1,1)
  65895. * @param extent x,y,z value that define the extent around the queries point of reference
  65896. */
  65897. setDefaultQueryExtent(extent: Vector3): void;
  65898. /**
  65899. * Get the Bounding box extent specified by setDefaultQueryExtent
  65900. * @returns the box extent values
  65901. */
  65902. getDefaultQueryExtent(): Vector3;
  65903. /**
  65904. * build the navmesh from a previously saved state using getNavmeshData
  65905. * @param data the Uint8Array returned by getNavmeshData
  65906. */
  65907. buildFromNavmeshData(data: Uint8Array): void;
  65908. /**
  65909. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65910. * @returns data the Uint8Array that can be saved and reused
  65911. */
  65912. getNavmeshData(): Uint8Array;
  65913. /**
  65914. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65915. * @param result output the box extent values
  65916. */
  65917. getDefaultQueryExtentToRef(result: Vector3): void;
  65918. /**
  65919. * Release all resources
  65920. */
  65921. dispose(): void;
  65922. }
  65923. /**
  65924. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65925. */
  65926. export interface ICrowd {
  65927. /**
  65928. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65929. * You can attach anything to that node. The node position is updated in the scene update tick.
  65930. * @param pos world position that will be constrained by the navigation mesh
  65931. * @param parameters agent parameters
  65932. * @param transform hooked to the agent that will be update by the scene
  65933. * @returns agent index
  65934. */
  65935. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65936. /**
  65937. * Returns the agent position in world space
  65938. * @param index agent index returned by addAgent
  65939. * @returns world space position
  65940. */
  65941. getAgentPosition(index: number): Vector3;
  65942. /**
  65943. * Gets the agent position result in world space
  65944. * @param index agent index returned by addAgent
  65945. * @param result output world space position
  65946. */
  65947. getAgentPositionToRef(index: number, result: Vector3): void;
  65948. /**
  65949. * Gets the agent velocity in world space
  65950. * @param index agent index returned by addAgent
  65951. * @returns world space velocity
  65952. */
  65953. getAgentVelocity(index: number): Vector3;
  65954. /**
  65955. * Gets the agent velocity result in world space
  65956. * @param index agent index returned by addAgent
  65957. * @param result output world space velocity
  65958. */
  65959. getAgentVelocityToRef(index: number, result: Vector3): void;
  65960. /**
  65961. * remove a particular agent previously created
  65962. * @param index agent index returned by addAgent
  65963. */
  65964. removeAgent(index: number): void;
  65965. /**
  65966. * get the list of all agents attached to this crowd
  65967. * @returns list of agent indices
  65968. */
  65969. getAgents(): number[];
  65970. /**
  65971. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65972. * @param deltaTime in seconds
  65973. */
  65974. update(deltaTime: number): void;
  65975. /**
  65976. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65977. * @param index agent index returned by addAgent
  65978. * @param destination targeted world position
  65979. */
  65980. agentGoto(index: number, destination: Vector3): void;
  65981. /**
  65982. * Teleport the agent to a new position
  65983. * @param index agent index returned by addAgent
  65984. * @param destination targeted world position
  65985. */
  65986. agentTeleport(index: number, destination: Vector3): void;
  65987. /**
  65988. * Update agent parameters
  65989. * @param index agent index returned by addAgent
  65990. * @param parameters agent parameters
  65991. */
  65992. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65993. /**
  65994. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65995. * The queries will try to find a solution within those bounds
  65996. * default is (1,1,1)
  65997. * @param extent x,y,z value that define the extent around the queries point of reference
  65998. */
  65999. setDefaultQueryExtent(extent: Vector3): void;
  66000. /**
  66001. * Get the Bounding box extent specified by setDefaultQueryExtent
  66002. * @returns the box extent values
  66003. */
  66004. getDefaultQueryExtent(): Vector3;
  66005. /**
  66006. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66007. * @param result output the box extent values
  66008. */
  66009. getDefaultQueryExtentToRef(result: Vector3): void;
  66010. /**
  66011. * Release all resources
  66012. */
  66013. dispose(): void;
  66014. }
  66015. /**
  66016. * Configures an agent
  66017. */
  66018. export interface IAgentParameters {
  66019. /**
  66020. * Agent radius. [Limit: >= 0]
  66021. */
  66022. radius: number;
  66023. /**
  66024. * Agent height. [Limit: > 0]
  66025. */
  66026. height: number;
  66027. /**
  66028. * Maximum allowed acceleration. [Limit: >= 0]
  66029. */
  66030. maxAcceleration: number;
  66031. /**
  66032. * Maximum allowed speed. [Limit: >= 0]
  66033. */
  66034. maxSpeed: number;
  66035. /**
  66036. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66037. */
  66038. collisionQueryRange: number;
  66039. /**
  66040. * The path visibility optimization range. [Limit: > 0]
  66041. */
  66042. pathOptimizationRange: number;
  66043. /**
  66044. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66045. */
  66046. separationWeight: number;
  66047. }
  66048. /**
  66049. * Configures the navigation mesh creation
  66050. */
  66051. export interface INavMeshParameters {
  66052. /**
  66053. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66054. */
  66055. cs: number;
  66056. /**
  66057. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66058. */
  66059. ch: number;
  66060. /**
  66061. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66062. */
  66063. walkableSlopeAngle: number;
  66064. /**
  66065. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66066. * be considered walkable. [Limit: >= 3] [Units: vx]
  66067. */
  66068. walkableHeight: number;
  66069. /**
  66070. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66071. */
  66072. walkableClimb: number;
  66073. /**
  66074. * The distance to erode/shrink the walkable area of the heightfield away from
  66075. * obstructions. [Limit: >=0] [Units: vx]
  66076. */
  66077. walkableRadius: number;
  66078. /**
  66079. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66080. */
  66081. maxEdgeLen: number;
  66082. /**
  66083. * The maximum distance a simplfied contour's border edges should deviate
  66084. * the original raw contour. [Limit: >=0] [Units: vx]
  66085. */
  66086. maxSimplificationError: number;
  66087. /**
  66088. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66089. */
  66090. minRegionArea: number;
  66091. /**
  66092. * Any regions with a span count smaller than this value will, if possible,
  66093. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66094. */
  66095. mergeRegionArea: number;
  66096. /**
  66097. * The maximum number of vertices allowed for polygons generated during the
  66098. * contour to polygon conversion process. [Limit: >= 3]
  66099. */
  66100. maxVertsPerPoly: number;
  66101. /**
  66102. * Sets the sampling distance to use when generating the detail mesh.
  66103. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66104. */
  66105. detailSampleDist: number;
  66106. /**
  66107. * The maximum distance the detail mesh surface should deviate from heightfield
  66108. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66109. */
  66110. detailSampleMaxError: number;
  66111. }
  66112. }
  66113. declare module BABYLON {
  66114. /**
  66115. * RecastJS navigation plugin
  66116. */
  66117. export class RecastJSPlugin implements INavigationEnginePlugin {
  66118. /**
  66119. * Reference to the Recast library
  66120. */
  66121. bjsRECAST: any;
  66122. /**
  66123. * plugin name
  66124. */
  66125. name: string;
  66126. /**
  66127. * the first navmesh created. We might extend this to support multiple navmeshes
  66128. */
  66129. navMesh: any;
  66130. /**
  66131. * Initializes the recastJS plugin
  66132. * @param recastInjection can be used to inject your own recast reference
  66133. */
  66134. constructor(recastInjection?: any);
  66135. /**
  66136. * Creates a navigation mesh
  66137. * @param meshes array of all the geometry used to compute the navigatio mesh
  66138. * @param parameters bunch of parameters used to filter geometry
  66139. */
  66140. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66141. /**
  66142. * Create a navigation mesh debug mesh
  66143. * @param scene is where the mesh will be added
  66144. * @returns debug display mesh
  66145. */
  66146. createDebugNavMesh(scene: Scene): Mesh;
  66147. /**
  66148. * Get a navigation mesh constrained position, closest to the parameter position
  66149. * @param position world position
  66150. * @returns the closest point to position constrained by the navigation mesh
  66151. */
  66152. getClosestPoint(position: Vector3): Vector3;
  66153. /**
  66154. * Get a navigation mesh constrained position, closest to the parameter position
  66155. * @param position world position
  66156. * @param result output the closest point to position constrained by the navigation mesh
  66157. */
  66158. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66159. /**
  66160. * Get a navigation mesh constrained position, within a particular radius
  66161. * @param position world position
  66162. * @param maxRadius the maximum distance to the constrained world position
  66163. * @returns the closest point to position constrained by the navigation mesh
  66164. */
  66165. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66166. /**
  66167. * Get a navigation mesh constrained position, within a particular radius
  66168. * @param position world position
  66169. * @param maxRadius the maximum distance to the constrained world position
  66170. * @param result output the closest point to position constrained by the navigation mesh
  66171. */
  66172. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66173. /**
  66174. * Compute the final position from a segment made of destination-position
  66175. * @param position world position
  66176. * @param destination world position
  66177. * @returns the resulting point along the navmesh
  66178. */
  66179. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66180. /**
  66181. * Compute the final position from a segment made of destination-position
  66182. * @param position world position
  66183. * @param destination world position
  66184. * @param result output the resulting point along the navmesh
  66185. */
  66186. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66187. /**
  66188. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66189. * @param start world position
  66190. * @param end world position
  66191. * @returns array containing world position composing the path
  66192. */
  66193. computePath(start: Vector3, end: Vector3): Vector3[];
  66194. /**
  66195. * Create a new Crowd so you can add agents
  66196. * @param maxAgents the maximum agent count in the crowd
  66197. * @param maxAgentRadius the maximum radius an agent can have
  66198. * @param scene to attach the crowd to
  66199. * @returns the crowd you can add agents to
  66200. */
  66201. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66202. /**
  66203. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66204. * The queries will try to find a solution within those bounds
  66205. * default is (1,1,1)
  66206. * @param extent x,y,z value that define the extent around the queries point of reference
  66207. */
  66208. setDefaultQueryExtent(extent: Vector3): void;
  66209. /**
  66210. * Get the Bounding box extent specified by setDefaultQueryExtent
  66211. * @returns the box extent values
  66212. */
  66213. getDefaultQueryExtent(): Vector3;
  66214. /**
  66215. * build the navmesh from a previously saved state using getNavmeshData
  66216. * @param data the Uint8Array returned by getNavmeshData
  66217. */
  66218. buildFromNavmeshData(data: Uint8Array): void;
  66219. /**
  66220. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66221. * @returns data the Uint8Array that can be saved and reused
  66222. */
  66223. getNavmeshData(): Uint8Array;
  66224. /**
  66225. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66226. * @param result output the box extent values
  66227. */
  66228. getDefaultQueryExtentToRef(result: Vector3): void;
  66229. /**
  66230. * Disposes
  66231. */
  66232. dispose(): void;
  66233. /**
  66234. * If this plugin is supported
  66235. * @returns true if plugin is supported
  66236. */
  66237. isSupported(): boolean;
  66238. }
  66239. /**
  66240. * Recast detour crowd implementation
  66241. */
  66242. export class RecastJSCrowd implements ICrowd {
  66243. /**
  66244. * Recast/detour plugin
  66245. */
  66246. bjsRECASTPlugin: RecastJSPlugin;
  66247. /**
  66248. * Link to the detour crowd
  66249. */
  66250. recastCrowd: any;
  66251. /**
  66252. * One transform per agent
  66253. */
  66254. transforms: TransformNode[];
  66255. /**
  66256. * All agents created
  66257. */
  66258. agents: number[];
  66259. /**
  66260. * Link to the scene is kept to unregister the crowd from the scene
  66261. */
  66262. private _scene;
  66263. /**
  66264. * Observer for crowd updates
  66265. */
  66266. private _onBeforeAnimationsObserver;
  66267. /**
  66268. * Constructor
  66269. * @param plugin recastJS plugin
  66270. * @param maxAgents the maximum agent count in the crowd
  66271. * @param maxAgentRadius the maximum radius an agent can have
  66272. * @param scene to attach the crowd to
  66273. * @returns the crowd you can add agents to
  66274. */
  66275. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66276. /**
  66277. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66278. * You can attach anything to that node. The node position is updated in the scene update tick.
  66279. * @param pos world position that will be constrained by the navigation mesh
  66280. * @param parameters agent parameters
  66281. * @param transform hooked to the agent that will be update by the scene
  66282. * @returns agent index
  66283. */
  66284. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66285. /**
  66286. * Returns the agent position in world space
  66287. * @param index agent index returned by addAgent
  66288. * @returns world space position
  66289. */
  66290. getAgentPosition(index: number): Vector3;
  66291. /**
  66292. * Returns the agent position result in world space
  66293. * @param index agent index returned by addAgent
  66294. * @param result output world space position
  66295. */
  66296. getAgentPositionToRef(index: number, result: Vector3): void;
  66297. /**
  66298. * Returns the agent velocity in world space
  66299. * @param index agent index returned by addAgent
  66300. * @returns world space velocity
  66301. */
  66302. getAgentVelocity(index: number): Vector3;
  66303. /**
  66304. * Returns the agent velocity result in world space
  66305. * @param index agent index returned by addAgent
  66306. * @param result output world space velocity
  66307. */
  66308. getAgentVelocityToRef(index: number, result: Vector3): void;
  66309. /**
  66310. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66311. * @param index agent index returned by addAgent
  66312. * @param destination targeted world position
  66313. */
  66314. agentGoto(index: number, destination: Vector3): void;
  66315. /**
  66316. * Teleport the agent to a new position
  66317. * @param index agent index returned by addAgent
  66318. * @param destination targeted world position
  66319. */
  66320. agentTeleport(index: number, destination: Vector3): void;
  66321. /**
  66322. * Update agent parameters
  66323. * @param index agent index returned by addAgent
  66324. * @param parameters agent parameters
  66325. */
  66326. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66327. /**
  66328. * remove a particular agent previously created
  66329. * @param index agent index returned by addAgent
  66330. */
  66331. removeAgent(index: number): void;
  66332. /**
  66333. * get the list of all agents attached to this crowd
  66334. * @returns list of agent indices
  66335. */
  66336. getAgents(): number[];
  66337. /**
  66338. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66339. * @param deltaTime in seconds
  66340. */
  66341. update(deltaTime: number): void;
  66342. /**
  66343. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66344. * The queries will try to find a solution within those bounds
  66345. * default is (1,1,1)
  66346. * @param extent x,y,z value that define the extent around the queries point of reference
  66347. */
  66348. setDefaultQueryExtent(extent: Vector3): void;
  66349. /**
  66350. * Get the Bounding box extent specified by setDefaultQueryExtent
  66351. * @returns the box extent values
  66352. */
  66353. getDefaultQueryExtent(): Vector3;
  66354. /**
  66355. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66356. * @param result output the box extent values
  66357. */
  66358. getDefaultQueryExtentToRef(result: Vector3): void;
  66359. /**
  66360. * Release all resources
  66361. */
  66362. dispose(): void;
  66363. }
  66364. }
  66365. declare module BABYLON {
  66366. /**
  66367. * Class used to enable access to IndexedDB
  66368. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66369. */
  66370. export class Database implements IOfflineProvider {
  66371. private _callbackManifestChecked;
  66372. private _currentSceneUrl;
  66373. private _db;
  66374. private _enableSceneOffline;
  66375. private _enableTexturesOffline;
  66376. private _manifestVersionFound;
  66377. private _mustUpdateRessources;
  66378. private _hasReachedQuota;
  66379. private _isSupported;
  66380. private _idbFactory;
  66381. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66382. private static IsUASupportingBlobStorage;
  66383. /**
  66384. * Gets a boolean indicating if Database storate is enabled (off by default)
  66385. */
  66386. static IDBStorageEnabled: boolean;
  66387. /**
  66388. * Gets a boolean indicating if scene must be saved in the database
  66389. */
  66390. get enableSceneOffline(): boolean;
  66391. /**
  66392. * Gets a boolean indicating if textures must be saved in the database
  66393. */
  66394. get enableTexturesOffline(): boolean;
  66395. /**
  66396. * Creates a new Database
  66397. * @param urlToScene defines the url to load the scene
  66398. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66399. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66400. */
  66401. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66402. private static _ParseURL;
  66403. private static _ReturnFullUrlLocation;
  66404. private _checkManifestFile;
  66405. /**
  66406. * Open the database and make it available
  66407. * @param successCallback defines the callback to call on success
  66408. * @param errorCallback defines the callback to call on error
  66409. */
  66410. open(successCallback: () => void, errorCallback: () => void): void;
  66411. /**
  66412. * Loads an image from the database
  66413. * @param url defines the url to load from
  66414. * @param image defines the target DOM image
  66415. */
  66416. loadImage(url: string, image: HTMLImageElement): void;
  66417. private _loadImageFromDBAsync;
  66418. private _saveImageIntoDBAsync;
  66419. private _checkVersionFromDB;
  66420. private _loadVersionFromDBAsync;
  66421. private _saveVersionIntoDBAsync;
  66422. /**
  66423. * Loads a file from database
  66424. * @param url defines the URL to load from
  66425. * @param sceneLoaded defines a callback to call on success
  66426. * @param progressCallBack defines a callback to call when progress changed
  66427. * @param errorCallback defines a callback to call on error
  66428. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66429. */
  66430. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66431. private _loadFileAsync;
  66432. private _saveFileAsync;
  66433. /**
  66434. * Validates if xhr data is correct
  66435. * @param xhr defines the request to validate
  66436. * @param dataType defines the expected data type
  66437. * @returns true if data is correct
  66438. */
  66439. private static _ValidateXHRData;
  66440. }
  66441. }
  66442. declare module BABYLON {
  66443. /** @hidden */
  66444. export var gpuUpdateParticlesPixelShader: {
  66445. name: string;
  66446. shader: string;
  66447. };
  66448. }
  66449. declare module BABYLON {
  66450. /** @hidden */
  66451. export var gpuUpdateParticlesVertexShader: {
  66452. name: string;
  66453. shader: string;
  66454. };
  66455. }
  66456. declare module BABYLON {
  66457. /** @hidden */
  66458. export var clipPlaneFragmentDeclaration2: {
  66459. name: string;
  66460. shader: string;
  66461. };
  66462. }
  66463. declare module BABYLON {
  66464. /** @hidden */
  66465. export var gpuRenderParticlesPixelShader: {
  66466. name: string;
  66467. shader: string;
  66468. };
  66469. }
  66470. declare module BABYLON {
  66471. /** @hidden */
  66472. export var clipPlaneVertexDeclaration2: {
  66473. name: string;
  66474. shader: string;
  66475. };
  66476. }
  66477. declare module BABYLON {
  66478. /** @hidden */
  66479. export var gpuRenderParticlesVertexShader: {
  66480. name: string;
  66481. shader: string;
  66482. };
  66483. }
  66484. declare module BABYLON {
  66485. /**
  66486. * This represents a GPU particle system in Babylon
  66487. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66488. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66489. */
  66490. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66491. /**
  66492. * The layer mask we are rendering the particles through.
  66493. */
  66494. layerMask: number;
  66495. private _capacity;
  66496. private _activeCount;
  66497. private _currentActiveCount;
  66498. private _accumulatedCount;
  66499. private _renderEffect;
  66500. private _updateEffect;
  66501. private _buffer0;
  66502. private _buffer1;
  66503. private _spriteBuffer;
  66504. private _updateVAO;
  66505. private _renderVAO;
  66506. private _targetIndex;
  66507. private _sourceBuffer;
  66508. private _targetBuffer;
  66509. private _engine;
  66510. private _currentRenderId;
  66511. private _started;
  66512. private _stopped;
  66513. private _timeDelta;
  66514. private _randomTexture;
  66515. private _randomTexture2;
  66516. private _attributesStrideSize;
  66517. private _updateEffectOptions;
  66518. private _randomTextureSize;
  66519. private _actualFrame;
  66520. private _customEffect;
  66521. private readonly _rawTextureWidth;
  66522. /**
  66523. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66524. */
  66525. static get IsSupported(): boolean;
  66526. /**
  66527. * An event triggered when the system is disposed.
  66528. */
  66529. onDisposeObservable: Observable<IParticleSystem>;
  66530. /**
  66531. * Gets the maximum number of particles active at the same time.
  66532. * @returns The max number of active particles.
  66533. */
  66534. getCapacity(): number;
  66535. /**
  66536. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66537. * to override the particles.
  66538. */
  66539. forceDepthWrite: boolean;
  66540. /**
  66541. * Gets or set the number of active particles
  66542. */
  66543. get activeParticleCount(): number;
  66544. set activeParticleCount(value: number);
  66545. private _preWarmDone;
  66546. /**
  66547. * Specifies if the particles are updated in emitter local space or world space.
  66548. */
  66549. isLocal: boolean;
  66550. /**
  66551. * Is this system ready to be used/rendered
  66552. * @return true if the system is ready
  66553. */
  66554. isReady(): boolean;
  66555. /**
  66556. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66557. * @returns True if it has been started, otherwise false.
  66558. */
  66559. isStarted(): boolean;
  66560. /**
  66561. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66562. * @returns True if it has been stopped, otherwise false.
  66563. */
  66564. isStopped(): boolean;
  66565. /**
  66566. * Gets a boolean indicating that the system is stopping
  66567. * @returns true if the system is currently stopping
  66568. */
  66569. isStopping(): boolean;
  66570. /**
  66571. * Gets the number of particles active at the same time.
  66572. * @returns The number of active particles.
  66573. */
  66574. getActiveCount(): number;
  66575. /**
  66576. * Starts the particle system and begins to emit
  66577. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66578. */
  66579. start(delay?: number): void;
  66580. /**
  66581. * Stops the particle system.
  66582. */
  66583. stop(): void;
  66584. /**
  66585. * Remove all active particles
  66586. */
  66587. reset(): void;
  66588. /**
  66589. * Returns the string "GPUParticleSystem"
  66590. * @returns a string containing the class name
  66591. */
  66592. getClassName(): string;
  66593. /**
  66594. * Gets the custom effect used to render the particles
  66595. * @param blendMode Blend mode for which the effect should be retrieved
  66596. * @returns The effect
  66597. */
  66598. getCustomEffect(blendMode?: number): Nullable<Effect>;
  66599. /**
  66600. * Sets the custom effect used to render the particles
  66601. * @param effect The effect to set
  66602. * @param blendMode Blend mode for which the effect should be set
  66603. */
  66604. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  66605. /** @hidden */
  66606. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  66607. /**
  66608. * Observable that will be called just before the particles are drawn
  66609. */
  66610. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  66611. /**
  66612. * Gets the name of the particle vertex shader
  66613. */
  66614. get vertexShaderName(): string;
  66615. private _colorGradientsTexture;
  66616. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66617. /**
  66618. * Adds a new color gradient
  66619. * @param gradient defines the gradient to use (between 0 and 1)
  66620. * @param color1 defines the color to affect to the specified gradient
  66621. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66622. * @returns the current particle system
  66623. */
  66624. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66625. private _refreshColorGradient;
  66626. /** Force the system to rebuild all gradients that need to be resync */
  66627. forceRefreshGradients(): void;
  66628. /**
  66629. * Remove a specific color gradient
  66630. * @param gradient defines the gradient to remove
  66631. * @returns the current particle system
  66632. */
  66633. removeColorGradient(gradient: number): GPUParticleSystem;
  66634. private _angularSpeedGradientsTexture;
  66635. private _sizeGradientsTexture;
  66636. private _velocityGradientsTexture;
  66637. private _limitVelocityGradientsTexture;
  66638. private _dragGradientsTexture;
  66639. private _addFactorGradient;
  66640. /**
  66641. * Adds a new size gradient
  66642. * @param gradient defines the gradient to use (between 0 and 1)
  66643. * @param factor defines the size factor to affect to the specified gradient
  66644. * @returns the current particle system
  66645. */
  66646. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66647. /**
  66648. * Remove a specific size gradient
  66649. * @param gradient defines the gradient to remove
  66650. * @returns the current particle system
  66651. */
  66652. removeSizeGradient(gradient: number): GPUParticleSystem;
  66653. private _refreshFactorGradient;
  66654. /**
  66655. * Adds a new angular speed gradient
  66656. * @param gradient defines the gradient to use (between 0 and 1)
  66657. * @param factor defines the angular speed to affect to the specified gradient
  66658. * @returns the current particle system
  66659. */
  66660. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66661. /**
  66662. * Remove a specific angular speed gradient
  66663. * @param gradient defines the gradient to remove
  66664. * @returns the current particle system
  66665. */
  66666. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66667. /**
  66668. * Adds a new velocity gradient
  66669. * @param gradient defines the gradient to use (between 0 and 1)
  66670. * @param factor defines the velocity to affect to the specified gradient
  66671. * @returns the current particle system
  66672. */
  66673. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66674. /**
  66675. * Remove a specific velocity gradient
  66676. * @param gradient defines the gradient to remove
  66677. * @returns the current particle system
  66678. */
  66679. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66680. /**
  66681. * Adds a new limit velocity gradient
  66682. * @param gradient defines the gradient to use (between 0 and 1)
  66683. * @param factor defines the limit velocity value to affect to the specified gradient
  66684. * @returns the current particle system
  66685. */
  66686. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66687. /**
  66688. * Remove a specific limit velocity gradient
  66689. * @param gradient defines the gradient to remove
  66690. * @returns the current particle system
  66691. */
  66692. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66693. /**
  66694. * Adds a new drag gradient
  66695. * @param gradient defines the gradient to use (between 0 and 1)
  66696. * @param factor defines the drag value to affect to the specified gradient
  66697. * @returns the current particle system
  66698. */
  66699. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66700. /**
  66701. * Remove a specific drag gradient
  66702. * @param gradient defines the gradient to remove
  66703. * @returns the current particle system
  66704. */
  66705. removeDragGradient(gradient: number): GPUParticleSystem;
  66706. /**
  66707. * Not supported by GPUParticleSystem
  66708. * @param gradient defines the gradient to use (between 0 and 1)
  66709. * @param factor defines the emit rate value to affect to the specified gradient
  66710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66711. * @returns the current particle system
  66712. */
  66713. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66714. /**
  66715. * Not supported by GPUParticleSystem
  66716. * @param gradient defines the gradient to remove
  66717. * @returns the current particle system
  66718. */
  66719. removeEmitRateGradient(gradient: number): IParticleSystem;
  66720. /**
  66721. * Not supported by GPUParticleSystem
  66722. * @param gradient defines the gradient to use (between 0 and 1)
  66723. * @param factor defines the start size value to affect to the specified gradient
  66724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66725. * @returns the current particle system
  66726. */
  66727. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66728. /**
  66729. * Not supported by GPUParticleSystem
  66730. * @param gradient defines the gradient to remove
  66731. * @returns the current particle system
  66732. */
  66733. removeStartSizeGradient(gradient: number): IParticleSystem;
  66734. /**
  66735. * Not supported by GPUParticleSystem
  66736. * @param gradient defines the gradient to use (between 0 and 1)
  66737. * @param min defines the color remap minimal range
  66738. * @param max defines the color remap maximal range
  66739. * @returns the current particle system
  66740. */
  66741. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66742. /**
  66743. * Not supported by GPUParticleSystem
  66744. * @param gradient defines the gradient to remove
  66745. * @returns the current particle system
  66746. */
  66747. removeColorRemapGradient(): IParticleSystem;
  66748. /**
  66749. * Not supported by GPUParticleSystem
  66750. * @param gradient defines the gradient to use (between 0 and 1)
  66751. * @param min defines the alpha remap minimal range
  66752. * @param max defines the alpha remap maximal range
  66753. * @returns the current particle system
  66754. */
  66755. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66756. /**
  66757. * Not supported by GPUParticleSystem
  66758. * @param gradient defines the gradient to remove
  66759. * @returns the current particle system
  66760. */
  66761. removeAlphaRemapGradient(): IParticleSystem;
  66762. /**
  66763. * Not supported by GPUParticleSystem
  66764. * @param gradient defines the gradient to use (between 0 and 1)
  66765. * @param color defines the color to affect to the specified gradient
  66766. * @returns the current particle system
  66767. */
  66768. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66769. /**
  66770. * Not supported by GPUParticleSystem
  66771. * @param gradient defines the gradient to remove
  66772. * @returns the current particle system
  66773. */
  66774. removeRampGradient(): IParticleSystem;
  66775. /**
  66776. * Not supported by GPUParticleSystem
  66777. * @returns the list of ramp gradients
  66778. */
  66779. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66780. /**
  66781. * Not supported by GPUParticleSystem
  66782. * Gets or sets a boolean indicating that ramp gradients must be used
  66783. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66784. */
  66785. get useRampGradients(): boolean;
  66786. set useRampGradients(value: boolean);
  66787. /**
  66788. * Not supported by GPUParticleSystem
  66789. * @param gradient defines the gradient to use (between 0 and 1)
  66790. * @param factor defines the life time factor to affect to the specified gradient
  66791. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66792. * @returns the current particle system
  66793. */
  66794. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66795. /**
  66796. * Not supported by GPUParticleSystem
  66797. * @param gradient defines the gradient to remove
  66798. * @returns the current particle system
  66799. */
  66800. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66801. /**
  66802. * Instantiates a GPU particle system.
  66803. * 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.
  66804. * @param name The name of the particle system
  66805. * @param options The options used to create the system
  66806. * @param scene The scene the particle system belongs to
  66807. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66808. * @param customEffect a custom effect used to change the way particles are rendered by default
  66809. */
  66810. constructor(name: string, options: Partial<{
  66811. capacity: number;
  66812. randomTextureSize: number;
  66813. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  66814. protected _reset(): void;
  66815. private _createUpdateVAO;
  66816. private _createRenderVAO;
  66817. private _initialize;
  66818. /** @hidden */
  66819. _recreateUpdateEffect(): void;
  66820. private _getEffect;
  66821. /**
  66822. * Fill the defines array according to the current settings of the particle system
  66823. * @param defines Array to be updated
  66824. * @param blendMode blend mode to take into account when updating the array
  66825. */
  66826. fillDefines(defines: Array<string>, blendMode?: number): void;
  66827. /**
  66828. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  66829. * @param uniforms Uniforms array to fill
  66830. * @param attributes Attributes array to fill
  66831. * @param samplers Samplers array to fill
  66832. */
  66833. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  66834. /** @hidden */
  66835. _recreateRenderEffect(): Effect;
  66836. /**
  66837. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66838. * @param preWarm defines if we are in the pre-warmimg phase
  66839. */
  66840. animate(preWarm?: boolean): void;
  66841. private _createFactorGradientTexture;
  66842. private _createSizeGradientTexture;
  66843. private _createAngularSpeedGradientTexture;
  66844. private _createVelocityGradientTexture;
  66845. private _createLimitVelocityGradientTexture;
  66846. private _createDragGradientTexture;
  66847. private _createColorGradientTexture;
  66848. /**
  66849. * Renders the particle system in its current state
  66850. * @param preWarm defines if the system should only update the particles but not render them
  66851. * @returns the current number of particles
  66852. */
  66853. render(preWarm?: boolean): number;
  66854. /**
  66855. * Rebuilds the particle system
  66856. */
  66857. rebuild(): void;
  66858. private _releaseBuffers;
  66859. private _releaseVAOs;
  66860. /**
  66861. * Disposes the particle system and free the associated resources
  66862. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66863. */
  66864. dispose(disposeTexture?: boolean): void;
  66865. /**
  66866. * Clones the particle system.
  66867. * @param name The name of the cloned object
  66868. * @param newEmitter The new emitter to use
  66869. * @returns the cloned particle system
  66870. */
  66871. clone(name: string, newEmitter: any): GPUParticleSystem;
  66872. /**
  66873. * Serializes the particle system to a JSON object
  66874. * @param serializeTexture defines if the texture must be serialized as well
  66875. * @returns the JSON object
  66876. */
  66877. serialize(serializeTexture?: boolean): any;
  66878. /**
  66879. * Parses a JSON object to create a GPU particle system.
  66880. * @param parsedParticleSystem The JSON object to parse
  66881. * @param scene The scene to create the particle system in
  66882. * @param rootUrl The root url to use to load external dependencies like texture
  66883. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66884. * @returns the parsed GPU particle system
  66885. */
  66886. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66887. }
  66888. }
  66889. declare module BABYLON {
  66890. /**
  66891. * Represents a set of particle systems working together to create a specific effect
  66892. */
  66893. export class ParticleSystemSet implements IDisposable {
  66894. /**
  66895. * Gets or sets base Assets URL
  66896. */
  66897. static BaseAssetsUrl: string;
  66898. private _emitterCreationOptions;
  66899. private _emitterNode;
  66900. /**
  66901. * Gets the particle system list
  66902. */
  66903. systems: IParticleSystem[];
  66904. /**
  66905. * Gets the emitter node used with this set
  66906. */
  66907. get emitterNode(): Nullable<TransformNode>;
  66908. /**
  66909. * Creates a new emitter mesh as a sphere
  66910. * @param options defines the options used to create the sphere
  66911. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66912. * @param scene defines the hosting scene
  66913. */
  66914. setEmitterAsSphere(options: {
  66915. diameter: number;
  66916. segments: number;
  66917. color: Color3;
  66918. }, renderingGroupId: number, scene: Scene): void;
  66919. /**
  66920. * Starts all particle systems of the set
  66921. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66922. */
  66923. start(emitter?: AbstractMesh): void;
  66924. /**
  66925. * Release all associated resources
  66926. */
  66927. dispose(): void;
  66928. /**
  66929. * Serialize the set into a JSON compatible object
  66930. * @param serializeTexture defines if the texture must be serialized as well
  66931. * @returns a JSON compatible representation of the set
  66932. */
  66933. serialize(serializeTexture?: boolean): any;
  66934. /**
  66935. * Parse a new ParticleSystemSet from a serialized source
  66936. * @param data defines a JSON compatible representation of the set
  66937. * @param scene defines the hosting scene
  66938. * @param gpu defines if we want GPU particles or CPU particles
  66939. * @returns a new ParticleSystemSet
  66940. */
  66941. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66942. }
  66943. }
  66944. declare module BABYLON {
  66945. /**
  66946. * This class is made for on one-liner static method to help creating particle system set.
  66947. */
  66948. export class ParticleHelper {
  66949. /**
  66950. * Gets or sets base Assets URL
  66951. */
  66952. static BaseAssetsUrl: string;
  66953. /** Define the Url to load snippets */
  66954. static SnippetUrl: string;
  66955. /**
  66956. * Create a default particle system that you can tweak
  66957. * @param emitter defines the emitter to use
  66958. * @param capacity defines the system capacity (default is 500 particles)
  66959. * @param scene defines the hosting scene
  66960. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66961. * @returns the new Particle system
  66962. */
  66963. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66964. /**
  66965. * This is the main static method (one-liner) of this helper to create different particle systems
  66966. * @param type This string represents the type to the particle system to create
  66967. * @param scene The scene where the particle system should live
  66968. * @param gpu If the system will use gpu
  66969. * @returns the ParticleSystemSet created
  66970. */
  66971. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66972. /**
  66973. * Static function used to export a particle system to a ParticleSystemSet variable.
  66974. * Please note that the emitter shape is not exported
  66975. * @param systems defines the particle systems to export
  66976. * @returns the created particle system set
  66977. */
  66978. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66979. /**
  66980. * Creates a particle system from a snippet saved in a remote file
  66981. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  66982. * @param url defines the url to load from
  66983. * @param scene defines the hosting scene
  66984. * @param gpu If the system will use gpu
  66985. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66986. * @returns a promise that will resolve to the new particle system
  66987. */
  66988. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66989. /**
  66990. * Creates a particle system from a snippet saved by the particle system editor
  66991. * @param snippetId defines the snippet to load
  66992. * @param scene defines the hosting scene
  66993. * @param gpu If the system will use gpu
  66994. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66995. * @returns a promise that will resolve to the new particle system
  66996. */
  66997. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66998. }
  66999. }
  67000. declare module BABYLON {
  67001. interface Engine {
  67002. /**
  67003. * Create an effect to use with particle systems.
  67004. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67005. * the particle system for which you want to create a custom effect in the last parameter
  67006. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67007. * @param uniformsNames defines a list of attribute names
  67008. * @param samplers defines an array of string used to represent textures
  67009. * @param defines defines the string containing the defines to use to compile the shaders
  67010. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67011. * @param onCompiled defines a function to call when the effect creation is successful
  67012. * @param onError defines a function to call when the effect creation has failed
  67013. * @param particleSystem the particle system you want to create the effect for
  67014. * @returns the new Effect
  67015. */
  67016. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67017. }
  67018. interface Mesh {
  67019. /**
  67020. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67021. * @returns an array of IParticleSystem
  67022. */
  67023. getEmittedParticleSystems(): IParticleSystem[];
  67024. /**
  67025. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67026. * @returns an array of IParticleSystem
  67027. */
  67028. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67029. }
  67030. }
  67031. declare module BABYLON {
  67032. /** Defines the 4 color options */
  67033. export enum PointColor {
  67034. /** color value */
  67035. Color = 2,
  67036. /** uv value */
  67037. UV = 1,
  67038. /** random value */
  67039. Random = 0,
  67040. /** stated value */
  67041. Stated = 3
  67042. }
  67043. /**
  67044. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67045. * 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.
  67046. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67047. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67048. *
  67049. * Full documentation here : TO BE ENTERED
  67050. */
  67051. export class PointsCloudSystem implements IDisposable {
  67052. /**
  67053. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67054. * Example : var p = SPS.particles[i];
  67055. */
  67056. particles: CloudPoint[];
  67057. /**
  67058. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67059. */
  67060. nbParticles: number;
  67061. /**
  67062. * This a counter for your own usage. It's not set by any SPS functions.
  67063. */
  67064. counter: number;
  67065. /**
  67066. * The PCS name. This name is also given to the underlying mesh.
  67067. */
  67068. name: string;
  67069. /**
  67070. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67071. */
  67072. mesh: Mesh;
  67073. /**
  67074. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67075. * Please read :
  67076. */
  67077. vars: any;
  67078. /**
  67079. * @hidden
  67080. */
  67081. _size: number;
  67082. private _scene;
  67083. private _promises;
  67084. private _positions;
  67085. private _indices;
  67086. private _normals;
  67087. private _colors;
  67088. private _uvs;
  67089. private _indices32;
  67090. private _positions32;
  67091. private _colors32;
  67092. private _uvs32;
  67093. private _updatable;
  67094. private _isVisibilityBoxLocked;
  67095. private _alwaysVisible;
  67096. private _groups;
  67097. private _groupCounter;
  67098. private _computeParticleColor;
  67099. private _computeParticleTexture;
  67100. private _computeParticleRotation;
  67101. private _computeBoundingBox;
  67102. private _isReady;
  67103. /**
  67104. * Creates a PCS (Points Cloud System) object
  67105. * @param name (String) is the PCS name, this will be the underlying mesh name
  67106. * @param pointSize (number) is the size for each point
  67107. * @param scene (Scene) is the scene in which the PCS is added
  67108. * @param options defines the options of the PCS e.g.
  67109. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67110. */
  67111. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67112. updatable?: boolean;
  67113. });
  67114. /**
  67115. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67116. * If no points were added to the PCS, the returned mesh is just a single point.
  67117. * @returns a promise for the created mesh
  67118. */
  67119. buildMeshAsync(): Promise<Mesh>;
  67120. /**
  67121. * @hidden
  67122. */
  67123. private _buildMesh;
  67124. private _addParticle;
  67125. private _randomUnitVector;
  67126. private _getColorIndicesForCoord;
  67127. private _setPointsColorOrUV;
  67128. private _colorFromTexture;
  67129. private _calculateDensity;
  67130. /**
  67131. * Adds points to the PCS in random positions within a unit sphere
  67132. * @param nb (positive integer) the number of particles to be created from this model
  67133. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67134. * @returns the number of groups in the system
  67135. */
  67136. addPoints(nb: number, pointFunction?: any): number;
  67137. /**
  67138. * Adds points to the PCS from the surface of the model shape
  67139. * @param mesh is any Mesh object that will be used as a surface model for the points
  67140. * @param nb (positive integer) the number of particles to be created from this model
  67141. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67142. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67143. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67144. * @returns the number of groups in the system
  67145. */
  67146. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67147. /**
  67148. * Adds points to the PCS inside the model shape
  67149. * @param mesh is any Mesh object that will be used as a surface model for the points
  67150. * @param nb (positive integer) the number of particles to be created from this model
  67151. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67152. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67153. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67154. * @returns the number of groups in the system
  67155. */
  67156. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67157. /**
  67158. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67159. * This method calls `updateParticle()` for each particle of the SPS.
  67160. * For an animated SPS, it is usually called within the render loop.
  67161. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67162. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67163. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67164. * @returns the PCS.
  67165. */
  67166. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67167. /**
  67168. * Disposes the PCS.
  67169. */
  67170. dispose(): void;
  67171. /**
  67172. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67173. * doc :
  67174. * @returns the PCS.
  67175. */
  67176. refreshVisibleSize(): PointsCloudSystem;
  67177. /**
  67178. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67179. * @param size the size (float) of the visibility box
  67180. * note : this doesn't lock the PCS mesh bounding box.
  67181. * doc :
  67182. */
  67183. setVisibilityBox(size: number): void;
  67184. /**
  67185. * Gets whether the PCS is always visible or not
  67186. * doc :
  67187. */
  67188. get isAlwaysVisible(): boolean;
  67189. /**
  67190. * Sets the PCS as always visible or not
  67191. * doc :
  67192. */
  67193. set isAlwaysVisible(val: boolean);
  67194. /**
  67195. * Tells to `setParticles()` to compute the particle rotations or not
  67196. * Default value : false. The PCS is faster when it's set to false
  67197. * Note : particle rotations are only applied to parent particles
  67198. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67199. */
  67200. set computeParticleRotation(val: boolean);
  67201. /**
  67202. * Tells to `setParticles()` to compute the particle colors or not.
  67203. * Default value : true. The PCS is faster when it's set to false.
  67204. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67205. */
  67206. set computeParticleColor(val: boolean);
  67207. set computeParticleTexture(val: boolean);
  67208. /**
  67209. * Gets if `setParticles()` computes the particle colors or not.
  67210. * Default value : false. The PCS is faster when it's set to false.
  67211. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67212. */
  67213. get computeParticleColor(): boolean;
  67214. /**
  67215. * Gets if `setParticles()` computes the particle textures or not.
  67216. * Default value : false. The PCS is faster when it's set to false.
  67217. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67218. */
  67219. get computeParticleTexture(): boolean;
  67220. /**
  67221. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67222. */
  67223. set computeBoundingBox(val: boolean);
  67224. /**
  67225. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67226. */
  67227. get computeBoundingBox(): boolean;
  67228. /**
  67229. * This function does nothing. It may be overwritten to set all the particle first values.
  67230. * The PCS doesn't call this function, you may have to call it by your own.
  67231. * doc :
  67232. */
  67233. initParticles(): void;
  67234. /**
  67235. * This function does nothing. It may be overwritten to recycle a particle
  67236. * The PCS doesn't call this function, you can to call it
  67237. * doc :
  67238. * @param particle The particle to recycle
  67239. * @returns the recycled particle
  67240. */
  67241. recycleParticle(particle: CloudPoint): CloudPoint;
  67242. /**
  67243. * Updates a particle : this function should be overwritten by the user.
  67244. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67245. * doc :
  67246. * @example : just set a particle position or velocity and recycle conditions
  67247. * @param particle The particle to update
  67248. * @returns the updated particle
  67249. */
  67250. updateParticle(particle: CloudPoint): CloudPoint;
  67251. /**
  67252. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67253. * This does nothing and may be overwritten by the user.
  67254. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67255. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67256. * @param update the boolean update value actually passed to setParticles()
  67257. */
  67258. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67259. /**
  67260. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67261. * This will be passed three parameters.
  67262. * This does nothing and may be overwritten by the user.
  67263. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67264. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67265. * @param update the boolean update value actually passed to setParticles()
  67266. */
  67267. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67268. }
  67269. }
  67270. declare module BABYLON {
  67271. /**
  67272. * Represents one particle of a points cloud system.
  67273. */
  67274. export class CloudPoint {
  67275. /**
  67276. * particle global index
  67277. */
  67278. idx: number;
  67279. /**
  67280. * The color of the particle
  67281. */
  67282. color: Nullable<Color4>;
  67283. /**
  67284. * The world space position of the particle.
  67285. */
  67286. position: Vector3;
  67287. /**
  67288. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67289. */
  67290. rotation: Vector3;
  67291. /**
  67292. * The world space rotation quaternion of the particle.
  67293. */
  67294. rotationQuaternion: Nullable<Quaternion>;
  67295. /**
  67296. * The uv of the particle.
  67297. */
  67298. uv: Nullable<Vector2>;
  67299. /**
  67300. * The current speed of the particle.
  67301. */
  67302. velocity: Vector3;
  67303. /**
  67304. * The pivot point in the particle local space.
  67305. */
  67306. pivot: Vector3;
  67307. /**
  67308. * Must the particle be translated from its pivot point in its local space ?
  67309. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67310. * Default : false
  67311. */
  67312. translateFromPivot: boolean;
  67313. /**
  67314. * Index of this particle in the global "positions" array (Internal use)
  67315. * @hidden
  67316. */
  67317. _pos: number;
  67318. /**
  67319. * @hidden Index of this particle in the global "indices" array (Internal use)
  67320. */
  67321. _ind: number;
  67322. /**
  67323. * Group this particle belongs to
  67324. */
  67325. _group: PointsGroup;
  67326. /**
  67327. * Group id of this particle
  67328. */
  67329. groupId: number;
  67330. /**
  67331. * Index of the particle in its group id (Internal use)
  67332. */
  67333. idxInGroup: number;
  67334. /**
  67335. * @hidden Particle BoundingInfo object (Internal use)
  67336. */
  67337. _boundingInfo: BoundingInfo;
  67338. /**
  67339. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67340. */
  67341. _pcs: PointsCloudSystem;
  67342. /**
  67343. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67344. */
  67345. _stillInvisible: boolean;
  67346. /**
  67347. * @hidden Last computed particle rotation matrix
  67348. */
  67349. _rotationMatrix: number[];
  67350. /**
  67351. * Parent particle Id, if any.
  67352. * Default null.
  67353. */
  67354. parentId: Nullable<number>;
  67355. /**
  67356. * @hidden Internal global position in the PCS.
  67357. */
  67358. _globalPosition: Vector3;
  67359. /**
  67360. * Creates a Point Cloud object.
  67361. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67362. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67363. * @param group (PointsGroup) is the group the particle belongs to
  67364. * @param groupId (integer) is the group identifier in the PCS.
  67365. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67366. * @param pcs defines the PCS it is associated to
  67367. */
  67368. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67369. /**
  67370. * get point size
  67371. */
  67372. get size(): Vector3;
  67373. /**
  67374. * Set point size
  67375. */
  67376. set size(scale: Vector3);
  67377. /**
  67378. * Legacy support, changed quaternion to rotationQuaternion
  67379. */
  67380. get quaternion(): Nullable<Quaternion>;
  67381. /**
  67382. * Legacy support, changed quaternion to rotationQuaternion
  67383. */
  67384. set quaternion(q: Nullable<Quaternion>);
  67385. /**
  67386. * Returns a boolean. True if the particle intersects a mesh, else false
  67387. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67388. * @param target is the object (point or mesh) what the intersection is computed against
  67389. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67390. * @returns true if it intersects
  67391. */
  67392. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67393. /**
  67394. * get the rotation matrix of the particle
  67395. * @hidden
  67396. */
  67397. getRotationMatrix(m: Matrix): void;
  67398. }
  67399. /**
  67400. * Represents a group of points in a points cloud system
  67401. * * PCS internal tool, don't use it manually.
  67402. */
  67403. export class PointsGroup {
  67404. /**
  67405. * The group id
  67406. * @hidden
  67407. */
  67408. groupID: number;
  67409. /**
  67410. * image data for group (internal use)
  67411. * @hidden
  67412. */
  67413. _groupImageData: Nullable<ArrayBufferView>;
  67414. /**
  67415. * Image Width (internal use)
  67416. * @hidden
  67417. */
  67418. _groupImgWidth: number;
  67419. /**
  67420. * Image Height (internal use)
  67421. * @hidden
  67422. */
  67423. _groupImgHeight: number;
  67424. /**
  67425. * Custom position function (internal use)
  67426. * @hidden
  67427. */
  67428. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67429. /**
  67430. * density per facet for surface points
  67431. * @hidden
  67432. */
  67433. _groupDensity: number[];
  67434. /**
  67435. * Only when points are colored by texture carries pointer to texture list array
  67436. * @hidden
  67437. */
  67438. _textureNb: number;
  67439. /**
  67440. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67441. * PCS internal tool, don't use it manually.
  67442. * @hidden
  67443. */
  67444. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67445. }
  67446. }
  67447. declare module BABYLON {
  67448. interface Scene {
  67449. /** @hidden (Backing field) */
  67450. _physicsEngine: Nullable<IPhysicsEngine>;
  67451. /** @hidden */
  67452. _physicsTimeAccumulator: number;
  67453. /**
  67454. * Gets the current physics engine
  67455. * @returns a IPhysicsEngine or null if none attached
  67456. */
  67457. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67458. /**
  67459. * Enables physics to the current scene
  67460. * @param gravity defines the scene's gravity for the physics engine
  67461. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67462. * @return a boolean indicating if the physics engine was initialized
  67463. */
  67464. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67465. /**
  67466. * Disables and disposes the physics engine associated with the scene
  67467. */
  67468. disablePhysicsEngine(): void;
  67469. /**
  67470. * Gets a boolean indicating if there is an active physics engine
  67471. * @returns a boolean indicating if there is an active physics engine
  67472. */
  67473. isPhysicsEnabled(): boolean;
  67474. /**
  67475. * Deletes a physics compound impostor
  67476. * @param compound defines the compound to delete
  67477. */
  67478. deleteCompoundImpostor(compound: any): void;
  67479. /**
  67480. * An event triggered when physic simulation is about to be run
  67481. */
  67482. onBeforePhysicsObservable: Observable<Scene>;
  67483. /**
  67484. * An event triggered when physic simulation has been done
  67485. */
  67486. onAfterPhysicsObservable: Observable<Scene>;
  67487. }
  67488. interface AbstractMesh {
  67489. /** @hidden */
  67490. _physicsImpostor: Nullable<PhysicsImpostor>;
  67491. /**
  67492. * Gets or sets impostor used for physic simulation
  67493. * @see https://doc.babylonjs.com/features/physics_engine
  67494. */
  67495. physicsImpostor: Nullable<PhysicsImpostor>;
  67496. /**
  67497. * Gets the current physics impostor
  67498. * @see https://doc.babylonjs.com/features/physics_engine
  67499. * @returns a physics impostor or null
  67500. */
  67501. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67502. /** Apply a physic impulse to the mesh
  67503. * @param force defines the force to apply
  67504. * @param contactPoint defines where to apply the force
  67505. * @returns the current mesh
  67506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67507. */
  67508. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67509. /**
  67510. * Creates a physic joint between two meshes
  67511. * @param otherMesh defines the other mesh to use
  67512. * @param pivot1 defines the pivot to use on this mesh
  67513. * @param pivot2 defines the pivot to use on the other mesh
  67514. * @param options defines additional options (can be plugin dependent)
  67515. * @returns the current mesh
  67516. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67517. */
  67518. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67519. /** @hidden */
  67520. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67521. }
  67522. /**
  67523. * Defines the physics engine scene component responsible to manage a physics engine
  67524. */
  67525. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67526. /**
  67527. * The component name helpful to identify the component in the list of scene components.
  67528. */
  67529. readonly name: string;
  67530. /**
  67531. * The scene the component belongs to.
  67532. */
  67533. scene: Scene;
  67534. /**
  67535. * Creates a new instance of the component for the given scene
  67536. * @param scene Defines the scene to register the component in
  67537. */
  67538. constructor(scene: Scene);
  67539. /**
  67540. * Registers the component in a given scene
  67541. */
  67542. register(): void;
  67543. /**
  67544. * Rebuilds the elements related to this component in case of
  67545. * context lost for instance.
  67546. */
  67547. rebuild(): void;
  67548. /**
  67549. * Disposes the component and the associated ressources
  67550. */
  67551. dispose(): void;
  67552. }
  67553. }
  67554. declare module BABYLON {
  67555. /**
  67556. * A helper for physics simulations
  67557. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67558. */
  67559. export class PhysicsHelper {
  67560. private _scene;
  67561. private _physicsEngine;
  67562. /**
  67563. * Initializes the Physics helper
  67564. * @param scene Babylon.js scene
  67565. */
  67566. constructor(scene: Scene);
  67567. /**
  67568. * Applies a radial explosion impulse
  67569. * @param origin the origin of the explosion
  67570. * @param radiusOrEventOptions the radius or the options of radial explosion
  67571. * @param strength the explosion strength
  67572. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67573. * @returns A physics radial explosion event, or null
  67574. */
  67575. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67576. /**
  67577. * Applies a radial explosion force
  67578. * @param origin the origin of the explosion
  67579. * @param radiusOrEventOptions the radius or the options of radial explosion
  67580. * @param strength the explosion strength
  67581. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67582. * @returns A physics radial explosion event, or null
  67583. */
  67584. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67585. /**
  67586. * Creates a gravitational field
  67587. * @param origin the origin of the explosion
  67588. * @param radiusOrEventOptions the radius or the options of radial explosion
  67589. * @param strength the explosion strength
  67590. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67591. * @returns A physics gravitational field event, or null
  67592. */
  67593. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67594. /**
  67595. * Creates a physics updraft event
  67596. * @param origin the origin of the updraft
  67597. * @param radiusOrEventOptions the radius or the options of the updraft
  67598. * @param strength the strength of the updraft
  67599. * @param height the height of the updraft
  67600. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67601. * @returns A physics updraft event, or null
  67602. */
  67603. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67604. /**
  67605. * Creates a physics vortex event
  67606. * @param origin the of the vortex
  67607. * @param radiusOrEventOptions the radius or the options of the vortex
  67608. * @param strength the strength of the vortex
  67609. * @param height the height of the vortex
  67610. * @returns a Physics vortex event, or null
  67611. * A physics vortex event or null
  67612. */
  67613. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67614. }
  67615. /**
  67616. * Represents a physics radial explosion event
  67617. */
  67618. class PhysicsRadialExplosionEvent {
  67619. private _scene;
  67620. private _options;
  67621. private _sphere;
  67622. private _dataFetched;
  67623. /**
  67624. * Initializes a radial explosioin event
  67625. * @param _scene BabylonJS scene
  67626. * @param _options The options for the vortex event
  67627. */
  67628. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67629. /**
  67630. * Returns the data related to the radial explosion event (sphere).
  67631. * @returns The radial explosion event data
  67632. */
  67633. getData(): PhysicsRadialExplosionEventData;
  67634. /**
  67635. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67636. * @param impostor A physics imposter
  67637. * @param origin the origin of the explosion
  67638. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67639. */
  67640. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67641. /**
  67642. * Triggers affecterd impostors callbacks
  67643. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67644. */
  67645. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67646. /**
  67647. * Disposes the sphere.
  67648. * @param force Specifies if the sphere should be disposed by force
  67649. */
  67650. dispose(force?: boolean): void;
  67651. /*** Helpers ***/
  67652. private _prepareSphere;
  67653. private _intersectsWithSphere;
  67654. }
  67655. /**
  67656. * Represents a gravitational field event
  67657. */
  67658. class PhysicsGravitationalFieldEvent {
  67659. private _physicsHelper;
  67660. private _scene;
  67661. private _origin;
  67662. private _options;
  67663. private _tickCallback;
  67664. private _sphere;
  67665. private _dataFetched;
  67666. /**
  67667. * Initializes the physics gravitational field event
  67668. * @param _physicsHelper A physics helper
  67669. * @param _scene BabylonJS scene
  67670. * @param _origin The origin position of the gravitational field event
  67671. * @param _options The options for the vortex event
  67672. */
  67673. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67674. /**
  67675. * Returns the data related to the gravitational field event (sphere).
  67676. * @returns A gravitational field event
  67677. */
  67678. getData(): PhysicsGravitationalFieldEventData;
  67679. /**
  67680. * Enables the gravitational field.
  67681. */
  67682. enable(): void;
  67683. /**
  67684. * Disables the gravitational field.
  67685. */
  67686. disable(): void;
  67687. /**
  67688. * Disposes the sphere.
  67689. * @param force The force to dispose from the gravitational field event
  67690. */
  67691. dispose(force?: boolean): void;
  67692. private _tick;
  67693. }
  67694. /**
  67695. * Represents a physics updraft event
  67696. */
  67697. class PhysicsUpdraftEvent {
  67698. private _scene;
  67699. private _origin;
  67700. private _options;
  67701. private _physicsEngine;
  67702. private _originTop;
  67703. private _originDirection;
  67704. private _tickCallback;
  67705. private _cylinder;
  67706. private _cylinderPosition;
  67707. private _dataFetched;
  67708. /**
  67709. * Initializes the physics updraft event
  67710. * @param _scene BabylonJS scene
  67711. * @param _origin The origin position of the updraft
  67712. * @param _options The options for the updraft event
  67713. */
  67714. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67715. /**
  67716. * Returns the data related to the updraft event (cylinder).
  67717. * @returns A physics updraft event
  67718. */
  67719. getData(): PhysicsUpdraftEventData;
  67720. /**
  67721. * Enables the updraft.
  67722. */
  67723. enable(): void;
  67724. /**
  67725. * Disables the updraft.
  67726. */
  67727. disable(): void;
  67728. /**
  67729. * Disposes the cylinder.
  67730. * @param force Specifies if the updraft should be disposed by force
  67731. */
  67732. dispose(force?: boolean): void;
  67733. private getImpostorHitData;
  67734. private _tick;
  67735. /*** Helpers ***/
  67736. private _prepareCylinder;
  67737. private _intersectsWithCylinder;
  67738. }
  67739. /**
  67740. * Represents a physics vortex event
  67741. */
  67742. class PhysicsVortexEvent {
  67743. private _scene;
  67744. private _origin;
  67745. private _options;
  67746. private _physicsEngine;
  67747. private _originTop;
  67748. private _tickCallback;
  67749. private _cylinder;
  67750. private _cylinderPosition;
  67751. private _dataFetched;
  67752. /**
  67753. * Initializes the physics vortex event
  67754. * @param _scene The BabylonJS scene
  67755. * @param _origin The origin position of the vortex
  67756. * @param _options The options for the vortex event
  67757. */
  67758. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67759. /**
  67760. * Returns the data related to the vortex event (cylinder).
  67761. * @returns The physics vortex event data
  67762. */
  67763. getData(): PhysicsVortexEventData;
  67764. /**
  67765. * Enables the vortex.
  67766. */
  67767. enable(): void;
  67768. /**
  67769. * Disables the cortex.
  67770. */
  67771. disable(): void;
  67772. /**
  67773. * Disposes the sphere.
  67774. * @param force
  67775. */
  67776. dispose(force?: boolean): void;
  67777. private getImpostorHitData;
  67778. private _tick;
  67779. /*** Helpers ***/
  67780. private _prepareCylinder;
  67781. private _intersectsWithCylinder;
  67782. }
  67783. /**
  67784. * Options fot the radial explosion event
  67785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67786. */
  67787. export class PhysicsRadialExplosionEventOptions {
  67788. /**
  67789. * The radius of the sphere for the radial explosion.
  67790. */
  67791. radius: number;
  67792. /**
  67793. * The strenth of the explosion.
  67794. */
  67795. strength: number;
  67796. /**
  67797. * The strenght of the force in correspondence to the distance of the affected object
  67798. */
  67799. falloff: PhysicsRadialImpulseFalloff;
  67800. /**
  67801. * Sphere options for the radial explosion.
  67802. */
  67803. sphere: {
  67804. segments: number;
  67805. diameter: number;
  67806. };
  67807. /**
  67808. * Sphere options for the radial explosion.
  67809. */
  67810. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67811. }
  67812. /**
  67813. * Options fot the updraft event
  67814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67815. */
  67816. export class PhysicsUpdraftEventOptions {
  67817. /**
  67818. * The radius of the cylinder for the vortex
  67819. */
  67820. radius: number;
  67821. /**
  67822. * The strenth of the updraft.
  67823. */
  67824. strength: number;
  67825. /**
  67826. * The height of the cylinder for the updraft.
  67827. */
  67828. height: number;
  67829. /**
  67830. * The mode for the the updraft.
  67831. */
  67832. updraftMode: PhysicsUpdraftMode;
  67833. }
  67834. /**
  67835. * Options fot the vortex event
  67836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67837. */
  67838. export class PhysicsVortexEventOptions {
  67839. /**
  67840. * The radius of the cylinder for the vortex
  67841. */
  67842. radius: number;
  67843. /**
  67844. * The strenth of the vortex.
  67845. */
  67846. strength: number;
  67847. /**
  67848. * The height of the cylinder for the vortex.
  67849. */
  67850. height: number;
  67851. /**
  67852. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67853. */
  67854. centripetalForceThreshold: number;
  67855. /**
  67856. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67857. */
  67858. centripetalForceMultiplier: number;
  67859. /**
  67860. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67861. */
  67862. centrifugalForceMultiplier: number;
  67863. /**
  67864. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67865. */
  67866. updraftForceMultiplier: number;
  67867. }
  67868. /**
  67869. * The strenght of the force in correspondence to the distance of the affected object
  67870. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67871. */
  67872. export enum PhysicsRadialImpulseFalloff {
  67873. /** Defines that impulse is constant in strength across it's whole radius */
  67874. Constant = 0,
  67875. /** Defines that impulse gets weaker if it's further from the origin */
  67876. Linear = 1
  67877. }
  67878. /**
  67879. * The strength of the force in correspondence to the distance of the affected object
  67880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67881. */
  67882. export enum PhysicsUpdraftMode {
  67883. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67884. Center = 0,
  67885. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67886. Perpendicular = 1
  67887. }
  67888. /**
  67889. * Interface for a physics hit data
  67890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67891. */
  67892. export interface PhysicsHitData {
  67893. /**
  67894. * The force applied at the contact point
  67895. */
  67896. force: Vector3;
  67897. /**
  67898. * The contact point
  67899. */
  67900. contactPoint: Vector3;
  67901. /**
  67902. * The distance from the origin to the contact point
  67903. */
  67904. distanceFromOrigin: number;
  67905. }
  67906. /**
  67907. * Interface for radial explosion event data
  67908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67909. */
  67910. export interface PhysicsRadialExplosionEventData {
  67911. /**
  67912. * A sphere used for the radial explosion event
  67913. */
  67914. sphere: Mesh;
  67915. }
  67916. /**
  67917. * Interface for gravitational field event data
  67918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67919. */
  67920. export interface PhysicsGravitationalFieldEventData {
  67921. /**
  67922. * A sphere mesh used for the gravitational field event
  67923. */
  67924. sphere: Mesh;
  67925. }
  67926. /**
  67927. * Interface for updraft event data
  67928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67929. */
  67930. export interface PhysicsUpdraftEventData {
  67931. /**
  67932. * A cylinder used for the updraft event
  67933. */
  67934. cylinder: Mesh;
  67935. }
  67936. /**
  67937. * Interface for vortex event data
  67938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67939. */
  67940. export interface PhysicsVortexEventData {
  67941. /**
  67942. * A cylinder used for the vortex event
  67943. */
  67944. cylinder: Mesh;
  67945. }
  67946. /**
  67947. * Interface for an affected physics impostor
  67948. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67949. */
  67950. export interface PhysicsAffectedImpostorWithData {
  67951. /**
  67952. * The impostor affected by the effect
  67953. */
  67954. impostor: PhysicsImpostor;
  67955. /**
  67956. * The data about the hit/horce from the explosion
  67957. */
  67958. hitData: PhysicsHitData;
  67959. }
  67960. }
  67961. declare module BABYLON {
  67962. /** @hidden */
  67963. export var blackAndWhitePixelShader: {
  67964. name: string;
  67965. shader: string;
  67966. };
  67967. }
  67968. declare module BABYLON {
  67969. /**
  67970. * Post process used to render in black and white
  67971. */
  67972. export class BlackAndWhitePostProcess extends PostProcess {
  67973. /**
  67974. * Linear about to convert he result to black and white (default: 1)
  67975. */
  67976. degree: number;
  67977. /**
  67978. * Creates a black and white post process
  67979. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67980. * @param name The name of the effect.
  67981. * @param options The required width/height ratio to downsize to before computing the render pass.
  67982. * @param camera The camera to apply the render pass to.
  67983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67984. * @param engine The engine which the post process will be applied. (default: current engine)
  67985. * @param reusable If the post process can be reused on the same frame. (default: false)
  67986. */
  67987. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67988. }
  67989. }
  67990. declare module BABYLON {
  67991. /**
  67992. * This represents a set of one or more post processes in Babylon.
  67993. * A post process can be used to apply a shader to a texture after it is rendered.
  67994. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67995. */
  67996. export class PostProcessRenderEffect {
  67997. private _postProcesses;
  67998. private _getPostProcesses;
  67999. private _singleInstance;
  68000. private _cameras;
  68001. private _indicesForCamera;
  68002. /**
  68003. * Name of the effect
  68004. * @hidden
  68005. */
  68006. _name: string;
  68007. /**
  68008. * Instantiates a post process render effect.
  68009. * A post process can be used to apply a shader to a texture after it is rendered.
  68010. * @param engine The engine the effect is tied to
  68011. * @param name The name of the effect
  68012. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68013. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68014. */
  68015. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68016. /**
  68017. * Checks if all the post processes in the effect are supported.
  68018. */
  68019. get isSupported(): boolean;
  68020. /**
  68021. * Updates the current state of the effect
  68022. * @hidden
  68023. */
  68024. _update(): void;
  68025. /**
  68026. * Attaches the effect on cameras
  68027. * @param cameras The camera to attach to.
  68028. * @hidden
  68029. */
  68030. _attachCameras(cameras: Camera): void;
  68031. /**
  68032. * Attaches the effect on cameras
  68033. * @param cameras The camera to attach to.
  68034. * @hidden
  68035. */
  68036. _attachCameras(cameras: Camera[]): void;
  68037. /**
  68038. * Detaches the effect on cameras
  68039. * @param cameras The camera to detatch from.
  68040. * @hidden
  68041. */
  68042. _detachCameras(cameras: Camera): void;
  68043. /**
  68044. * Detatches the effect on cameras
  68045. * @param cameras The camera to detatch from.
  68046. * @hidden
  68047. */
  68048. _detachCameras(cameras: Camera[]): void;
  68049. /**
  68050. * Enables the effect on given cameras
  68051. * @param cameras The camera to enable.
  68052. * @hidden
  68053. */
  68054. _enable(cameras: Camera): void;
  68055. /**
  68056. * Enables the effect on given cameras
  68057. * @param cameras The camera to enable.
  68058. * @hidden
  68059. */
  68060. _enable(cameras: Nullable<Camera[]>): void;
  68061. /**
  68062. * Disables the effect on the given cameras
  68063. * @param cameras The camera to disable.
  68064. * @hidden
  68065. */
  68066. _disable(cameras: Camera): void;
  68067. /**
  68068. * Disables the effect on the given cameras
  68069. * @param cameras The camera to disable.
  68070. * @hidden
  68071. */
  68072. _disable(cameras: Nullable<Camera[]>): void;
  68073. /**
  68074. * Gets a list of the post processes contained in the effect.
  68075. * @param camera The camera to get the post processes on.
  68076. * @returns The list of the post processes in the effect.
  68077. */
  68078. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68079. }
  68080. }
  68081. declare module BABYLON {
  68082. /** @hidden */
  68083. export var extractHighlightsPixelShader: {
  68084. name: string;
  68085. shader: string;
  68086. };
  68087. }
  68088. declare module BABYLON {
  68089. /**
  68090. * 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.
  68091. */
  68092. export class ExtractHighlightsPostProcess extends PostProcess {
  68093. /**
  68094. * The luminance threshold, pixels below this value will be set to black.
  68095. */
  68096. threshold: number;
  68097. /** @hidden */
  68098. _exposure: number;
  68099. /**
  68100. * Post process which has the input texture to be used when performing highlight extraction
  68101. * @hidden
  68102. */
  68103. _inputPostProcess: Nullable<PostProcess>;
  68104. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68105. }
  68106. }
  68107. declare module BABYLON {
  68108. /** @hidden */
  68109. export var bloomMergePixelShader: {
  68110. name: string;
  68111. shader: string;
  68112. };
  68113. }
  68114. declare module BABYLON {
  68115. /**
  68116. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68117. */
  68118. export class BloomMergePostProcess extends PostProcess {
  68119. /** Weight of the bloom to be added to the original input. */
  68120. weight: number;
  68121. /**
  68122. * Creates a new instance of @see BloomMergePostProcess
  68123. * @param name The name of the effect.
  68124. * @param originalFromInput Post process which's input will be used for the merge.
  68125. * @param blurred Blurred highlights post process which's output will be used.
  68126. * @param weight Weight of the bloom to be added to the original input.
  68127. * @param options The required width/height ratio to downsize to before computing the render pass.
  68128. * @param camera The camera to apply the render pass to.
  68129. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68130. * @param engine The engine which the post process will be applied. (default: current engine)
  68131. * @param reusable If the post process can be reused on the same frame. (default: false)
  68132. * @param textureType Type of textures used when performing the post process. (default: 0)
  68133. * @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)
  68134. */
  68135. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68136. /** Weight of the bloom to be added to the original input. */
  68137. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68138. }
  68139. }
  68140. declare module BABYLON {
  68141. /**
  68142. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68143. */
  68144. export class BloomEffect extends PostProcessRenderEffect {
  68145. private bloomScale;
  68146. /**
  68147. * @hidden Internal
  68148. */
  68149. _effects: Array<PostProcess>;
  68150. /**
  68151. * @hidden Internal
  68152. */
  68153. _downscale: ExtractHighlightsPostProcess;
  68154. private _blurX;
  68155. private _blurY;
  68156. private _merge;
  68157. /**
  68158. * The luminance threshold to find bright areas of the image to bloom.
  68159. */
  68160. get threshold(): number;
  68161. set threshold(value: number);
  68162. /**
  68163. * The strength of the bloom.
  68164. */
  68165. get weight(): number;
  68166. set weight(value: number);
  68167. /**
  68168. * Specifies the size of the bloom blur kernel, relative to the final output size
  68169. */
  68170. get kernel(): number;
  68171. set kernel(value: number);
  68172. /**
  68173. * Creates a new instance of @see BloomEffect
  68174. * @param scene The scene the effect belongs to.
  68175. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68176. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68177. * @param bloomWeight The the strength of bloom.
  68178. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68179. * @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)
  68180. */
  68181. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68182. /**
  68183. * Disposes each of the internal effects for a given camera.
  68184. * @param camera The camera to dispose the effect on.
  68185. */
  68186. disposeEffects(camera: Camera): void;
  68187. /**
  68188. * @hidden Internal
  68189. */
  68190. _updateEffects(): void;
  68191. /**
  68192. * Internal
  68193. * @returns if all the contained post processes are ready.
  68194. * @hidden
  68195. */
  68196. _isReady(): boolean;
  68197. }
  68198. }
  68199. declare module BABYLON {
  68200. /** @hidden */
  68201. export var chromaticAberrationPixelShader: {
  68202. name: string;
  68203. shader: string;
  68204. };
  68205. }
  68206. declare module BABYLON {
  68207. /**
  68208. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68209. */
  68210. export class ChromaticAberrationPostProcess extends PostProcess {
  68211. /**
  68212. * The amount of seperation of rgb channels (default: 30)
  68213. */
  68214. aberrationAmount: number;
  68215. /**
  68216. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68217. */
  68218. radialIntensity: number;
  68219. /**
  68220. * 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))
  68221. */
  68222. direction: Vector2;
  68223. /**
  68224. * 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))
  68225. */
  68226. centerPosition: Vector2;
  68227. /**
  68228. * Creates a new instance ChromaticAberrationPostProcess
  68229. * @param name The name of the effect.
  68230. * @param screenWidth The width of the screen to apply the effect on.
  68231. * @param screenHeight The height of the screen to apply the effect on.
  68232. * @param options The required width/height ratio to downsize to before computing the render pass.
  68233. * @param camera The camera to apply the render pass to.
  68234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68235. * @param engine The engine which the post process will be applied. (default: current engine)
  68236. * @param reusable If the post process can be reused on the same frame. (default: false)
  68237. * @param textureType Type of textures used when performing the post process. (default: 0)
  68238. * @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)
  68239. */
  68240. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68241. }
  68242. }
  68243. declare module BABYLON {
  68244. /** @hidden */
  68245. export var circleOfConfusionPixelShader: {
  68246. name: string;
  68247. shader: string;
  68248. };
  68249. }
  68250. declare module BABYLON {
  68251. /**
  68252. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68253. */
  68254. export class CircleOfConfusionPostProcess extends PostProcess {
  68255. /**
  68256. * 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.
  68257. */
  68258. lensSize: number;
  68259. /**
  68260. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68261. */
  68262. fStop: number;
  68263. /**
  68264. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68265. */
  68266. focusDistance: number;
  68267. /**
  68268. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68269. */
  68270. focalLength: number;
  68271. private _depthTexture;
  68272. /**
  68273. * Creates a new instance CircleOfConfusionPostProcess
  68274. * @param name The name of the effect.
  68275. * @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.
  68276. * @param options The required width/height ratio to downsize to before computing the render pass.
  68277. * @param camera The camera to apply the render pass to.
  68278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68279. * @param engine The engine which the post process will be applied. (default: current engine)
  68280. * @param reusable If the post process can be reused on the same frame. (default: false)
  68281. * @param textureType Type of textures used when performing the post process. (default: 0)
  68282. * @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)
  68283. */
  68284. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68285. /**
  68286. * 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.
  68287. */
  68288. set depthTexture(value: RenderTargetTexture);
  68289. }
  68290. }
  68291. declare module BABYLON {
  68292. /** @hidden */
  68293. export var colorCorrectionPixelShader: {
  68294. name: string;
  68295. shader: string;
  68296. };
  68297. }
  68298. declare module BABYLON {
  68299. /**
  68300. *
  68301. * This post-process allows the modification of rendered colors by using
  68302. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68303. *
  68304. * The object needs to be provided an url to a texture containing the color
  68305. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68306. * Use an image editing software to tweak the LUT to match your needs.
  68307. *
  68308. * For an example of a color LUT, see here:
  68309. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68310. * For explanations on color grading, see here:
  68311. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68312. *
  68313. */
  68314. export class ColorCorrectionPostProcess extends PostProcess {
  68315. private _colorTableTexture;
  68316. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68317. }
  68318. }
  68319. declare module BABYLON {
  68320. /** @hidden */
  68321. export var convolutionPixelShader: {
  68322. name: string;
  68323. shader: string;
  68324. };
  68325. }
  68326. declare module BABYLON {
  68327. /**
  68328. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68329. * input texture to perform effects such as edge detection or sharpening
  68330. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68331. */
  68332. export class ConvolutionPostProcess extends PostProcess {
  68333. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68334. kernel: number[];
  68335. /**
  68336. * Creates a new instance ConvolutionPostProcess
  68337. * @param name The name of the effect.
  68338. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68339. * @param options The required width/height ratio to downsize to before computing the render pass.
  68340. * @param camera The camera to apply the render pass to.
  68341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68342. * @param engine The engine which the post process will be applied. (default: current engine)
  68343. * @param reusable If the post process can be reused on the same frame. (default: false)
  68344. * @param textureType Type of textures used when performing the post process. (default: 0)
  68345. */
  68346. constructor(name: string,
  68347. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68348. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68349. /**
  68350. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68351. */
  68352. static EdgeDetect0Kernel: number[];
  68353. /**
  68354. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68355. */
  68356. static EdgeDetect1Kernel: number[];
  68357. /**
  68358. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68359. */
  68360. static EdgeDetect2Kernel: number[];
  68361. /**
  68362. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68363. */
  68364. static SharpenKernel: number[];
  68365. /**
  68366. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68367. */
  68368. static EmbossKernel: number[];
  68369. /**
  68370. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68371. */
  68372. static GaussianKernel: number[];
  68373. }
  68374. }
  68375. declare module BABYLON {
  68376. /**
  68377. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68378. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68379. * based on samples that have a large difference in distance than the center pixel.
  68380. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68381. */
  68382. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68383. direction: Vector2;
  68384. /**
  68385. * Creates a new instance CircleOfConfusionPostProcess
  68386. * @param name The name of the effect.
  68387. * @param scene The scene the effect belongs to.
  68388. * @param direction The direction the blur should be applied.
  68389. * @param kernel The size of the kernel used to blur.
  68390. * @param options The required width/height ratio to downsize to before computing the render pass.
  68391. * @param camera The camera to apply the render pass to.
  68392. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68393. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68394. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68395. * @param engine The engine which the post process will be applied. (default: current engine)
  68396. * @param reusable If the post process can be reused on the same frame. (default: false)
  68397. * @param textureType Type of textures used when performing the post process. (default: 0)
  68398. * @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)
  68399. */
  68400. 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);
  68401. }
  68402. }
  68403. declare module BABYLON {
  68404. /** @hidden */
  68405. export var depthOfFieldMergePixelShader: {
  68406. name: string;
  68407. shader: string;
  68408. };
  68409. }
  68410. declare module BABYLON {
  68411. /**
  68412. * Options to be set when merging outputs from the default pipeline.
  68413. */
  68414. export class DepthOfFieldMergePostProcessOptions {
  68415. /**
  68416. * The original image to merge on top of
  68417. */
  68418. originalFromInput: PostProcess;
  68419. /**
  68420. * Parameters to perform the merge of the depth of field effect
  68421. */
  68422. depthOfField?: {
  68423. circleOfConfusion: PostProcess;
  68424. blurSteps: Array<PostProcess>;
  68425. };
  68426. /**
  68427. * Parameters to perform the merge of bloom effect
  68428. */
  68429. bloom?: {
  68430. blurred: PostProcess;
  68431. weight: number;
  68432. };
  68433. }
  68434. /**
  68435. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68436. */
  68437. export class DepthOfFieldMergePostProcess extends PostProcess {
  68438. private blurSteps;
  68439. /**
  68440. * Creates a new instance of DepthOfFieldMergePostProcess
  68441. * @param name The name of the effect.
  68442. * @param originalFromInput Post process which's input will be used for the merge.
  68443. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68444. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68445. * @param options The required width/height ratio to downsize to before computing the render pass.
  68446. * @param camera The camera to apply the render pass to.
  68447. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68448. * @param engine The engine which the post process will be applied. (default: current engine)
  68449. * @param reusable If the post process can be reused on the same frame. (default: false)
  68450. * @param textureType Type of textures used when performing the post process. (default: 0)
  68451. * @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)
  68452. */
  68453. 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);
  68454. /**
  68455. * Updates the effect with the current post process compile time values and recompiles the shader.
  68456. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68457. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68458. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68459. * @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
  68460. * @param onCompiled Called when the shader has been compiled.
  68461. * @param onError Called if there is an error when compiling a shader.
  68462. */
  68463. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68464. }
  68465. }
  68466. declare module BABYLON {
  68467. /**
  68468. * Specifies the level of max blur that should be applied when using the depth of field effect
  68469. */
  68470. export enum DepthOfFieldEffectBlurLevel {
  68471. /**
  68472. * Subtle blur
  68473. */
  68474. Low = 0,
  68475. /**
  68476. * Medium blur
  68477. */
  68478. Medium = 1,
  68479. /**
  68480. * Large blur
  68481. */
  68482. High = 2
  68483. }
  68484. /**
  68485. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68486. */
  68487. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68488. private _circleOfConfusion;
  68489. /**
  68490. * @hidden Internal, blurs from high to low
  68491. */
  68492. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68493. private _depthOfFieldBlurY;
  68494. private _dofMerge;
  68495. /**
  68496. * @hidden Internal post processes in depth of field effect
  68497. */
  68498. _effects: Array<PostProcess>;
  68499. /**
  68500. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68501. */
  68502. set focalLength(value: number);
  68503. get focalLength(): number;
  68504. /**
  68505. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68506. */
  68507. set fStop(value: number);
  68508. get fStop(): number;
  68509. /**
  68510. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68511. */
  68512. set focusDistance(value: number);
  68513. get focusDistance(): number;
  68514. /**
  68515. * 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.
  68516. */
  68517. set lensSize(value: number);
  68518. get lensSize(): number;
  68519. /**
  68520. * Creates a new instance DepthOfFieldEffect
  68521. * @param scene The scene the effect belongs to.
  68522. * @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.
  68523. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68524. * @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)
  68525. */
  68526. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68527. /**
  68528. * Get the current class name of the current effet
  68529. * @returns "DepthOfFieldEffect"
  68530. */
  68531. getClassName(): string;
  68532. /**
  68533. * 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.
  68534. */
  68535. set depthTexture(value: RenderTargetTexture);
  68536. /**
  68537. * Disposes each of the internal effects for a given camera.
  68538. * @param camera The camera to dispose the effect on.
  68539. */
  68540. disposeEffects(camera: Camera): void;
  68541. /**
  68542. * @hidden Internal
  68543. */
  68544. _updateEffects(): void;
  68545. /**
  68546. * Internal
  68547. * @returns if all the contained post processes are ready.
  68548. * @hidden
  68549. */
  68550. _isReady(): boolean;
  68551. }
  68552. }
  68553. declare module BABYLON {
  68554. /** @hidden */
  68555. export var displayPassPixelShader: {
  68556. name: string;
  68557. shader: string;
  68558. };
  68559. }
  68560. declare module BABYLON {
  68561. /**
  68562. * DisplayPassPostProcess which produces an output the same as it's input
  68563. */
  68564. export class DisplayPassPostProcess extends PostProcess {
  68565. /**
  68566. * Creates the DisplayPassPostProcess
  68567. * @param name The name of the effect.
  68568. * @param options The required width/height ratio to downsize to before computing the render pass.
  68569. * @param camera The camera to apply the render pass to.
  68570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68571. * @param engine The engine which the post process will be applied. (default: current engine)
  68572. * @param reusable If the post process can be reused on the same frame. (default: false)
  68573. */
  68574. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68575. }
  68576. }
  68577. declare module BABYLON {
  68578. /** @hidden */
  68579. export var filterPixelShader: {
  68580. name: string;
  68581. shader: string;
  68582. };
  68583. }
  68584. declare module BABYLON {
  68585. /**
  68586. * Applies a kernel filter to the image
  68587. */
  68588. export class FilterPostProcess extends PostProcess {
  68589. /** The matrix to be applied to the image */
  68590. kernelMatrix: Matrix;
  68591. /**
  68592. *
  68593. * @param name The name of the effect.
  68594. * @param kernelMatrix The matrix to be applied to the image
  68595. * @param options The required width/height ratio to downsize to before computing the render pass.
  68596. * @param camera The camera to apply the render pass to.
  68597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68598. * @param engine The engine which the post process will be applied. (default: current engine)
  68599. * @param reusable If the post process can be reused on the same frame. (default: false)
  68600. */
  68601. constructor(name: string,
  68602. /** The matrix to be applied to the image */
  68603. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68604. }
  68605. }
  68606. declare module BABYLON {
  68607. /** @hidden */
  68608. export var fxaaPixelShader: {
  68609. name: string;
  68610. shader: string;
  68611. };
  68612. }
  68613. declare module BABYLON {
  68614. /** @hidden */
  68615. export var fxaaVertexShader: {
  68616. name: string;
  68617. shader: string;
  68618. };
  68619. }
  68620. declare module BABYLON {
  68621. /**
  68622. * Fxaa post process
  68623. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68624. */
  68625. export class FxaaPostProcess extends PostProcess {
  68626. /** @hidden */
  68627. texelWidth: number;
  68628. /** @hidden */
  68629. texelHeight: number;
  68630. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68631. private _getDefines;
  68632. }
  68633. }
  68634. declare module BABYLON {
  68635. /** @hidden */
  68636. export var grainPixelShader: {
  68637. name: string;
  68638. shader: string;
  68639. };
  68640. }
  68641. declare module BABYLON {
  68642. /**
  68643. * The GrainPostProcess adds noise to the image at mid luminance levels
  68644. */
  68645. export class GrainPostProcess extends PostProcess {
  68646. /**
  68647. * The intensity of the grain added (default: 30)
  68648. */
  68649. intensity: number;
  68650. /**
  68651. * If the grain should be randomized on every frame
  68652. */
  68653. animated: boolean;
  68654. /**
  68655. * Creates a new instance of @see GrainPostProcess
  68656. * @param name The name of the effect.
  68657. * @param options The required width/height ratio to downsize to before computing the render pass.
  68658. * @param camera The camera to apply the render pass to.
  68659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68660. * @param engine The engine which the post process will be applied. (default: current engine)
  68661. * @param reusable If the post process can be reused on the same frame. (default: false)
  68662. * @param textureType Type of textures used when performing the post process. (default: 0)
  68663. * @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)
  68664. */
  68665. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68666. }
  68667. }
  68668. declare module BABYLON {
  68669. /** @hidden */
  68670. export var highlightsPixelShader: {
  68671. name: string;
  68672. shader: string;
  68673. };
  68674. }
  68675. declare module BABYLON {
  68676. /**
  68677. * Extracts highlights from the image
  68678. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68679. */
  68680. export class HighlightsPostProcess extends PostProcess {
  68681. /**
  68682. * Extracts highlights from the image
  68683. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68684. * @param name The name of the effect.
  68685. * @param options The required width/height ratio to downsize to before computing the render pass.
  68686. * @param camera The camera to apply the render pass to.
  68687. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68688. * @param engine The engine which the post process will be applied. (default: current engine)
  68689. * @param reusable If the post process can be reused on the same frame. (default: false)
  68690. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68691. */
  68692. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68693. }
  68694. }
  68695. declare module BABYLON {
  68696. /** @hidden */
  68697. export var mrtFragmentDeclaration: {
  68698. name: string;
  68699. shader: string;
  68700. };
  68701. }
  68702. declare module BABYLON {
  68703. /** @hidden */
  68704. export var geometryPixelShader: {
  68705. name: string;
  68706. shader: string;
  68707. };
  68708. }
  68709. declare module BABYLON {
  68710. /** @hidden */
  68711. export var geometryVertexShader: {
  68712. name: string;
  68713. shader: string;
  68714. };
  68715. }
  68716. declare module BABYLON {
  68717. /** @hidden */
  68718. interface ISavedTransformationMatrix {
  68719. world: Matrix;
  68720. viewProjection: Matrix;
  68721. }
  68722. /**
  68723. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68724. */
  68725. export class GeometryBufferRenderer {
  68726. /**
  68727. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68728. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68729. */
  68730. static readonly POSITION_TEXTURE_TYPE: number;
  68731. /**
  68732. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68733. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68734. */
  68735. static readonly VELOCITY_TEXTURE_TYPE: number;
  68736. /**
  68737. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68738. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68739. */
  68740. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68741. /**
  68742. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68743. * in order to compute objects velocities when enableVelocity is set to "true"
  68744. * @hidden
  68745. */
  68746. _previousTransformationMatrices: {
  68747. [index: number]: ISavedTransformationMatrix;
  68748. };
  68749. /**
  68750. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68751. * in order to compute objects velocities when enableVelocity is set to "true"
  68752. * @hidden
  68753. */
  68754. _previousBonesTransformationMatrices: {
  68755. [index: number]: Float32Array;
  68756. };
  68757. /**
  68758. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68759. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68760. */
  68761. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68762. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68763. renderTransparentMeshes: boolean;
  68764. private _scene;
  68765. private _multiRenderTarget;
  68766. private _ratio;
  68767. private _enablePosition;
  68768. private _enableVelocity;
  68769. private _enableReflectivity;
  68770. private _positionIndex;
  68771. private _velocityIndex;
  68772. private _reflectivityIndex;
  68773. protected _effect: Effect;
  68774. protected _cachedDefines: string;
  68775. /**
  68776. * Set the render list (meshes to be rendered) used in the G buffer.
  68777. */
  68778. set renderList(meshes: Mesh[]);
  68779. /**
  68780. * Gets wether or not G buffer are supported by the running hardware.
  68781. * This requires draw buffer supports
  68782. */
  68783. get isSupported(): boolean;
  68784. /**
  68785. * Returns the index of the given texture type in the G-Buffer textures array
  68786. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68787. * @returns the index of the given texture type in the G-Buffer textures array
  68788. */
  68789. getTextureIndex(textureType: number): number;
  68790. /**
  68791. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68792. */
  68793. get enablePosition(): boolean;
  68794. /**
  68795. * Sets whether or not objects positions are enabled for the G buffer.
  68796. */
  68797. set enablePosition(enable: boolean);
  68798. /**
  68799. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68800. */
  68801. get enableVelocity(): boolean;
  68802. /**
  68803. * Sets wether or not objects velocities are enabled for the G buffer.
  68804. */
  68805. set enableVelocity(enable: boolean);
  68806. /**
  68807. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68808. */
  68809. get enableReflectivity(): boolean;
  68810. /**
  68811. * Sets wether or not objects roughness are enabled for the G buffer.
  68812. */
  68813. set enableReflectivity(enable: boolean);
  68814. /**
  68815. * Gets the scene associated with the buffer.
  68816. */
  68817. get scene(): Scene;
  68818. /**
  68819. * Gets the ratio used by the buffer during its creation.
  68820. * How big is the buffer related to the main canvas.
  68821. */
  68822. get ratio(): number;
  68823. /** @hidden */
  68824. static _SceneComponentInitialization: (scene: Scene) => void;
  68825. /**
  68826. * Creates a new G Buffer for the scene
  68827. * @param scene The scene the buffer belongs to
  68828. * @param ratio How big is the buffer related to the main canvas.
  68829. */
  68830. constructor(scene: Scene, ratio?: number);
  68831. /**
  68832. * Checks wether everything is ready to render a submesh to the G buffer.
  68833. * @param subMesh the submesh to check readiness for
  68834. * @param useInstances is the mesh drawn using instance or not
  68835. * @returns true if ready otherwise false
  68836. */
  68837. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68838. /**
  68839. * Gets the current underlying G Buffer.
  68840. * @returns the buffer
  68841. */
  68842. getGBuffer(): MultiRenderTarget;
  68843. /**
  68844. * Gets the number of samples used to render the buffer (anti aliasing).
  68845. */
  68846. get samples(): number;
  68847. /**
  68848. * Sets the number of samples used to render the buffer (anti aliasing).
  68849. */
  68850. set samples(value: number);
  68851. /**
  68852. * Disposes the renderer and frees up associated resources.
  68853. */
  68854. dispose(): void;
  68855. protected _createRenderTargets(): void;
  68856. private _copyBonesTransformationMatrices;
  68857. }
  68858. }
  68859. declare module BABYLON {
  68860. interface Scene {
  68861. /** @hidden (Backing field) */
  68862. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68863. /**
  68864. * Gets or Sets the current geometry buffer associated to the scene.
  68865. */
  68866. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68867. /**
  68868. * Enables a GeometryBufferRender and associates it with the scene
  68869. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68870. * @returns the GeometryBufferRenderer
  68871. */
  68872. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68873. /**
  68874. * Disables the GeometryBufferRender associated with the scene
  68875. */
  68876. disableGeometryBufferRenderer(): void;
  68877. }
  68878. /**
  68879. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68880. * in several rendering techniques.
  68881. */
  68882. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68883. /**
  68884. * The component name helpful to identify the component in the list of scene components.
  68885. */
  68886. readonly name: string;
  68887. /**
  68888. * The scene the component belongs to.
  68889. */
  68890. scene: Scene;
  68891. /**
  68892. * Creates a new instance of the component for the given scene
  68893. * @param scene Defines the scene to register the component in
  68894. */
  68895. constructor(scene: Scene);
  68896. /**
  68897. * Registers the component in a given scene
  68898. */
  68899. register(): void;
  68900. /**
  68901. * Rebuilds the elements related to this component in case of
  68902. * context lost for instance.
  68903. */
  68904. rebuild(): void;
  68905. /**
  68906. * Disposes the component and the associated ressources
  68907. */
  68908. dispose(): void;
  68909. private _gatherRenderTargets;
  68910. }
  68911. }
  68912. declare module BABYLON {
  68913. /** @hidden */
  68914. export var motionBlurPixelShader: {
  68915. name: string;
  68916. shader: string;
  68917. };
  68918. }
  68919. declare module BABYLON {
  68920. /**
  68921. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68922. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68923. * As an example, all you have to do is to create the post-process:
  68924. * var mb = new BABYLON.MotionBlurPostProcess(
  68925. * 'mb', // The name of the effect.
  68926. * scene, // The scene containing the objects to blur according to their velocity.
  68927. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68928. * camera // The camera to apply the render pass to.
  68929. * );
  68930. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68931. */
  68932. export class MotionBlurPostProcess extends PostProcess {
  68933. /**
  68934. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68935. */
  68936. motionStrength: number;
  68937. /**
  68938. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68939. */
  68940. get motionBlurSamples(): number;
  68941. /**
  68942. * Sets the number of iterations to be used for motion blur quality
  68943. */
  68944. set motionBlurSamples(samples: number);
  68945. private _motionBlurSamples;
  68946. private _geometryBufferRenderer;
  68947. /**
  68948. * Creates a new instance MotionBlurPostProcess
  68949. * @param name The name of the effect.
  68950. * @param scene The scene containing the objects to blur according to their velocity.
  68951. * @param options The required width/height ratio to downsize to before computing the render pass.
  68952. * @param camera The camera to apply the render pass to.
  68953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68954. * @param engine The engine which the post process will be applied. (default: current engine)
  68955. * @param reusable If the post process can be reused on the same frame. (default: false)
  68956. * @param textureType Type of textures used when performing the post process. (default: 0)
  68957. * @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)
  68958. */
  68959. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68960. /**
  68961. * Excludes the given skinned mesh from computing bones velocities.
  68962. * 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.
  68963. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68964. */
  68965. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68966. /**
  68967. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68968. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68969. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68970. */
  68971. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68972. /**
  68973. * Disposes the post process.
  68974. * @param camera The camera to dispose the post process on.
  68975. */
  68976. dispose(camera?: Camera): void;
  68977. }
  68978. }
  68979. declare module BABYLON {
  68980. /** @hidden */
  68981. export var refractionPixelShader: {
  68982. name: string;
  68983. shader: string;
  68984. };
  68985. }
  68986. declare module BABYLON {
  68987. /**
  68988. * Post process which applies a refractin texture
  68989. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68990. */
  68991. export class RefractionPostProcess extends PostProcess {
  68992. /** the base color of the refraction (used to taint the rendering) */
  68993. color: Color3;
  68994. /** simulated refraction depth */
  68995. depth: number;
  68996. /** the coefficient of the base color (0 to remove base color tainting) */
  68997. colorLevel: number;
  68998. private _refTexture;
  68999. private _ownRefractionTexture;
  69000. /**
  69001. * Gets or sets the refraction texture
  69002. * Please note that you are responsible for disposing the texture if you set it manually
  69003. */
  69004. get refractionTexture(): Texture;
  69005. set refractionTexture(value: Texture);
  69006. /**
  69007. * Initializes the RefractionPostProcess
  69008. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69009. * @param name The name of the effect.
  69010. * @param refractionTextureUrl Url of the refraction texture to use
  69011. * @param color the base color of the refraction (used to taint the rendering)
  69012. * @param depth simulated refraction depth
  69013. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69014. * @param camera The camera to apply the render pass to.
  69015. * @param options The required width/height ratio to downsize to before computing the render pass.
  69016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69017. * @param engine The engine which the post process will be applied. (default: current engine)
  69018. * @param reusable If the post process can be reused on the same frame. (default: false)
  69019. */
  69020. constructor(name: string, refractionTextureUrl: string,
  69021. /** the base color of the refraction (used to taint the rendering) */
  69022. color: Color3,
  69023. /** simulated refraction depth */
  69024. depth: number,
  69025. /** the coefficient of the base color (0 to remove base color tainting) */
  69026. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69027. /**
  69028. * Disposes of the post process
  69029. * @param camera Camera to dispose post process on
  69030. */
  69031. dispose(camera: Camera): void;
  69032. }
  69033. }
  69034. declare module BABYLON {
  69035. /** @hidden */
  69036. export var sharpenPixelShader: {
  69037. name: string;
  69038. shader: string;
  69039. };
  69040. }
  69041. declare module BABYLON {
  69042. /**
  69043. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69044. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69045. */
  69046. export class SharpenPostProcess extends PostProcess {
  69047. /**
  69048. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69049. */
  69050. colorAmount: number;
  69051. /**
  69052. * How much sharpness should be applied (default: 0.3)
  69053. */
  69054. edgeAmount: number;
  69055. /**
  69056. * Creates a new instance ConvolutionPostProcess
  69057. * @param name The name of the effect.
  69058. * @param options The required width/height ratio to downsize to before computing the render pass.
  69059. * @param camera The camera to apply the render pass to.
  69060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69061. * @param engine The engine which the post process will be applied. (default: current engine)
  69062. * @param reusable If the post process can be reused on the same frame. (default: false)
  69063. * @param textureType Type of textures used when performing the post process. (default: 0)
  69064. * @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)
  69065. */
  69066. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69067. }
  69068. }
  69069. declare module BABYLON {
  69070. /**
  69071. * PostProcessRenderPipeline
  69072. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69073. */
  69074. export class PostProcessRenderPipeline {
  69075. private engine;
  69076. private _renderEffects;
  69077. private _renderEffectsForIsolatedPass;
  69078. /**
  69079. * List of inspectable custom properties (used by the Inspector)
  69080. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69081. */
  69082. inspectableCustomProperties: IInspectable[];
  69083. /**
  69084. * @hidden
  69085. */
  69086. protected _cameras: Camera[];
  69087. /** @hidden */
  69088. _name: string;
  69089. /**
  69090. * Gets pipeline name
  69091. */
  69092. get name(): string;
  69093. /** Gets the list of attached cameras */
  69094. get cameras(): Camera[];
  69095. /**
  69096. * Initializes a PostProcessRenderPipeline
  69097. * @param engine engine to add the pipeline to
  69098. * @param name name of the pipeline
  69099. */
  69100. constructor(engine: Engine, name: string);
  69101. /**
  69102. * Gets the class name
  69103. * @returns "PostProcessRenderPipeline"
  69104. */
  69105. getClassName(): string;
  69106. /**
  69107. * If all the render effects in the pipeline are supported
  69108. */
  69109. get isSupported(): boolean;
  69110. /**
  69111. * Adds an effect to the pipeline
  69112. * @param renderEffect the effect to add
  69113. */
  69114. addEffect(renderEffect: PostProcessRenderEffect): void;
  69115. /** @hidden */
  69116. _rebuild(): void;
  69117. /** @hidden */
  69118. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69119. /** @hidden */
  69120. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69121. /** @hidden */
  69122. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69123. /** @hidden */
  69124. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69125. /** @hidden */
  69126. _attachCameras(cameras: Camera, unique: boolean): void;
  69127. /** @hidden */
  69128. _attachCameras(cameras: Camera[], unique: boolean): void;
  69129. /** @hidden */
  69130. _detachCameras(cameras: Camera): void;
  69131. /** @hidden */
  69132. _detachCameras(cameras: Nullable<Camera[]>): void;
  69133. /** @hidden */
  69134. _update(): void;
  69135. /** @hidden */
  69136. _reset(): void;
  69137. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69138. /**
  69139. * Disposes of the pipeline
  69140. */
  69141. dispose(): void;
  69142. }
  69143. }
  69144. declare module BABYLON {
  69145. /**
  69146. * PostProcessRenderPipelineManager class
  69147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69148. */
  69149. export class PostProcessRenderPipelineManager {
  69150. private _renderPipelines;
  69151. /**
  69152. * Initializes a PostProcessRenderPipelineManager
  69153. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69154. */
  69155. constructor();
  69156. /**
  69157. * Gets the list of supported render pipelines
  69158. */
  69159. get supportedPipelines(): PostProcessRenderPipeline[];
  69160. /**
  69161. * Adds a pipeline to the manager
  69162. * @param renderPipeline The pipeline to add
  69163. */
  69164. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69165. /**
  69166. * Attaches a camera to the pipeline
  69167. * @param renderPipelineName The name of the pipeline to attach to
  69168. * @param cameras the camera to attach
  69169. * @param unique if the camera can be attached multiple times to the pipeline
  69170. */
  69171. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69172. /**
  69173. * Detaches a camera from the pipeline
  69174. * @param renderPipelineName The name of the pipeline to detach from
  69175. * @param cameras the camera to detach
  69176. */
  69177. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69178. /**
  69179. * Enables an effect by name on a pipeline
  69180. * @param renderPipelineName the name of the pipeline to enable the effect in
  69181. * @param renderEffectName the name of the effect to enable
  69182. * @param cameras the cameras that the effect should be enabled on
  69183. */
  69184. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69185. /**
  69186. * Disables an effect by name on a pipeline
  69187. * @param renderPipelineName the name of the pipeline to disable the effect in
  69188. * @param renderEffectName the name of the effect to disable
  69189. * @param cameras the cameras that the effect should be disabled on
  69190. */
  69191. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69192. /**
  69193. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69194. */
  69195. update(): void;
  69196. /** @hidden */
  69197. _rebuild(): void;
  69198. /**
  69199. * Disposes of the manager and pipelines
  69200. */
  69201. dispose(): void;
  69202. }
  69203. }
  69204. declare module BABYLON {
  69205. interface Scene {
  69206. /** @hidden (Backing field) */
  69207. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69208. /**
  69209. * Gets the postprocess render pipeline manager
  69210. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69211. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69212. */
  69213. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69214. }
  69215. /**
  69216. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69217. */
  69218. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69219. /**
  69220. * The component name helpfull to identify the component in the list of scene components.
  69221. */
  69222. readonly name: string;
  69223. /**
  69224. * The scene the component belongs to.
  69225. */
  69226. scene: Scene;
  69227. /**
  69228. * Creates a new instance of the component for the given scene
  69229. * @param scene Defines the scene to register the component in
  69230. */
  69231. constructor(scene: Scene);
  69232. /**
  69233. * Registers the component in a given scene
  69234. */
  69235. register(): void;
  69236. /**
  69237. * Rebuilds the elements related to this component in case of
  69238. * context lost for instance.
  69239. */
  69240. rebuild(): void;
  69241. /**
  69242. * Disposes the component and the associated ressources
  69243. */
  69244. dispose(): void;
  69245. private _gatherRenderTargets;
  69246. }
  69247. }
  69248. declare module BABYLON {
  69249. /**
  69250. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69251. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69252. */
  69253. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69254. private _scene;
  69255. private _camerasToBeAttached;
  69256. /**
  69257. * ID of the sharpen post process,
  69258. */
  69259. private readonly SharpenPostProcessId;
  69260. /**
  69261. * @ignore
  69262. * ID of the image processing post process;
  69263. */
  69264. readonly ImageProcessingPostProcessId: string;
  69265. /**
  69266. * @ignore
  69267. * ID of the Fast Approximate Anti-Aliasing post process;
  69268. */
  69269. readonly FxaaPostProcessId: string;
  69270. /**
  69271. * ID of the chromatic aberration post process,
  69272. */
  69273. private readonly ChromaticAberrationPostProcessId;
  69274. /**
  69275. * ID of the grain post process
  69276. */
  69277. private readonly GrainPostProcessId;
  69278. /**
  69279. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69280. */
  69281. sharpen: SharpenPostProcess;
  69282. private _sharpenEffect;
  69283. private bloom;
  69284. /**
  69285. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69286. */
  69287. depthOfField: DepthOfFieldEffect;
  69288. /**
  69289. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69290. */
  69291. fxaa: FxaaPostProcess;
  69292. /**
  69293. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69294. */
  69295. imageProcessing: ImageProcessingPostProcess;
  69296. /**
  69297. * Chromatic aberration post process which will shift rgb colors in the image
  69298. */
  69299. chromaticAberration: ChromaticAberrationPostProcess;
  69300. private _chromaticAberrationEffect;
  69301. /**
  69302. * Grain post process which add noise to the image
  69303. */
  69304. grain: GrainPostProcess;
  69305. private _grainEffect;
  69306. /**
  69307. * Glow post process which adds a glow to emissive areas of the image
  69308. */
  69309. private _glowLayer;
  69310. /**
  69311. * Animations which can be used to tweak settings over a period of time
  69312. */
  69313. animations: Animation[];
  69314. private _imageProcessingConfigurationObserver;
  69315. private _sharpenEnabled;
  69316. private _bloomEnabled;
  69317. private _depthOfFieldEnabled;
  69318. private _depthOfFieldBlurLevel;
  69319. private _fxaaEnabled;
  69320. private _imageProcessingEnabled;
  69321. private _defaultPipelineTextureType;
  69322. private _bloomScale;
  69323. private _chromaticAberrationEnabled;
  69324. private _grainEnabled;
  69325. private _buildAllowed;
  69326. /**
  69327. * Gets active scene
  69328. */
  69329. get scene(): Scene;
  69330. /**
  69331. * Enable or disable the sharpen process from the pipeline
  69332. */
  69333. set sharpenEnabled(enabled: boolean);
  69334. get sharpenEnabled(): boolean;
  69335. private _resizeObserver;
  69336. private _hardwareScaleLevel;
  69337. private _bloomKernel;
  69338. /**
  69339. * Specifies the size of the bloom blur kernel, relative to the final output size
  69340. */
  69341. get bloomKernel(): number;
  69342. set bloomKernel(value: number);
  69343. /**
  69344. * Specifies the weight of the bloom in the final rendering
  69345. */
  69346. private _bloomWeight;
  69347. /**
  69348. * Specifies the luma threshold for the area that will be blurred by the bloom
  69349. */
  69350. private _bloomThreshold;
  69351. private _hdr;
  69352. /**
  69353. * The strength of the bloom.
  69354. */
  69355. set bloomWeight(value: number);
  69356. get bloomWeight(): number;
  69357. /**
  69358. * The strength of the bloom.
  69359. */
  69360. set bloomThreshold(value: number);
  69361. get bloomThreshold(): number;
  69362. /**
  69363. * The scale of the bloom, lower value will provide better performance.
  69364. */
  69365. set bloomScale(value: number);
  69366. get bloomScale(): number;
  69367. /**
  69368. * Enable or disable the bloom from the pipeline
  69369. */
  69370. set bloomEnabled(enabled: boolean);
  69371. get bloomEnabled(): boolean;
  69372. private _rebuildBloom;
  69373. /**
  69374. * If the depth of field is enabled.
  69375. */
  69376. get depthOfFieldEnabled(): boolean;
  69377. set depthOfFieldEnabled(enabled: boolean);
  69378. /**
  69379. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69380. */
  69381. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69382. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69383. /**
  69384. * If the anti aliasing is enabled.
  69385. */
  69386. set fxaaEnabled(enabled: boolean);
  69387. get fxaaEnabled(): boolean;
  69388. private _samples;
  69389. /**
  69390. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69391. */
  69392. set samples(sampleCount: number);
  69393. get samples(): number;
  69394. /**
  69395. * If image processing is enabled.
  69396. */
  69397. set imageProcessingEnabled(enabled: boolean);
  69398. get imageProcessingEnabled(): boolean;
  69399. /**
  69400. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69401. */
  69402. set glowLayerEnabled(enabled: boolean);
  69403. get glowLayerEnabled(): boolean;
  69404. /**
  69405. * Gets the glow layer (or null if not defined)
  69406. */
  69407. get glowLayer(): Nullable<GlowLayer>;
  69408. /**
  69409. * Enable or disable the chromaticAberration process from the pipeline
  69410. */
  69411. set chromaticAberrationEnabled(enabled: boolean);
  69412. get chromaticAberrationEnabled(): boolean;
  69413. /**
  69414. * Enable or disable the grain process from the pipeline
  69415. */
  69416. set grainEnabled(enabled: boolean);
  69417. get grainEnabled(): boolean;
  69418. /**
  69419. * @constructor
  69420. * @param name - The rendering pipeline name (default: "")
  69421. * @param hdr - If high dynamic range textures should be used (default: true)
  69422. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69423. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69424. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69425. */
  69426. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69427. /**
  69428. * Get the class name
  69429. * @returns "DefaultRenderingPipeline"
  69430. */
  69431. getClassName(): string;
  69432. /**
  69433. * Force the compilation of the entire pipeline.
  69434. */
  69435. prepare(): void;
  69436. private _hasCleared;
  69437. private _prevPostProcess;
  69438. private _prevPrevPostProcess;
  69439. private _setAutoClearAndTextureSharing;
  69440. private _depthOfFieldSceneObserver;
  69441. private _buildPipeline;
  69442. private _disposePostProcesses;
  69443. /**
  69444. * Adds a camera to the pipeline
  69445. * @param camera the camera to be added
  69446. */
  69447. addCamera(camera: Camera): void;
  69448. /**
  69449. * Removes a camera from the pipeline
  69450. * @param camera the camera to remove
  69451. */
  69452. removeCamera(camera: Camera): void;
  69453. /**
  69454. * Dispose of the pipeline and stop all post processes
  69455. */
  69456. dispose(): void;
  69457. /**
  69458. * Serialize the rendering pipeline (Used when exporting)
  69459. * @returns the serialized object
  69460. */
  69461. serialize(): any;
  69462. /**
  69463. * Parse the serialized pipeline
  69464. * @param source Source pipeline.
  69465. * @param scene The scene to load the pipeline to.
  69466. * @param rootUrl The URL of the serialized pipeline.
  69467. * @returns An instantiated pipeline from the serialized object.
  69468. */
  69469. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69470. }
  69471. }
  69472. declare module BABYLON {
  69473. /** @hidden */
  69474. export var lensHighlightsPixelShader: {
  69475. name: string;
  69476. shader: string;
  69477. };
  69478. }
  69479. declare module BABYLON {
  69480. /** @hidden */
  69481. export var depthOfFieldPixelShader: {
  69482. name: string;
  69483. shader: string;
  69484. };
  69485. }
  69486. declare module BABYLON {
  69487. /**
  69488. * BABYLON.JS Chromatic Aberration GLSL Shader
  69489. * Author: Olivier Guyot
  69490. * Separates very slightly R, G and B colors on the edges of the screen
  69491. * Inspired by Francois Tarlier & Martins Upitis
  69492. */
  69493. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69494. /**
  69495. * @ignore
  69496. * The chromatic aberration PostProcess id in the pipeline
  69497. */
  69498. LensChromaticAberrationEffect: string;
  69499. /**
  69500. * @ignore
  69501. * The highlights enhancing PostProcess id in the pipeline
  69502. */
  69503. HighlightsEnhancingEffect: string;
  69504. /**
  69505. * @ignore
  69506. * The depth-of-field PostProcess id in the pipeline
  69507. */
  69508. LensDepthOfFieldEffect: string;
  69509. private _scene;
  69510. private _depthTexture;
  69511. private _grainTexture;
  69512. private _chromaticAberrationPostProcess;
  69513. private _highlightsPostProcess;
  69514. private _depthOfFieldPostProcess;
  69515. private _edgeBlur;
  69516. private _grainAmount;
  69517. private _chromaticAberration;
  69518. private _distortion;
  69519. private _highlightsGain;
  69520. private _highlightsThreshold;
  69521. private _dofDistance;
  69522. private _dofAperture;
  69523. private _dofDarken;
  69524. private _dofPentagon;
  69525. private _blurNoise;
  69526. /**
  69527. * @constructor
  69528. *
  69529. * Effect parameters are as follow:
  69530. * {
  69531. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69532. * edge_blur: number; // from 0 to x (1 for realism)
  69533. * distortion: number; // from 0 to x (1 for realism)
  69534. * grain_amount: number; // from 0 to 1
  69535. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69536. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69537. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69538. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69539. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69540. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69541. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69542. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69543. * }
  69544. * Note: if an effect parameter is unset, effect is disabled
  69545. *
  69546. * @param name The rendering pipeline name
  69547. * @param parameters - An object containing all parameters (see above)
  69548. * @param scene The scene linked to this pipeline
  69549. * @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)
  69550. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69551. */
  69552. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69553. /**
  69554. * Get the class name
  69555. * @returns "LensRenderingPipeline"
  69556. */
  69557. getClassName(): string;
  69558. /**
  69559. * Gets associated scene
  69560. */
  69561. get scene(): Scene;
  69562. /**
  69563. * Gets or sets the edge blur
  69564. */
  69565. get edgeBlur(): number;
  69566. set edgeBlur(value: number);
  69567. /**
  69568. * Gets or sets the grain amount
  69569. */
  69570. get grainAmount(): number;
  69571. set grainAmount(value: number);
  69572. /**
  69573. * Gets or sets the chromatic aberration amount
  69574. */
  69575. get chromaticAberration(): number;
  69576. set chromaticAberration(value: number);
  69577. /**
  69578. * Gets or sets the depth of field aperture
  69579. */
  69580. get dofAperture(): number;
  69581. set dofAperture(value: number);
  69582. /**
  69583. * Gets or sets the edge distortion
  69584. */
  69585. get edgeDistortion(): number;
  69586. set edgeDistortion(value: number);
  69587. /**
  69588. * Gets or sets the depth of field distortion
  69589. */
  69590. get dofDistortion(): number;
  69591. set dofDistortion(value: number);
  69592. /**
  69593. * Gets or sets the darken out of focus amount
  69594. */
  69595. get darkenOutOfFocus(): number;
  69596. set darkenOutOfFocus(value: number);
  69597. /**
  69598. * Gets or sets a boolean indicating if blur noise is enabled
  69599. */
  69600. get blurNoise(): boolean;
  69601. set blurNoise(value: boolean);
  69602. /**
  69603. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69604. */
  69605. get pentagonBokeh(): boolean;
  69606. set pentagonBokeh(value: boolean);
  69607. /**
  69608. * Gets or sets the highlight grain amount
  69609. */
  69610. get highlightsGain(): number;
  69611. set highlightsGain(value: number);
  69612. /**
  69613. * Gets or sets the highlight threshold
  69614. */
  69615. get highlightsThreshold(): number;
  69616. set highlightsThreshold(value: number);
  69617. /**
  69618. * Sets the amount of blur at the edges
  69619. * @param amount blur amount
  69620. */
  69621. setEdgeBlur(amount: number): void;
  69622. /**
  69623. * Sets edge blur to 0
  69624. */
  69625. disableEdgeBlur(): void;
  69626. /**
  69627. * Sets the amout of grain
  69628. * @param amount Amount of grain
  69629. */
  69630. setGrainAmount(amount: number): void;
  69631. /**
  69632. * Set grain amount to 0
  69633. */
  69634. disableGrain(): void;
  69635. /**
  69636. * Sets the chromatic aberration amount
  69637. * @param amount amount of chromatic aberration
  69638. */
  69639. setChromaticAberration(amount: number): void;
  69640. /**
  69641. * Sets chromatic aberration amount to 0
  69642. */
  69643. disableChromaticAberration(): void;
  69644. /**
  69645. * Sets the EdgeDistortion amount
  69646. * @param amount amount of EdgeDistortion
  69647. */
  69648. setEdgeDistortion(amount: number): void;
  69649. /**
  69650. * Sets edge distortion to 0
  69651. */
  69652. disableEdgeDistortion(): void;
  69653. /**
  69654. * Sets the FocusDistance amount
  69655. * @param amount amount of FocusDistance
  69656. */
  69657. setFocusDistance(amount: number): void;
  69658. /**
  69659. * Disables depth of field
  69660. */
  69661. disableDepthOfField(): void;
  69662. /**
  69663. * Sets the Aperture amount
  69664. * @param amount amount of Aperture
  69665. */
  69666. setAperture(amount: number): void;
  69667. /**
  69668. * Sets the DarkenOutOfFocus amount
  69669. * @param amount amount of DarkenOutOfFocus
  69670. */
  69671. setDarkenOutOfFocus(amount: number): void;
  69672. private _pentagonBokehIsEnabled;
  69673. /**
  69674. * Creates a pentagon bokeh effect
  69675. */
  69676. enablePentagonBokeh(): void;
  69677. /**
  69678. * Disables the pentagon bokeh effect
  69679. */
  69680. disablePentagonBokeh(): void;
  69681. /**
  69682. * Enables noise blur
  69683. */
  69684. enableNoiseBlur(): void;
  69685. /**
  69686. * Disables noise blur
  69687. */
  69688. disableNoiseBlur(): void;
  69689. /**
  69690. * Sets the HighlightsGain amount
  69691. * @param amount amount of HighlightsGain
  69692. */
  69693. setHighlightsGain(amount: number): void;
  69694. /**
  69695. * Sets the HighlightsThreshold amount
  69696. * @param amount amount of HighlightsThreshold
  69697. */
  69698. setHighlightsThreshold(amount: number): void;
  69699. /**
  69700. * Disables highlights
  69701. */
  69702. disableHighlights(): void;
  69703. /**
  69704. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69705. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69706. */
  69707. dispose(disableDepthRender?: boolean): void;
  69708. private _createChromaticAberrationPostProcess;
  69709. private _createHighlightsPostProcess;
  69710. private _createDepthOfFieldPostProcess;
  69711. private _createGrainTexture;
  69712. }
  69713. }
  69714. declare module BABYLON {
  69715. /** @hidden */
  69716. export var fibonacci: {
  69717. name: string;
  69718. shader: string;
  69719. };
  69720. }
  69721. declare module BABYLON {
  69722. /** @hidden */
  69723. export var diffusionProfile: {
  69724. name: string;
  69725. shader: string;
  69726. };
  69727. }
  69728. declare module BABYLON {
  69729. /** @hidden */
  69730. export var subSurfaceScatteringPixelShader: {
  69731. name: string;
  69732. shader: string;
  69733. };
  69734. }
  69735. declare module BABYLON {
  69736. /**
  69737. * Sub surface scattering post process
  69738. */
  69739. export class SubSurfaceScatteringPostProcess extends PostProcess {
  69740. /** @hidden */
  69741. texelWidth: number;
  69742. /** @hidden */
  69743. texelHeight: number;
  69744. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69745. }
  69746. }
  69747. declare module BABYLON {
  69748. /**
  69749. * Interface for defining prepass effects in the prepass post-process pipeline
  69750. */
  69751. export interface PrePassEffectConfiguration {
  69752. /**
  69753. * Post process to attach for this effect
  69754. */
  69755. postProcess: PostProcess;
  69756. /**
  69757. * Is the effect enabled
  69758. */
  69759. enabled: boolean;
  69760. /**
  69761. * Disposes the effect configuration
  69762. */
  69763. dispose(): void;
  69764. /**
  69765. * Disposes the effect configuration
  69766. */
  69767. createPostProcess: () => PostProcess;
  69768. }
  69769. }
  69770. declare module BABYLON {
  69771. /**
  69772. * Contains all parameters needed for the prepass to perform
  69773. * screen space subsurface scattering
  69774. */
  69775. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  69776. private _ssDiffusionS;
  69777. private _ssFilterRadii;
  69778. private _ssDiffusionD;
  69779. /**
  69780. * Post process to attach for screen space subsurface scattering
  69781. */
  69782. postProcess: SubSurfaceScatteringPostProcess;
  69783. /**
  69784. * Diffusion profile color for subsurface scattering
  69785. */
  69786. get ssDiffusionS(): number[];
  69787. /**
  69788. * Diffusion profile max color channel value for subsurface scattering
  69789. */
  69790. get ssDiffusionD(): number[];
  69791. /**
  69792. * Diffusion profile filter radius for subsurface scattering
  69793. */
  69794. get ssFilterRadii(): number[];
  69795. /**
  69796. * Is subsurface enabled
  69797. */
  69798. enabled: boolean;
  69799. /**
  69800. * Diffusion profile colors for subsurface scattering
  69801. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  69802. * See ...
  69803. * Note that you can only store up to 5 of them
  69804. */
  69805. ssDiffusionProfileColors: Color3[];
  69806. /**
  69807. * Defines the ratio real world => scene units.
  69808. * Used for subsurface scattering
  69809. */
  69810. metersPerUnit: number;
  69811. private _scene;
  69812. /**
  69813. * Builds a subsurface configuration object
  69814. * @param scene The scene
  69815. */
  69816. constructor(scene: Scene);
  69817. /**
  69818. * Adds a new diffusion profile.
  69819. * Useful for more realistic subsurface scattering on diverse materials.
  69820. * @param color The color of the diffusion profile. Should be the average color of the material.
  69821. * @return The index of the diffusion profile for the material subsurface configuration
  69822. */
  69823. addDiffusionProfile(color: Color3): number;
  69824. /**
  69825. * Creates the sss post process
  69826. * @return The created post process
  69827. */
  69828. createPostProcess(): SubSurfaceScatteringPostProcess;
  69829. /**
  69830. * Deletes all diffusion profiles.
  69831. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  69832. */
  69833. clearAllDiffusionProfiles(): void;
  69834. /**
  69835. * Disposes this object
  69836. */
  69837. dispose(): void;
  69838. /**
  69839. * @hidden
  69840. * https://zero-radiance.github.io/post/sampling-diffusion/
  69841. *
  69842. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  69843. * ------------------------------------------------------------------------------------
  69844. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  69845. * PDF[r, phi, s] = r * R[r, phi, s]
  69846. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  69847. * ------------------------------------------------------------------------------------
  69848. * We importance sample the color channel with the widest scattering distance.
  69849. */
  69850. getDiffusionProfileParameters(color: Color3): number;
  69851. /**
  69852. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  69853. * 'u' is the random number (the value of the CDF): [0, 1).
  69854. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  69855. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  69856. */
  69857. private _sampleBurleyDiffusionProfile;
  69858. }
  69859. }
  69860. declare module BABYLON {
  69861. /**
  69862. * Renders a pre pass of the scene
  69863. * This means every mesh in the scene will be rendered to a render target texture
  69864. * And then this texture will be composited to the rendering canvas with post processes
  69865. * It is necessary for effects like subsurface scattering or deferred shading
  69866. */
  69867. export class PrePassRenderer {
  69868. /** @hidden */
  69869. static _SceneComponentInitialization: (scene: Scene) => void;
  69870. private _scene;
  69871. private _engine;
  69872. private _isDirty;
  69873. /**
  69874. * Number of textures in the multi render target texture where the scene is directly rendered
  69875. */
  69876. readonly mrtCount: number;
  69877. /**
  69878. * The render target where the scene is directly rendered
  69879. */
  69880. prePassRT: MultiRenderTarget;
  69881. private _mrtTypes;
  69882. private _multiRenderAttachments;
  69883. private _defaultAttachments;
  69884. private _clearAttachments;
  69885. private _postProcesses;
  69886. private readonly _clearColor;
  69887. /**
  69888. * Image processing post process for composition
  69889. */
  69890. imageProcessingPostProcess: ImageProcessingPostProcess;
  69891. /**
  69892. * Configuration for sub surface scattering post process
  69893. */
  69894. subSurfaceConfiguration: SubSurfaceConfiguration;
  69895. /**
  69896. * Should materials render their geometry on the MRT
  69897. */
  69898. materialsShouldRenderGeometry: boolean;
  69899. /**
  69900. * Should materials render the irradiance information on the MRT
  69901. */
  69902. materialsShouldRenderIrradiance: boolean;
  69903. private _enabled;
  69904. /**
  69905. * Indicates if the prepass is enabled
  69906. */
  69907. get enabled(): boolean;
  69908. /**
  69909. * How many samples are used for MSAA of the scene render target
  69910. */
  69911. get samples(): number;
  69912. set samples(n: number);
  69913. /**
  69914. * Instanciates a prepass renderer
  69915. * @param scene The scene
  69916. */
  69917. constructor(scene: Scene);
  69918. private _initializeAttachments;
  69919. private _createCompositionEffect;
  69920. /**
  69921. * Indicates if rendering a prepass is supported
  69922. */
  69923. get isSupported(): boolean;
  69924. /**
  69925. * Sets the proper output textures to draw in the engine.
  69926. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  69927. */
  69928. bindAttachmentsForEffect(effect: Effect): void;
  69929. /**
  69930. * @hidden
  69931. */
  69932. _beforeCameraDraw(): void;
  69933. /**
  69934. * @hidden
  69935. */
  69936. _afterCameraDraw(): void;
  69937. private _checkRTSize;
  69938. private _bindFrameBuffer;
  69939. /**
  69940. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  69941. */
  69942. clear(): void;
  69943. private _setState;
  69944. private _enable;
  69945. private _disable;
  69946. private _resetPostProcessChain;
  69947. private _bindPostProcessChain;
  69948. /**
  69949. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  69950. */
  69951. markAsDirty(): void;
  69952. private _update;
  69953. /**
  69954. * Disposes the prepass renderer.
  69955. */
  69956. dispose(): void;
  69957. }
  69958. }
  69959. declare module BABYLON {
  69960. /** @hidden */
  69961. export var ssao2PixelShader: {
  69962. name: string;
  69963. shader: string;
  69964. };
  69965. }
  69966. declare module BABYLON {
  69967. /** @hidden */
  69968. export var ssaoCombinePixelShader: {
  69969. name: string;
  69970. shader: string;
  69971. };
  69972. }
  69973. declare module BABYLON {
  69974. /**
  69975. * Render pipeline to produce ssao effect
  69976. */
  69977. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69978. /**
  69979. * @ignore
  69980. * The PassPostProcess id in the pipeline that contains the original scene color
  69981. */
  69982. SSAOOriginalSceneColorEffect: string;
  69983. /**
  69984. * @ignore
  69985. * The SSAO PostProcess id in the pipeline
  69986. */
  69987. SSAORenderEffect: string;
  69988. /**
  69989. * @ignore
  69990. * The horizontal blur PostProcess id in the pipeline
  69991. */
  69992. SSAOBlurHRenderEffect: string;
  69993. /**
  69994. * @ignore
  69995. * The vertical blur PostProcess id in the pipeline
  69996. */
  69997. SSAOBlurVRenderEffect: string;
  69998. /**
  69999. * @ignore
  70000. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70001. */
  70002. SSAOCombineRenderEffect: string;
  70003. /**
  70004. * The output strength of the SSAO post-process. Default value is 1.0.
  70005. */
  70006. totalStrength: number;
  70007. /**
  70008. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70009. */
  70010. maxZ: number;
  70011. /**
  70012. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70013. */
  70014. minZAspect: number;
  70015. private _samples;
  70016. /**
  70017. * Number of samples used for the SSAO calculations. Default value is 8
  70018. */
  70019. set samples(n: number);
  70020. get samples(): number;
  70021. private _textureSamples;
  70022. /**
  70023. * Number of samples to use for antialiasing
  70024. */
  70025. set textureSamples(n: number);
  70026. get textureSamples(): number;
  70027. /**
  70028. * Force rendering the geometry through geometry buffer
  70029. */
  70030. private _forceGeometryBuffer;
  70031. /**
  70032. * Ratio object used for SSAO ratio and blur ratio
  70033. */
  70034. private _ratio;
  70035. /**
  70036. * Dynamically generated sphere sampler.
  70037. */
  70038. private _sampleSphere;
  70039. /**
  70040. * Blur filter offsets
  70041. */
  70042. private _samplerOffsets;
  70043. private _expensiveBlur;
  70044. /**
  70045. * If bilateral blur should be used
  70046. */
  70047. set expensiveBlur(b: boolean);
  70048. get expensiveBlur(): boolean;
  70049. /**
  70050. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70051. */
  70052. radius: number;
  70053. /**
  70054. * The base color of the SSAO post-process
  70055. * The final result is "base + ssao" between [0, 1]
  70056. */
  70057. base: number;
  70058. /**
  70059. * Support test.
  70060. */
  70061. static get IsSupported(): boolean;
  70062. private _scene;
  70063. private _randomTexture;
  70064. private _originalColorPostProcess;
  70065. private _ssaoPostProcess;
  70066. private _blurHPostProcess;
  70067. private _blurVPostProcess;
  70068. private _ssaoCombinePostProcess;
  70069. private _prePassRenderer;
  70070. /**
  70071. * Gets active scene
  70072. */
  70073. get scene(): Scene;
  70074. /**
  70075. * @constructor
  70076. * @param name The rendering pipeline name
  70077. * @param scene The scene linked to this pipeline
  70078. * @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 }
  70079. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70080. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70081. */
  70082. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70083. /**
  70084. * Get the class name
  70085. * @returns "SSAO2RenderingPipeline"
  70086. */
  70087. getClassName(): string;
  70088. /**
  70089. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70090. */
  70091. dispose(disableGeometryBufferRenderer?: boolean): void;
  70092. private _createBlurPostProcess;
  70093. /** @hidden */
  70094. _rebuild(): void;
  70095. private _bits;
  70096. private _radicalInverse_VdC;
  70097. private _hammersley;
  70098. private _hemisphereSample_uniform;
  70099. private _generateHemisphere;
  70100. private _getDefinesForSSAO;
  70101. private _createSSAOPostProcess;
  70102. private _createSSAOCombinePostProcess;
  70103. private _createRandomTexture;
  70104. /**
  70105. * Serialize the rendering pipeline (Used when exporting)
  70106. * @returns the serialized object
  70107. */
  70108. serialize(): any;
  70109. /**
  70110. * Parse the serialized pipeline
  70111. * @param source Source pipeline.
  70112. * @param scene The scene to load the pipeline to.
  70113. * @param rootUrl The URL of the serialized pipeline.
  70114. * @returns An instantiated pipeline from the serialized object.
  70115. */
  70116. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70117. }
  70118. }
  70119. declare module BABYLON {
  70120. /** @hidden */
  70121. export var ssaoPixelShader: {
  70122. name: string;
  70123. shader: string;
  70124. };
  70125. }
  70126. declare module BABYLON {
  70127. /**
  70128. * Render pipeline to produce ssao effect
  70129. */
  70130. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70131. /**
  70132. * @ignore
  70133. * The PassPostProcess id in the pipeline that contains the original scene color
  70134. */
  70135. SSAOOriginalSceneColorEffect: string;
  70136. /**
  70137. * @ignore
  70138. * The SSAO PostProcess id in the pipeline
  70139. */
  70140. SSAORenderEffect: string;
  70141. /**
  70142. * @ignore
  70143. * The horizontal blur PostProcess id in the pipeline
  70144. */
  70145. SSAOBlurHRenderEffect: string;
  70146. /**
  70147. * @ignore
  70148. * The vertical blur PostProcess id in the pipeline
  70149. */
  70150. SSAOBlurVRenderEffect: string;
  70151. /**
  70152. * @ignore
  70153. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70154. */
  70155. SSAOCombineRenderEffect: string;
  70156. /**
  70157. * The output strength of the SSAO post-process. Default value is 1.0.
  70158. */
  70159. totalStrength: number;
  70160. /**
  70161. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70162. */
  70163. radius: number;
  70164. /**
  70165. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70166. * Must not be equal to fallOff and superior to fallOff.
  70167. * Default value is 0.0075
  70168. */
  70169. area: number;
  70170. /**
  70171. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70172. * Must not be equal to area and inferior to area.
  70173. * Default value is 0.000001
  70174. */
  70175. fallOff: number;
  70176. /**
  70177. * The base color of the SSAO post-process
  70178. * The final result is "base + ssao" between [0, 1]
  70179. */
  70180. base: number;
  70181. private _scene;
  70182. private _depthTexture;
  70183. private _randomTexture;
  70184. private _originalColorPostProcess;
  70185. private _ssaoPostProcess;
  70186. private _blurHPostProcess;
  70187. private _blurVPostProcess;
  70188. private _ssaoCombinePostProcess;
  70189. private _firstUpdate;
  70190. /**
  70191. * Gets active scene
  70192. */
  70193. get scene(): Scene;
  70194. /**
  70195. * @constructor
  70196. * @param name - The rendering pipeline name
  70197. * @param scene - The scene linked to this pipeline
  70198. * @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 }
  70199. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70200. */
  70201. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70202. /**
  70203. * Get the class name
  70204. * @returns "SSAORenderingPipeline"
  70205. */
  70206. getClassName(): string;
  70207. /**
  70208. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70209. */
  70210. dispose(disableDepthRender?: boolean): void;
  70211. private _createBlurPostProcess;
  70212. /** @hidden */
  70213. _rebuild(): void;
  70214. private _createSSAOPostProcess;
  70215. private _createSSAOCombinePostProcess;
  70216. private _createRandomTexture;
  70217. }
  70218. }
  70219. declare module BABYLON {
  70220. /** @hidden */
  70221. export var screenSpaceReflectionPixelShader: {
  70222. name: string;
  70223. shader: string;
  70224. };
  70225. }
  70226. declare module BABYLON {
  70227. /**
  70228. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70229. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70230. */
  70231. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70232. /**
  70233. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70234. */
  70235. threshold: number;
  70236. /**
  70237. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70238. */
  70239. strength: number;
  70240. /**
  70241. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70242. */
  70243. reflectionSpecularFalloffExponent: number;
  70244. /**
  70245. * 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]
  70246. */
  70247. step: number;
  70248. /**
  70249. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70250. */
  70251. roughnessFactor: number;
  70252. private _geometryBufferRenderer;
  70253. private _enableSmoothReflections;
  70254. private _reflectionSamples;
  70255. private _smoothSteps;
  70256. /**
  70257. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70258. * @param name The name of the effect.
  70259. * @param scene The scene containing the objects to calculate reflections.
  70260. * @param options The required width/height ratio to downsize to before computing the render pass.
  70261. * @param camera The camera to apply the render pass to.
  70262. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70263. * @param engine The engine which the post process will be applied. (default: current engine)
  70264. * @param reusable If the post process can be reused on the same frame. (default: false)
  70265. * @param textureType Type of textures used when performing the post process. (default: 0)
  70266. * @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)
  70267. */
  70268. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70269. /**
  70270. * Gets wether or not smoothing reflections is enabled.
  70271. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70272. */
  70273. get enableSmoothReflections(): boolean;
  70274. /**
  70275. * Sets wether or not smoothing reflections is enabled.
  70276. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70277. */
  70278. set enableSmoothReflections(enabled: boolean);
  70279. /**
  70280. * Gets the number of samples taken while computing reflections. More samples count is high,
  70281. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70282. */
  70283. get reflectionSamples(): number;
  70284. /**
  70285. * Sets the number of samples taken while computing reflections. More samples count is high,
  70286. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70287. */
  70288. set reflectionSamples(samples: number);
  70289. /**
  70290. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70291. * more the post-process will require GPU power and can generate a drop in FPS.
  70292. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70293. */
  70294. get smoothSteps(): number;
  70295. set smoothSteps(steps: number);
  70296. private _updateEffectDefines;
  70297. }
  70298. }
  70299. declare module BABYLON {
  70300. /** @hidden */
  70301. export var standardPixelShader: {
  70302. name: string;
  70303. shader: string;
  70304. };
  70305. }
  70306. declare module BABYLON {
  70307. /**
  70308. * Standard rendering pipeline
  70309. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70310. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70311. */
  70312. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70313. /**
  70314. * Public members
  70315. */
  70316. /**
  70317. * Post-process which contains the original scene color before the pipeline applies all the effects
  70318. */
  70319. originalPostProcess: Nullable<PostProcess>;
  70320. /**
  70321. * Post-process used to down scale an image x4
  70322. */
  70323. downSampleX4PostProcess: Nullable<PostProcess>;
  70324. /**
  70325. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70326. */
  70327. brightPassPostProcess: Nullable<PostProcess>;
  70328. /**
  70329. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70330. */
  70331. blurHPostProcesses: PostProcess[];
  70332. /**
  70333. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70334. */
  70335. blurVPostProcesses: PostProcess[];
  70336. /**
  70337. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70338. */
  70339. textureAdderPostProcess: Nullable<PostProcess>;
  70340. /**
  70341. * Post-process used to create volumetric lighting effect
  70342. */
  70343. volumetricLightPostProcess: Nullable<PostProcess>;
  70344. /**
  70345. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70346. */
  70347. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70348. /**
  70349. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70350. */
  70351. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70352. /**
  70353. * Post-process used to merge the volumetric light effect and the real scene color
  70354. */
  70355. volumetricLightMergePostProces: Nullable<PostProcess>;
  70356. /**
  70357. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70358. */
  70359. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70360. /**
  70361. * Base post-process used to calculate the average luminance of the final image for HDR
  70362. */
  70363. luminancePostProcess: Nullable<PostProcess>;
  70364. /**
  70365. * Post-processes used to create down sample post-processes in order to get
  70366. * the average luminance of the final image for HDR
  70367. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70368. */
  70369. luminanceDownSamplePostProcesses: PostProcess[];
  70370. /**
  70371. * Post-process used to create a HDR effect (light adaptation)
  70372. */
  70373. hdrPostProcess: Nullable<PostProcess>;
  70374. /**
  70375. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70376. */
  70377. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70378. /**
  70379. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70380. */
  70381. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70382. /**
  70383. * Post-process used to merge the final HDR post-process and the real scene color
  70384. */
  70385. hdrFinalPostProcess: Nullable<PostProcess>;
  70386. /**
  70387. * Post-process used to create a lens flare effect
  70388. */
  70389. lensFlarePostProcess: Nullable<PostProcess>;
  70390. /**
  70391. * Post-process that merges the result of the lens flare post-process and the real scene color
  70392. */
  70393. lensFlareComposePostProcess: Nullable<PostProcess>;
  70394. /**
  70395. * Post-process used to create a motion blur effect
  70396. */
  70397. motionBlurPostProcess: Nullable<PostProcess>;
  70398. /**
  70399. * Post-process used to create a depth of field effect
  70400. */
  70401. depthOfFieldPostProcess: Nullable<PostProcess>;
  70402. /**
  70403. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70404. */
  70405. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70406. /**
  70407. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70408. */
  70409. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70410. /**
  70411. * Represents the brightness threshold in order to configure the illuminated surfaces
  70412. */
  70413. brightThreshold: number;
  70414. /**
  70415. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70416. */
  70417. blurWidth: number;
  70418. /**
  70419. * Sets if the blur for highlighted surfaces must be only horizontal
  70420. */
  70421. horizontalBlur: boolean;
  70422. /**
  70423. * Gets the overall exposure used by the pipeline
  70424. */
  70425. get exposure(): number;
  70426. /**
  70427. * Sets the overall exposure used by the pipeline
  70428. */
  70429. set exposure(value: number);
  70430. /**
  70431. * Texture used typically to simulate "dirty" on camera lens
  70432. */
  70433. lensTexture: Nullable<Texture>;
  70434. /**
  70435. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70436. */
  70437. volumetricLightCoefficient: number;
  70438. /**
  70439. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70440. */
  70441. volumetricLightPower: number;
  70442. /**
  70443. * Used the set the blur intensity to smooth the volumetric lights
  70444. */
  70445. volumetricLightBlurScale: number;
  70446. /**
  70447. * Light (spot or directional) used to generate the volumetric lights rays
  70448. * The source light must have a shadow generate so the pipeline can get its
  70449. * depth map
  70450. */
  70451. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70452. /**
  70453. * For eye adaptation, represents the minimum luminance the eye can see
  70454. */
  70455. hdrMinimumLuminance: number;
  70456. /**
  70457. * For eye adaptation, represents the decrease luminance speed
  70458. */
  70459. hdrDecreaseRate: number;
  70460. /**
  70461. * For eye adaptation, represents the increase luminance speed
  70462. */
  70463. hdrIncreaseRate: number;
  70464. /**
  70465. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70466. */
  70467. get hdrAutoExposure(): boolean;
  70468. /**
  70469. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70470. */
  70471. set hdrAutoExposure(value: boolean);
  70472. /**
  70473. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70474. */
  70475. lensColorTexture: Nullable<Texture>;
  70476. /**
  70477. * The overall strengh for the lens flare effect
  70478. */
  70479. lensFlareStrength: number;
  70480. /**
  70481. * Dispersion coefficient for lens flare ghosts
  70482. */
  70483. lensFlareGhostDispersal: number;
  70484. /**
  70485. * Main lens flare halo width
  70486. */
  70487. lensFlareHaloWidth: number;
  70488. /**
  70489. * Based on the lens distortion effect, defines how much the lens flare result
  70490. * is distorted
  70491. */
  70492. lensFlareDistortionStrength: number;
  70493. /**
  70494. * Configures the blur intensity used for for lens flare (halo)
  70495. */
  70496. lensFlareBlurWidth: number;
  70497. /**
  70498. * Lens star texture must be used to simulate rays on the flares and is available
  70499. * in the documentation
  70500. */
  70501. lensStarTexture: Nullable<Texture>;
  70502. /**
  70503. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70504. * flare effect by taking account of the dirt texture
  70505. */
  70506. lensFlareDirtTexture: Nullable<Texture>;
  70507. /**
  70508. * Represents the focal length for the depth of field effect
  70509. */
  70510. depthOfFieldDistance: number;
  70511. /**
  70512. * Represents the blur intensity for the blurred part of the depth of field effect
  70513. */
  70514. depthOfFieldBlurWidth: number;
  70515. /**
  70516. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70517. */
  70518. get motionStrength(): number;
  70519. /**
  70520. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70521. */
  70522. set motionStrength(strength: number);
  70523. /**
  70524. * Gets wether or not the motion blur post-process is object based or screen based.
  70525. */
  70526. get objectBasedMotionBlur(): boolean;
  70527. /**
  70528. * Sets wether or not the motion blur post-process should be object based or screen based
  70529. */
  70530. set objectBasedMotionBlur(value: boolean);
  70531. /**
  70532. * List of animations for the pipeline (IAnimatable implementation)
  70533. */
  70534. animations: Animation[];
  70535. /**
  70536. * Private members
  70537. */
  70538. private _scene;
  70539. private _currentDepthOfFieldSource;
  70540. private _basePostProcess;
  70541. private _fixedExposure;
  70542. private _currentExposure;
  70543. private _hdrAutoExposure;
  70544. private _hdrCurrentLuminance;
  70545. private _motionStrength;
  70546. private _isObjectBasedMotionBlur;
  70547. private _floatTextureType;
  70548. private _camerasToBeAttached;
  70549. private _ratio;
  70550. private _bloomEnabled;
  70551. private _depthOfFieldEnabled;
  70552. private _vlsEnabled;
  70553. private _lensFlareEnabled;
  70554. private _hdrEnabled;
  70555. private _motionBlurEnabled;
  70556. private _fxaaEnabled;
  70557. private _screenSpaceReflectionsEnabled;
  70558. private _motionBlurSamples;
  70559. private _volumetricLightStepsCount;
  70560. private _samples;
  70561. /**
  70562. * @ignore
  70563. * Specifies if the bloom pipeline is enabled
  70564. */
  70565. get BloomEnabled(): boolean;
  70566. set BloomEnabled(enabled: boolean);
  70567. /**
  70568. * @ignore
  70569. * Specifies if the depth of field pipeline is enabed
  70570. */
  70571. get DepthOfFieldEnabled(): boolean;
  70572. set DepthOfFieldEnabled(enabled: boolean);
  70573. /**
  70574. * @ignore
  70575. * Specifies if the lens flare pipeline is enabed
  70576. */
  70577. get LensFlareEnabled(): boolean;
  70578. set LensFlareEnabled(enabled: boolean);
  70579. /**
  70580. * @ignore
  70581. * Specifies if the HDR pipeline is enabled
  70582. */
  70583. get HDREnabled(): boolean;
  70584. set HDREnabled(enabled: boolean);
  70585. /**
  70586. * @ignore
  70587. * Specifies if the volumetric lights scattering effect is enabled
  70588. */
  70589. get VLSEnabled(): boolean;
  70590. set VLSEnabled(enabled: boolean);
  70591. /**
  70592. * @ignore
  70593. * Specifies if the motion blur effect is enabled
  70594. */
  70595. get MotionBlurEnabled(): boolean;
  70596. set MotionBlurEnabled(enabled: boolean);
  70597. /**
  70598. * Specifies if anti-aliasing is enabled
  70599. */
  70600. get fxaaEnabled(): boolean;
  70601. set fxaaEnabled(enabled: boolean);
  70602. /**
  70603. * Specifies if screen space reflections are enabled.
  70604. */
  70605. get screenSpaceReflectionsEnabled(): boolean;
  70606. set screenSpaceReflectionsEnabled(enabled: boolean);
  70607. /**
  70608. * Specifies the number of steps used to calculate the volumetric lights
  70609. * Typically in interval [50, 200]
  70610. */
  70611. get volumetricLightStepsCount(): number;
  70612. set volumetricLightStepsCount(count: number);
  70613. /**
  70614. * Specifies the number of samples used for the motion blur effect
  70615. * Typically in interval [16, 64]
  70616. */
  70617. get motionBlurSamples(): number;
  70618. set motionBlurSamples(samples: number);
  70619. /**
  70620. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70621. */
  70622. get samples(): number;
  70623. set samples(sampleCount: number);
  70624. /**
  70625. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70626. * @constructor
  70627. * @param name The rendering pipeline name
  70628. * @param scene The scene linked to this pipeline
  70629. * @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)
  70630. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70631. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70632. */
  70633. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70634. private _buildPipeline;
  70635. private _createDownSampleX4PostProcess;
  70636. private _createBrightPassPostProcess;
  70637. private _createBlurPostProcesses;
  70638. private _createTextureAdderPostProcess;
  70639. private _createVolumetricLightPostProcess;
  70640. private _createLuminancePostProcesses;
  70641. private _createHdrPostProcess;
  70642. private _createLensFlarePostProcess;
  70643. private _createDepthOfFieldPostProcess;
  70644. private _createMotionBlurPostProcess;
  70645. private _getDepthTexture;
  70646. private _disposePostProcesses;
  70647. /**
  70648. * Dispose of the pipeline and stop all post processes
  70649. */
  70650. dispose(): void;
  70651. /**
  70652. * Serialize the rendering pipeline (Used when exporting)
  70653. * @returns the serialized object
  70654. */
  70655. serialize(): any;
  70656. /**
  70657. * Parse the serialized pipeline
  70658. * @param source Source pipeline.
  70659. * @param scene The scene to load the pipeline to.
  70660. * @param rootUrl The URL of the serialized pipeline.
  70661. * @returns An instantiated pipeline from the serialized object.
  70662. */
  70663. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70664. /**
  70665. * Luminance steps
  70666. */
  70667. static LuminanceSteps: number;
  70668. }
  70669. }
  70670. declare module BABYLON {
  70671. /** @hidden */
  70672. export var stereoscopicInterlacePixelShader: {
  70673. name: string;
  70674. shader: string;
  70675. };
  70676. }
  70677. declare module BABYLON {
  70678. /**
  70679. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70680. */
  70681. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70682. private _stepSize;
  70683. private _passedProcess;
  70684. /**
  70685. * Initializes a StereoscopicInterlacePostProcessI
  70686. * @param name The name of the effect.
  70687. * @param rigCameras The rig cameras to be appled to the post process
  70688. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70689. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70691. * @param engine The engine which the post process will be applied. (default: current engine)
  70692. * @param reusable If the post process can be reused on the same frame. (default: false)
  70693. */
  70694. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70695. }
  70696. /**
  70697. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70698. */
  70699. export class StereoscopicInterlacePostProcess extends PostProcess {
  70700. private _stepSize;
  70701. private _passedProcess;
  70702. /**
  70703. * Initializes a StereoscopicInterlacePostProcess
  70704. * @param name The name of the effect.
  70705. * @param rigCameras The rig cameras to be appled to the post process
  70706. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70708. * @param engine The engine which the post process will be applied. (default: current engine)
  70709. * @param reusable If the post process can be reused on the same frame. (default: false)
  70710. */
  70711. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70712. }
  70713. }
  70714. declare module BABYLON {
  70715. /** @hidden */
  70716. export var tonemapPixelShader: {
  70717. name: string;
  70718. shader: string;
  70719. };
  70720. }
  70721. declare module BABYLON {
  70722. /** Defines operator used for tonemapping */
  70723. export enum TonemappingOperator {
  70724. /** Hable */
  70725. Hable = 0,
  70726. /** Reinhard */
  70727. Reinhard = 1,
  70728. /** HejiDawson */
  70729. HejiDawson = 2,
  70730. /** Photographic */
  70731. Photographic = 3
  70732. }
  70733. /**
  70734. * Defines a post process to apply tone mapping
  70735. */
  70736. export class TonemapPostProcess extends PostProcess {
  70737. private _operator;
  70738. /** Defines the required exposure adjustement */
  70739. exposureAdjustment: number;
  70740. /**
  70741. * Creates a new TonemapPostProcess
  70742. * @param name defines the name of the postprocess
  70743. * @param _operator defines the operator to use
  70744. * @param exposureAdjustment defines the required exposure adjustement
  70745. * @param camera defines the camera to use (can be null)
  70746. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70747. * @param engine defines the hosting engine (can be ignore if camera is set)
  70748. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70749. */
  70750. constructor(name: string, _operator: TonemappingOperator,
  70751. /** Defines the required exposure adjustement */
  70752. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70753. }
  70754. }
  70755. declare module BABYLON {
  70756. /** @hidden */
  70757. export var volumetricLightScatteringPixelShader: {
  70758. name: string;
  70759. shader: string;
  70760. };
  70761. }
  70762. declare module BABYLON {
  70763. /** @hidden */
  70764. export var volumetricLightScatteringPassVertexShader: {
  70765. name: string;
  70766. shader: string;
  70767. };
  70768. }
  70769. declare module BABYLON {
  70770. /** @hidden */
  70771. export var volumetricLightScatteringPassPixelShader: {
  70772. name: string;
  70773. shader: string;
  70774. };
  70775. }
  70776. declare module BABYLON {
  70777. /**
  70778. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70779. */
  70780. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70781. private _volumetricLightScatteringPass;
  70782. private _volumetricLightScatteringRTT;
  70783. private _viewPort;
  70784. private _screenCoordinates;
  70785. private _cachedDefines;
  70786. /**
  70787. * If not undefined, the mesh position is computed from the attached node position
  70788. */
  70789. attachedNode: {
  70790. position: Vector3;
  70791. };
  70792. /**
  70793. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70794. */
  70795. customMeshPosition: Vector3;
  70796. /**
  70797. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70798. */
  70799. useCustomMeshPosition: boolean;
  70800. /**
  70801. * If the post-process should inverse the light scattering direction
  70802. */
  70803. invert: boolean;
  70804. /**
  70805. * The internal mesh used by the post-process
  70806. */
  70807. mesh: Mesh;
  70808. /**
  70809. * @hidden
  70810. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70811. */
  70812. get useDiffuseColor(): boolean;
  70813. set useDiffuseColor(useDiffuseColor: boolean);
  70814. /**
  70815. * Array containing the excluded meshes not rendered in the internal pass
  70816. */
  70817. excludedMeshes: AbstractMesh[];
  70818. /**
  70819. * Controls the overall intensity of the post-process
  70820. */
  70821. exposure: number;
  70822. /**
  70823. * Dissipates each sample's contribution in range [0, 1]
  70824. */
  70825. decay: number;
  70826. /**
  70827. * Controls the overall intensity of each sample
  70828. */
  70829. weight: number;
  70830. /**
  70831. * Controls the density of each sample
  70832. */
  70833. density: number;
  70834. /**
  70835. * @constructor
  70836. * @param name The post-process name
  70837. * @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)
  70838. * @param camera The camera that the post-process will be attached to
  70839. * @param mesh The mesh used to create the light scattering
  70840. * @param samples The post-process quality, default 100
  70841. * @param samplingModeThe post-process filtering mode
  70842. * @param engine The babylon engine
  70843. * @param reusable If the post-process is reusable
  70844. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70845. */
  70846. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70847. /**
  70848. * Returns the string "VolumetricLightScatteringPostProcess"
  70849. * @returns "VolumetricLightScatteringPostProcess"
  70850. */
  70851. getClassName(): string;
  70852. private _isReady;
  70853. /**
  70854. * Sets the new light position for light scattering effect
  70855. * @param position The new custom light position
  70856. */
  70857. setCustomMeshPosition(position: Vector3): void;
  70858. /**
  70859. * Returns the light position for light scattering effect
  70860. * @return Vector3 The custom light position
  70861. */
  70862. getCustomMeshPosition(): Vector3;
  70863. /**
  70864. * Disposes the internal assets and detaches the post-process from the camera
  70865. */
  70866. dispose(camera: Camera): void;
  70867. /**
  70868. * Returns the render target texture used by the post-process
  70869. * @return the render target texture used by the post-process
  70870. */
  70871. getPass(): RenderTargetTexture;
  70872. private _meshExcluded;
  70873. private _createPass;
  70874. private _updateMeshScreenCoordinates;
  70875. /**
  70876. * Creates a default mesh for the Volumeric Light Scattering post-process
  70877. * @param name The mesh name
  70878. * @param scene The scene where to create the mesh
  70879. * @return the default mesh
  70880. */
  70881. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70882. }
  70883. }
  70884. declare module BABYLON {
  70885. interface Scene {
  70886. /** @hidden (Backing field) */
  70887. _boundingBoxRenderer: BoundingBoxRenderer;
  70888. /** @hidden (Backing field) */
  70889. _forceShowBoundingBoxes: boolean;
  70890. /**
  70891. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70892. */
  70893. forceShowBoundingBoxes: boolean;
  70894. /**
  70895. * Gets the bounding box renderer associated with the scene
  70896. * @returns a BoundingBoxRenderer
  70897. */
  70898. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70899. }
  70900. interface AbstractMesh {
  70901. /** @hidden (Backing field) */
  70902. _showBoundingBox: boolean;
  70903. /**
  70904. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70905. */
  70906. showBoundingBox: boolean;
  70907. }
  70908. /**
  70909. * Component responsible of rendering the bounding box of the meshes in a scene.
  70910. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70911. */
  70912. export class BoundingBoxRenderer implements ISceneComponent {
  70913. /**
  70914. * The component name helpfull to identify the component in the list of scene components.
  70915. */
  70916. readonly name: string;
  70917. /**
  70918. * The scene the component belongs to.
  70919. */
  70920. scene: Scene;
  70921. /**
  70922. * Color of the bounding box lines placed in front of an object
  70923. */
  70924. frontColor: Color3;
  70925. /**
  70926. * Color of the bounding box lines placed behind an object
  70927. */
  70928. backColor: Color3;
  70929. /**
  70930. * Defines if the renderer should show the back lines or not
  70931. */
  70932. showBackLines: boolean;
  70933. /**
  70934. * Observable raised before rendering a bounding box
  70935. */
  70936. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  70937. /**
  70938. * Observable raised after rendering a bounding box
  70939. */
  70940. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  70941. /**
  70942. * @hidden
  70943. */
  70944. renderList: SmartArray<BoundingBox>;
  70945. private _colorShader;
  70946. private _vertexBuffers;
  70947. private _indexBuffer;
  70948. private _fillIndexBuffer;
  70949. private _fillIndexData;
  70950. /**
  70951. * Instantiates a new bounding box renderer in a scene.
  70952. * @param scene the scene the renderer renders in
  70953. */
  70954. constructor(scene: Scene);
  70955. /**
  70956. * Registers the component in a given scene
  70957. */
  70958. register(): void;
  70959. private _evaluateSubMesh;
  70960. private _activeMesh;
  70961. private _prepareRessources;
  70962. private _createIndexBuffer;
  70963. /**
  70964. * Rebuilds the elements related to this component in case of
  70965. * context lost for instance.
  70966. */
  70967. rebuild(): void;
  70968. /**
  70969. * @hidden
  70970. */
  70971. reset(): void;
  70972. /**
  70973. * Render the bounding boxes of a specific rendering group
  70974. * @param renderingGroupId defines the rendering group to render
  70975. */
  70976. render(renderingGroupId: number): void;
  70977. /**
  70978. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70979. * @param mesh Define the mesh to render the occlusion bounding box for
  70980. */
  70981. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70982. /**
  70983. * Dispose and release the resources attached to this renderer.
  70984. */
  70985. dispose(): void;
  70986. }
  70987. }
  70988. declare module BABYLON {
  70989. interface Scene {
  70990. /** @hidden (Backing field) */
  70991. _depthRenderer: {
  70992. [id: string]: DepthRenderer;
  70993. };
  70994. /**
  70995. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70996. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70997. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70998. * @returns the created depth renderer
  70999. */
  71000. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71001. /**
  71002. * Disables a depth renderer for a given camera
  71003. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71004. */
  71005. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71006. }
  71007. /**
  71008. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71009. * in several rendering techniques.
  71010. */
  71011. export class DepthRendererSceneComponent implements ISceneComponent {
  71012. /**
  71013. * The component name helpfull to identify the component in the list of scene components.
  71014. */
  71015. readonly name: string;
  71016. /**
  71017. * The scene the component belongs to.
  71018. */
  71019. scene: Scene;
  71020. /**
  71021. * Creates a new instance of the component for the given scene
  71022. * @param scene Defines the scene to register the component in
  71023. */
  71024. constructor(scene: Scene);
  71025. /**
  71026. * Registers the component in a given scene
  71027. */
  71028. register(): void;
  71029. /**
  71030. * Rebuilds the elements related to this component in case of
  71031. * context lost for instance.
  71032. */
  71033. rebuild(): void;
  71034. /**
  71035. * Disposes the component and the associated ressources
  71036. */
  71037. dispose(): void;
  71038. private _gatherRenderTargets;
  71039. private _gatherActiveCameraRenderTargets;
  71040. }
  71041. }
  71042. declare module BABYLON {
  71043. interface AbstractScene {
  71044. /** @hidden (Backing field) */
  71045. _prePassRenderer: Nullable<PrePassRenderer>;
  71046. /**
  71047. * Gets or Sets the current prepass renderer associated to the scene.
  71048. */
  71049. prePassRenderer: Nullable<PrePassRenderer>;
  71050. /**
  71051. * Enables the prepass and associates it with the scene
  71052. * @returns the PrePassRenderer
  71053. */
  71054. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71055. /**
  71056. * Disables the prepass associated with the scene
  71057. */
  71058. disablePrePassRenderer(): void;
  71059. }
  71060. /**
  71061. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71062. * in several rendering techniques.
  71063. */
  71064. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71065. /**
  71066. * The component name helpful to identify the component in the list of scene components.
  71067. */
  71068. readonly name: string;
  71069. /**
  71070. * The scene the component belongs to.
  71071. */
  71072. scene: Scene;
  71073. /**
  71074. * Creates a new instance of the component for the given scene
  71075. * @param scene Defines the scene to register the component in
  71076. */
  71077. constructor(scene: Scene);
  71078. /**
  71079. * Registers the component in a given scene
  71080. */
  71081. register(): void;
  71082. private _beforeCameraDraw;
  71083. private _afterCameraDraw;
  71084. private _beforeClearStage;
  71085. /**
  71086. * Serializes the component data to the specified json object
  71087. * @param serializationObject The object to serialize to
  71088. */
  71089. serialize(serializationObject: any): void;
  71090. /**
  71091. * Adds all the elements from the container to the scene
  71092. * @param container the container holding the elements
  71093. */
  71094. addFromContainer(container: AbstractScene): void;
  71095. /**
  71096. * Removes all the elements in the container from the scene
  71097. * @param container contains the elements to remove
  71098. * @param dispose if the removed element should be disposed (default: false)
  71099. */
  71100. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71101. /**
  71102. * Rebuilds the elements related to this component in case of
  71103. * context lost for instance.
  71104. */
  71105. rebuild(): void;
  71106. /**
  71107. * Disposes the component and the associated ressources
  71108. */
  71109. dispose(): void;
  71110. }
  71111. }
  71112. declare module BABYLON {
  71113. /** @hidden */
  71114. export var outlinePixelShader: {
  71115. name: string;
  71116. shader: string;
  71117. };
  71118. }
  71119. declare module BABYLON {
  71120. /** @hidden */
  71121. export var outlineVertexShader: {
  71122. name: string;
  71123. shader: string;
  71124. };
  71125. }
  71126. declare module BABYLON {
  71127. interface Scene {
  71128. /** @hidden */
  71129. _outlineRenderer: OutlineRenderer;
  71130. /**
  71131. * Gets the outline renderer associated with the scene
  71132. * @returns a OutlineRenderer
  71133. */
  71134. getOutlineRenderer(): OutlineRenderer;
  71135. }
  71136. interface AbstractMesh {
  71137. /** @hidden (Backing field) */
  71138. _renderOutline: boolean;
  71139. /**
  71140. * Gets or sets a boolean indicating if the outline must be rendered as well
  71141. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71142. */
  71143. renderOutline: boolean;
  71144. /** @hidden (Backing field) */
  71145. _renderOverlay: boolean;
  71146. /**
  71147. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71148. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71149. */
  71150. renderOverlay: boolean;
  71151. }
  71152. /**
  71153. * This class is responsible to draw bothe outline/overlay of meshes.
  71154. * It should not be used directly but through the available method on mesh.
  71155. */
  71156. export class OutlineRenderer implements ISceneComponent {
  71157. /**
  71158. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71159. */
  71160. private static _StencilReference;
  71161. /**
  71162. * The name of the component. Each component must have a unique name.
  71163. */
  71164. name: string;
  71165. /**
  71166. * The scene the component belongs to.
  71167. */
  71168. scene: Scene;
  71169. /**
  71170. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71171. */
  71172. zOffset: number;
  71173. private _engine;
  71174. private _effect;
  71175. private _cachedDefines;
  71176. private _savedDepthWrite;
  71177. /**
  71178. * Instantiates a new outline renderer. (There could be only one per scene).
  71179. * @param scene Defines the scene it belongs to
  71180. */
  71181. constructor(scene: Scene);
  71182. /**
  71183. * Register the component to one instance of a scene.
  71184. */
  71185. register(): void;
  71186. /**
  71187. * Rebuilds the elements related to this component in case of
  71188. * context lost for instance.
  71189. */
  71190. rebuild(): void;
  71191. /**
  71192. * Disposes the component and the associated ressources.
  71193. */
  71194. dispose(): void;
  71195. /**
  71196. * Renders the outline in the canvas.
  71197. * @param subMesh Defines the sumesh to render
  71198. * @param batch Defines the batch of meshes in case of instances
  71199. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71200. */
  71201. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71202. /**
  71203. * Returns whether or not the outline renderer is ready for a given submesh.
  71204. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71205. * @param subMesh Defines the submesh to check readyness for
  71206. * @param useInstances Defines wheter wee are trying to render instances or not
  71207. * @returns true if ready otherwise false
  71208. */
  71209. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71210. private _beforeRenderingMesh;
  71211. private _afterRenderingMesh;
  71212. }
  71213. }
  71214. declare module BABYLON {
  71215. /**
  71216. * Defines the basic options interface of a Sprite Frame Source Size.
  71217. */
  71218. export interface ISpriteJSONSpriteSourceSize {
  71219. /**
  71220. * number of the original width of the Frame
  71221. */
  71222. w: number;
  71223. /**
  71224. * number of the original height of the Frame
  71225. */
  71226. h: number;
  71227. }
  71228. /**
  71229. * Defines the basic options interface of a Sprite Frame Data.
  71230. */
  71231. export interface ISpriteJSONSpriteFrameData {
  71232. /**
  71233. * number of the x offset of the Frame
  71234. */
  71235. x: number;
  71236. /**
  71237. * number of the y offset of the Frame
  71238. */
  71239. y: number;
  71240. /**
  71241. * number of the width of the Frame
  71242. */
  71243. w: number;
  71244. /**
  71245. * number of the height of the Frame
  71246. */
  71247. h: number;
  71248. }
  71249. /**
  71250. * Defines the basic options interface of a JSON Sprite.
  71251. */
  71252. export interface ISpriteJSONSprite {
  71253. /**
  71254. * string name of the Frame
  71255. */
  71256. filename: string;
  71257. /**
  71258. * ISpriteJSONSpriteFrame basic object of the frame data
  71259. */
  71260. frame: ISpriteJSONSpriteFrameData;
  71261. /**
  71262. * boolean to flag is the frame was rotated.
  71263. */
  71264. rotated: boolean;
  71265. /**
  71266. * boolean to flag is the frame was trimmed.
  71267. */
  71268. trimmed: boolean;
  71269. /**
  71270. * ISpriteJSONSpriteFrame basic object of the source data
  71271. */
  71272. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71273. /**
  71274. * ISpriteJSONSpriteFrame basic object of the source data
  71275. */
  71276. sourceSize: ISpriteJSONSpriteSourceSize;
  71277. }
  71278. /**
  71279. * Defines the basic options interface of a JSON atlas.
  71280. */
  71281. export interface ISpriteJSONAtlas {
  71282. /**
  71283. * Array of objects that contain the frame data.
  71284. */
  71285. frames: Array<ISpriteJSONSprite>;
  71286. /**
  71287. * object basic object containing the sprite meta data.
  71288. */
  71289. meta?: object;
  71290. }
  71291. }
  71292. declare module BABYLON {
  71293. /** @hidden */
  71294. export var spriteMapPixelShader: {
  71295. name: string;
  71296. shader: string;
  71297. };
  71298. }
  71299. declare module BABYLON {
  71300. /** @hidden */
  71301. export var spriteMapVertexShader: {
  71302. name: string;
  71303. shader: string;
  71304. };
  71305. }
  71306. declare module BABYLON {
  71307. /**
  71308. * Defines the basic options interface of a SpriteMap
  71309. */
  71310. export interface ISpriteMapOptions {
  71311. /**
  71312. * Vector2 of the number of cells in the grid.
  71313. */
  71314. stageSize?: Vector2;
  71315. /**
  71316. * Vector2 of the size of the output plane in World Units.
  71317. */
  71318. outputSize?: Vector2;
  71319. /**
  71320. * Vector3 of the position of the output plane in World Units.
  71321. */
  71322. outputPosition?: Vector3;
  71323. /**
  71324. * Vector3 of the rotation of the output plane.
  71325. */
  71326. outputRotation?: Vector3;
  71327. /**
  71328. * number of layers that the system will reserve in resources.
  71329. */
  71330. layerCount?: number;
  71331. /**
  71332. * number of max animation frames a single cell will reserve in resources.
  71333. */
  71334. maxAnimationFrames?: number;
  71335. /**
  71336. * number cell index of the base tile when the system compiles.
  71337. */
  71338. baseTile?: number;
  71339. /**
  71340. * boolean flip the sprite after its been repositioned by the framing data.
  71341. */
  71342. flipU?: boolean;
  71343. /**
  71344. * Vector3 scalar of the global RGB values of the SpriteMap.
  71345. */
  71346. colorMultiply?: Vector3;
  71347. }
  71348. /**
  71349. * Defines the IDisposable interface in order to be cleanable from resources.
  71350. */
  71351. export interface ISpriteMap extends IDisposable {
  71352. /**
  71353. * String name of the SpriteMap.
  71354. */
  71355. name: string;
  71356. /**
  71357. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71358. */
  71359. atlasJSON: ISpriteJSONAtlas;
  71360. /**
  71361. * Texture of the SpriteMap.
  71362. */
  71363. spriteSheet: Texture;
  71364. /**
  71365. * The parameters to initialize the SpriteMap with.
  71366. */
  71367. options: ISpriteMapOptions;
  71368. }
  71369. /**
  71370. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71371. */
  71372. export class SpriteMap implements ISpriteMap {
  71373. /** The Name of the spriteMap */
  71374. name: string;
  71375. /** The JSON file with the frame and meta data */
  71376. atlasJSON: ISpriteJSONAtlas;
  71377. /** The systems Sprite Sheet Texture */
  71378. spriteSheet: Texture;
  71379. /** Arguments passed with the Constructor */
  71380. options: ISpriteMapOptions;
  71381. /** Public Sprite Storage array, parsed from atlasJSON */
  71382. sprites: Array<ISpriteJSONSprite>;
  71383. /** Returns the Number of Sprites in the System */
  71384. get spriteCount(): number;
  71385. /** Returns the Position of Output Plane*/
  71386. get position(): Vector3;
  71387. /** Returns the Position of Output Plane*/
  71388. set position(v: Vector3);
  71389. /** Returns the Rotation of Output Plane*/
  71390. get rotation(): Vector3;
  71391. /** Returns the Rotation of Output Plane*/
  71392. set rotation(v: Vector3);
  71393. /** Sets the AnimationMap*/
  71394. get animationMap(): RawTexture;
  71395. /** Sets the AnimationMap*/
  71396. set animationMap(v: RawTexture);
  71397. /** Scene that the SpriteMap was created in */
  71398. private _scene;
  71399. /** Texture Buffer of Float32 that holds tile frame data*/
  71400. private _frameMap;
  71401. /** Texture Buffers of Float32 that holds tileMap data*/
  71402. private _tileMaps;
  71403. /** Texture Buffer of Float32 that holds Animation Data*/
  71404. private _animationMap;
  71405. /** Custom ShaderMaterial Central to the System*/
  71406. private _material;
  71407. /** Custom ShaderMaterial Central to the System*/
  71408. private _output;
  71409. /** Systems Time Ticker*/
  71410. private _time;
  71411. /**
  71412. * Creates a new SpriteMap
  71413. * @param name defines the SpriteMaps Name
  71414. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71415. * @param spriteSheet is the Texture that the Sprites are on.
  71416. * @param options a basic deployment configuration
  71417. * @param scene The Scene that the map is deployed on
  71418. */
  71419. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71420. /**
  71421. * Returns tileID location
  71422. * @returns Vector2 the cell position ID
  71423. */
  71424. getTileID(): Vector2;
  71425. /**
  71426. * Gets the UV location of the mouse over the SpriteMap.
  71427. * @returns Vector2 the UV position of the mouse interaction
  71428. */
  71429. getMousePosition(): Vector2;
  71430. /**
  71431. * Creates the "frame" texture Buffer
  71432. * -------------------------------------
  71433. * Structure of frames
  71434. * "filename": "Falling-Water-2.png",
  71435. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71436. * "rotated": true,
  71437. * "trimmed": true,
  71438. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71439. * "sourceSize": {"w":32,"h":32}
  71440. * @returns RawTexture of the frameMap
  71441. */
  71442. private _createFrameBuffer;
  71443. /**
  71444. * Creates the tileMap texture Buffer
  71445. * @param buffer normally and array of numbers, or a false to generate from scratch
  71446. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71447. * @returns RawTexture of the tileMap
  71448. */
  71449. private _createTileBuffer;
  71450. /**
  71451. * Modifies the data of the tileMaps
  71452. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71453. * @param pos is the iVector2 Coordinates of the Tile
  71454. * @param tile The SpriteIndex of the new Tile
  71455. */
  71456. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71457. /**
  71458. * Creates the animationMap texture Buffer
  71459. * @param buffer normally and array of numbers, or a false to generate from scratch
  71460. * @returns RawTexture of the animationMap
  71461. */
  71462. private _createTileAnimationBuffer;
  71463. /**
  71464. * Modifies the data of the animationMap
  71465. * @param cellID is the Index of the Sprite
  71466. * @param _frame is the target Animation frame
  71467. * @param toCell is the Target Index of the next frame of the animation
  71468. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71469. * @param speed is a global scalar of the time variable on the map.
  71470. */
  71471. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71472. /**
  71473. * Exports the .tilemaps file
  71474. */
  71475. saveTileMaps(): void;
  71476. /**
  71477. * Imports the .tilemaps file
  71478. * @param url of the .tilemaps file
  71479. */
  71480. loadTileMaps(url: string): void;
  71481. /**
  71482. * Release associated resources
  71483. */
  71484. dispose(): void;
  71485. }
  71486. }
  71487. declare module BABYLON {
  71488. /**
  71489. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71490. * @see https://doc.babylonjs.com/babylon101/sprites
  71491. */
  71492. export class SpritePackedManager extends SpriteManager {
  71493. /** defines the packed manager's name */
  71494. name: string;
  71495. /**
  71496. * Creates a new sprite manager from a packed sprite sheet
  71497. * @param name defines the manager's name
  71498. * @param imgUrl defines the sprite sheet url
  71499. * @param capacity defines the maximum allowed number of sprites
  71500. * @param scene defines the hosting scene
  71501. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71502. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71503. * @param samplingMode defines the smapling mode to use with spritesheet
  71504. * @param fromPacked set to true; do not alter
  71505. */
  71506. constructor(
  71507. /** defines the packed manager's name */
  71508. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71509. }
  71510. }
  71511. declare module BABYLON {
  71512. /**
  71513. * Defines the list of states available for a task inside a AssetsManager
  71514. */
  71515. export enum AssetTaskState {
  71516. /**
  71517. * Initialization
  71518. */
  71519. INIT = 0,
  71520. /**
  71521. * Running
  71522. */
  71523. RUNNING = 1,
  71524. /**
  71525. * Done
  71526. */
  71527. DONE = 2,
  71528. /**
  71529. * Error
  71530. */
  71531. ERROR = 3
  71532. }
  71533. /**
  71534. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71535. */
  71536. export abstract class AbstractAssetTask {
  71537. /**
  71538. * Task name
  71539. */ name: string;
  71540. /**
  71541. * Callback called when the task is successful
  71542. */
  71543. onSuccess: (task: any) => void;
  71544. /**
  71545. * Callback called when the task is not successful
  71546. */
  71547. onError: (task: any, message?: string, exception?: any) => void;
  71548. /**
  71549. * Creates a new AssetsManager
  71550. * @param name defines the name of the task
  71551. */
  71552. constructor(
  71553. /**
  71554. * Task name
  71555. */ name: string);
  71556. private _isCompleted;
  71557. private _taskState;
  71558. private _errorObject;
  71559. /**
  71560. * Get if the task is completed
  71561. */
  71562. get isCompleted(): boolean;
  71563. /**
  71564. * Gets the current state of the task
  71565. */
  71566. get taskState(): AssetTaskState;
  71567. /**
  71568. * Gets the current error object (if task is in error)
  71569. */
  71570. get errorObject(): {
  71571. message?: string;
  71572. exception?: any;
  71573. };
  71574. /**
  71575. * Internal only
  71576. * @hidden
  71577. */
  71578. _setErrorObject(message?: string, exception?: any): void;
  71579. /**
  71580. * Execute the current task
  71581. * @param scene defines the scene where you want your assets to be loaded
  71582. * @param onSuccess is a callback called when the task is successfully executed
  71583. * @param onError is a callback called if an error occurs
  71584. */
  71585. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71586. /**
  71587. * Execute the current task
  71588. * @param scene defines the scene where you want your assets to be loaded
  71589. * @param onSuccess is a callback called when the task is successfully executed
  71590. * @param onError is a callback called if an error occurs
  71591. */
  71592. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71593. /**
  71594. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71595. * This can be used with failed tasks that have the reason for failure fixed.
  71596. */
  71597. reset(): void;
  71598. private onErrorCallback;
  71599. private onDoneCallback;
  71600. }
  71601. /**
  71602. * Define the interface used by progress events raised during assets loading
  71603. */
  71604. export interface IAssetsProgressEvent {
  71605. /**
  71606. * Defines the number of remaining tasks to process
  71607. */
  71608. remainingCount: number;
  71609. /**
  71610. * Defines the total number of tasks
  71611. */
  71612. totalCount: number;
  71613. /**
  71614. * Defines the task that was just processed
  71615. */
  71616. task: AbstractAssetTask;
  71617. }
  71618. /**
  71619. * Class used to share progress information about assets loading
  71620. */
  71621. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71622. /**
  71623. * Defines the number of remaining tasks to process
  71624. */
  71625. remainingCount: number;
  71626. /**
  71627. * Defines the total number of tasks
  71628. */
  71629. totalCount: number;
  71630. /**
  71631. * Defines the task that was just processed
  71632. */
  71633. task: AbstractAssetTask;
  71634. /**
  71635. * Creates a AssetsProgressEvent
  71636. * @param remainingCount defines the number of remaining tasks to process
  71637. * @param totalCount defines the total number of tasks
  71638. * @param task defines the task that was just processed
  71639. */
  71640. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71641. }
  71642. /**
  71643. * Define a task used by AssetsManager to load meshes
  71644. */
  71645. export class MeshAssetTask extends AbstractAssetTask {
  71646. /**
  71647. * Defines the name of the task
  71648. */
  71649. name: string;
  71650. /**
  71651. * Defines the list of mesh's names you want to load
  71652. */
  71653. meshesNames: any;
  71654. /**
  71655. * Defines the root url to use as a base to load your meshes and associated resources
  71656. */
  71657. rootUrl: string;
  71658. /**
  71659. * Defines the filename or File of the scene to load from
  71660. */
  71661. sceneFilename: string | File;
  71662. /**
  71663. * Gets the list of loaded meshes
  71664. */
  71665. loadedMeshes: Array<AbstractMesh>;
  71666. /**
  71667. * Gets the list of loaded particle systems
  71668. */
  71669. loadedParticleSystems: Array<IParticleSystem>;
  71670. /**
  71671. * Gets the list of loaded skeletons
  71672. */
  71673. loadedSkeletons: Array<Skeleton>;
  71674. /**
  71675. * Gets the list of loaded animation groups
  71676. */
  71677. loadedAnimationGroups: Array<AnimationGroup>;
  71678. /**
  71679. * Callback called when the task is successful
  71680. */
  71681. onSuccess: (task: MeshAssetTask) => void;
  71682. /**
  71683. * Callback called when the task is successful
  71684. */
  71685. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71686. /**
  71687. * Creates a new MeshAssetTask
  71688. * @param name defines the name of the task
  71689. * @param meshesNames defines the list of mesh's names you want to load
  71690. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71691. * @param sceneFilename defines the filename or File of the scene to load from
  71692. */
  71693. constructor(
  71694. /**
  71695. * Defines the name of the task
  71696. */
  71697. name: string,
  71698. /**
  71699. * Defines the list of mesh's names you want to load
  71700. */
  71701. meshesNames: any,
  71702. /**
  71703. * Defines the root url to use as a base to load your meshes and associated resources
  71704. */
  71705. rootUrl: string,
  71706. /**
  71707. * Defines the filename or File of the scene to load from
  71708. */
  71709. sceneFilename: string | File);
  71710. /**
  71711. * Execute the current task
  71712. * @param scene defines the scene where you want your assets to be loaded
  71713. * @param onSuccess is a callback called when the task is successfully executed
  71714. * @param onError is a callback called if an error occurs
  71715. */
  71716. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71717. }
  71718. /**
  71719. * Define a task used by AssetsManager to load text content
  71720. */
  71721. export class TextFileAssetTask extends AbstractAssetTask {
  71722. /**
  71723. * Defines the name of the task
  71724. */
  71725. name: string;
  71726. /**
  71727. * Defines the location of the file to load
  71728. */
  71729. url: string;
  71730. /**
  71731. * Gets the loaded text string
  71732. */
  71733. text: string;
  71734. /**
  71735. * Callback called when the task is successful
  71736. */
  71737. onSuccess: (task: TextFileAssetTask) => void;
  71738. /**
  71739. * Callback called when the task is successful
  71740. */
  71741. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71742. /**
  71743. * Creates a new TextFileAssetTask object
  71744. * @param name defines the name of the task
  71745. * @param url defines the location of the file to load
  71746. */
  71747. constructor(
  71748. /**
  71749. * Defines the name of the task
  71750. */
  71751. name: string,
  71752. /**
  71753. * Defines the location of the file to load
  71754. */
  71755. url: string);
  71756. /**
  71757. * Execute the current task
  71758. * @param scene defines the scene where you want your assets to be loaded
  71759. * @param onSuccess is a callback called when the task is successfully executed
  71760. * @param onError is a callback called if an error occurs
  71761. */
  71762. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71763. }
  71764. /**
  71765. * Define a task used by AssetsManager to load binary data
  71766. */
  71767. export class BinaryFileAssetTask extends AbstractAssetTask {
  71768. /**
  71769. * Defines the name of the task
  71770. */
  71771. name: string;
  71772. /**
  71773. * Defines the location of the file to load
  71774. */
  71775. url: string;
  71776. /**
  71777. * Gets the lodaded data (as an array buffer)
  71778. */
  71779. data: ArrayBuffer;
  71780. /**
  71781. * Callback called when the task is successful
  71782. */
  71783. onSuccess: (task: BinaryFileAssetTask) => void;
  71784. /**
  71785. * Callback called when the task is successful
  71786. */
  71787. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71788. /**
  71789. * Creates a new BinaryFileAssetTask object
  71790. * @param name defines the name of the new task
  71791. * @param url defines the location of the file to load
  71792. */
  71793. constructor(
  71794. /**
  71795. * Defines the name of the task
  71796. */
  71797. name: string,
  71798. /**
  71799. * Defines the location of the file to load
  71800. */
  71801. url: string);
  71802. /**
  71803. * Execute the current task
  71804. * @param scene defines the scene where you want your assets to be loaded
  71805. * @param onSuccess is a callback called when the task is successfully executed
  71806. * @param onError is a callback called if an error occurs
  71807. */
  71808. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71809. }
  71810. /**
  71811. * Define a task used by AssetsManager to load images
  71812. */
  71813. export class ImageAssetTask extends AbstractAssetTask {
  71814. /**
  71815. * Defines the name of the task
  71816. */
  71817. name: string;
  71818. /**
  71819. * Defines the location of the image to load
  71820. */
  71821. url: string;
  71822. /**
  71823. * Gets the loaded images
  71824. */
  71825. image: HTMLImageElement;
  71826. /**
  71827. * Callback called when the task is successful
  71828. */
  71829. onSuccess: (task: ImageAssetTask) => void;
  71830. /**
  71831. * Callback called when the task is successful
  71832. */
  71833. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71834. /**
  71835. * Creates a new ImageAssetTask
  71836. * @param name defines the name of the task
  71837. * @param url defines the location of the image to load
  71838. */
  71839. constructor(
  71840. /**
  71841. * Defines the name of the task
  71842. */
  71843. name: string,
  71844. /**
  71845. * Defines the location of the image to load
  71846. */
  71847. url: string);
  71848. /**
  71849. * Execute the current task
  71850. * @param scene defines the scene where you want your assets to be loaded
  71851. * @param onSuccess is a callback called when the task is successfully executed
  71852. * @param onError is a callback called if an error occurs
  71853. */
  71854. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71855. }
  71856. /**
  71857. * Defines the interface used by texture loading tasks
  71858. */
  71859. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71860. /**
  71861. * Gets the loaded texture
  71862. */
  71863. texture: TEX;
  71864. }
  71865. /**
  71866. * Define a task used by AssetsManager to load 2D textures
  71867. */
  71868. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71869. /**
  71870. * Defines the name of the task
  71871. */
  71872. name: string;
  71873. /**
  71874. * Defines the location of the file to load
  71875. */
  71876. url: string;
  71877. /**
  71878. * Defines if mipmap should not be generated (default is false)
  71879. */
  71880. noMipmap?: boolean | undefined;
  71881. /**
  71882. * Defines if texture must be inverted on Y axis (default is true)
  71883. */
  71884. invertY: boolean;
  71885. /**
  71886. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71887. */
  71888. samplingMode: number;
  71889. /**
  71890. * Gets the loaded texture
  71891. */
  71892. texture: Texture;
  71893. /**
  71894. * Callback called when the task is successful
  71895. */
  71896. onSuccess: (task: TextureAssetTask) => void;
  71897. /**
  71898. * Callback called when the task is successful
  71899. */
  71900. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71901. /**
  71902. * Creates a new TextureAssetTask object
  71903. * @param name defines the name of the task
  71904. * @param url defines the location of the file to load
  71905. * @param noMipmap defines if mipmap should not be generated (default is false)
  71906. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71907. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71908. */
  71909. constructor(
  71910. /**
  71911. * Defines the name of the task
  71912. */
  71913. name: string,
  71914. /**
  71915. * Defines the location of the file to load
  71916. */
  71917. url: string,
  71918. /**
  71919. * Defines if mipmap should not be generated (default is false)
  71920. */
  71921. noMipmap?: boolean | undefined,
  71922. /**
  71923. * Defines if texture must be inverted on Y axis (default is true)
  71924. */
  71925. invertY?: boolean,
  71926. /**
  71927. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71928. */
  71929. samplingMode?: number);
  71930. /**
  71931. * Execute the current task
  71932. * @param scene defines the scene where you want your assets to be loaded
  71933. * @param onSuccess is a callback called when the task is successfully executed
  71934. * @param onError is a callback called if an error occurs
  71935. */
  71936. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71937. }
  71938. /**
  71939. * Define a task used by AssetsManager to load cube textures
  71940. */
  71941. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71942. /**
  71943. * Defines the name of the task
  71944. */
  71945. name: string;
  71946. /**
  71947. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71948. */
  71949. url: string;
  71950. /**
  71951. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71952. */
  71953. extensions?: string[] | undefined;
  71954. /**
  71955. * Defines if mipmaps should not be generated (default is false)
  71956. */
  71957. noMipmap?: boolean | undefined;
  71958. /**
  71959. * Defines the explicit list of files (undefined by default)
  71960. */
  71961. files?: string[] | undefined;
  71962. /**
  71963. * Gets the loaded texture
  71964. */
  71965. texture: CubeTexture;
  71966. /**
  71967. * Callback called when the task is successful
  71968. */
  71969. onSuccess: (task: CubeTextureAssetTask) => void;
  71970. /**
  71971. * Callback called when the task is successful
  71972. */
  71973. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71974. /**
  71975. * Creates a new CubeTextureAssetTask
  71976. * @param name defines the name of the task
  71977. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71978. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71979. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71980. * @param files defines the explicit list of files (undefined by default)
  71981. */
  71982. constructor(
  71983. /**
  71984. * Defines the name of the task
  71985. */
  71986. name: string,
  71987. /**
  71988. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71989. */
  71990. url: string,
  71991. /**
  71992. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71993. */
  71994. extensions?: string[] | undefined,
  71995. /**
  71996. * Defines if mipmaps should not be generated (default is false)
  71997. */
  71998. noMipmap?: boolean | undefined,
  71999. /**
  72000. * Defines the explicit list of files (undefined by default)
  72001. */
  72002. files?: string[] | undefined);
  72003. /**
  72004. * Execute the current task
  72005. * @param scene defines the scene where you want your assets to be loaded
  72006. * @param onSuccess is a callback called when the task is successfully executed
  72007. * @param onError is a callback called if an error occurs
  72008. */
  72009. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72010. }
  72011. /**
  72012. * Define a task used by AssetsManager to load HDR cube textures
  72013. */
  72014. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72015. /**
  72016. * Defines the name of the task
  72017. */
  72018. name: string;
  72019. /**
  72020. * Defines the location of the file to load
  72021. */
  72022. url: string;
  72023. /**
  72024. * Defines the desired size (the more it increases the longer the generation will be)
  72025. */
  72026. size: number;
  72027. /**
  72028. * Defines if mipmaps should not be generated (default is false)
  72029. */
  72030. noMipmap: boolean;
  72031. /**
  72032. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72033. */
  72034. generateHarmonics: boolean;
  72035. /**
  72036. * 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)
  72037. */
  72038. gammaSpace: boolean;
  72039. /**
  72040. * Internal Use Only
  72041. */
  72042. reserved: boolean;
  72043. /**
  72044. * Gets the loaded texture
  72045. */
  72046. texture: HDRCubeTexture;
  72047. /**
  72048. * Callback called when the task is successful
  72049. */
  72050. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72051. /**
  72052. * Callback called when the task is successful
  72053. */
  72054. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72055. /**
  72056. * Creates a new HDRCubeTextureAssetTask object
  72057. * @param name defines the name of the task
  72058. * @param url defines the location of the file to load
  72059. * @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.
  72060. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72061. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72062. * @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)
  72063. * @param reserved Internal use only
  72064. */
  72065. constructor(
  72066. /**
  72067. * Defines the name of the task
  72068. */
  72069. name: string,
  72070. /**
  72071. * Defines the location of the file to load
  72072. */
  72073. url: string,
  72074. /**
  72075. * Defines the desired size (the more it increases the longer the generation will be)
  72076. */
  72077. size: number,
  72078. /**
  72079. * Defines if mipmaps should not be generated (default is false)
  72080. */
  72081. noMipmap?: boolean,
  72082. /**
  72083. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72084. */
  72085. generateHarmonics?: boolean,
  72086. /**
  72087. * 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)
  72088. */
  72089. gammaSpace?: boolean,
  72090. /**
  72091. * Internal Use Only
  72092. */
  72093. reserved?: boolean);
  72094. /**
  72095. * Execute the current task
  72096. * @param scene defines the scene where you want your assets to be loaded
  72097. * @param onSuccess is a callback called when the task is successfully executed
  72098. * @param onError is a callback called if an error occurs
  72099. */
  72100. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72101. }
  72102. /**
  72103. * Define a task used by AssetsManager to load Equirectangular cube textures
  72104. */
  72105. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72106. /**
  72107. * Defines the name of the task
  72108. */
  72109. name: string;
  72110. /**
  72111. * Defines the location of the file to load
  72112. */
  72113. url: string;
  72114. /**
  72115. * Defines the desired size (the more it increases the longer the generation will be)
  72116. */
  72117. size: number;
  72118. /**
  72119. * Defines if mipmaps should not be generated (default is false)
  72120. */
  72121. noMipmap: boolean;
  72122. /**
  72123. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72124. * but the standard material would require them in Gamma space) (default is true)
  72125. */
  72126. gammaSpace: boolean;
  72127. /**
  72128. * Gets the loaded texture
  72129. */
  72130. texture: EquiRectangularCubeTexture;
  72131. /**
  72132. * Callback called when the task is successful
  72133. */
  72134. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72135. /**
  72136. * Callback called when the task is successful
  72137. */
  72138. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72139. /**
  72140. * Creates a new EquiRectangularCubeTextureAssetTask object
  72141. * @param name defines the name of the task
  72142. * @param url defines the location of the file to load
  72143. * @param size defines the desired size (the more it increases the longer the generation will be)
  72144. * If the size is omitted this implies you are using a preprocessed cubemap.
  72145. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72146. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72147. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72148. * (default is true)
  72149. */
  72150. constructor(
  72151. /**
  72152. * Defines the name of the task
  72153. */
  72154. name: string,
  72155. /**
  72156. * Defines the location of the file to load
  72157. */
  72158. url: string,
  72159. /**
  72160. * Defines the desired size (the more it increases the longer the generation will be)
  72161. */
  72162. size: number,
  72163. /**
  72164. * Defines if mipmaps should not be generated (default is false)
  72165. */
  72166. noMipmap?: boolean,
  72167. /**
  72168. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72169. * but the standard material would require them in Gamma space) (default is true)
  72170. */
  72171. gammaSpace?: boolean);
  72172. /**
  72173. * Execute the current task
  72174. * @param scene defines the scene where you want your assets to be loaded
  72175. * @param onSuccess is a callback called when the task is successfully executed
  72176. * @param onError is a callback called if an error occurs
  72177. */
  72178. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72179. }
  72180. /**
  72181. * This class can be used to easily import assets into a scene
  72182. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72183. */
  72184. export class AssetsManager {
  72185. private _scene;
  72186. private _isLoading;
  72187. protected _tasks: AbstractAssetTask[];
  72188. protected _waitingTasksCount: number;
  72189. protected _totalTasksCount: number;
  72190. /**
  72191. * Callback called when all tasks are processed
  72192. */
  72193. onFinish: (tasks: AbstractAssetTask[]) => void;
  72194. /**
  72195. * Callback called when a task is successful
  72196. */
  72197. onTaskSuccess: (task: AbstractAssetTask) => void;
  72198. /**
  72199. * Callback called when a task had an error
  72200. */
  72201. onTaskError: (task: AbstractAssetTask) => void;
  72202. /**
  72203. * Callback called when a task is done (whatever the result is)
  72204. */
  72205. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72206. /**
  72207. * Observable called when all tasks are processed
  72208. */
  72209. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72210. /**
  72211. * Observable called when a task had an error
  72212. */
  72213. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72214. /**
  72215. * Observable called when all tasks were executed
  72216. */
  72217. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72218. /**
  72219. * Observable called when a task is done (whatever the result is)
  72220. */
  72221. onProgressObservable: Observable<IAssetsProgressEvent>;
  72222. /**
  72223. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72224. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72225. */
  72226. useDefaultLoadingScreen: boolean;
  72227. /**
  72228. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72229. * when all assets have been downloaded.
  72230. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72231. */
  72232. autoHideLoadingUI: boolean;
  72233. /**
  72234. * Creates a new AssetsManager
  72235. * @param scene defines the scene to work on
  72236. */
  72237. constructor(scene: Scene);
  72238. /**
  72239. * Add a MeshAssetTask to the list of active tasks
  72240. * @param taskName defines the name of the new task
  72241. * @param meshesNames defines the name of meshes to load
  72242. * @param rootUrl defines the root url to use to locate files
  72243. * @param sceneFilename defines the filename of the scene file
  72244. * @returns a new MeshAssetTask object
  72245. */
  72246. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72247. /**
  72248. * Add a TextFileAssetTask to the list of active tasks
  72249. * @param taskName defines the name of the new task
  72250. * @param url defines the url of the file to load
  72251. * @returns a new TextFileAssetTask object
  72252. */
  72253. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72254. /**
  72255. * Add a BinaryFileAssetTask to the list of active tasks
  72256. * @param taskName defines the name of the new task
  72257. * @param url defines the url of the file to load
  72258. * @returns a new BinaryFileAssetTask object
  72259. */
  72260. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72261. /**
  72262. * Add a ImageAssetTask to the list of active tasks
  72263. * @param taskName defines the name of the new task
  72264. * @param url defines the url of the file to load
  72265. * @returns a new ImageAssetTask object
  72266. */
  72267. addImageTask(taskName: string, url: string): ImageAssetTask;
  72268. /**
  72269. * Add a TextureAssetTask to the list of active tasks
  72270. * @param taskName defines the name of the new task
  72271. * @param url defines the url of the file to load
  72272. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72273. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72274. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72275. * @returns a new TextureAssetTask object
  72276. */
  72277. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72278. /**
  72279. * Add a CubeTextureAssetTask to the list of active tasks
  72280. * @param taskName defines the name of the new task
  72281. * @param url defines the url of the file to load
  72282. * @param extensions defines the extension to use to load the cube map (can be null)
  72283. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72284. * @param files defines the list of files to load (can be null)
  72285. * @returns a new CubeTextureAssetTask object
  72286. */
  72287. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72288. /**
  72289. *
  72290. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72291. * @param taskName defines the name of the new task
  72292. * @param url defines the url of the file to load
  72293. * @param size defines the size you want for the cubemap (can be null)
  72294. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72295. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72296. * @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)
  72297. * @param reserved Internal use only
  72298. * @returns a new HDRCubeTextureAssetTask object
  72299. */
  72300. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72301. /**
  72302. *
  72303. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72304. * @param taskName defines the name of the new task
  72305. * @param url defines the url of the file to load
  72306. * @param size defines the size you want for the cubemap (can be null)
  72307. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72308. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72309. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72310. * @returns a new EquiRectangularCubeTextureAssetTask object
  72311. */
  72312. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72313. /**
  72314. * Remove a task from the assets manager.
  72315. * @param task the task to remove
  72316. */
  72317. removeTask(task: AbstractAssetTask): void;
  72318. private _decreaseWaitingTasksCount;
  72319. private _runTask;
  72320. /**
  72321. * Reset the AssetsManager and remove all tasks
  72322. * @return the current instance of the AssetsManager
  72323. */
  72324. reset(): AssetsManager;
  72325. /**
  72326. * Start the loading process
  72327. * @return the current instance of the AssetsManager
  72328. */
  72329. load(): AssetsManager;
  72330. /**
  72331. * Start the loading process as an async operation
  72332. * @return a promise returning the list of failed tasks
  72333. */
  72334. loadAsync(): Promise<void>;
  72335. }
  72336. }
  72337. declare module BABYLON {
  72338. /**
  72339. * Wrapper class for promise with external resolve and reject.
  72340. */
  72341. export class Deferred<T> {
  72342. /**
  72343. * The promise associated with this deferred object.
  72344. */
  72345. readonly promise: Promise<T>;
  72346. private _resolve;
  72347. private _reject;
  72348. /**
  72349. * The resolve method of the promise associated with this deferred object.
  72350. */
  72351. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72352. /**
  72353. * The reject method of the promise associated with this deferred object.
  72354. */
  72355. get reject(): (reason?: any) => void;
  72356. /**
  72357. * Constructor for this deferred object.
  72358. */
  72359. constructor();
  72360. }
  72361. }
  72362. declare module BABYLON {
  72363. /**
  72364. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72365. */
  72366. export class MeshExploder {
  72367. private _centerMesh;
  72368. private _meshes;
  72369. private _meshesOrigins;
  72370. private _toCenterVectors;
  72371. private _scaledDirection;
  72372. private _newPosition;
  72373. private _centerPosition;
  72374. /**
  72375. * Explodes meshes from a center mesh.
  72376. * @param meshes The meshes to explode.
  72377. * @param centerMesh The mesh to be center of explosion.
  72378. */
  72379. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72380. private _setCenterMesh;
  72381. /**
  72382. * Get class name
  72383. * @returns "MeshExploder"
  72384. */
  72385. getClassName(): string;
  72386. /**
  72387. * "Exploded meshes"
  72388. * @returns Array of meshes with the centerMesh at index 0.
  72389. */
  72390. getMeshes(): Array<Mesh>;
  72391. /**
  72392. * Explodes meshes giving a specific direction
  72393. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72394. */
  72395. explode(direction?: number): void;
  72396. }
  72397. }
  72398. declare module BABYLON {
  72399. /**
  72400. * Class used to help managing file picking and drag'n'drop
  72401. */
  72402. export class FilesInput {
  72403. /**
  72404. * List of files ready to be loaded
  72405. */
  72406. static get FilesToLoad(): {
  72407. [key: string]: File;
  72408. };
  72409. /**
  72410. * Callback called when a file is processed
  72411. */
  72412. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72413. private _engine;
  72414. private _currentScene;
  72415. private _sceneLoadedCallback;
  72416. private _progressCallback;
  72417. private _additionalRenderLoopLogicCallback;
  72418. private _textureLoadingCallback;
  72419. private _startingProcessingFilesCallback;
  72420. private _onReloadCallback;
  72421. private _errorCallback;
  72422. private _elementToMonitor;
  72423. private _sceneFileToLoad;
  72424. private _filesToLoad;
  72425. /**
  72426. * Creates a new FilesInput
  72427. * @param engine defines the rendering engine
  72428. * @param scene defines the hosting scene
  72429. * @param sceneLoadedCallback callback called when scene is loaded
  72430. * @param progressCallback callback called to track progress
  72431. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72432. * @param textureLoadingCallback callback called when a texture is loading
  72433. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72434. * @param onReloadCallback callback called when a reload is requested
  72435. * @param errorCallback callback call if an error occurs
  72436. */
  72437. 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>);
  72438. private _dragEnterHandler;
  72439. private _dragOverHandler;
  72440. private _dropHandler;
  72441. /**
  72442. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72443. * @param elementToMonitor defines the DOM element to track
  72444. */
  72445. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72446. /** Gets the current list of files to load */
  72447. get filesToLoad(): File[];
  72448. /**
  72449. * Release all associated resources
  72450. */
  72451. dispose(): void;
  72452. private renderFunction;
  72453. private drag;
  72454. private drop;
  72455. private _traverseFolder;
  72456. private _processFiles;
  72457. /**
  72458. * Load files from a drop event
  72459. * @param event defines the drop event to use as source
  72460. */
  72461. loadFiles(event: any): void;
  72462. private _processReload;
  72463. /**
  72464. * Reload the current scene from the loaded files
  72465. */
  72466. reload(): void;
  72467. }
  72468. }
  72469. declare module BABYLON {
  72470. /**
  72471. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72472. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72473. */
  72474. export class SceneOptimization {
  72475. /**
  72476. * Defines the priority of this optimization (0 by default which means first in the list)
  72477. */
  72478. priority: number;
  72479. /**
  72480. * Gets a string describing the action executed by the current optimization
  72481. * @returns description string
  72482. */
  72483. getDescription(): string;
  72484. /**
  72485. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72486. * @param scene defines the current scene where to apply this optimization
  72487. * @param optimizer defines the current optimizer
  72488. * @returns true if everything that can be done was applied
  72489. */
  72490. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72491. /**
  72492. * Creates the SceneOptimization object
  72493. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72494. * @param desc defines the description associated with the optimization
  72495. */
  72496. constructor(
  72497. /**
  72498. * Defines the priority of this optimization (0 by default which means first in the list)
  72499. */
  72500. priority?: number);
  72501. }
  72502. /**
  72503. * Defines an optimization used to reduce the size of render target textures
  72504. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72505. */
  72506. export class TextureOptimization extends SceneOptimization {
  72507. /**
  72508. * Defines the priority of this optimization (0 by default which means first in the list)
  72509. */
  72510. priority: number;
  72511. /**
  72512. * 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
  72513. */
  72514. maximumSize: number;
  72515. /**
  72516. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72517. */
  72518. step: number;
  72519. /**
  72520. * Gets a string describing the action executed by the current optimization
  72521. * @returns description string
  72522. */
  72523. getDescription(): string;
  72524. /**
  72525. * Creates the TextureOptimization object
  72526. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72527. * @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
  72528. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72529. */
  72530. constructor(
  72531. /**
  72532. * Defines the priority of this optimization (0 by default which means first in the list)
  72533. */
  72534. priority?: number,
  72535. /**
  72536. * 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
  72537. */
  72538. maximumSize?: number,
  72539. /**
  72540. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72541. */
  72542. step?: number);
  72543. /**
  72544. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72545. * @param scene defines the current scene where to apply this optimization
  72546. * @param optimizer defines the current optimizer
  72547. * @returns true if everything that can be done was applied
  72548. */
  72549. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72550. }
  72551. /**
  72552. * Defines an optimization used to increase or decrease the rendering resolution
  72553. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72554. */
  72555. export class HardwareScalingOptimization extends SceneOptimization {
  72556. /**
  72557. * Defines the priority of this optimization (0 by default which means first in the list)
  72558. */
  72559. priority: number;
  72560. /**
  72561. * Defines the maximum scale to use (2 by default)
  72562. */
  72563. maximumScale: number;
  72564. /**
  72565. * Defines the step to use between two passes (0.5 by default)
  72566. */
  72567. step: number;
  72568. private _currentScale;
  72569. private _directionOffset;
  72570. /**
  72571. * Gets a string describing the action executed by the current optimization
  72572. * @return description string
  72573. */
  72574. getDescription(): string;
  72575. /**
  72576. * Creates the HardwareScalingOptimization object
  72577. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72578. * @param maximumScale defines the maximum scale to use (2 by default)
  72579. * @param step defines the step to use between two passes (0.5 by default)
  72580. */
  72581. constructor(
  72582. /**
  72583. * Defines the priority of this optimization (0 by default which means first in the list)
  72584. */
  72585. priority?: number,
  72586. /**
  72587. * Defines the maximum scale to use (2 by default)
  72588. */
  72589. maximumScale?: number,
  72590. /**
  72591. * Defines the step to use between two passes (0.5 by default)
  72592. */
  72593. step?: number);
  72594. /**
  72595. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72596. * @param scene defines the current scene where to apply this optimization
  72597. * @param optimizer defines the current optimizer
  72598. * @returns true if everything that can be done was applied
  72599. */
  72600. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72601. }
  72602. /**
  72603. * Defines an optimization used to remove shadows
  72604. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72605. */
  72606. export class ShadowsOptimization extends SceneOptimization {
  72607. /**
  72608. * Gets a string describing the action executed by the current optimization
  72609. * @return description string
  72610. */
  72611. getDescription(): string;
  72612. /**
  72613. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72614. * @param scene defines the current scene where to apply this optimization
  72615. * @param optimizer defines the current optimizer
  72616. * @returns true if everything that can be done was applied
  72617. */
  72618. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72619. }
  72620. /**
  72621. * Defines an optimization used to turn post-processes off
  72622. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72623. */
  72624. export class PostProcessesOptimization extends SceneOptimization {
  72625. /**
  72626. * Gets a string describing the action executed by the current optimization
  72627. * @return description string
  72628. */
  72629. getDescription(): string;
  72630. /**
  72631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72632. * @param scene defines the current scene where to apply this optimization
  72633. * @param optimizer defines the current optimizer
  72634. * @returns true if everything that can be done was applied
  72635. */
  72636. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72637. }
  72638. /**
  72639. * Defines an optimization used to turn lens flares off
  72640. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72641. */
  72642. export class LensFlaresOptimization extends SceneOptimization {
  72643. /**
  72644. * Gets a string describing the action executed by the current optimization
  72645. * @return description string
  72646. */
  72647. getDescription(): string;
  72648. /**
  72649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72650. * @param scene defines the current scene where to apply this optimization
  72651. * @param optimizer defines the current optimizer
  72652. * @returns true if everything that can be done was applied
  72653. */
  72654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72655. }
  72656. /**
  72657. * Defines an optimization based on user defined callback.
  72658. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72659. */
  72660. export class CustomOptimization extends SceneOptimization {
  72661. /**
  72662. * Callback called to apply the custom optimization.
  72663. */
  72664. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72665. /**
  72666. * Callback called to get custom description
  72667. */
  72668. onGetDescription: () => string;
  72669. /**
  72670. * Gets a string describing the action executed by the current optimization
  72671. * @returns description string
  72672. */
  72673. getDescription(): string;
  72674. /**
  72675. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72676. * @param scene defines the current scene where to apply this optimization
  72677. * @param optimizer defines the current optimizer
  72678. * @returns true if everything that can be done was applied
  72679. */
  72680. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72681. }
  72682. /**
  72683. * Defines an optimization used to turn particles off
  72684. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72685. */
  72686. export class ParticlesOptimization extends SceneOptimization {
  72687. /**
  72688. * Gets a string describing the action executed by the current optimization
  72689. * @return description string
  72690. */
  72691. getDescription(): string;
  72692. /**
  72693. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72694. * @param scene defines the current scene where to apply this optimization
  72695. * @param optimizer defines the current optimizer
  72696. * @returns true if everything that can be done was applied
  72697. */
  72698. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72699. }
  72700. /**
  72701. * Defines an optimization used to turn render targets off
  72702. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72703. */
  72704. export class RenderTargetsOptimization extends SceneOptimization {
  72705. /**
  72706. * Gets a string describing the action executed by the current optimization
  72707. * @return description string
  72708. */
  72709. getDescription(): string;
  72710. /**
  72711. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72712. * @param scene defines the current scene where to apply this optimization
  72713. * @param optimizer defines the current optimizer
  72714. * @returns true if everything that can be done was applied
  72715. */
  72716. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72717. }
  72718. /**
  72719. * Defines an optimization used to merge meshes with compatible materials
  72720. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72721. */
  72722. export class MergeMeshesOptimization extends SceneOptimization {
  72723. private static _UpdateSelectionTree;
  72724. /**
  72725. * Gets or sets a boolean which defines if optimization octree has to be updated
  72726. */
  72727. static get UpdateSelectionTree(): boolean;
  72728. /**
  72729. * Gets or sets a boolean which defines if optimization octree has to be updated
  72730. */
  72731. static set UpdateSelectionTree(value: boolean);
  72732. /**
  72733. * Gets a string describing the action executed by the current optimization
  72734. * @return description string
  72735. */
  72736. getDescription(): string;
  72737. private _canBeMerged;
  72738. /**
  72739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72740. * @param scene defines the current scene where to apply this optimization
  72741. * @param optimizer defines the current optimizer
  72742. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72743. * @returns true if everything that can be done was applied
  72744. */
  72745. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72746. }
  72747. /**
  72748. * Defines a list of options used by SceneOptimizer
  72749. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72750. */
  72751. export class SceneOptimizerOptions {
  72752. /**
  72753. * Defines the target frame rate to reach (60 by default)
  72754. */
  72755. targetFrameRate: number;
  72756. /**
  72757. * Defines the interval between two checkes (2000ms by default)
  72758. */
  72759. trackerDuration: number;
  72760. /**
  72761. * Gets the list of optimizations to apply
  72762. */
  72763. optimizations: SceneOptimization[];
  72764. /**
  72765. * Creates a new list of options used by SceneOptimizer
  72766. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72767. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72768. */
  72769. constructor(
  72770. /**
  72771. * Defines the target frame rate to reach (60 by default)
  72772. */
  72773. targetFrameRate?: number,
  72774. /**
  72775. * Defines the interval between two checkes (2000ms by default)
  72776. */
  72777. trackerDuration?: number);
  72778. /**
  72779. * Add a new optimization
  72780. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72781. * @returns the current SceneOptimizerOptions
  72782. */
  72783. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72784. /**
  72785. * Add a new custom optimization
  72786. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72787. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72788. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72789. * @returns the current SceneOptimizerOptions
  72790. */
  72791. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72792. /**
  72793. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72794. * @param targetFrameRate defines the target frame rate (60 by default)
  72795. * @returns a SceneOptimizerOptions object
  72796. */
  72797. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72798. /**
  72799. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72800. * @param targetFrameRate defines the target frame rate (60 by default)
  72801. * @returns a SceneOptimizerOptions object
  72802. */
  72803. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72804. /**
  72805. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72806. * @param targetFrameRate defines the target frame rate (60 by default)
  72807. * @returns a SceneOptimizerOptions object
  72808. */
  72809. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72810. }
  72811. /**
  72812. * Class used to run optimizations in order to reach a target frame rate
  72813. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72814. */
  72815. export class SceneOptimizer implements IDisposable {
  72816. private _isRunning;
  72817. private _options;
  72818. private _scene;
  72819. private _currentPriorityLevel;
  72820. private _targetFrameRate;
  72821. private _trackerDuration;
  72822. private _currentFrameRate;
  72823. private _sceneDisposeObserver;
  72824. private _improvementMode;
  72825. /**
  72826. * Defines an observable called when the optimizer reaches the target frame rate
  72827. */
  72828. onSuccessObservable: Observable<SceneOptimizer>;
  72829. /**
  72830. * Defines an observable called when the optimizer enables an optimization
  72831. */
  72832. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72833. /**
  72834. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72835. */
  72836. onFailureObservable: Observable<SceneOptimizer>;
  72837. /**
  72838. * Gets a boolean indicating if the optimizer is in improvement mode
  72839. */
  72840. get isInImprovementMode(): boolean;
  72841. /**
  72842. * Gets the current priority level (0 at start)
  72843. */
  72844. get currentPriorityLevel(): number;
  72845. /**
  72846. * Gets the current frame rate checked by the SceneOptimizer
  72847. */
  72848. get currentFrameRate(): number;
  72849. /**
  72850. * Gets or sets the current target frame rate (60 by default)
  72851. */
  72852. get targetFrameRate(): number;
  72853. /**
  72854. * Gets or sets the current target frame rate (60 by default)
  72855. */
  72856. set targetFrameRate(value: number);
  72857. /**
  72858. * Gets or sets the current interval between two checks (every 2000ms by default)
  72859. */
  72860. get trackerDuration(): number;
  72861. /**
  72862. * Gets or sets the current interval between two checks (every 2000ms by default)
  72863. */
  72864. set trackerDuration(value: number);
  72865. /**
  72866. * Gets the list of active optimizations
  72867. */
  72868. get optimizations(): SceneOptimization[];
  72869. /**
  72870. * Creates a new SceneOptimizer
  72871. * @param scene defines the scene to work on
  72872. * @param options defines the options to use with the SceneOptimizer
  72873. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72874. * @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)
  72875. */
  72876. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72877. /**
  72878. * Stops the current optimizer
  72879. */
  72880. stop(): void;
  72881. /**
  72882. * Reset the optimizer to initial step (current priority level = 0)
  72883. */
  72884. reset(): void;
  72885. /**
  72886. * Start the optimizer. By default it will try to reach a specific framerate
  72887. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72888. */
  72889. start(): void;
  72890. private _checkCurrentState;
  72891. /**
  72892. * Release all resources
  72893. */
  72894. dispose(): void;
  72895. /**
  72896. * Helper function to create a SceneOptimizer with one single line of code
  72897. * @param scene defines the scene to work on
  72898. * @param options defines the options to use with the SceneOptimizer
  72899. * @param onSuccess defines a callback to call on success
  72900. * @param onFailure defines a callback to call on failure
  72901. * @returns the new SceneOptimizer object
  72902. */
  72903. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72904. }
  72905. }
  72906. declare module BABYLON {
  72907. /**
  72908. * Class used to serialize a scene into a string
  72909. */
  72910. export class SceneSerializer {
  72911. /**
  72912. * Clear cache used by a previous serialization
  72913. */
  72914. static ClearCache(): void;
  72915. /**
  72916. * Serialize a scene into a JSON compatible object
  72917. * @param scene defines the scene to serialize
  72918. * @returns a JSON compatible object
  72919. */
  72920. static Serialize(scene: Scene): any;
  72921. /**
  72922. * Serialize a mesh into a JSON compatible object
  72923. * @param toSerialize defines the mesh to serialize
  72924. * @param withParents defines if parents must be serialized as well
  72925. * @param withChildren defines if children must be serialized as well
  72926. * @returns a JSON compatible object
  72927. */
  72928. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72929. }
  72930. }
  72931. declare module BABYLON {
  72932. /**
  72933. * Class used to host texture specific utilities
  72934. */
  72935. export class TextureTools {
  72936. /**
  72937. * Uses the GPU to create a copy texture rescaled at a given size
  72938. * @param texture Texture to copy from
  72939. * @param width defines the desired width
  72940. * @param height defines the desired height
  72941. * @param useBilinearMode defines if bilinear mode has to be used
  72942. * @return the generated texture
  72943. */
  72944. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72945. }
  72946. }
  72947. declare module BABYLON {
  72948. /**
  72949. * This represents the different options available for the video capture.
  72950. */
  72951. export interface VideoRecorderOptions {
  72952. /** Defines the mime type of the video. */
  72953. mimeType: string;
  72954. /** Defines the FPS the video should be recorded at. */
  72955. fps: number;
  72956. /** Defines the chunk size for the recording data. */
  72957. recordChunckSize: number;
  72958. /** The audio tracks to attach to the recording. */
  72959. audioTracks?: MediaStreamTrack[];
  72960. }
  72961. /**
  72962. * This can help with recording videos from BabylonJS.
  72963. * This is based on the available WebRTC functionalities of the browser.
  72964. *
  72965. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  72966. */
  72967. export class VideoRecorder {
  72968. private static readonly _defaultOptions;
  72969. /**
  72970. * Returns whether or not the VideoRecorder is available in your browser.
  72971. * @param engine Defines the Babylon Engine.
  72972. * @returns true if supported otherwise false.
  72973. */
  72974. static IsSupported(engine: Engine): boolean;
  72975. private readonly _options;
  72976. private _canvas;
  72977. private _mediaRecorder;
  72978. private _recordedChunks;
  72979. private _fileName;
  72980. private _resolve;
  72981. private _reject;
  72982. /**
  72983. * True when a recording is already in progress.
  72984. */
  72985. get isRecording(): boolean;
  72986. /**
  72987. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72988. * @param engine Defines the BabylonJS Engine you wish to record.
  72989. * @param options Defines options that can be used to customize the capture.
  72990. */
  72991. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72992. /**
  72993. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72994. */
  72995. stopRecording(): void;
  72996. /**
  72997. * Starts recording the canvas for a max duration specified in parameters.
  72998. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72999. * If null no automatic download will start and you can rely on the promise to get the data back.
  73000. * @param maxDuration Defines the maximum recording time in seconds.
  73001. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73002. * @return A promise callback at the end of the recording with the video data in Blob.
  73003. */
  73004. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73005. /**
  73006. * Releases internal resources used during the recording.
  73007. */
  73008. dispose(): void;
  73009. private _handleDataAvailable;
  73010. private _handleError;
  73011. private _handleStop;
  73012. }
  73013. }
  73014. declare module BABYLON {
  73015. /**
  73016. * Class containing a set of static utilities functions for screenshots
  73017. */
  73018. export class ScreenshotTools {
  73019. /**
  73020. * Captures a screenshot of the current rendering
  73021. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73022. * @param engine defines the rendering engine
  73023. * @param camera defines the source camera
  73024. * @param size This parameter can be set to a single number or to an object with the
  73025. * following (optional) properties: precision, width, height. If a single number is passed,
  73026. * it will be used for both width and height. If an object is passed, the screenshot size
  73027. * will be derived from the parameters. The precision property is a multiplier allowing
  73028. * rendering at a higher or lower resolution
  73029. * @param successCallback defines the callback receives a single parameter which contains the
  73030. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73031. * src parameter of an <img> to display it
  73032. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73033. * Check your browser for supported MIME types
  73034. */
  73035. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73036. /**
  73037. * Captures a screenshot of the current rendering
  73038. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73039. * @param engine defines the rendering engine
  73040. * @param camera defines the source camera
  73041. * @param size This parameter can be set to a single number or to an object with the
  73042. * following (optional) properties: precision, width, height. If a single number is passed,
  73043. * it will be used for both width and height. If an object is passed, the screenshot size
  73044. * will be derived from the parameters. The precision property is a multiplier allowing
  73045. * rendering at a higher or lower resolution
  73046. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73047. * Check your browser for supported MIME types
  73048. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73049. * to the src parameter of an <img> to display it
  73050. */
  73051. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73052. /**
  73053. * Generates an image screenshot from the specified camera.
  73054. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73055. * @param engine The engine to use for rendering
  73056. * @param camera The camera to use for rendering
  73057. * @param size This parameter can be set to a single number or to an object with the
  73058. * following (optional) properties: precision, width, height. If a single number is passed,
  73059. * it will be used for both width and height. If an object is passed, the screenshot size
  73060. * will be derived from the parameters. The precision property is a multiplier allowing
  73061. * rendering at a higher or lower resolution
  73062. * @param successCallback The callback receives a single parameter which contains the
  73063. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73064. * src parameter of an <img> to display it
  73065. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73066. * Check your browser for supported MIME types
  73067. * @param samples Texture samples (default: 1)
  73068. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73069. * @param fileName A name for for the downloaded file.
  73070. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73071. */
  73072. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73073. /**
  73074. * Generates an image screenshot from the specified camera.
  73075. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73076. * @param engine The engine to use for rendering
  73077. * @param camera The camera to use for rendering
  73078. * @param size This parameter can be set to a single number or to an object with the
  73079. * following (optional) properties: precision, width, height. If a single number is passed,
  73080. * it will be used for both width and height. If an object is passed, the screenshot size
  73081. * will be derived from the parameters. The precision property is a multiplier allowing
  73082. * rendering at a higher or lower resolution
  73083. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73084. * Check your browser for supported MIME types
  73085. * @param samples Texture samples (default: 1)
  73086. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73087. * @param fileName A name for for the downloaded file.
  73088. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73089. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73090. * to the src parameter of an <img> to display it
  73091. */
  73092. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73093. /**
  73094. * Gets height and width for screenshot size
  73095. * @private
  73096. */
  73097. private static _getScreenshotSize;
  73098. }
  73099. }
  73100. declare module BABYLON {
  73101. /**
  73102. * Interface for a data buffer
  73103. */
  73104. export interface IDataBuffer {
  73105. /**
  73106. * Reads bytes from the data buffer.
  73107. * @param byteOffset The byte offset to read
  73108. * @param byteLength The byte length to read
  73109. * @returns A promise that resolves when the bytes are read
  73110. */
  73111. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73112. /**
  73113. * The byte length of the buffer.
  73114. */
  73115. readonly byteLength: number;
  73116. }
  73117. /**
  73118. * Utility class for reading from a data buffer
  73119. */
  73120. export class DataReader {
  73121. /**
  73122. * The data buffer associated with this data reader.
  73123. */
  73124. readonly buffer: IDataBuffer;
  73125. /**
  73126. * The current byte offset from the beginning of the data buffer.
  73127. */
  73128. byteOffset: number;
  73129. private _dataView;
  73130. private _dataByteOffset;
  73131. /**
  73132. * Constructor
  73133. * @param buffer The buffer to read
  73134. */
  73135. constructor(buffer: IDataBuffer);
  73136. /**
  73137. * Loads the given byte length.
  73138. * @param byteLength The byte length to load
  73139. * @returns A promise that resolves when the load is complete
  73140. */
  73141. loadAsync(byteLength: number): Promise<void>;
  73142. /**
  73143. * Read a unsigned 32-bit integer from the currently loaded data range.
  73144. * @returns The 32-bit integer read
  73145. */
  73146. readUint32(): number;
  73147. /**
  73148. * Read a byte array from the currently loaded data range.
  73149. * @param byteLength The byte length to read
  73150. * @returns The byte array read
  73151. */
  73152. readUint8Array(byteLength: number): Uint8Array;
  73153. /**
  73154. * Read a string from the currently loaded data range.
  73155. * @param byteLength The byte length to read
  73156. * @returns The string read
  73157. */
  73158. readString(byteLength: number): string;
  73159. /**
  73160. * Skips the given byte length the currently loaded data range.
  73161. * @param byteLength The byte length to skip
  73162. */
  73163. skipBytes(byteLength: number): void;
  73164. }
  73165. }
  73166. declare module BABYLON {
  73167. /**
  73168. * Class for storing data to local storage if available or in-memory storage otherwise
  73169. */
  73170. export class DataStorage {
  73171. private static _Storage;
  73172. private static _GetStorage;
  73173. /**
  73174. * Reads a string from the data storage
  73175. * @param key The key to read
  73176. * @param defaultValue The value if the key doesn't exist
  73177. * @returns The string value
  73178. */
  73179. static ReadString(key: string, defaultValue: string): string;
  73180. /**
  73181. * Writes a string to the data storage
  73182. * @param key The key to write
  73183. * @param value The value to write
  73184. */
  73185. static WriteString(key: string, value: string): void;
  73186. /**
  73187. * Reads a boolean from the data storage
  73188. * @param key The key to read
  73189. * @param defaultValue The value if the key doesn't exist
  73190. * @returns The boolean value
  73191. */
  73192. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73193. /**
  73194. * Writes a boolean to the data storage
  73195. * @param key The key to write
  73196. * @param value The value to write
  73197. */
  73198. static WriteBoolean(key: string, value: boolean): void;
  73199. /**
  73200. * Reads a number from the data storage
  73201. * @param key The key to read
  73202. * @param defaultValue The value if the key doesn't exist
  73203. * @returns The number value
  73204. */
  73205. static ReadNumber(key: string, defaultValue: number): number;
  73206. /**
  73207. * Writes a number to the data storage
  73208. * @param key The key to write
  73209. * @param value The value to write
  73210. */
  73211. static WriteNumber(key: string, value: number): void;
  73212. }
  73213. }
  73214. declare module BABYLON {
  73215. /**
  73216. * An interface for all Hit test features
  73217. */
  73218. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73219. /**
  73220. * Triggered when new babylon (transformed) hit test results are available
  73221. */
  73222. onHitTestResultObservable: Observable<T[]>;
  73223. }
  73224. /**
  73225. * Options used for hit testing
  73226. */
  73227. export interface IWebXRLegacyHitTestOptions {
  73228. /**
  73229. * Only test when user interacted with the scene. Default - hit test every frame
  73230. */
  73231. testOnPointerDownOnly?: boolean;
  73232. /**
  73233. * The node to use to transform the local results to world coordinates
  73234. */
  73235. worldParentNode?: TransformNode;
  73236. }
  73237. /**
  73238. * Interface defining the babylon result of raycasting/hit-test
  73239. */
  73240. export interface IWebXRLegacyHitResult {
  73241. /**
  73242. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73243. */
  73244. transformationMatrix: Matrix;
  73245. /**
  73246. * The native hit test result
  73247. */
  73248. xrHitResult: XRHitResult | XRHitTestResult;
  73249. }
  73250. /**
  73251. * The currently-working hit-test module.
  73252. * Hit test (or Ray-casting) is used to interact with the real world.
  73253. * For further information read here - https://github.com/immersive-web/hit-test
  73254. */
  73255. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73256. /**
  73257. * options to use when constructing this feature
  73258. */
  73259. readonly options: IWebXRLegacyHitTestOptions;
  73260. private _direction;
  73261. private _mat;
  73262. private _onSelectEnabled;
  73263. private _origin;
  73264. /**
  73265. * The module's name
  73266. */
  73267. static readonly Name: string;
  73268. /**
  73269. * The (Babylon) version of this module.
  73270. * This is an integer representing the implementation version.
  73271. * This number does not correspond to the WebXR specs version
  73272. */
  73273. static readonly Version: number;
  73274. /**
  73275. * Populated with the last native XR Hit Results
  73276. */
  73277. lastNativeXRHitResults: XRHitResult[];
  73278. /**
  73279. * Triggered when new babylon (transformed) hit test results are available
  73280. */
  73281. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73282. /**
  73283. * Creates a new instance of the (legacy version) hit test feature
  73284. * @param _xrSessionManager an instance of WebXRSessionManager
  73285. * @param options options to use when constructing this feature
  73286. */
  73287. constructor(_xrSessionManager: WebXRSessionManager,
  73288. /**
  73289. * options to use when constructing this feature
  73290. */
  73291. options?: IWebXRLegacyHitTestOptions);
  73292. /**
  73293. * execute a hit test with an XR Ray
  73294. *
  73295. * @param xrSession a native xrSession that will execute this hit test
  73296. * @param xrRay the ray (position and direction) to use for ray-casting
  73297. * @param referenceSpace native XR reference space to use for the hit-test
  73298. * @param filter filter function that will filter the results
  73299. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73300. */
  73301. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73302. /**
  73303. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73304. * @param event the (select) event to use to select with
  73305. * @param referenceSpace the reference space to use for this hit test
  73306. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73307. */
  73308. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73309. /**
  73310. * attach this feature
  73311. * Will usually be called by the features manager
  73312. *
  73313. * @returns true if successful.
  73314. */
  73315. attach(): boolean;
  73316. /**
  73317. * detach this feature.
  73318. * Will usually be called by the features manager
  73319. *
  73320. * @returns true if successful.
  73321. */
  73322. detach(): boolean;
  73323. /**
  73324. * Dispose this feature and all of the resources attached
  73325. */
  73326. dispose(): void;
  73327. protected _onXRFrame(frame: XRFrame): void;
  73328. private _onHitTestResults;
  73329. private _onSelect;
  73330. }
  73331. }
  73332. declare module BABYLON {
  73333. /**
  73334. * Options used for hit testing (version 2)
  73335. */
  73336. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73337. /**
  73338. * Do not create a permanent hit test. Will usually be used when only
  73339. * transient inputs are needed.
  73340. */
  73341. disablePermanentHitTest?: boolean;
  73342. /**
  73343. * Enable transient (for example touch-based) hit test inspections
  73344. */
  73345. enableTransientHitTest?: boolean;
  73346. /**
  73347. * Offset ray for the permanent hit test
  73348. */
  73349. offsetRay?: Vector3;
  73350. /**
  73351. * Offset ray for the transient hit test
  73352. */
  73353. transientOffsetRay?: Vector3;
  73354. /**
  73355. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73356. */
  73357. useReferenceSpace?: boolean;
  73358. }
  73359. /**
  73360. * Interface defining the babylon result of hit-test
  73361. */
  73362. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73363. /**
  73364. * The input source that generated this hit test (if transient)
  73365. */
  73366. inputSource?: XRInputSource;
  73367. /**
  73368. * Is this a transient hit test
  73369. */
  73370. isTransient?: boolean;
  73371. /**
  73372. * Position of the hit test result
  73373. */
  73374. position: Vector3;
  73375. /**
  73376. * Rotation of the hit test result
  73377. */
  73378. rotationQuaternion: Quaternion;
  73379. /**
  73380. * The native hit test result
  73381. */
  73382. xrHitResult: XRHitTestResult;
  73383. }
  73384. /**
  73385. * The currently-working hit-test module.
  73386. * Hit test (or Ray-casting) is used to interact with the real world.
  73387. * For further information read here - https://github.com/immersive-web/hit-test
  73388. *
  73389. * Tested on chrome (mobile) 80.
  73390. */
  73391. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73392. /**
  73393. * options to use when constructing this feature
  73394. */
  73395. readonly options: IWebXRHitTestOptions;
  73396. private _tmpMat;
  73397. private _tmpPos;
  73398. private _tmpQuat;
  73399. private _transientXrHitTestSource;
  73400. private _xrHitTestSource;
  73401. private initHitTestSource;
  73402. /**
  73403. * The module's name
  73404. */
  73405. static readonly Name: string;
  73406. /**
  73407. * The (Babylon) version of this module.
  73408. * This is an integer representing the implementation version.
  73409. * This number does not correspond to the WebXR specs version
  73410. */
  73411. static readonly Version: number;
  73412. /**
  73413. * When set to true, each hit test will have its own position/rotation objects
  73414. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73415. * the developers will clone them or copy them as they see fit.
  73416. */
  73417. autoCloneTransformation: boolean;
  73418. /**
  73419. * Triggered when new babylon (transformed) hit test results are available
  73420. */
  73421. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73422. /**
  73423. * Use this to temporarily pause hit test checks.
  73424. */
  73425. paused: boolean;
  73426. /**
  73427. * Creates a new instance of the hit test feature
  73428. * @param _xrSessionManager an instance of WebXRSessionManager
  73429. * @param options options to use when constructing this feature
  73430. */
  73431. constructor(_xrSessionManager: WebXRSessionManager,
  73432. /**
  73433. * options to use when constructing this feature
  73434. */
  73435. options?: IWebXRHitTestOptions);
  73436. /**
  73437. * attach this feature
  73438. * Will usually be called by the features manager
  73439. *
  73440. * @returns true if successful.
  73441. */
  73442. attach(): boolean;
  73443. /**
  73444. * detach this feature.
  73445. * Will usually be called by the features manager
  73446. *
  73447. * @returns true if successful.
  73448. */
  73449. detach(): boolean;
  73450. /**
  73451. * Dispose this feature and all of the resources attached
  73452. */
  73453. dispose(): void;
  73454. protected _onXRFrame(frame: XRFrame): void;
  73455. private _processWebXRHitTestResult;
  73456. }
  73457. }
  73458. declare module BABYLON {
  73459. /**
  73460. * Configuration options of the anchor system
  73461. */
  73462. export interface IWebXRAnchorSystemOptions {
  73463. /**
  73464. * a node that will be used to convert local to world coordinates
  73465. */
  73466. worldParentNode?: TransformNode;
  73467. /**
  73468. * If set to true a reference of the created anchors will be kept until the next session starts
  73469. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73470. */
  73471. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73472. }
  73473. /**
  73474. * A babylon container for an XR Anchor
  73475. */
  73476. export interface IWebXRAnchor {
  73477. /**
  73478. * A babylon-assigned ID for this anchor
  73479. */
  73480. id: number;
  73481. /**
  73482. * Transformation matrix to apply to an object attached to this anchor
  73483. */
  73484. transformationMatrix: Matrix;
  73485. /**
  73486. * The native anchor object
  73487. */
  73488. xrAnchor: XRAnchor;
  73489. /**
  73490. * if defined, this object will be constantly updated by the anchor's position and rotation
  73491. */
  73492. attachedNode?: TransformNode;
  73493. }
  73494. /**
  73495. * An implementation of the anchor system for WebXR.
  73496. * For further information see https://github.com/immersive-web/anchors/
  73497. */
  73498. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73499. private _options;
  73500. private _lastFrameDetected;
  73501. private _trackedAnchors;
  73502. private _referenceSpaceForFrameAnchors;
  73503. private _futureAnchors;
  73504. /**
  73505. * The module's name
  73506. */
  73507. static readonly Name: string;
  73508. /**
  73509. * The (Babylon) version of this module.
  73510. * This is an integer representing the implementation version.
  73511. * This number does not correspond to the WebXR specs version
  73512. */
  73513. static readonly Version: number;
  73514. /**
  73515. * Observers registered here will be executed when a new anchor was added to the session
  73516. */
  73517. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73518. /**
  73519. * Observers registered here will be executed when an anchor was removed from the session
  73520. */
  73521. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73522. /**
  73523. * Observers registered here will be executed when an existing anchor updates
  73524. * This can execute N times every frame
  73525. */
  73526. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73527. /**
  73528. * Set the reference space to use for anchor creation, when not using a hit test.
  73529. * Will default to the session's reference space if not defined
  73530. */
  73531. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73532. /**
  73533. * constructs a new anchor system
  73534. * @param _xrSessionManager an instance of WebXRSessionManager
  73535. * @param _options configuration object for this feature
  73536. */
  73537. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73538. private _tmpVector;
  73539. private _tmpQuaternion;
  73540. private _populateTmpTransformation;
  73541. /**
  73542. * Create a new anchor point using a hit test result at a specific point in the scene
  73543. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73544. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73545. *
  73546. * @param hitTestResult The hit test result to use for this anchor creation
  73547. * @param position an optional position offset for this anchor
  73548. * @param rotationQuaternion an optional rotation offset for this anchor
  73549. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73550. */
  73551. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73552. /**
  73553. * Add a new anchor at a specific position and rotation
  73554. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73555. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73556. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73557. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73558. *
  73559. * @param position the position in which to add an anchor
  73560. * @param rotationQuaternion an optional rotation for the anchor transformation
  73561. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73562. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73563. */
  73564. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73565. /**
  73566. * detach this feature.
  73567. * Will usually be called by the features manager
  73568. *
  73569. * @returns true if successful.
  73570. */
  73571. detach(): boolean;
  73572. /**
  73573. * Dispose this feature and all of the resources attached
  73574. */
  73575. dispose(): void;
  73576. protected _onXRFrame(frame: XRFrame): void;
  73577. /**
  73578. * avoiding using Array.find for global support.
  73579. * @param xrAnchor the plane to find in the array
  73580. */
  73581. private _findIndexInAnchorArray;
  73582. private _updateAnchorWithXRFrame;
  73583. private _createAnchorAtTransformation;
  73584. }
  73585. }
  73586. declare module BABYLON {
  73587. /**
  73588. * Options used in the plane detector module
  73589. */
  73590. export interface IWebXRPlaneDetectorOptions {
  73591. /**
  73592. * The node to use to transform the local results to world coordinates
  73593. */
  73594. worldParentNode?: TransformNode;
  73595. /**
  73596. * If set to true a reference of the created planes will be kept until the next session starts
  73597. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73598. */
  73599. doNotRemovePlanesOnSessionEnded?: boolean;
  73600. }
  73601. /**
  73602. * A babylon interface for a WebXR plane.
  73603. * A Plane is actually a polygon, built from N points in space
  73604. *
  73605. * Supported in chrome 79, not supported in canary 81 ATM
  73606. */
  73607. export interface IWebXRPlane {
  73608. /**
  73609. * a babylon-assigned ID for this polygon
  73610. */
  73611. id: number;
  73612. /**
  73613. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73614. */
  73615. polygonDefinition: Array<Vector3>;
  73616. /**
  73617. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73618. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73619. */
  73620. transformationMatrix: Matrix;
  73621. /**
  73622. * the native xr-plane object
  73623. */
  73624. xrPlane: XRPlane;
  73625. }
  73626. /**
  73627. * The plane detector is used to detect planes in the real world when in AR
  73628. * For more information see https://github.com/immersive-web/real-world-geometry/
  73629. */
  73630. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73631. private _options;
  73632. private _detectedPlanes;
  73633. private _enabled;
  73634. private _lastFrameDetected;
  73635. /**
  73636. * The module's name
  73637. */
  73638. static readonly Name: string;
  73639. /**
  73640. * The (Babylon) version of this module.
  73641. * This is an integer representing the implementation version.
  73642. * This number does not correspond to the WebXR specs version
  73643. */
  73644. static readonly Version: number;
  73645. /**
  73646. * Observers registered here will be executed when a new plane was added to the session
  73647. */
  73648. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73649. /**
  73650. * Observers registered here will be executed when a plane is no longer detected in the session
  73651. */
  73652. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73653. /**
  73654. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73655. * This can execute N times every frame
  73656. */
  73657. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73658. /**
  73659. * construct a new Plane Detector
  73660. * @param _xrSessionManager an instance of xr Session manager
  73661. * @param _options configuration to use when constructing this feature
  73662. */
  73663. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73664. /**
  73665. * detach this feature.
  73666. * Will usually be called by the features manager
  73667. *
  73668. * @returns true if successful.
  73669. */
  73670. detach(): boolean;
  73671. /**
  73672. * Dispose this feature and all of the resources attached
  73673. */
  73674. dispose(): void;
  73675. protected _onXRFrame(frame: XRFrame): void;
  73676. private _init;
  73677. private _updatePlaneWithXRPlane;
  73678. /**
  73679. * avoiding using Array.find for global support.
  73680. * @param xrPlane the plane to find in the array
  73681. */
  73682. private findIndexInPlaneArray;
  73683. }
  73684. }
  73685. declare module BABYLON {
  73686. /**
  73687. * Options interface for the background remover plugin
  73688. */
  73689. export interface IWebXRBackgroundRemoverOptions {
  73690. /**
  73691. * Further background meshes to disable when entering AR
  73692. */
  73693. backgroundMeshes?: AbstractMesh[];
  73694. /**
  73695. * flags to configure the removal of the environment helper.
  73696. * If not set, the entire background will be removed. If set, flags should be set as well.
  73697. */
  73698. environmentHelperRemovalFlags?: {
  73699. /**
  73700. * Should the skybox be removed (default false)
  73701. */
  73702. skyBox?: boolean;
  73703. /**
  73704. * Should the ground be removed (default false)
  73705. */
  73706. ground?: boolean;
  73707. };
  73708. /**
  73709. * don't disable the environment helper
  73710. */
  73711. ignoreEnvironmentHelper?: boolean;
  73712. }
  73713. /**
  73714. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73715. */
  73716. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73717. /**
  73718. * read-only options to be used in this module
  73719. */
  73720. readonly options: IWebXRBackgroundRemoverOptions;
  73721. /**
  73722. * The module's name
  73723. */
  73724. static readonly Name: string;
  73725. /**
  73726. * The (Babylon) version of this module.
  73727. * This is an integer representing the implementation version.
  73728. * This number does not correspond to the WebXR specs version
  73729. */
  73730. static readonly Version: number;
  73731. /**
  73732. * registered observers will be triggered when the background state changes
  73733. */
  73734. onBackgroundStateChangedObservable: Observable<boolean>;
  73735. /**
  73736. * constructs a new background remover module
  73737. * @param _xrSessionManager the session manager for this module
  73738. * @param options read-only options to be used in this module
  73739. */
  73740. constructor(_xrSessionManager: WebXRSessionManager,
  73741. /**
  73742. * read-only options to be used in this module
  73743. */
  73744. options?: IWebXRBackgroundRemoverOptions);
  73745. /**
  73746. * attach this feature
  73747. * Will usually be called by the features manager
  73748. *
  73749. * @returns true if successful.
  73750. */
  73751. attach(): boolean;
  73752. /**
  73753. * detach this feature.
  73754. * Will usually be called by the features manager
  73755. *
  73756. * @returns true if successful.
  73757. */
  73758. detach(): boolean;
  73759. /**
  73760. * Dispose this feature and all of the resources attached
  73761. */
  73762. dispose(): void;
  73763. protected _onXRFrame(_xrFrame: XRFrame): void;
  73764. private _setBackgroundState;
  73765. }
  73766. }
  73767. declare module BABYLON {
  73768. /**
  73769. * Options for the controller physics feature
  73770. */
  73771. export class IWebXRControllerPhysicsOptions {
  73772. /**
  73773. * Should the headset get its own impostor
  73774. */
  73775. enableHeadsetImpostor?: boolean;
  73776. /**
  73777. * Optional parameters for the headset impostor
  73778. */
  73779. headsetImpostorParams?: {
  73780. /**
  73781. * The type of impostor to create. Default is sphere
  73782. */
  73783. impostorType: number;
  73784. /**
  73785. * the size of the impostor. Defaults to 10cm
  73786. */
  73787. impostorSize?: number | {
  73788. width: number;
  73789. height: number;
  73790. depth: number;
  73791. };
  73792. /**
  73793. * Friction definitions
  73794. */
  73795. friction?: number;
  73796. /**
  73797. * Restitution
  73798. */
  73799. restitution?: number;
  73800. };
  73801. /**
  73802. * The physics properties of the future impostors
  73803. */
  73804. physicsProperties?: {
  73805. /**
  73806. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73807. * Note that this requires a physics engine that supports mesh impostors!
  73808. */
  73809. useControllerMesh?: boolean;
  73810. /**
  73811. * The type of impostor to create. Default is sphere
  73812. */
  73813. impostorType?: number;
  73814. /**
  73815. * the size of the impostor. Defaults to 10cm
  73816. */
  73817. impostorSize?: number | {
  73818. width: number;
  73819. height: number;
  73820. depth: number;
  73821. };
  73822. /**
  73823. * Friction definitions
  73824. */
  73825. friction?: number;
  73826. /**
  73827. * Restitution
  73828. */
  73829. restitution?: number;
  73830. };
  73831. /**
  73832. * the xr input to use with this pointer selection
  73833. */
  73834. xrInput: WebXRInput;
  73835. }
  73836. /**
  73837. * Add physics impostor to your webxr controllers,
  73838. * including naive calculation of their linear and angular velocity
  73839. */
  73840. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73841. private readonly _options;
  73842. private _attachController;
  73843. private _controllers;
  73844. private _debugMode;
  73845. private _delta;
  73846. private _headsetImpostor?;
  73847. private _headsetMesh?;
  73848. private _lastTimestamp;
  73849. private _tmpQuaternion;
  73850. private _tmpVector;
  73851. /**
  73852. * The module's name
  73853. */
  73854. static readonly Name: string;
  73855. /**
  73856. * The (Babylon) version of this module.
  73857. * This is an integer representing the implementation version.
  73858. * This number does not correspond to the webxr specs version
  73859. */
  73860. static readonly Version: number;
  73861. /**
  73862. * Construct a new Controller Physics Feature
  73863. * @param _xrSessionManager the corresponding xr session manager
  73864. * @param _options options to create this feature with
  73865. */
  73866. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73867. /**
  73868. * @hidden
  73869. * enable debugging - will show console outputs and the impostor mesh
  73870. */
  73871. _enablePhysicsDebug(): void;
  73872. /**
  73873. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73874. * @param xrController the controller to add
  73875. */
  73876. addController(xrController: WebXRInputSource): void;
  73877. /**
  73878. * attach this feature
  73879. * Will usually be called by the features manager
  73880. *
  73881. * @returns true if successful.
  73882. */
  73883. attach(): boolean;
  73884. /**
  73885. * detach this feature.
  73886. * Will usually be called by the features manager
  73887. *
  73888. * @returns true if successful.
  73889. */
  73890. detach(): boolean;
  73891. /**
  73892. * Get the headset impostor, if enabled
  73893. * @returns the impostor
  73894. */
  73895. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73896. /**
  73897. * Get the physics impostor of a specific controller.
  73898. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73899. * @param controller the controller or the controller id of which to get the impostor
  73900. * @returns the impostor or null
  73901. */
  73902. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73903. /**
  73904. * Update the physics properties provided in the constructor
  73905. * @param newProperties the new properties object
  73906. */
  73907. setPhysicsProperties(newProperties: {
  73908. impostorType?: number;
  73909. impostorSize?: number | {
  73910. width: number;
  73911. height: number;
  73912. depth: number;
  73913. };
  73914. friction?: number;
  73915. restitution?: number;
  73916. }): void;
  73917. protected _onXRFrame(_xrFrame: any): void;
  73918. private _detachController;
  73919. }
  73920. }
  73921. declare module BABYLON {
  73922. /**
  73923. * The motion controller class for all microsoft mixed reality controllers
  73924. */
  73925. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73926. protected readonly _mapping: {
  73927. defaultButton: {
  73928. valueNodeName: string;
  73929. unpressedNodeName: string;
  73930. pressedNodeName: string;
  73931. };
  73932. defaultAxis: {
  73933. valueNodeName: string;
  73934. minNodeName: string;
  73935. maxNodeName: string;
  73936. };
  73937. buttons: {
  73938. "xr-standard-trigger": {
  73939. rootNodeName: string;
  73940. componentProperty: string;
  73941. states: string[];
  73942. };
  73943. "xr-standard-squeeze": {
  73944. rootNodeName: string;
  73945. componentProperty: string;
  73946. states: string[];
  73947. };
  73948. "xr-standard-touchpad": {
  73949. rootNodeName: string;
  73950. labelAnchorNodeName: string;
  73951. touchPointNodeName: string;
  73952. };
  73953. "xr-standard-thumbstick": {
  73954. rootNodeName: string;
  73955. componentProperty: string;
  73956. states: string[];
  73957. };
  73958. };
  73959. axes: {
  73960. "xr-standard-touchpad": {
  73961. "x-axis": {
  73962. rootNodeName: string;
  73963. };
  73964. "y-axis": {
  73965. rootNodeName: string;
  73966. };
  73967. };
  73968. "xr-standard-thumbstick": {
  73969. "x-axis": {
  73970. rootNodeName: string;
  73971. };
  73972. "y-axis": {
  73973. rootNodeName: string;
  73974. };
  73975. };
  73976. };
  73977. };
  73978. /**
  73979. * The base url used to load the left and right controller models
  73980. */
  73981. static MODEL_BASE_URL: string;
  73982. /**
  73983. * The name of the left controller model file
  73984. */
  73985. static MODEL_LEFT_FILENAME: string;
  73986. /**
  73987. * The name of the right controller model file
  73988. */
  73989. static MODEL_RIGHT_FILENAME: string;
  73990. profileId: string;
  73991. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  73992. protected _getFilenameAndPath(): {
  73993. filename: string;
  73994. path: string;
  73995. };
  73996. protected _getModelLoadingConstraints(): boolean;
  73997. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73998. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73999. protected _updateModel(): void;
  74000. }
  74001. }
  74002. declare module BABYLON {
  74003. /**
  74004. * The motion controller class for oculus touch (quest, rift).
  74005. * This class supports legacy mapping as well the standard xr mapping
  74006. */
  74007. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74008. private _forceLegacyControllers;
  74009. private _modelRootNode;
  74010. /**
  74011. * The base url used to load the left and right controller models
  74012. */
  74013. static MODEL_BASE_URL: string;
  74014. /**
  74015. * The name of the left controller model file
  74016. */
  74017. static MODEL_LEFT_FILENAME: string;
  74018. /**
  74019. * The name of the right controller model file
  74020. */
  74021. static MODEL_RIGHT_FILENAME: string;
  74022. /**
  74023. * Base Url for the Quest controller model.
  74024. */
  74025. static QUEST_MODEL_BASE_URL: string;
  74026. profileId: string;
  74027. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74028. protected _getFilenameAndPath(): {
  74029. filename: string;
  74030. path: string;
  74031. };
  74032. protected _getModelLoadingConstraints(): boolean;
  74033. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74034. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74035. protected _updateModel(): void;
  74036. /**
  74037. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74038. * between the touch and touch 2.
  74039. */
  74040. private _isQuest;
  74041. }
  74042. }
  74043. declare module BABYLON {
  74044. /**
  74045. * The motion controller class for the standard HTC-Vive controllers
  74046. */
  74047. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74048. private _modelRootNode;
  74049. /**
  74050. * The base url used to load the left and right controller models
  74051. */
  74052. static MODEL_BASE_URL: string;
  74053. /**
  74054. * File name for the controller model.
  74055. */
  74056. static MODEL_FILENAME: string;
  74057. profileId: string;
  74058. /**
  74059. * Create a new Vive motion controller object
  74060. * @param scene the scene to use to create this controller
  74061. * @param gamepadObject the corresponding gamepad object
  74062. * @param handedness the handedness of the controller
  74063. */
  74064. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74065. protected _getFilenameAndPath(): {
  74066. filename: string;
  74067. path: string;
  74068. };
  74069. protected _getModelLoadingConstraints(): boolean;
  74070. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74071. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74072. protected _updateModel(): void;
  74073. }
  74074. }
  74075. declare module BABYLON {
  74076. /**
  74077. * A cursor which tracks a point on a path
  74078. */
  74079. export class PathCursor {
  74080. private path;
  74081. /**
  74082. * Stores path cursor callbacks for when an onchange event is triggered
  74083. */
  74084. private _onchange;
  74085. /**
  74086. * The value of the path cursor
  74087. */
  74088. value: number;
  74089. /**
  74090. * The animation array of the path cursor
  74091. */
  74092. animations: Animation[];
  74093. /**
  74094. * Initializes the path cursor
  74095. * @param path The path to track
  74096. */
  74097. constructor(path: Path2);
  74098. /**
  74099. * Gets the cursor point on the path
  74100. * @returns A point on the path cursor at the cursor location
  74101. */
  74102. getPoint(): Vector3;
  74103. /**
  74104. * Moves the cursor ahead by the step amount
  74105. * @param step The amount to move the cursor forward
  74106. * @returns This path cursor
  74107. */
  74108. moveAhead(step?: number): PathCursor;
  74109. /**
  74110. * Moves the cursor behind by the step amount
  74111. * @param step The amount to move the cursor back
  74112. * @returns This path cursor
  74113. */
  74114. moveBack(step?: number): PathCursor;
  74115. /**
  74116. * Moves the cursor by the step amount
  74117. * If the step amount is greater than one, an exception is thrown
  74118. * @param step The amount to move the cursor
  74119. * @returns This path cursor
  74120. */
  74121. move(step: number): PathCursor;
  74122. /**
  74123. * Ensures that the value is limited between zero and one
  74124. * @returns This path cursor
  74125. */
  74126. private ensureLimits;
  74127. /**
  74128. * Runs onchange callbacks on change (used by the animation engine)
  74129. * @returns This path cursor
  74130. */
  74131. private raiseOnChange;
  74132. /**
  74133. * Executes a function on change
  74134. * @param f A path cursor onchange callback
  74135. * @returns This path cursor
  74136. */
  74137. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74138. }
  74139. }
  74140. declare module BABYLON {
  74141. /** @hidden */
  74142. export var blurPixelShader: {
  74143. name: string;
  74144. shader: string;
  74145. };
  74146. }
  74147. declare module BABYLON {
  74148. /** @hidden */
  74149. export var pointCloudVertexDeclaration: {
  74150. name: string;
  74151. shader: string;
  74152. };
  74153. }
  74154. // Mixins
  74155. interface Window {
  74156. mozIndexedDB: IDBFactory;
  74157. webkitIndexedDB: IDBFactory;
  74158. msIndexedDB: IDBFactory;
  74159. webkitURL: typeof URL;
  74160. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74161. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74162. WebGLRenderingContext: WebGLRenderingContext;
  74163. MSGesture: MSGesture;
  74164. CANNON: any;
  74165. AudioContext: AudioContext;
  74166. webkitAudioContext: AudioContext;
  74167. PointerEvent: any;
  74168. Math: Math;
  74169. Uint8Array: Uint8ArrayConstructor;
  74170. Float32Array: Float32ArrayConstructor;
  74171. mozURL: typeof URL;
  74172. msURL: typeof URL;
  74173. VRFrameData: any; // WebVR, from specs 1.1
  74174. DracoDecoderModule: any;
  74175. setImmediate(handler: (...args: any[]) => void): number;
  74176. }
  74177. interface HTMLCanvasElement {
  74178. requestPointerLock(): void;
  74179. msRequestPointerLock?(): void;
  74180. mozRequestPointerLock?(): void;
  74181. webkitRequestPointerLock?(): void;
  74182. /** Track wether a record is in progress */
  74183. isRecording: boolean;
  74184. /** Capture Stream method defined by some browsers */
  74185. captureStream(fps?: number): MediaStream;
  74186. }
  74187. interface CanvasRenderingContext2D {
  74188. msImageSmoothingEnabled: boolean;
  74189. }
  74190. interface MouseEvent {
  74191. mozMovementX: number;
  74192. mozMovementY: number;
  74193. webkitMovementX: number;
  74194. webkitMovementY: number;
  74195. msMovementX: number;
  74196. msMovementY: number;
  74197. }
  74198. interface Navigator {
  74199. mozGetVRDevices: (any: any) => any;
  74200. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74201. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74202. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74203. webkitGetGamepads(): Gamepad[];
  74204. msGetGamepads(): Gamepad[];
  74205. webkitGamepads(): Gamepad[];
  74206. }
  74207. interface HTMLVideoElement {
  74208. mozSrcObject: any;
  74209. }
  74210. interface Math {
  74211. fround(x: number): number;
  74212. imul(a: number, b: number): number;
  74213. }
  74214. interface WebGLRenderingContext {
  74215. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74216. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74217. vertexAttribDivisor(index: number, divisor: number): void;
  74218. createVertexArray(): any;
  74219. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74220. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74221. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74222. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74223. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74224. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74225. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74226. // Queries
  74227. createQuery(): WebGLQuery;
  74228. deleteQuery(query: WebGLQuery): void;
  74229. beginQuery(target: number, query: WebGLQuery): void;
  74230. endQuery(target: number): void;
  74231. getQueryParameter(query: WebGLQuery, pname: number): any;
  74232. getQuery(target: number, pname: number): any;
  74233. MAX_SAMPLES: number;
  74234. RGBA8: number;
  74235. READ_FRAMEBUFFER: number;
  74236. DRAW_FRAMEBUFFER: number;
  74237. UNIFORM_BUFFER: number;
  74238. HALF_FLOAT_OES: number;
  74239. RGBA16F: number;
  74240. RGBA32F: number;
  74241. R32F: number;
  74242. RG32F: number;
  74243. RGB32F: number;
  74244. R16F: number;
  74245. RG16F: number;
  74246. RGB16F: number;
  74247. RED: number;
  74248. RG: number;
  74249. R8: number;
  74250. RG8: number;
  74251. UNSIGNED_INT_24_8: number;
  74252. DEPTH24_STENCIL8: number;
  74253. MIN: number;
  74254. MAX: number;
  74255. /* Multiple Render Targets */
  74256. drawBuffers(buffers: number[]): void;
  74257. readBuffer(src: number): void;
  74258. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74259. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74260. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74261. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74262. // Occlusion Query
  74263. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74264. ANY_SAMPLES_PASSED: number;
  74265. QUERY_RESULT_AVAILABLE: number;
  74266. QUERY_RESULT: number;
  74267. }
  74268. interface WebGLProgram {
  74269. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74270. }
  74271. interface EXT_disjoint_timer_query {
  74272. QUERY_COUNTER_BITS_EXT: number;
  74273. TIME_ELAPSED_EXT: number;
  74274. TIMESTAMP_EXT: number;
  74275. GPU_DISJOINT_EXT: number;
  74276. QUERY_RESULT_EXT: number;
  74277. QUERY_RESULT_AVAILABLE_EXT: number;
  74278. queryCounterEXT(query: WebGLQuery, target: number): void;
  74279. createQueryEXT(): WebGLQuery;
  74280. beginQueryEXT(target: number, query: WebGLQuery): void;
  74281. endQueryEXT(target: number): void;
  74282. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74283. deleteQueryEXT(query: WebGLQuery): void;
  74284. }
  74285. interface WebGLUniformLocation {
  74286. _currentState: any;
  74287. }
  74288. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74289. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74290. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74291. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74292. interface WebGLRenderingContext {
  74293. readonly RASTERIZER_DISCARD: number;
  74294. readonly DEPTH_COMPONENT24: number;
  74295. readonly TEXTURE_3D: number;
  74296. readonly TEXTURE_2D_ARRAY: number;
  74297. readonly TEXTURE_COMPARE_FUNC: number;
  74298. readonly TEXTURE_COMPARE_MODE: number;
  74299. readonly COMPARE_REF_TO_TEXTURE: number;
  74300. readonly TEXTURE_WRAP_R: number;
  74301. readonly HALF_FLOAT: number;
  74302. readonly RGB8: number;
  74303. readonly RED_INTEGER: number;
  74304. readonly RG_INTEGER: number;
  74305. readonly RGB_INTEGER: number;
  74306. readonly RGBA_INTEGER: number;
  74307. readonly R8_SNORM: number;
  74308. readonly RG8_SNORM: number;
  74309. readonly RGB8_SNORM: number;
  74310. readonly RGBA8_SNORM: number;
  74311. readonly R8I: number;
  74312. readonly RG8I: number;
  74313. readonly RGB8I: number;
  74314. readonly RGBA8I: number;
  74315. readonly R8UI: number;
  74316. readonly RG8UI: number;
  74317. readonly RGB8UI: number;
  74318. readonly RGBA8UI: number;
  74319. readonly R16I: number;
  74320. readonly RG16I: number;
  74321. readonly RGB16I: number;
  74322. readonly RGBA16I: number;
  74323. readonly R16UI: number;
  74324. readonly RG16UI: number;
  74325. readonly RGB16UI: number;
  74326. readonly RGBA16UI: number;
  74327. readonly R32I: number;
  74328. readonly RG32I: number;
  74329. readonly RGB32I: number;
  74330. readonly RGBA32I: number;
  74331. readonly R32UI: number;
  74332. readonly RG32UI: number;
  74333. readonly RGB32UI: number;
  74334. readonly RGBA32UI: number;
  74335. readonly RGB10_A2UI: number;
  74336. readonly R11F_G11F_B10F: number;
  74337. readonly RGB9_E5: number;
  74338. readonly RGB10_A2: number;
  74339. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74340. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74341. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74342. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74343. readonly DEPTH_COMPONENT32F: number;
  74344. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74345. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74346. 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;
  74347. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74348. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74349. readonly TRANSFORM_FEEDBACK: number;
  74350. readonly INTERLEAVED_ATTRIBS: number;
  74351. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74352. createTransformFeedback(): WebGLTransformFeedback;
  74353. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74354. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74355. beginTransformFeedback(primitiveMode: number): void;
  74356. endTransformFeedback(): void;
  74357. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74358. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74359. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74360. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74361. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74362. }
  74363. interface ImageBitmap {
  74364. readonly width: number;
  74365. readonly height: number;
  74366. close(): void;
  74367. }
  74368. interface WebGLQuery extends WebGLObject {
  74369. }
  74370. declare var WebGLQuery: {
  74371. prototype: WebGLQuery;
  74372. new(): WebGLQuery;
  74373. };
  74374. interface WebGLSampler extends WebGLObject {
  74375. }
  74376. declare var WebGLSampler: {
  74377. prototype: WebGLSampler;
  74378. new(): WebGLSampler;
  74379. };
  74380. interface WebGLSync extends WebGLObject {
  74381. }
  74382. declare var WebGLSync: {
  74383. prototype: WebGLSync;
  74384. new(): WebGLSync;
  74385. };
  74386. interface WebGLTransformFeedback extends WebGLObject {
  74387. }
  74388. declare var WebGLTransformFeedback: {
  74389. prototype: WebGLTransformFeedback;
  74390. new(): WebGLTransformFeedback;
  74391. };
  74392. interface WebGLVertexArrayObject extends WebGLObject {
  74393. }
  74394. declare var WebGLVertexArrayObject: {
  74395. prototype: WebGLVertexArrayObject;
  74396. new(): WebGLVertexArrayObject;
  74397. };
  74398. // Type definitions for WebVR API
  74399. // Project: https://w3c.github.io/webvr/
  74400. // Definitions by: six a <https://github.com/lostfictions>
  74401. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74402. interface VRDisplay extends EventTarget {
  74403. /**
  74404. * Dictionary of capabilities describing the VRDisplay.
  74405. */
  74406. readonly capabilities: VRDisplayCapabilities;
  74407. /**
  74408. * z-depth defining the far plane of the eye view frustum
  74409. * enables mapping of values in the render target depth
  74410. * attachment to scene coordinates. Initially set to 10000.0.
  74411. */
  74412. depthFar: number;
  74413. /**
  74414. * z-depth defining the near plane of the eye view frustum
  74415. * enables mapping of values in the render target depth
  74416. * attachment to scene coordinates. Initially set to 0.01.
  74417. */
  74418. depthNear: number;
  74419. /**
  74420. * An identifier for this distinct VRDisplay. Used as an
  74421. * association point in the Gamepad API.
  74422. */
  74423. readonly displayId: number;
  74424. /**
  74425. * A display name, a user-readable name identifying it.
  74426. */
  74427. readonly displayName: string;
  74428. readonly isConnected: boolean;
  74429. readonly isPresenting: boolean;
  74430. /**
  74431. * If this VRDisplay supports room-scale experiences, the optional
  74432. * stage attribute contains details on the room-scale parameters.
  74433. */
  74434. readonly stageParameters: VRStageParameters | null;
  74435. /**
  74436. * Passing the value returned by `requestAnimationFrame` to
  74437. * `cancelAnimationFrame` will unregister the callback.
  74438. * @param handle Define the hanle of the request to cancel
  74439. */
  74440. cancelAnimationFrame(handle: number): void;
  74441. /**
  74442. * Stops presenting to the VRDisplay.
  74443. * @returns a promise to know when it stopped
  74444. */
  74445. exitPresent(): Promise<void>;
  74446. /**
  74447. * Return the current VREyeParameters for the given eye.
  74448. * @param whichEye Define the eye we want the parameter for
  74449. * @returns the eye parameters
  74450. */
  74451. getEyeParameters(whichEye: string): VREyeParameters;
  74452. /**
  74453. * Populates the passed VRFrameData with the information required to render
  74454. * the current frame.
  74455. * @param frameData Define the data structure to populate
  74456. * @returns true if ok otherwise false
  74457. */
  74458. getFrameData(frameData: VRFrameData): boolean;
  74459. /**
  74460. * Get the layers currently being presented.
  74461. * @returns the list of VR layers
  74462. */
  74463. getLayers(): VRLayer[];
  74464. /**
  74465. * Return a VRPose containing the future predicted pose of the VRDisplay
  74466. * when the current frame will be presented. The value returned will not
  74467. * change until JavaScript has returned control to the browser.
  74468. *
  74469. * The VRPose will contain the position, orientation, velocity,
  74470. * and acceleration of each of these properties.
  74471. * @returns the pose object
  74472. */
  74473. getPose(): VRPose;
  74474. /**
  74475. * Return the current instantaneous pose of the VRDisplay, with no
  74476. * prediction applied.
  74477. * @returns the current instantaneous pose
  74478. */
  74479. getImmediatePose(): VRPose;
  74480. /**
  74481. * The callback passed to `requestAnimationFrame` will be called
  74482. * any time a new frame should be rendered. When the VRDisplay is
  74483. * presenting the callback will be called at the native refresh
  74484. * rate of the HMD. When not presenting this function acts
  74485. * identically to how window.requestAnimationFrame acts. Content should
  74486. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74487. * asynchronously from other displays and at differing refresh rates.
  74488. * @param callback Define the eaction to run next frame
  74489. * @returns the request handle it
  74490. */
  74491. requestAnimationFrame(callback: FrameRequestCallback): number;
  74492. /**
  74493. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74494. * Repeat calls while already presenting will update the VRLayers being displayed.
  74495. * @param layers Define the list of layer to present
  74496. * @returns a promise to know when the request has been fulfilled
  74497. */
  74498. requestPresent(layers: VRLayer[]): Promise<void>;
  74499. /**
  74500. * Reset the pose for this display, treating its current position and
  74501. * orientation as the "origin/zero" values. VRPose.position,
  74502. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74503. * updated when calling resetPose(). This should be called in only
  74504. * sitting-space experiences.
  74505. */
  74506. resetPose(): void;
  74507. /**
  74508. * The VRLayer provided to the VRDisplay will be captured and presented
  74509. * in the HMD. Calling this function has the same effect on the source
  74510. * canvas as any other operation that uses its source image, and canvases
  74511. * created without preserveDrawingBuffer set to true will be cleared.
  74512. * @param pose Define the pose to submit
  74513. */
  74514. submitFrame(pose?: VRPose): void;
  74515. }
  74516. declare var VRDisplay: {
  74517. prototype: VRDisplay;
  74518. new(): VRDisplay;
  74519. };
  74520. interface VRLayer {
  74521. leftBounds?: number[] | Float32Array | null;
  74522. rightBounds?: number[] | Float32Array | null;
  74523. source?: HTMLCanvasElement | null;
  74524. }
  74525. interface VRDisplayCapabilities {
  74526. readonly canPresent: boolean;
  74527. readonly hasExternalDisplay: boolean;
  74528. readonly hasOrientation: boolean;
  74529. readonly hasPosition: boolean;
  74530. readonly maxLayers: number;
  74531. }
  74532. interface VREyeParameters {
  74533. /** @deprecated */
  74534. readonly fieldOfView: VRFieldOfView;
  74535. readonly offset: Float32Array;
  74536. readonly renderHeight: number;
  74537. readonly renderWidth: number;
  74538. }
  74539. interface VRFieldOfView {
  74540. readonly downDegrees: number;
  74541. readonly leftDegrees: number;
  74542. readonly rightDegrees: number;
  74543. readonly upDegrees: number;
  74544. }
  74545. interface VRFrameData {
  74546. readonly leftProjectionMatrix: Float32Array;
  74547. readonly leftViewMatrix: Float32Array;
  74548. readonly pose: VRPose;
  74549. readonly rightProjectionMatrix: Float32Array;
  74550. readonly rightViewMatrix: Float32Array;
  74551. readonly timestamp: number;
  74552. }
  74553. interface VRPose {
  74554. readonly angularAcceleration: Float32Array | null;
  74555. readonly angularVelocity: Float32Array | null;
  74556. readonly linearAcceleration: Float32Array | null;
  74557. readonly linearVelocity: Float32Array | null;
  74558. readonly orientation: Float32Array | null;
  74559. readonly position: Float32Array | null;
  74560. readonly timestamp: number;
  74561. }
  74562. interface VRStageParameters {
  74563. sittingToStandingTransform?: Float32Array;
  74564. sizeX?: number;
  74565. sizeY?: number;
  74566. }
  74567. interface Navigator {
  74568. getVRDisplays(): Promise<VRDisplay[]>;
  74569. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74570. }
  74571. interface Window {
  74572. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74573. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74574. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74575. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74576. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74577. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74578. }
  74579. interface Gamepad {
  74580. readonly displayId: number;
  74581. }
  74582. type XRSessionMode =
  74583. | "inline"
  74584. | "immersive-vr"
  74585. | "immersive-ar";
  74586. type XRReferenceSpaceType =
  74587. | "viewer"
  74588. | "local"
  74589. | "local-floor"
  74590. | "bounded-floor"
  74591. | "unbounded";
  74592. type XREnvironmentBlendMode =
  74593. | "opaque"
  74594. | "additive"
  74595. | "alpha-blend";
  74596. type XRVisibilityState =
  74597. | "visible"
  74598. | "visible-blurred"
  74599. | "hidden";
  74600. type XRHandedness =
  74601. | "none"
  74602. | "left"
  74603. | "right";
  74604. type XRTargetRayMode =
  74605. | "gaze"
  74606. | "tracked-pointer"
  74607. | "screen";
  74608. type XREye =
  74609. | "none"
  74610. | "left"
  74611. | "right";
  74612. type XREventType =
  74613. | "devicechange"
  74614. | "visibilitychange"
  74615. | "end"
  74616. | "inputsourceschange"
  74617. | "select"
  74618. | "selectstart"
  74619. | "selectend"
  74620. | "squeeze"
  74621. | "squeezestart"
  74622. | "squeezeend"
  74623. | "reset";
  74624. interface XRSpace extends EventTarget {
  74625. }
  74626. interface XRRenderState {
  74627. depthNear?: number;
  74628. depthFar?: number;
  74629. inlineVerticalFieldOfView?: number;
  74630. baseLayer?: XRWebGLLayer;
  74631. }
  74632. interface XRInputSource {
  74633. handedness: XRHandedness;
  74634. targetRayMode: XRTargetRayMode;
  74635. targetRaySpace: XRSpace;
  74636. gripSpace: XRSpace | undefined;
  74637. gamepad: Gamepad | undefined;
  74638. profiles: Array<string>;
  74639. }
  74640. interface XRSessionInit {
  74641. optionalFeatures?: string[];
  74642. requiredFeatures?: string[];
  74643. }
  74644. interface XRSession {
  74645. addEventListener: Function;
  74646. removeEventListener: Function;
  74647. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74648. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74649. requestAnimationFrame: Function;
  74650. end(): Promise<void>;
  74651. renderState: XRRenderState;
  74652. inputSources: Array<XRInputSource>;
  74653. // hit test
  74654. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74655. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74656. // legacy AR hit test
  74657. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74658. // legacy plane detection
  74659. updateWorldTrackingState(options: {
  74660. planeDetectionState?: { enabled: boolean; }
  74661. }): void;
  74662. }
  74663. interface XRReferenceSpace extends XRSpace {
  74664. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74665. onreset: any;
  74666. }
  74667. type XRPlaneSet = Set<XRPlane>;
  74668. type XRAnchorSet = Set<XRAnchor>;
  74669. interface XRFrame {
  74670. session: XRSession;
  74671. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74672. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74673. // AR
  74674. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74675. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74676. // Anchors
  74677. trackedAnchors?: XRAnchorSet;
  74678. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74679. // Planes
  74680. worldInformation: {
  74681. detectedPlanes?: XRPlaneSet;
  74682. };
  74683. }
  74684. interface XRViewerPose extends XRPose {
  74685. views: Array<XRView>;
  74686. }
  74687. interface XRPose {
  74688. transform: XRRigidTransform;
  74689. emulatedPosition: boolean;
  74690. }
  74691. interface XRWebGLLayerOptions {
  74692. antialias?: boolean;
  74693. depth?: boolean;
  74694. stencil?: boolean;
  74695. alpha?: boolean;
  74696. multiview?: boolean;
  74697. framebufferScaleFactor?: number;
  74698. }
  74699. declare var XRWebGLLayer: {
  74700. prototype: XRWebGLLayer;
  74701. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74702. };
  74703. interface XRWebGLLayer {
  74704. framebuffer: WebGLFramebuffer;
  74705. framebufferWidth: number;
  74706. framebufferHeight: number;
  74707. getViewport: Function;
  74708. }
  74709. declare class XRRigidTransform {
  74710. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  74711. position: DOMPointReadOnly;
  74712. orientation: DOMPointReadOnly;
  74713. matrix: Float32Array;
  74714. inverse: XRRigidTransform;
  74715. }
  74716. interface XRView {
  74717. eye: XREye;
  74718. projectionMatrix: Float32Array;
  74719. transform: XRRigidTransform;
  74720. }
  74721. interface XRInputSourceChangeEvent {
  74722. session: XRSession;
  74723. removed: Array<XRInputSource>;
  74724. added: Array<XRInputSource>;
  74725. }
  74726. interface XRInputSourceEvent extends Event {
  74727. readonly frame: XRFrame;
  74728. readonly inputSource: XRInputSource;
  74729. }
  74730. // Experimental(er) features
  74731. declare class XRRay {
  74732. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  74733. origin: DOMPointReadOnly;
  74734. direction: DOMPointReadOnly;
  74735. matrix: Float32Array;
  74736. }
  74737. declare enum XRHitTestTrackableType {
  74738. "point",
  74739. "plane"
  74740. }
  74741. interface XRHitResult {
  74742. hitMatrix: Float32Array;
  74743. }
  74744. interface XRTransientInputHitTestResult {
  74745. readonly inputSource: XRInputSource;
  74746. readonly results: Array<XRHitTestResult>;
  74747. }
  74748. interface XRHitTestResult {
  74749. getPose(baseSpace: XRSpace): XRPose | undefined;
  74750. // When anchor system is enabled
  74751. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  74752. }
  74753. interface XRHitTestSource {
  74754. cancel(): void;
  74755. }
  74756. interface XRTransientInputHitTestSource {
  74757. cancel(): void;
  74758. }
  74759. interface XRHitTestOptionsInit {
  74760. space: XRSpace;
  74761. entityTypes?: Array<XRHitTestTrackableType>;
  74762. offsetRay?: XRRay;
  74763. }
  74764. interface XRTransientInputHitTestOptionsInit {
  74765. profile: string;
  74766. entityTypes?: Array<XRHitTestTrackableType>;
  74767. offsetRay?: XRRay;
  74768. }
  74769. interface XRAnchor {
  74770. anchorSpace: XRSpace;
  74771. delete(): void;
  74772. }
  74773. interface XRPlane {
  74774. orientation: "Horizontal" | "Vertical";
  74775. planeSpace: XRSpace;
  74776. polygon: Array<DOMPointReadOnly>;
  74777. lastChangedTime: number;
  74778. }
  74779. /**
  74780. * @ignore
  74781. */
  74782. declare module BABYLON.GLTF2.Exporter {
  74783. }
  74784. /**
  74785. * @ignore
  74786. */
  74787. declare module BABYLON.GLTF1 {
  74788. }
  74789. declare module BABYLON.GUI {
  74790. /**
  74791. * Class used to specific a value and its associated unit
  74792. */
  74793. export class ValueAndUnit {
  74794. /** defines the unit to store */
  74795. unit: number;
  74796. /** defines a boolean indicating if the value can be negative */
  74797. negativeValueAllowed: boolean;
  74798. private _value;
  74799. private _originalUnit;
  74800. /**
  74801. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  74802. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  74803. */
  74804. ignoreAdaptiveScaling: boolean;
  74805. /**
  74806. * Creates a new ValueAndUnit
  74807. * @param value defines the value to store
  74808. * @param unit defines the unit to store
  74809. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  74810. */
  74811. constructor(value: number,
  74812. /** defines the unit to store */
  74813. unit?: number,
  74814. /** defines a boolean indicating if the value can be negative */
  74815. negativeValueAllowed?: boolean);
  74816. /** Gets a boolean indicating if the value is a percentage */
  74817. get isPercentage(): boolean;
  74818. /** Gets a boolean indicating if the value is store as pixel */
  74819. get isPixel(): boolean;
  74820. /** Gets direct internal value */
  74821. get internalValue(): number;
  74822. /**
  74823. * Gets value as pixel
  74824. * @param host defines the root host
  74825. * @param refValue defines the reference value for percentages
  74826. * @returns the value as pixel
  74827. */
  74828. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  74829. /**
  74830. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  74831. * @param value defines the value to store
  74832. * @param unit defines the unit to store
  74833. * @returns the current ValueAndUnit
  74834. */
  74835. updateInPlace(value: number, unit?: number): ValueAndUnit;
  74836. /**
  74837. * Gets the value accordingly to its unit
  74838. * @param host defines the root host
  74839. * @returns the value
  74840. */
  74841. getValue(host: AdvancedDynamicTexture): number;
  74842. /**
  74843. * Gets a string representation of the value
  74844. * @param host defines the root host
  74845. * @param decimals defines an optional number of decimals to display
  74846. * @returns a string
  74847. */
  74848. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  74849. /**
  74850. * Store a value parsed from a string
  74851. * @param source defines the source string
  74852. * @returns true if the value was successfully parsed
  74853. */
  74854. fromString(source: string | number): boolean;
  74855. private static _Regex;
  74856. private static _UNITMODE_PERCENTAGE;
  74857. private static _UNITMODE_PIXEL;
  74858. /** UNITMODE_PERCENTAGE */
  74859. static get UNITMODE_PERCENTAGE(): number;
  74860. /** UNITMODE_PIXEL */
  74861. static get UNITMODE_PIXEL(): number;
  74862. }
  74863. }
  74864. declare module BABYLON.GUI {
  74865. /**
  74866. * Define a style used by control to automatically setup properties based on a template.
  74867. * Only support font related properties so far
  74868. */
  74869. export class Style implements BABYLON.IDisposable {
  74870. private _fontFamily;
  74871. private _fontStyle;
  74872. private _fontWeight;
  74873. /** @hidden */
  74874. _host: AdvancedDynamicTexture;
  74875. /** @hidden */
  74876. _fontSize: ValueAndUnit;
  74877. /**
  74878. * BABYLON.Observable raised when the style values are changed
  74879. */
  74880. onChangedObservable: BABYLON.Observable<Style>;
  74881. /**
  74882. * Creates a new style object
  74883. * @param host defines the AdvancedDynamicTexture which hosts this style
  74884. */
  74885. constructor(host: AdvancedDynamicTexture);
  74886. /**
  74887. * Gets or sets the font size
  74888. */
  74889. get fontSize(): string | number;
  74890. set fontSize(value: string | number);
  74891. /**
  74892. * Gets or sets the font family
  74893. */
  74894. get fontFamily(): string;
  74895. set fontFamily(value: string);
  74896. /**
  74897. * Gets or sets the font style
  74898. */
  74899. get fontStyle(): string;
  74900. set fontStyle(value: string);
  74901. /** Gets or sets font weight */
  74902. get fontWeight(): string;
  74903. set fontWeight(value: string);
  74904. /** Dispose all associated resources */
  74905. dispose(): void;
  74906. }
  74907. }
  74908. declare module BABYLON.GUI {
  74909. /**
  74910. * Class used to transport BABYLON.Vector2 information for pointer events
  74911. */
  74912. export class Vector2WithInfo extends BABYLON.Vector2 {
  74913. /** defines the current mouse button index */
  74914. buttonIndex: number;
  74915. /**
  74916. * Creates a new Vector2WithInfo
  74917. * @param source defines the vector2 data to transport
  74918. * @param buttonIndex defines the current mouse button index
  74919. */
  74920. constructor(source: BABYLON.Vector2,
  74921. /** defines the current mouse button index */
  74922. buttonIndex?: number);
  74923. }
  74924. /** Class used to provide 2D matrix features */
  74925. export class Matrix2D {
  74926. /** Gets the internal array of 6 floats used to store matrix data */
  74927. m: Float32Array;
  74928. /**
  74929. * Creates a new matrix
  74930. * @param m00 defines value for (0, 0)
  74931. * @param m01 defines value for (0, 1)
  74932. * @param m10 defines value for (1, 0)
  74933. * @param m11 defines value for (1, 1)
  74934. * @param m20 defines value for (2, 0)
  74935. * @param m21 defines value for (2, 1)
  74936. */
  74937. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  74938. /**
  74939. * Fills the matrix from direct values
  74940. * @param m00 defines value for (0, 0)
  74941. * @param m01 defines value for (0, 1)
  74942. * @param m10 defines value for (1, 0)
  74943. * @param m11 defines value for (1, 1)
  74944. * @param m20 defines value for (2, 0)
  74945. * @param m21 defines value for (2, 1)
  74946. * @returns the current modified matrix
  74947. */
  74948. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  74949. /**
  74950. * Gets matrix determinant
  74951. * @returns the determinant
  74952. */
  74953. determinant(): number;
  74954. /**
  74955. * Inverses the matrix and stores it in a target matrix
  74956. * @param result defines the target matrix
  74957. * @returns the current matrix
  74958. */
  74959. invertToRef(result: Matrix2D): Matrix2D;
  74960. /**
  74961. * Multiplies the current matrix with another one
  74962. * @param other defines the second operand
  74963. * @param result defines the target matrix
  74964. * @returns the current matrix
  74965. */
  74966. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  74967. /**
  74968. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  74969. * @param x defines the x coordinate to transform
  74970. * @param y defines the x coordinate to transform
  74971. * @param result defines the target vector2
  74972. * @returns the current matrix
  74973. */
  74974. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  74975. /**
  74976. * Creates an identity matrix
  74977. * @returns a new matrix
  74978. */
  74979. static Identity(): Matrix2D;
  74980. /**
  74981. * Creates a translation matrix and stores it in a target matrix
  74982. * @param x defines the x coordinate of the translation
  74983. * @param y defines the y coordinate of the translation
  74984. * @param result defines the target matrix
  74985. */
  74986. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  74987. /**
  74988. * Creates a scaling matrix and stores it in a target matrix
  74989. * @param x defines the x coordinate of the scaling
  74990. * @param y defines the y coordinate of the scaling
  74991. * @param result defines the target matrix
  74992. */
  74993. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  74994. /**
  74995. * Creates a rotation matrix and stores it in a target matrix
  74996. * @param angle defines the rotation angle
  74997. * @param result defines the target matrix
  74998. */
  74999. static RotationToRef(angle: number, result: Matrix2D): void;
  75000. private static _TempPreTranslationMatrix;
  75001. private static _TempPostTranslationMatrix;
  75002. private static _TempRotationMatrix;
  75003. private static _TempScalingMatrix;
  75004. private static _TempCompose0;
  75005. private static _TempCompose1;
  75006. private static _TempCompose2;
  75007. /**
  75008. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75009. * @param tx defines the x coordinate of the translation
  75010. * @param ty defines the y coordinate of the translation
  75011. * @param angle defines the rotation angle
  75012. * @param scaleX defines the x coordinate of the scaling
  75013. * @param scaleY defines the y coordinate of the scaling
  75014. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75015. * @param result defines the target matrix
  75016. */
  75017. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75018. }
  75019. }
  75020. declare module BABYLON.GUI {
  75021. /**
  75022. * Class used to store 2D control sizes
  75023. */
  75024. export class Measure {
  75025. /** defines left coordinate */
  75026. left: number;
  75027. /** defines top coordinate */
  75028. top: number;
  75029. /** defines width dimension */
  75030. width: number;
  75031. /** defines height dimension */
  75032. height: number;
  75033. /**
  75034. * Creates a new measure
  75035. * @param left defines left coordinate
  75036. * @param top defines top coordinate
  75037. * @param width defines width dimension
  75038. * @param height defines height dimension
  75039. */
  75040. constructor(
  75041. /** defines left coordinate */
  75042. left: number,
  75043. /** defines top coordinate */
  75044. top: number,
  75045. /** defines width dimension */
  75046. width: number,
  75047. /** defines height dimension */
  75048. height: number);
  75049. /**
  75050. * Copy from another measure
  75051. * @param other defines the other measure to copy from
  75052. */
  75053. copyFrom(other: Measure): void;
  75054. /**
  75055. * Copy from a group of 4 floats
  75056. * @param left defines left coordinate
  75057. * @param top defines top coordinate
  75058. * @param width defines width dimension
  75059. * @param height defines height dimension
  75060. */
  75061. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75062. /**
  75063. * Computes the axis aligned bounding box measure for two given measures
  75064. * @param a Input measure
  75065. * @param b Input measure
  75066. * @param result the resulting bounding measure
  75067. */
  75068. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75069. /**
  75070. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75071. * @param transform the matrix to transform the measure before computing the AABB
  75072. * @param result the resulting AABB
  75073. */
  75074. transformToRef(transform: Matrix2D, result: Measure): void;
  75075. /**
  75076. * Check equality between this measure and another one
  75077. * @param other defines the other measures
  75078. * @returns true if both measures are equals
  75079. */
  75080. isEqualsTo(other: Measure): boolean;
  75081. /**
  75082. * Creates an empty measure
  75083. * @returns a new measure
  75084. */
  75085. static Empty(): Measure;
  75086. }
  75087. }
  75088. declare module BABYLON.GUI {
  75089. /**
  75090. * Interface used to define a control that can receive focus
  75091. */
  75092. export interface IFocusableControl {
  75093. /**
  75094. * Function called when the control receives the focus
  75095. */
  75096. onFocus(): void;
  75097. /**
  75098. * Function called when the control loses the focus
  75099. */
  75100. onBlur(): void;
  75101. /**
  75102. * Function called to let the control handle keyboard events
  75103. * @param evt defines the current keyboard event
  75104. */
  75105. processKeyboard(evt: KeyboardEvent): void;
  75106. /**
  75107. * Function called to get the list of controls that should not steal the focus from this control
  75108. * @returns an array of controls
  75109. */
  75110. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75111. }
  75112. /**
  75113. * Class used to create texture to support 2D GUI elements
  75114. * @see https://doc.babylonjs.com/how_to/gui
  75115. */
  75116. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75117. private _isDirty;
  75118. private _renderObserver;
  75119. private _resizeObserver;
  75120. private _preKeyboardObserver;
  75121. private _pointerMoveObserver;
  75122. private _pointerObserver;
  75123. private _canvasPointerOutObserver;
  75124. private _background;
  75125. /** @hidden */
  75126. _rootContainer: Container;
  75127. /** @hidden */
  75128. _lastPickedControl: Control;
  75129. /** @hidden */
  75130. _lastControlOver: {
  75131. [pointerId: number]: Control;
  75132. };
  75133. /** @hidden */
  75134. _lastControlDown: {
  75135. [pointerId: number]: Control;
  75136. };
  75137. /** @hidden */
  75138. _capturingControl: {
  75139. [pointerId: number]: Control;
  75140. };
  75141. /** @hidden */
  75142. _shouldBlockPointer: boolean;
  75143. /** @hidden */
  75144. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75145. /** @hidden */
  75146. _linkedControls: Control[];
  75147. private _isFullscreen;
  75148. private _fullscreenViewport;
  75149. private _idealWidth;
  75150. private _idealHeight;
  75151. private _useSmallestIdeal;
  75152. private _renderAtIdealSize;
  75153. private _focusedControl;
  75154. private _blockNextFocusCheck;
  75155. private _renderScale;
  75156. private _rootElement;
  75157. private _cursorChanged;
  75158. private _defaultMousePointerId;
  75159. /** @hidden */
  75160. _numLayoutCalls: number;
  75161. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75162. get numLayoutCalls(): number;
  75163. /** @hidden */
  75164. _numRenderCalls: number;
  75165. /** Gets the number of render calls made the last time the ADT has been rendered */
  75166. get numRenderCalls(): number;
  75167. /**
  75168. * Define type to string to ensure compatibility across browsers
  75169. * Safari doesn't support DataTransfer constructor
  75170. */
  75171. private _clipboardData;
  75172. /**
  75173. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75174. */
  75175. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75176. /**
  75177. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75178. */
  75179. onControlPickedObservable: BABYLON.Observable<Control>;
  75180. /**
  75181. * BABYLON.Observable event triggered before layout is evaluated
  75182. */
  75183. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75184. /**
  75185. * BABYLON.Observable event triggered after the layout was evaluated
  75186. */
  75187. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75188. /**
  75189. * BABYLON.Observable event triggered before the texture is rendered
  75190. */
  75191. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75192. /**
  75193. * BABYLON.Observable event triggered after the texture was rendered
  75194. */
  75195. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75196. /**
  75197. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75198. */
  75199. premulAlpha: boolean;
  75200. /**
  75201. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75202. * Useful when you want more antialiasing
  75203. */
  75204. get renderScale(): number;
  75205. set renderScale(value: number);
  75206. /** Gets or sets the background color */
  75207. get background(): string;
  75208. set background(value: string);
  75209. /**
  75210. * Gets or sets the ideal width used to design controls.
  75211. * The GUI will then rescale everything accordingly
  75212. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75213. */
  75214. get idealWidth(): number;
  75215. set idealWidth(value: number);
  75216. /**
  75217. * Gets or sets the ideal height used to design controls.
  75218. * The GUI will then rescale everything accordingly
  75219. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75220. */
  75221. get idealHeight(): number;
  75222. set idealHeight(value: number);
  75223. /**
  75224. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75225. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75226. */
  75227. get useSmallestIdeal(): boolean;
  75228. set useSmallestIdeal(value: boolean);
  75229. /**
  75230. * Gets or sets a boolean indicating if adaptive scaling must be used
  75231. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75232. */
  75233. get renderAtIdealSize(): boolean;
  75234. set renderAtIdealSize(value: boolean);
  75235. /**
  75236. * Gets the ratio used when in "ideal mode"
  75237. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75238. * */
  75239. get idealRatio(): number;
  75240. /**
  75241. * Gets the underlying layer used to render the texture when in fullscreen mode
  75242. */
  75243. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75244. /**
  75245. * Gets the root container control
  75246. */
  75247. get rootContainer(): Container;
  75248. /**
  75249. * Returns an array containing the root container.
  75250. * This is mostly used to let the Inspector introspects the ADT
  75251. * @returns an array containing the rootContainer
  75252. */
  75253. getChildren(): Array<Container>;
  75254. /**
  75255. * Will return all controls that are inside this texture
  75256. * @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
  75257. * @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
  75258. * @return all child controls
  75259. */
  75260. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75261. /**
  75262. * Gets or sets the current focused control
  75263. */
  75264. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75265. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75266. /**
  75267. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75268. */
  75269. get isForeground(): boolean;
  75270. set isForeground(value: boolean);
  75271. /**
  75272. * Gets or set information about clipboardData
  75273. */
  75274. get clipboardData(): string;
  75275. set clipboardData(value: string);
  75276. /**
  75277. * Creates a new AdvancedDynamicTexture
  75278. * @param name defines the name of the texture
  75279. * @param width defines the width of the texture
  75280. * @param height defines the height of the texture
  75281. * @param scene defines the hosting scene
  75282. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75283. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75284. */
  75285. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75286. /**
  75287. * Get the current class name of the texture useful for serialization or dynamic coding.
  75288. * @returns "AdvancedDynamicTexture"
  75289. */
  75290. getClassName(): string;
  75291. /**
  75292. * Function used to execute a function on all controls
  75293. * @param func defines the function to execute
  75294. * @param container defines the container where controls belong. If null the root container will be used
  75295. */
  75296. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75297. private _useInvalidateRectOptimization;
  75298. /**
  75299. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75300. */
  75301. get useInvalidateRectOptimization(): boolean;
  75302. set useInvalidateRectOptimization(value: boolean);
  75303. private _invalidatedRectangle;
  75304. /**
  75305. * Invalidates a rectangle area on the gui texture
  75306. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75307. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75308. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75309. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75310. */
  75311. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75312. /**
  75313. * Marks the texture as dirty forcing a complete update
  75314. */
  75315. markAsDirty(): void;
  75316. /**
  75317. * Helper function used to create a new style
  75318. * @returns a new style
  75319. * @see https://doc.babylonjs.com/how_to/gui#styles
  75320. */
  75321. createStyle(): Style;
  75322. /**
  75323. * Adds a new control to the root container
  75324. * @param control defines the control to add
  75325. * @returns the current texture
  75326. */
  75327. addControl(control: Control): AdvancedDynamicTexture;
  75328. /**
  75329. * Removes a control from the root container
  75330. * @param control defines the control to remove
  75331. * @returns the current texture
  75332. */
  75333. removeControl(control: Control): AdvancedDynamicTexture;
  75334. /**
  75335. * Release all resources
  75336. */
  75337. dispose(): void;
  75338. private _onResize;
  75339. /** @hidden */
  75340. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75341. /**
  75342. * Get screen coordinates for a vector3
  75343. * @param position defines the position to project
  75344. * @param worldMatrix defines the world matrix to use
  75345. * @returns the projected position
  75346. */
  75347. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75348. private _checkUpdate;
  75349. private _clearMeasure;
  75350. private _render;
  75351. /** @hidden */
  75352. _changeCursor(cursor: string): void;
  75353. /** @hidden */
  75354. _registerLastControlDown(control: Control, pointerId: number): void;
  75355. private _doPicking;
  75356. /** @hidden */
  75357. _cleanControlAfterRemovalFromList(list: {
  75358. [pointerId: number]: Control;
  75359. }, control: Control): void;
  75360. /** @hidden */
  75361. _cleanControlAfterRemoval(control: Control): void;
  75362. /** Attach to all scene events required to support pointer events */
  75363. attach(): void;
  75364. /** @hidden */
  75365. private onClipboardCopy;
  75366. /** @hidden */
  75367. private onClipboardCut;
  75368. /** @hidden */
  75369. private onClipboardPaste;
  75370. /**
  75371. * Register the clipboard Events onto the canvas
  75372. */
  75373. registerClipboardEvents(): void;
  75374. /**
  75375. * Unregister the clipboard Events from the canvas
  75376. */
  75377. unRegisterClipboardEvents(): void;
  75378. /**
  75379. * Connect the texture to a hosting mesh to enable interactions
  75380. * @param mesh defines the mesh to attach to
  75381. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75382. */
  75383. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75384. /**
  75385. * Move the focus to a specific control
  75386. * @param control defines the control which will receive the focus
  75387. */
  75388. moveFocusToControl(control: IFocusableControl): void;
  75389. private _manageFocus;
  75390. private _attachToOnPointerOut;
  75391. /**
  75392. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75393. * @param mesh defines the mesh which will receive the texture
  75394. * @param width defines the texture width (1024 by default)
  75395. * @param height defines the texture height (1024 by default)
  75396. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75397. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75398. * @returns a new AdvancedDynamicTexture
  75399. */
  75400. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75401. /**
  75402. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75403. * In this mode the texture will rely on a layer for its rendering.
  75404. * This allows it to be treated like any other layer.
  75405. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75406. * LayerMask is set through advancedTexture.layer.layerMask
  75407. * @param name defines name for the texture
  75408. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75409. * @param scene defines the hsoting scene
  75410. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75411. * @returns a new AdvancedDynamicTexture
  75412. */
  75413. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75414. }
  75415. }
  75416. declare module BABYLON.GUI {
  75417. /**
  75418. * Root class used for all 2D controls
  75419. * @see https://doc.babylonjs.com/how_to/gui#controls
  75420. */
  75421. export class Control {
  75422. /** defines the name of the control */
  75423. name?: string | undefined;
  75424. /**
  75425. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75426. */
  75427. static AllowAlphaInheritance: boolean;
  75428. private _alpha;
  75429. private _alphaSet;
  75430. private _zIndex;
  75431. /** @hidden */
  75432. _host: AdvancedDynamicTexture;
  75433. /** Gets or sets the control parent */
  75434. parent: BABYLON.Nullable<Container>;
  75435. /** @hidden */
  75436. _currentMeasure: Measure;
  75437. private _fontFamily;
  75438. private _fontStyle;
  75439. private _fontWeight;
  75440. private _fontSize;
  75441. private _font;
  75442. /** @hidden */
  75443. _width: ValueAndUnit;
  75444. /** @hidden */
  75445. _height: ValueAndUnit;
  75446. /** @hidden */
  75447. protected _fontOffset: {
  75448. ascent: number;
  75449. height: number;
  75450. descent: number;
  75451. };
  75452. private _color;
  75453. private _style;
  75454. private _styleObserver;
  75455. /** @hidden */
  75456. protected _horizontalAlignment: number;
  75457. /** @hidden */
  75458. protected _verticalAlignment: number;
  75459. /** @hidden */
  75460. protected _isDirty: boolean;
  75461. /** @hidden */
  75462. protected _wasDirty: boolean;
  75463. /** @hidden */
  75464. _tempParentMeasure: Measure;
  75465. /** @hidden */
  75466. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75467. /** @hidden */
  75468. protected _cachedParentMeasure: Measure;
  75469. private _paddingLeft;
  75470. private _paddingRight;
  75471. private _paddingTop;
  75472. private _paddingBottom;
  75473. /** @hidden */
  75474. _left: ValueAndUnit;
  75475. /** @hidden */
  75476. _top: ValueAndUnit;
  75477. private _scaleX;
  75478. private _scaleY;
  75479. private _rotation;
  75480. private _transformCenterX;
  75481. private _transformCenterY;
  75482. /** @hidden */
  75483. _transformMatrix: Matrix2D;
  75484. /** @hidden */
  75485. protected _invertTransformMatrix: Matrix2D;
  75486. /** @hidden */
  75487. protected _transformedPosition: BABYLON.Vector2;
  75488. private _isMatrixDirty;
  75489. private _cachedOffsetX;
  75490. private _cachedOffsetY;
  75491. private _isVisible;
  75492. private _isHighlighted;
  75493. /** @hidden */
  75494. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75495. private _fontSet;
  75496. private _dummyVector2;
  75497. private _downCount;
  75498. private _enterCount;
  75499. private _doNotRender;
  75500. private _downPointerIds;
  75501. protected _isEnabled: boolean;
  75502. protected _disabledColor: string;
  75503. protected _disabledColorItem: string;
  75504. /** @hidden */
  75505. protected _rebuildLayout: boolean;
  75506. /** @hidden */
  75507. _customData: any;
  75508. /** @hidden */
  75509. _isClipped: boolean;
  75510. /** @hidden */
  75511. _automaticSize: boolean;
  75512. /** @hidden */
  75513. _tag: any;
  75514. /**
  75515. * 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
  75516. */
  75517. uniqueId: number;
  75518. /**
  75519. * Gets or sets an object used to store user defined information for the node
  75520. */
  75521. metadata: any;
  75522. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75523. isHitTestVisible: boolean;
  75524. /** Gets or sets a boolean indicating if the control can block pointer events */
  75525. isPointerBlocker: boolean;
  75526. /** Gets or sets a boolean indicating if the control can be focusable */
  75527. isFocusInvisible: boolean;
  75528. /**
  75529. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75530. * 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
  75531. */
  75532. clipChildren: boolean;
  75533. /**
  75534. * Gets or sets a boolean indicating that control content must be clipped
  75535. * 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
  75536. */
  75537. clipContent: boolean;
  75538. /**
  75539. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75540. */
  75541. useBitmapCache: boolean;
  75542. private _cacheData;
  75543. private _shadowOffsetX;
  75544. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75545. get shadowOffsetX(): number;
  75546. set shadowOffsetX(value: number);
  75547. private _shadowOffsetY;
  75548. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75549. get shadowOffsetY(): number;
  75550. set shadowOffsetY(value: number);
  75551. private _shadowBlur;
  75552. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75553. get shadowBlur(): number;
  75554. set shadowBlur(value: number);
  75555. private _shadowColor;
  75556. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75557. get shadowColor(): string;
  75558. set shadowColor(value: string);
  75559. /** Gets or sets the cursor to use when the control is hovered */
  75560. hoverCursor: string;
  75561. /** @hidden */
  75562. protected _linkOffsetX: ValueAndUnit;
  75563. /** @hidden */
  75564. protected _linkOffsetY: ValueAndUnit;
  75565. /** Gets the control type name */
  75566. get typeName(): string;
  75567. /**
  75568. * Get the current class name of the control.
  75569. * @returns current class name
  75570. */
  75571. getClassName(): string;
  75572. /**
  75573. * An event triggered when pointer wheel is scrolled
  75574. */
  75575. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75576. /**
  75577. * An event triggered when the pointer move over the control.
  75578. */
  75579. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75580. /**
  75581. * An event triggered when the pointer move out of the control.
  75582. */
  75583. onPointerOutObservable: BABYLON.Observable<Control>;
  75584. /**
  75585. * An event triggered when the pointer taps the control
  75586. */
  75587. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75588. /**
  75589. * An event triggered when pointer up
  75590. */
  75591. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75592. /**
  75593. * An event triggered when a control is clicked on
  75594. */
  75595. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75596. /**
  75597. * An event triggered when pointer enters the control
  75598. */
  75599. onPointerEnterObservable: BABYLON.Observable<Control>;
  75600. /**
  75601. * An event triggered when the control is marked as dirty
  75602. */
  75603. onDirtyObservable: BABYLON.Observable<Control>;
  75604. /**
  75605. * An event triggered before drawing the control
  75606. */
  75607. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75608. /**
  75609. * An event triggered after the control was drawn
  75610. */
  75611. onAfterDrawObservable: BABYLON.Observable<Control>;
  75612. /**
  75613. * An event triggered when the control has been disposed
  75614. */
  75615. onDisposeObservable: BABYLON.Observable<Control>;
  75616. /**
  75617. * Get the hosting AdvancedDynamicTexture
  75618. */
  75619. get host(): AdvancedDynamicTexture;
  75620. /** Gets or set information about font offsets (used to render and align text) */
  75621. get fontOffset(): {
  75622. ascent: number;
  75623. height: number;
  75624. descent: number;
  75625. };
  75626. set fontOffset(offset: {
  75627. ascent: number;
  75628. height: number;
  75629. descent: number;
  75630. });
  75631. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75632. get alpha(): number;
  75633. set alpha(value: number);
  75634. /**
  75635. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75636. */
  75637. get isHighlighted(): boolean;
  75638. set isHighlighted(value: boolean);
  75639. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75640. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75641. */
  75642. get scaleX(): number;
  75643. set scaleX(value: number);
  75644. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75645. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75646. */
  75647. get scaleY(): number;
  75648. set scaleY(value: number);
  75649. /** Gets or sets the rotation angle (0 by default)
  75650. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75651. */
  75652. get rotation(): number;
  75653. set rotation(value: number);
  75654. /** Gets or sets the transformation center on Y axis (0 by default)
  75655. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75656. */
  75657. get transformCenterY(): number;
  75658. set transformCenterY(value: number);
  75659. /** Gets or sets the transformation center on X axis (0 by default)
  75660. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75661. */
  75662. get transformCenterX(): number;
  75663. set transformCenterX(value: number);
  75664. /**
  75665. * Gets or sets the horizontal alignment
  75666. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75667. */
  75668. get horizontalAlignment(): number;
  75669. set horizontalAlignment(value: number);
  75670. /**
  75671. * Gets or sets the vertical alignment
  75672. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75673. */
  75674. get verticalAlignment(): number;
  75675. set verticalAlignment(value: number);
  75676. /**
  75677. * Gets or sets control width
  75678. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75679. */
  75680. get width(): string | number;
  75681. set width(value: string | number);
  75682. /**
  75683. * Gets or sets the control width in pixel
  75684. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75685. */
  75686. get widthInPixels(): number;
  75687. set widthInPixels(value: number);
  75688. /**
  75689. * Gets or sets control height
  75690. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75691. */
  75692. get height(): string | number;
  75693. set height(value: string | number);
  75694. /**
  75695. * Gets or sets control height in pixel
  75696. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75697. */
  75698. get heightInPixels(): number;
  75699. set heightInPixels(value: number);
  75700. /** Gets or set font family */
  75701. get fontFamily(): string;
  75702. set fontFamily(value: string);
  75703. /** Gets or sets font style */
  75704. get fontStyle(): string;
  75705. set fontStyle(value: string);
  75706. /** Gets or sets font weight */
  75707. get fontWeight(): string;
  75708. set fontWeight(value: string);
  75709. /**
  75710. * Gets or sets style
  75711. * @see https://doc.babylonjs.com/how_to/gui#styles
  75712. */
  75713. get style(): BABYLON.Nullable<Style>;
  75714. set style(value: BABYLON.Nullable<Style>);
  75715. /** @hidden */
  75716. get _isFontSizeInPercentage(): boolean;
  75717. /** Gets or sets font size in pixels */
  75718. get fontSizeInPixels(): number;
  75719. set fontSizeInPixels(value: number);
  75720. /** Gets or sets font size */
  75721. get fontSize(): string | number;
  75722. set fontSize(value: string | number);
  75723. /** Gets or sets foreground color */
  75724. get color(): string;
  75725. set color(value: string);
  75726. /** Gets or sets z index which is used to reorder controls on the z axis */
  75727. get zIndex(): number;
  75728. set zIndex(value: number);
  75729. /** Gets or sets a boolean indicating if the control can be rendered */
  75730. get notRenderable(): boolean;
  75731. set notRenderable(value: boolean);
  75732. /** Gets or sets a boolean indicating if the control is visible */
  75733. get isVisible(): boolean;
  75734. set isVisible(value: boolean);
  75735. /** Gets a boolean indicating that the control needs to update its rendering */
  75736. get isDirty(): boolean;
  75737. /**
  75738. * Gets the current linked mesh (or null if none)
  75739. */
  75740. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75741. /**
  75742. * Gets or sets a value indicating the padding to use on the left of the control
  75743. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75744. */
  75745. get paddingLeft(): string | number;
  75746. set paddingLeft(value: string | number);
  75747. /**
  75748. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  75749. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75750. */
  75751. get paddingLeftInPixels(): number;
  75752. set paddingLeftInPixels(value: number);
  75753. /**
  75754. * Gets or sets a value indicating the padding to use on the right of the control
  75755. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75756. */
  75757. get paddingRight(): string | number;
  75758. set paddingRight(value: string | number);
  75759. /**
  75760. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  75761. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75762. */
  75763. get paddingRightInPixels(): number;
  75764. set paddingRightInPixels(value: number);
  75765. /**
  75766. * Gets or sets a value indicating the padding to use on the top of the control
  75767. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75768. */
  75769. get paddingTop(): string | number;
  75770. set paddingTop(value: string | number);
  75771. /**
  75772. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  75773. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75774. */
  75775. get paddingTopInPixels(): number;
  75776. set paddingTopInPixels(value: number);
  75777. /**
  75778. * Gets or sets a value indicating the padding to use on the bottom of the control
  75779. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75780. */
  75781. get paddingBottom(): string | number;
  75782. set paddingBottom(value: string | number);
  75783. /**
  75784. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  75785. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75786. */
  75787. get paddingBottomInPixels(): number;
  75788. set paddingBottomInPixels(value: number);
  75789. /**
  75790. * Gets or sets a value indicating the left coordinate of the control
  75791. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75792. */
  75793. get left(): string | number;
  75794. set left(value: string | number);
  75795. /**
  75796. * Gets or sets a value indicating the left coordinate in pixels of the control
  75797. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75798. */
  75799. get leftInPixels(): number;
  75800. set leftInPixels(value: number);
  75801. /**
  75802. * Gets or sets a value indicating the top coordinate of the control
  75803. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75804. */
  75805. get top(): string | number;
  75806. set top(value: string | number);
  75807. /**
  75808. * Gets or sets a value indicating the top coordinate in pixels of the control
  75809. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75810. */
  75811. get topInPixels(): number;
  75812. set topInPixels(value: number);
  75813. /**
  75814. * Gets or sets a value indicating the offset on X axis to the linked mesh
  75815. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75816. */
  75817. get linkOffsetX(): string | number;
  75818. set linkOffsetX(value: string | number);
  75819. /**
  75820. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  75821. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75822. */
  75823. get linkOffsetXInPixels(): number;
  75824. set linkOffsetXInPixels(value: number);
  75825. /**
  75826. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  75827. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75828. */
  75829. get linkOffsetY(): string | number;
  75830. set linkOffsetY(value: string | number);
  75831. /**
  75832. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  75833. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75834. */
  75835. get linkOffsetYInPixels(): number;
  75836. set linkOffsetYInPixels(value: number);
  75837. /** Gets the center coordinate on X axis */
  75838. get centerX(): number;
  75839. /** Gets the center coordinate on Y axis */
  75840. get centerY(): number;
  75841. /** Gets or sets if control is Enabled*/
  75842. get isEnabled(): boolean;
  75843. set isEnabled(value: boolean);
  75844. /** Gets or sets background color of control if it's disabled*/
  75845. get disabledColor(): string;
  75846. set disabledColor(value: string);
  75847. /** Gets or sets front color of control if it's disabled*/
  75848. get disabledColorItem(): string;
  75849. set disabledColorItem(value: string);
  75850. /**
  75851. * Creates a new control
  75852. * @param name defines the name of the control
  75853. */
  75854. constructor(
  75855. /** defines the name of the control */
  75856. name?: string | undefined);
  75857. /** @hidden */
  75858. protected _getTypeName(): string;
  75859. /**
  75860. * Gets the first ascendant in the hierarchy of the given type
  75861. * @param className defines the required type
  75862. * @returns the ascendant or null if not found
  75863. */
  75864. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  75865. /** @hidden */
  75866. _resetFontCache(): void;
  75867. /**
  75868. * Determines if a container is an ascendant of the current control
  75869. * @param container defines the container to look for
  75870. * @returns true if the container is one of the ascendant of the control
  75871. */
  75872. isAscendant(container: Control): boolean;
  75873. /**
  75874. * Gets coordinates in local control space
  75875. * @param globalCoordinates defines the coordinates to transform
  75876. * @returns the new coordinates in local space
  75877. */
  75878. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75879. /**
  75880. * Gets coordinates in local control space
  75881. * @param globalCoordinates defines the coordinates to transform
  75882. * @param result defines the target vector2 where to store the result
  75883. * @returns the current control
  75884. */
  75885. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  75886. /**
  75887. * Gets coordinates in parent local control space
  75888. * @param globalCoordinates defines the coordinates to transform
  75889. * @returns the new coordinates in parent local space
  75890. */
  75891. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  75892. /**
  75893. * Move the current control to a vector3 position projected onto the screen.
  75894. * @param position defines the target position
  75895. * @param scene defines the hosting scene
  75896. */
  75897. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  75898. /**
  75899. * Will store all controls that have this control as ascendant in a given array
  75900. * @param results defines the array where to store the descendants
  75901. * @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
  75902. * @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
  75903. */
  75904. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  75905. /**
  75906. * Will return all controls that have this control as ascendant
  75907. * @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
  75908. * @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
  75909. * @return all child controls
  75910. */
  75911. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75912. /**
  75913. * Link current control with a target mesh
  75914. * @param mesh defines the mesh to link with
  75915. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  75916. */
  75917. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  75918. /** @hidden */
  75919. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  75920. /** @hidden */
  75921. _offsetLeft(offset: number): void;
  75922. /** @hidden */
  75923. _offsetTop(offset: number): void;
  75924. /** @hidden */
  75925. _markMatrixAsDirty(): void;
  75926. /** @hidden */
  75927. _flagDescendantsAsMatrixDirty(): void;
  75928. /** @hidden */
  75929. _intersectsRect(rect: Measure): boolean;
  75930. /** @hidden */
  75931. protected invalidateRect(): void;
  75932. /** @hidden */
  75933. _markAsDirty(force?: boolean): void;
  75934. /** @hidden */
  75935. _markAllAsDirty(): void;
  75936. /** @hidden */
  75937. _link(host: AdvancedDynamicTexture): void;
  75938. /** @hidden */
  75939. protected _transform(context?: CanvasRenderingContext2D): void;
  75940. /** @hidden */
  75941. _renderHighlight(context: CanvasRenderingContext2D): void;
  75942. /** @hidden */
  75943. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75944. /** @hidden */
  75945. protected _applyStates(context: CanvasRenderingContext2D): void;
  75946. /** @hidden */
  75947. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75948. /** @hidden */
  75949. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75950. protected _evaluateClippingState(parentMeasure: Measure): void;
  75951. /** @hidden */
  75952. _measure(): void;
  75953. /** @hidden */
  75954. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75955. /** @hidden */
  75956. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75957. /** @hidden */
  75958. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75959. /** @hidden */
  75960. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  75961. private static _ClipMeasure;
  75962. private _tmpMeasureA;
  75963. private _clip;
  75964. /** @hidden */
  75965. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  75966. /** @hidden */
  75967. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75968. /**
  75969. * Tests if a given coordinates belong to the current control
  75970. * @param x defines x coordinate to test
  75971. * @param y defines y coordinate to test
  75972. * @returns true if the coordinates are inside the control
  75973. */
  75974. contains(x: number, y: number): boolean;
  75975. /** @hidden */
  75976. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75977. /** @hidden */
  75978. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75979. /** @hidden */
  75980. _onPointerEnter(target: Control): boolean;
  75981. /** @hidden */
  75982. _onPointerOut(target: Control, force?: boolean): void;
  75983. /** @hidden */
  75984. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75985. /** @hidden */
  75986. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75987. /** @hidden */
  75988. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  75989. /** @hidden */
  75990. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  75991. /** @hidden */
  75992. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  75993. private _prepareFont;
  75994. /** Releases associated resources */
  75995. dispose(): void;
  75996. private static _HORIZONTAL_ALIGNMENT_LEFT;
  75997. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  75998. private static _HORIZONTAL_ALIGNMENT_CENTER;
  75999. private static _VERTICAL_ALIGNMENT_TOP;
  76000. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76001. private static _VERTICAL_ALIGNMENT_CENTER;
  76002. /** HORIZONTAL_ALIGNMENT_LEFT */
  76003. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76004. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76005. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76006. /** HORIZONTAL_ALIGNMENT_CENTER */
  76007. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76008. /** VERTICAL_ALIGNMENT_TOP */
  76009. static get VERTICAL_ALIGNMENT_TOP(): number;
  76010. /** VERTICAL_ALIGNMENT_BOTTOM */
  76011. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76012. /** VERTICAL_ALIGNMENT_CENTER */
  76013. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76014. private static _FontHeightSizes;
  76015. /** @hidden */
  76016. static _GetFontOffset(font: string): {
  76017. ascent: number;
  76018. height: number;
  76019. descent: number;
  76020. };
  76021. /**
  76022. * Creates a stack panel that can be used to render headers
  76023. * @param control defines the control to associate with the header
  76024. * @param text defines the text of the header
  76025. * @param size defines the size of the header
  76026. * @param options defines options used to configure the header
  76027. * @returns a new StackPanel
  76028. * @ignore
  76029. * @hidden
  76030. */
  76031. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76032. isHorizontal: boolean;
  76033. controlFirst: boolean;
  76034. }) => any;
  76035. /** @hidden */
  76036. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76037. }
  76038. }
  76039. declare module BABYLON.GUI {
  76040. /**
  76041. * Root class for 2D containers
  76042. * @see https://doc.babylonjs.com/how_to/gui#containers
  76043. */
  76044. export class Container extends Control {
  76045. name?: string | undefined;
  76046. /** @hidden */
  76047. _children: Control[];
  76048. /** @hidden */
  76049. protected _measureForChildren: Measure;
  76050. /** @hidden */
  76051. protected _background: string;
  76052. /** @hidden */
  76053. protected _adaptWidthToChildren: boolean;
  76054. /** @hidden */
  76055. protected _adaptHeightToChildren: boolean;
  76056. /**
  76057. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76058. */
  76059. logLayoutCycleErrors: boolean;
  76060. /**
  76061. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76062. */
  76063. maxLayoutCycle: number;
  76064. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76065. get adaptHeightToChildren(): boolean;
  76066. set adaptHeightToChildren(value: boolean);
  76067. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76068. get adaptWidthToChildren(): boolean;
  76069. set adaptWidthToChildren(value: boolean);
  76070. /** Gets or sets background color */
  76071. get background(): string;
  76072. set background(value: string);
  76073. /** Gets the list of children */
  76074. get children(): Control[];
  76075. /**
  76076. * Creates a new Container
  76077. * @param name defines the name of the container
  76078. */
  76079. constructor(name?: string | undefined);
  76080. protected _getTypeName(): string;
  76081. _flagDescendantsAsMatrixDirty(): void;
  76082. /**
  76083. * Gets a child using its name
  76084. * @param name defines the child name to look for
  76085. * @returns the child control if found
  76086. */
  76087. getChildByName(name: string): BABYLON.Nullable<Control>;
  76088. /**
  76089. * Gets a child using its type and its name
  76090. * @param name defines the child name to look for
  76091. * @param type defines the child type to look for
  76092. * @returns the child control if found
  76093. */
  76094. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76095. /**
  76096. * Search for a specific control in children
  76097. * @param control defines the control to look for
  76098. * @returns true if the control is in child list
  76099. */
  76100. containsControl(control: Control): boolean;
  76101. /**
  76102. * Adds a new control to the current container
  76103. * @param control defines the control to add
  76104. * @returns the current container
  76105. */
  76106. addControl(control: BABYLON.Nullable<Control>): Container;
  76107. /**
  76108. * Removes all controls from the current container
  76109. * @returns the current container
  76110. */
  76111. clearControls(): Container;
  76112. /**
  76113. * Removes a control from the current container
  76114. * @param control defines the control to remove
  76115. * @returns the current container
  76116. */
  76117. removeControl(control: Control): Container;
  76118. /** @hidden */
  76119. _reOrderControl(control: Control): void;
  76120. /** @hidden */
  76121. _offsetLeft(offset: number): void;
  76122. /** @hidden */
  76123. _offsetTop(offset: number): void;
  76124. /** @hidden */
  76125. _markAllAsDirty(): void;
  76126. /** @hidden */
  76127. protected _localDraw(context: CanvasRenderingContext2D): void;
  76128. /** @hidden */
  76129. _link(host: AdvancedDynamicTexture): void;
  76130. /** @hidden */
  76131. protected _beforeLayout(): void;
  76132. /** @hidden */
  76133. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76134. /** @hidden */
  76135. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76136. protected _postMeasure(): void;
  76137. /** @hidden */
  76138. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76139. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76140. /** @hidden */
  76141. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76142. /** @hidden */
  76143. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76144. /** Releases associated resources */
  76145. dispose(): void;
  76146. }
  76147. }
  76148. declare module BABYLON.GUI {
  76149. /** Class used to create rectangle container */
  76150. export class Rectangle extends Container {
  76151. name?: string | undefined;
  76152. private _thickness;
  76153. private _cornerRadius;
  76154. /** Gets or sets border thickness */
  76155. get thickness(): number;
  76156. set thickness(value: number);
  76157. /** Gets or sets the corner radius angle */
  76158. get cornerRadius(): number;
  76159. set cornerRadius(value: number);
  76160. /**
  76161. * Creates a new Rectangle
  76162. * @param name defines the control name
  76163. */
  76164. constructor(name?: string | undefined);
  76165. protected _getTypeName(): string;
  76166. protected _localDraw(context: CanvasRenderingContext2D): void;
  76167. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76168. private _drawRoundedRect;
  76169. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76170. }
  76171. }
  76172. declare module BABYLON.GUI {
  76173. /**
  76174. * Enum that determines the text-wrapping mode to use.
  76175. */
  76176. export enum TextWrapping {
  76177. /**
  76178. * Clip the text when it's larger than Control.width; this is the default mode.
  76179. */
  76180. Clip = 0,
  76181. /**
  76182. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76183. */
  76184. WordWrap = 1,
  76185. /**
  76186. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76187. */
  76188. Ellipsis = 2
  76189. }
  76190. /**
  76191. * Class used to create text block control
  76192. */
  76193. export class TextBlock extends Control {
  76194. /**
  76195. * Defines the name of the control
  76196. */
  76197. name?: string | undefined;
  76198. private _text;
  76199. private _textWrapping;
  76200. private _textHorizontalAlignment;
  76201. private _textVerticalAlignment;
  76202. private _lines;
  76203. private _resizeToFit;
  76204. private _lineSpacing;
  76205. private _outlineWidth;
  76206. private _outlineColor;
  76207. /**
  76208. * An event triggered after the text is changed
  76209. */
  76210. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76211. /**
  76212. * An event triggered after the text was broken up into lines
  76213. */
  76214. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76215. /**
  76216. * Function used to split a string into words. By default, a string is split at each space character found
  76217. */
  76218. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76219. /**
  76220. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76221. */
  76222. get lines(): any[];
  76223. /**
  76224. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76225. */
  76226. get resizeToFit(): boolean;
  76227. /**
  76228. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76229. */
  76230. set resizeToFit(value: boolean);
  76231. /**
  76232. * Gets or sets a boolean indicating if text must be wrapped
  76233. */
  76234. get textWrapping(): TextWrapping | boolean;
  76235. /**
  76236. * Gets or sets a boolean indicating if text must be wrapped
  76237. */
  76238. set textWrapping(value: TextWrapping | boolean);
  76239. /**
  76240. * Gets or sets text to display
  76241. */
  76242. get text(): string;
  76243. /**
  76244. * Gets or sets text to display
  76245. */
  76246. set text(value: string);
  76247. /**
  76248. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76249. */
  76250. get textHorizontalAlignment(): number;
  76251. /**
  76252. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76253. */
  76254. set textHorizontalAlignment(value: number);
  76255. /**
  76256. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76257. */
  76258. get textVerticalAlignment(): number;
  76259. /**
  76260. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76261. */
  76262. set textVerticalAlignment(value: number);
  76263. /**
  76264. * Gets or sets line spacing value
  76265. */
  76266. set lineSpacing(value: string | number);
  76267. /**
  76268. * Gets or sets line spacing value
  76269. */
  76270. get lineSpacing(): string | number;
  76271. /**
  76272. * Gets or sets outlineWidth of the text to display
  76273. */
  76274. get outlineWidth(): number;
  76275. /**
  76276. * Gets or sets outlineWidth of the text to display
  76277. */
  76278. set outlineWidth(value: number);
  76279. /**
  76280. * Gets or sets outlineColor of the text to display
  76281. */
  76282. get outlineColor(): string;
  76283. /**
  76284. * Gets or sets outlineColor of the text to display
  76285. */
  76286. set outlineColor(value: string);
  76287. /**
  76288. * Creates a new TextBlock object
  76289. * @param name defines the name of the control
  76290. * @param text defines the text to display (emptry string by default)
  76291. */
  76292. constructor(
  76293. /**
  76294. * Defines the name of the control
  76295. */
  76296. name?: string | undefined, text?: string);
  76297. protected _getTypeName(): string;
  76298. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76299. private _drawText;
  76300. /** @hidden */
  76301. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76302. protected _applyStates(context: CanvasRenderingContext2D): void;
  76303. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76304. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76305. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76306. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76307. protected _renderLines(context: CanvasRenderingContext2D): void;
  76308. /**
  76309. * Given a width constraint applied on the text block, find the expected height
  76310. * @returns expected height
  76311. */
  76312. computeExpectedHeight(): number;
  76313. dispose(): void;
  76314. }
  76315. }
  76316. declare module BABYLON.GUI {
  76317. /**
  76318. * Class used to create 2D images
  76319. */
  76320. export class Image extends Control {
  76321. name?: string | undefined;
  76322. private _workingCanvas;
  76323. private _domImage;
  76324. private _imageWidth;
  76325. private _imageHeight;
  76326. private _loaded;
  76327. private _stretch;
  76328. private _source;
  76329. private _autoScale;
  76330. private _sourceLeft;
  76331. private _sourceTop;
  76332. private _sourceWidth;
  76333. private _sourceHeight;
  76334. private _svgAttributesComputationCompleted;
  76335. private _isSVG;
  76336. private _cellWidth;
  76337. private _cellHeight;
  76338. private _cellId;
  76339. private _populateNinePatchSlicesFromImage;
  76340. private _sliceLeft;
  76341. private _sliceRight;
  76342. private _sliceTop;
  76343. private _sliceBottom;
  76344. private _detectPointerOnOpaqueOnly;
  76345. /**
  76346. * BABYLON.Observable notified when the content is loaded
  76347. */
  76348. onImageLoadedObservable: BABYLON.Observable<Image>;
  76349. /**
  76350. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76351. */
  76352. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76353. /**
  76354. * Gets a boolean indicating that the content is loaded
  76355. */
  76356. get isLoaded(): boolean;
  76357. /**
  76358. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76359. */
  76360. get populateNinePatchSlicesFromImage(): boolean;
  76361. set populateNinePatchSlicesFromImage(value: boolean);
  76362. /**
  76363. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76364. * Beware using this as this will comsume more memory as the image has to be stored twice
  76365. */
  76366. get detectPointerOnOpaqueOnly(): boolean;
  76367. set detectPointerOnOpaqueOnly(value: boolean);
  76368. /**
  76369. * Gets or sets the left value for slicing (9-patch)
  76370. */
  76371. get sliceLeft(): number;
  76372. set sliceLeft(value: number);
  76373. /**
  76374. * Gets or sets the right value for slicing (9-patch)
  76375. */
  76376. get sliceRight(): number;
  76377. set sliceRight(value: number);
  76378. /**
  76379. * Gets or sets the top value for slicing (9-patch)
  76380. */
  76381. get sliceTop(): number;
  76382. set sliceTop(value: number);
  76383. /**
  76384. * Gets or sets the bottom value for slicing (9-patch)
  76385. */
  76386. get sliceBottom(): number;
  76387. set sliceBottom(value: number);
  76388. /**
  76389. * Gets or sets the left coordinate in the source image
  76390. */
  76391. get sourceLeft(): number;
  76392. set sourceLeft(value: number);
  76393. /**
  76394. * Gets or sets the top coordinate in the source image
  76395. */
  76396. get sourceTop(): number;
  76397. set sourceTop(value: number);
  76398. /**
  76399. * Gets or sets the width to capture in the source image
  76400. */
  76401. get sourceWidth(): number;
  76402. set sourceWidth(value: number);
  76403. /**
  76404. * Gets or sets the height to capture in the source image
  76405. */
  76406. get sourceHeight(): number;
  76407. set sourceHeight(value: number);
  76408. /** Indicates if the format of the image is SVG */
  76409. get isSVG(): boolean;
  76410. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76411. get svgAttributesComputationCompleted(): boolean;
  76412. /**
  76413. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76414. * @see https://doc.babylonjs.com/how_to/gui#image
  76415. */
  76416. get autoScale(): boolean;
  76417. set autoScale(value: boolean);
  76418. /** Gets or sets the streching mode used by the image */
  76419. get stretch(): number;
  76420. set stretch(value: number);
  76421. /** @hidden */
  76422. _rotate90(n: number, preserveProperties?: boolean): Image;
  76423. private _handleRotationForSVGImage;
  76424. private _rotate90SourceProperties;
  76425. /**
  76426. * Gets or sets the internal DOM image used to render the control
  76427. */
  76428. set domImage(value: HTMLImageElement);
  76429. get domImage(): HTMLImageElement;
  76430. private _onImageLoaded;
  76431. private _extractNinePatchSliceDataFromImage;
  76432. /**
  76433. * Gets or sets image source url
  76434. */
  76435. set source(value: BABYLON.Nullable<string>);
  76436. /**
  76437. * Checks for svg document with icon id present
  76438. */
  76439. private _svgCheck;
  76440. /**
  76441. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76442. * given external svg file and icon id
  76443. */
  76444. private _getSVGAttribs;
  76445. /**
  76446. * Gets or sets the cell width to use when animation sheet is enabled
  76447. * @see https://doc.babylonjs.com/how_to/gui#image
  76448. */
  76449. get cellWidth(): number;
  76450. set cellWidth(value: number);
  76451. /**
  76452. * Gets or sets the cell height to use when animation sheet is enabled
  76453. * @see https://doc.babylonjs.com/how_to/gui#image
  76454. */
  76455. get cellHeight(): number;
  76456. set cellHeight(value: number);
  76457. /**
  76458. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76459. * @see https://doc.babylonjs.com/how_to/gui#image
  76460. */
  76461. get cellId(): number;
  76462. set cellId(value: number);
  76463. /**
  76464. * Creates a new Image
  76465. * @param name defines the control name
  76466. * @param url defines the image url
  76467. */
  76468. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76469. /**
  76470. * Tests if a given coordinates belong to the current control
  76471. * @param x defines x coordinate to test
  76472. * @param y defines y coordinate to test
  76473. * @returns true if the coordinates are inside the control
  76474. */
  76475. contains(x: number, y: number): boolean;
  76476. protected _getTypeName(): string;
  76477. /** Force the control to synchronize with its content */
  76478. synchronizeSizeWithContent(): void;
  76479. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76480. private _prepareWorkingCanvasForOpaqueDetection;
  76481. private _drawImage;
  76482. _draw(context: CanvasRenderingContext2D): void;
  76483. private _renderCornerPatch;
  76484. private _renderNinePatch;
  76485. dispose(): void;
  76486. /** STRETCH_NONE */
  76487. static readonly STRETCH_NONE: number;
  76488. /** STRETCH_FILL */
  76489. static readonly STRETCH_FILL: number;
  76490. /** STRETCH_UNIFORM */
  76491. static readonly STRETCH_UNIFORM: number;
  76492. /** STRETCH_EXTEND */
  76493. static readonly STRETCH_EXTEND: number;
  76494. /** NINE_PATCH */
  76495. static readonly STRETCH_NINE_PATCH: number;
  76496. }
  76497. }
  76498. declare module BABYLON.GUI {
  76499. /**
  76500. * Class used to create 2D buttons
  76501. */
  76502. export class Button extends Rectangle {
  76503. name?: string | undefined;
  76504. /**
  76505. * Function called to generate a pointer enter animation
  76506. */
  76507. pointerEnterAnimation: () => void;
  76508. /**
  76509. * Function called to generate a pointer out animation
  76510. */
  76511. pointerOutAnimation: () => void;
  76512. /**
  76513. * Function called to generate a pointer down animation
  76514. */
  76515. pointerDownAnimation: () => void;
  76516. /**
  76517. * Function called to generate a pointer up animation
  76518. */
  76519. pointerUpAnimation: () => void;
  76520. /**
  76521. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76522. */
  76523. delegatePickingToChildren: boolean;
  76524. private _image;
  76525. /**
  76526. * Returns the image part of the button (if any)
  76527. */
  76528. get image(): BABYLON.Nullable<Image>;
  76529. private _textBlock;
  76530. /**
  76531. * Returns the image part of the button (if any)
  76532. */
  76533. get textBlock(): BABYLON.Nullable<TextBlock>;
  76534. /**
  76535. * Creates a new Button
  76536. * @param name defines the name of the button
  76537. */
  76538. constructor(name?: string | undefined);
  76539. protected _getTypeName(): string;
  76540. /** @hidden */
  76541. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76542. /** @hidden */
  76543. _onPointerEnter(target: Control): boolean;
  76544. /** @hidden */
  76545. _onPointerOut(target: Control, force?: boolean): void;
  76546. /** @hidden */
  76547. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76548. /** @hidden */
  76549. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76550. /**
  76551. * Creates a new button made with an image and a text
  76552. * @param name defines the name of the button
  76553. * @param text defines the text of the button
  76554. * @param imageUrl defines the url of the image
  76555. * @returns a new Button
  76556. */
  76557. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76558. /**
  76559. * Creates a new button made with an image
  76560. * @param name defines the name of the button
  76561. * @param imageUrl defines the url of the image
  76562. * @returns a new Button
  76563. */
  76564. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76565. /**
  76566. * Creates a new button made with a text
  76567. * @param name defines the name of the button
  76568. * @param text defines the text of the button
  76569. * @returns a new Button
  76570. */
  76571. static CreateSimpleButton(name: string, text: string): Button;
  76572. /**
  76573. * Creates a new button made with an image and a centered text
  76574. * @param name defines the name of the button
  76575. * @param text defines the text of the button
  76576. * @param imageUrl defines the url of the image
  76577. * @returns a new Button
  76578. */
  76579. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76580. }
  76581. }
  76582. declare module BABYLON.GUI {
  76583. /**
  76584. * Class used to create a 2D stack panel container
  76585. */
  76586. export class StackPanel extends Container {
  76587. name?: string | undefined;
  76588. private _isVertical;
  76589. private _manualWidth;
  76590. private _manualHeight;
  76591. private _doNotTrackManualChanges;
  76592. /**
  76593. * Gets or sets a boolean indicating that layou warnings should be ignored
  76594. */
  76595. ignoreLayoutWarnings: boolean;
  76596. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76597. get isVertical(): boolean;
  76598. set isVertical(value: boolean);
  76599. /**
  76600. * Gets or sets panel width.
  76601. * This value should not be set when in horizontal mode as it will be computed automatically
  76602. */
  76603. set width(value: string | number);
  76604. get width(): string | number;
  76605. /**
  76606. * Gets or sets panel height.
  76607. * This value should not be set when in vertical mode as it will be computed automatically
  76608. */
  76609. set height(value: string | number);
  76610. get height(): string | number;
  76611. /**
  76612. * Creates a new StackPanel
  76613. * @param name defines control name
  76614. */
  76615. constructor(name?: string | undefined);
  76616. protected _getTypeName(): string;
  76617. /** @hidden */
  76618. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76619. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76620. protected _postMeasure(): void;
  76621. }
  76622. }
  76623. declare module BABYLON.GUI {
  76624. /**
  76625. * Class used to represent a 2D checkbox
  76626. */
  76627. export class Checkbox extends Control {
  76628. name?: string | undefined;
  76629. private _isChecked;
  76630. private _background;
  76631. private _checkSizeRatio;
  76632. private _thickness;
  76633. /** Gets or sets border thickness */
  76634. get thickness(): number;
  76635. set thickness(value: number);
  76636. /**
  76637. * BABYLON.Observable raised when isChecked property changes
  76638. */
  76639. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76640. /** Gets or sets a value indicating the ratio between overall size and check size */
  76641. get checkSizeRatio(): number;
  76642. set checkSizeRatio(value: number);
  76643. /** Gets or sets background color */
  76644. get background(): string;
  76645. set background(value: string);
  76646. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76647. get isChecked(): boolean;
  76648. set isChecked(value: boolean);
  76649. /**
  76650. * Creates a new CheckBox
  76651. * @param name defines the control name
  76652. */
  76653. constructor(name?: string | undefined);
  76654. protected _getTypeName(): string;
  76655. /** @hidden */
  76656. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76657. /** @hidden */
  76658. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76659. /**
  76660. * Utility function to easily create a checkbox with a header
  76661. * @param title defines the label to use for the header
  76662. * @param onValueChanged defines the callback to call when value changes
  76663. * @returns a StackPanel containing the checkbox and a textBlock
  76664. */
  76665. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76666. }
  76667. }
  76668. declare module BABYLON.GUI {
  76669. /**
  76670. * Class used to store key control properties
  76671. */
  76672. export class KeyPropertySet {
  76673. /** Width */
  76674. width?: string;
  76675. /** Height */
  76676. height?: string;
  76677. /** Left padding */
  76678. paddingLeft?: string;
  76679. /** Right padding */
  76680. paddingRight?: string;
  76681. /** Top padding */
  76682. paddingTop?: string;
  76683. /** Bottom padding */
  76684. paddingBottom?: string;
  76685. /** Foreground color */
  76686. color?: string;
  76687. /** Background color */
  76688. background?: string;
  76689. }
  76690. /**
  76691. * Class used to create virtual keyboard
  76692. */
  76693. export class VirtualKeyboard extends StackPanel {
  76694. /** BABYLON.Observable raised when a key is pressed */
  76695. onKeyPressObservable: BABYLON.Observable<string>;
  76696. /** Gets or sets default key button width */
  76697. defaultButtonWidth: string;
  76698. /** Gets or sets default key button height */
  76699. defaultButtonHeight: string;
  76700. /** Gets or sets default key button left padding */
  76701. defaultButtonPaddingLeft: string;
  76702. /** Gets or sets default key button right padding */
  76703. defaultButtonPaddingRight: string;
  76704. /** Gets or sets default key button top padding */
  76705. defaultButtonPaddingTop: string;
  76706. /** Gets or sets default key button bottom padding */
  76707. defaultButtonPaddingBottom: string;
  76708. /** Gets or sets default key button foreground color */
  76709. defaultButtonColor: string;
  76710. /** Gets or sets default key button background color */
  76711. defaultButtonBackground: string;
  76712. /** Gets or sets shift button foreground color */
  76713. shiftButtonColor: string;
  76714. /** Gets or sets shift button thickness*/
  76715. selectedShiftThickness: number;
  76716. /** Gets shift key state */
  76717. shiftState: number;
  76718. protected _getTypeName(): string;
  76719. private _createKey;
  76720. /**
  76721. * Adds a new row of keys
  76722. * @param keys defines the list of keys to add
  76723. * @param propertySets defines the associated property sets
  76724. */
  76725. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  76726. /**
  76727. * Set the shift key to a specific state
  76728. * @param shiftState defines the new shift state
  76729. */
  76730. applyShiftState(shiftState: number): void;
  76731. private _currentlyConnectedInputText;
  76732. private _connectedInputTexts;
  76733. private _onKeyPressObserver;
  76734. /** Gets the input text control currently attached to the keyboard */
  76735. get connectedInputText(): BABYLON.Nullable<InputText>;
  76736. /**
  76737. * Connects the keyboard with an input text control
  76738. *
  76739. * @param input defines the target control
  76740. */
  76741. connect(input: InputText): void;
  76742. /**
  76743. * Disconnects the keyboard from connected InputText controls
  76744. *
  76745. * @param input optionally defines a target control, otherwise all are disconnected
  76746. */
  76747. disconnect(input?: InputText): void;
  76748. private _removeConnectedInputObservables;
  76749. /**
  76750. * Release all resources
  76751. */
  76752. dispose(): void;
  76753. /**
  76754. * Creates a new keyboard using a default layout
  76755. *
  76756. * @param name defines control name
  76757. * @returns a new VirtualKeyboard
  76758. */
  76759. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  76760. }
  76761. }
  76762. declare module BABYLON.GUI {
  76763. /**
  76764. * Class used to create input text control
  76765. */
  76766. export class InputText extends Control implements IFocusableControl {
  76767. name?: string | undefined;
  76768. private _text;
  76769. private _placeholderText;
  76770. private _background;
  76771. private _focusedBackground;
  76772. private _focusedColor;
  76773. private _placeholderColor;
  76774. private _thickness;
  76775. private _margin;
  76776. private _autoStretchWidth;
  76777. private _maxWidth;
  76778. private _isFocused;
  76779. private _blinkTimeout;
  76780. private _blinkIsEven;
  76781. private _cursorOffset;
  76782. private _scrollLeft;
  76783. private _textWidth;
  76784. private _clickedCoordinate;
  76785. private _deadKey;
  76786. private _addKey;
  76787. private _currentKey;
  76788. private _isTextHighlightOn;
  76789. private _textHighlightColor;
  76790. private _highligherOpacity;
  76791. private _highlightedText;
  76792. private _startHighlightIndex;
  76793. private _endHighlightIndex;
  76794. private _cursorIndex;
  76795. private _onFocusSelectAll;
  76796. private _isPointerDown;
  76797. private _onClipboardObserver;
  76798. private _onPointerDblTapObserver;
  76799. /** @hidden */
  76800. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  76801. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  76802. promptMessage: string;
  76803. /** Force disable prompt on mobile device */
  76804. disableMobilePrompt: boolean;
  76805. /** BABYLON.Observable raised when the text changes */
  76806. onTextChangedObservable: BABYLON.Observable<InputText>;
  76807. /** BABYLON.Observable raised just before an entered character is to be added */
  76808. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  76809. /** BABYLON.Observable raised when the control gets the focus */
  76810. onFocusObservable: BABYLON.Observable<InputText>;
  76811. /** BABYLON.Observable raised when the control loses the focus */
  76812. onBlurObservable: BABYLON.Observable<InputText>;
  76813. /**Observable raised when the text is highlighted */
  76814. onTextHighlightObservable: BABYLON.Observable<InputText>;
  76815. /**Observable raised when copy event is triggered */
  76816. onTextCopyObservable: BABYLON.Observable<InputText>;
  76817. /** BABYLON.Observable raised when cut event is triggered */
  76818. onTextCutObservable: BABYLON.Observable<InputText>;
  76819. /** BABYLON.Observable raised when paste event is triggered */
  76820. onTextPasteObservable: BABYLON.Observable<InputText>;
  76821. /** BABYLON.Observable raised when a key event was processed */
  76822. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  76823. /** Gets or sets the maximum width allowed by the control */
  76824. get maxWidth(): string | number;
  76825. /** Gets the maximum width allowed by the control in pixels */
  76826. get maxWidthInPixels(): number;
  76827. set maxWidth(value: string | number);
  76828. /** Gets or sets the text highlighter transparency; default: 0.4 */
  76829. get highligherOpacity(): number;
  76830. set highligherOpacity(value: number);
  76831. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  76832. get onFocusSelectAll(): boolean;
  76833. set onFocusSelectAll(value: boolean);
  76834. /** Gets or sets the text hightlight color */
  76835. get textHighlightColor(): string;
  76836. set textHighlightColor(value: string);
  76837. /** Gets or sets control margin */
  76838. get margin(): string;
  76839. /** Gets control margin in pixels */
  76840. get marginInPixels(): number;
  76841. set margin(value: string);
  76842. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  76843. get autoStretchWidth(): boolean;
  76844. set autoStretchWidth(value: boolean);
  76845. /** Gets or sets border thickness */
  76846. get thickness(): number;
  76847. set thickness(value: number);
  76848. /** Gets or sets the background color when focused */
  76849. get focusedBackground(): string;
  76850. set focusedBackground(value: string);
  76851. /** Gets or sets the background color when focused */
  76852. get focusedColor(): string;
  76853. set focusedColor(value: string);
  76854. /** Gets or sets the background color */
  76855. get background(): string;
  76856. set background(value: string);
  76857. /** Gets or sets the placeholder color */
  76858. get placeholderColor(): string;
  76859. set placeholderColor(value: string);
  76860. /** Gets or sets the text displayed when the control is empty */
  76861. get placeholderText(): string;
  76862. set placeholderText(value: string);
  76863. /** Gets or sets the dead key flag */
  76864. get deadKey(): boolean;
  76865. set deadKey(flag: boolean);
  76866. /** Gets or sets the highlight text */
  76867. get highlightedText(): string;
  76868. set highlightedText(text: string);
  76869. /** Gets or sets if the current key should be added */
  76870. get addKey(): boolean;
  76871. set addKey(flag: boolean);
  76872. /** Gets or sets the value of the current key being entered */
  76873. get currentKey(): string;
  76874. set currentKey(key: string);
  76875. /** Gets or sets the text displayed in the control */
  76876. get text(): string;
  76877. set text(value: string);
  76878. /** Gets or sets control width */
  76879. get width(): string | number;
  76880. set width(value: string | number);
  76881. /**
  76882. * Creates a new InputText
  76883. * @param name defines the control name
  76884. * @param text defines the text of the control
  76885. */
  76886. constructor(name?: string | undefined, text?: string);
  76887. /** @hidden */
  76888. onBlur(): void;
  76889. /** @hidden */
  76890. onFocus(): void;
  76891. protected _getTypeName(): string;
  76892. /**
  76893. * Function called to get the list of controls that should not steal the focus from this control
  76894. * @returns an array of controls
  76895. */
  76896. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  76897. /** @hidden */
  76898. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  76899. /** @hidden */
  76900. private _updateValueFromCursorIndex;
  76901. /** @hidden */
  76902. private _processDblClick;
  76903. /** @hidden */
  76904. private _selectAllText;
  76905. /**
  76906. * Handles the keyboard event
  76907. * @param evt Defines the KeyboardEvent
  76908. */
  76909. processKeyboard(evt: KeyboardEvent): void;
  76910. /** @hidden */
  76911. private _onCopyText;
  76912. /** @hidden */
  76913. private _onCutText;
  76914. /** @hidden */
  76915. private _onPasteText;
  76916. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76917. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76918. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76919. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76920. protected _beforeRenderText(text: string): string;
  76921. dispose(): void;
  76922. }
  76923. }
  76924. declare module BABYLON.GUI {
  76925. /**
  76926. * Class used to create a 2D grid container
  76927. */
  76928. export class Grid extends Container {
  76929. name?: string | undefined;
  76930. private _rowDefinitions;
  76931. private _columnDefinitions;
  76932. private _cells;
  76933. private _childControls;
  76934. /**
  76935. * Gets the number of columns
  76936. */
  76937. get columnCount(): number;
  76938. /**
  76939. * Gets the number of rows
  76940. */
  76941. get rowCount(): number;
  76942. /** Gets the list of children */
  76943. get children(): Control[];
  76944. /** Gets the list of cells (e.g. the containers) */
  76945. get cells(): {
  76946. [key: string]: Container;
  76947. };
  76948. /**
  76949. * Gets the definition of a specific row
  76950. * @param index defines the index of the row
  76951. * @returns the row definition
  76952. */
  76953. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76954. /**
  76955. * Gets the definition of a specific column
  76956. * @param index defines the index of the column
  76957. * @returns the column definition
  76958. */
  76959. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  76960. /**
  76961. * Adds a new row to the grid
  76962. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76963. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  76964. * @returns the current grid
  76965. */
  76966. addRowDefinition(height: number, isPixel?: boolean): Grid;
  76967. /**
  76968. * Adds a new column to the grid
  76969. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76970. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76971. * @returns the current grid
  76972. */
  76973. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  76974. /**
  76975. * Update a row definition
  76976. * @param index defines the index of the row to update
  76977. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  76978. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  76979. * @returns the current grid
  76980. */
  76981. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  76982. /**
  76983. * Update a column definition
  76984. * @param index defines the index of the column to update
  76985. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  76986. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  76987. * @returns the current grid
  76988. */
  76989. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  76990. /**
  76991. * Gets the list of children stored in a specific cell
  76992. * @param row defines the row to check
  76993. * @param column defines the column to check
  76994. * @returns the list of controls
  76995. */
  76996. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  76997. /**
  76998. * Gets a string representing the child cell info (row x column)
  76999. * @param child defines the control to get info from
  77000. * @returns a string containing the child cell info (row x column)
  77001. */
  77002. getChildCellInfo(child: Control): string;
  77003. private _removeCell;
  77004. private _offsetCell;
  77005. /**
  77006. * Remove a column definition at specified index
  77007. * @param index defines the index of the column to remove
  77008. * @returns the current grid
  77009. */
  77010. removeColumnDefinition(index: number): Grid;
  77011. /**
  77012. * Remove a row definition at specified index
  77013. * @param index defines the index of the row to remove
  77014. * @returns the current grid
  77015. */
  77016. removeRowDefinition(index: number): Grid;
  77017. /**
  77018. * Adds a new control to the current grid
  77019. * @param control defines the control to add
  77020. * @param row defines the row where to add the control (0 by default)
  77021. * @param column defines the column where to add the control (0 by default)
  77022. * @returns the current grid
  77023. */
  77024. addControl(control: Control, row?: number, column?: number): Grid;
  77025. /**
  77026. * Removes a control from the current container
  77027. * @param control defines the control to remove
  77028. * @returns the current container
  77029. */
  77030. removeControl(control: Control): Container;
  77031. /**
  77032. * Creates a new Grid
  77033. * @param name defines control name
  77034. */
  77035. constructor(name?: string | undefined);
  77036. protected _getTypeName(): string;
  77037. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77038. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77039. _flagDescendantsAsMatrixDirty(): void;
  77040. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77041. /** Releases associated resources */
  77042. dispose(): void;
  77043. }
  77044. }
  77045. declare module BABYLON.GUI {
  77046. /** Class used to create color pickers */
  77047. export class ColorPicker extends Control {
  77048. name?: string | undefined;
  77049. private static _Epsilon;
  77050. private _colorWheelCanvas;
  77051. private _value;
  77052. private _tmpColor;
  77053. private _pointerStartedOnSquare;
  77054. private _pointerStartedOnWheel;
  77055. private _squareLeft;
  77056. private _squareTop;
  77057. private _squareSize;
  77058. private _h;
  77059. private _s;
  77060. private _v;
  77061. private _lastPointerDownID;
  77062. /**
  77063. * BABYLON.Observable raised when the value changes
  77064. */
  77065. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77066. /** Gets or sets the color of the color picker */
  77067. get value(): BABYLON.Color3;
  77068. set value(value: BABYLON.Color3);
  77069. /**
  77070. * Gets or sets control width
  77071. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77072. */
  77073. get width(): string | number;
  77074. set width(value: string | number);
  77075. /**
  77076. * Gets or sets control height
  77077. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77078. */
  77079. get height(): string | number;
  77080. /** Gets or sets control height */
  77081. set height(value: string | number);
  77082. /** Gets or sets control size */
  77083. get size(): string | number;
  77084. set size(value: string | number);
  77085. /**
  77086. * Creates a new ColorPicker
  77087. * @param name defines the control name
  77088. */
  77089. constructor(name?: string | undefined);
  77090. protected _getTypeName(): string;
  77091. /** @hidden */
  77092. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77093. private _updateSquareProps;
  77094. private _drawGradientSquare;
  77095. private _drawCircle;
  77096. private _createColorWheelCanvas;
  77097. /** @hidden */
  77098. _draw(context: CanvasRenderingContext2D): void;
  77099. private _pointerIsDown;
  77100. private _updateValueFromPointer;
  77101. private _isPointOnSquare;
  77102. private _isPointOnWheel;
  77103. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77104. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77105. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77106. /**
  77107. * This function expands the color picker by creating a color picker dialog with manual
  77108. * color value input and the ability to save colors into an array to be used later in
  77109. * subsequent launches of the dialogue.
  77110. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77111. * @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.
  77112. * @returns picked color as a hex string and the saved colors array as hex strings.
  77113. */
  77114. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77115. pickerWidth?: string;
  77116. pickerHeight?: string;
  77117. headerHeight?: string;
  77118. lastColor?: string;
  77119. swatchLimit?: number;
  77120. numSwatchesPerLine?: number;
  77121. savedColors?: Array<string>;
  77122. }): Promise<{
  77123. savedColors?: string[];
  77124. pickedColor: string;
  77125. }>;
  77126. }
  77127. }
  77128. declare module BABYLON.GUI {
  77129. /** Class used to create 2D ellipse containers */
  77130. export class Ellipse extends Container {
  77131. name?: string | undefined;
  77132. private _thickness;
  77133. /** Gets or sets border thickness */
  77134. get thickness(): number;
  77135. set thickness(value: number);
  77136. /**
  77137. * Creates a new Ellipse
  77138. * @param name defines the control name
  77139. */
  77140. constructor(name?: string | undefined);
  77141. protected _getTypeName(): string;
  77142. protected _localDraw(context: CanvasRenderingContext2D): void;
  77143. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77144. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77145. }
  77146. }
  77147. declare module BABYLON.GUI {
  77148. /**
  77149. * Class used to create a password control
  77150. */
  77151. export class InputPassword extends InputText {
  77152. protected _beforeRenderText(text: string): string;
  77153. }
  77154. }
  77155. declare module BABYLON.GUI {
  77156. /** Class used to render 2D lines */
  77157. export class Line extends Control {
  77158. name?: string | undefined;
  77159. private _lineWidth;
  77160. private _x1;
  77161. private _y1;
  77162. private _x2;
  77163. private _y2;
  77164. private _dash;
  77165. private _connectedControl;
  77166. private _connectedControlDirtyObserver;
  77167. /** Gets or sets the dash pattern */
  77168. get dash(): Array<number>;
  77169. set dash(value: Array<number>);
  77170. /** Gets or sets the control connected with the line end */
  77171. get connectedControl(): Control;
  77172. set connectedControl(value: Control);
  77173. /** Gets or sets start coordinates on X axis */
  77174. get x1(): string | number;
  77175. set x1(value: string | number);
  77176. /** Gets or sets start coordinates on Y axis */
  77177. get y1(): string | number;
  77178. set y1(value: string | number);
  77179. /** Gets or sets end coordinates on X axis */
  77180. get x2(): string | number;
  77181. set x2(value: string | number);
  77182. /** Gets or sets end coordinates on Y axis */
  77183. get y2(): string | number;
  77184. set y2(value: string | number);
  77185. /** Gets or sets line width */
  77186. get lineWidth(): number;
  77187. set lineWidth(value: number);
  77188. /** Gets or sets horizontal alignment */
  77189. set horizontalAlignment(value: number);
  77190. /** Gets or sets vertical alignment */
  77191. set verticalAlignment(value: number);
  77192. private get _effectiveX2();
  77193. private get _effectiveY2();
  77194. /**
  77195. * Creates a new Line
  77196. * @param name defines the control name
  77197. */
  77198. constructor(name?: string | undefined);
  77199. protected _getTypeName(): string;
  77200. _draw(context: CanvasRenderingContext2D): void;
  77201. _measure(): void;
  77202. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77203. /**
  77204. * Move one end of the line given 3D cartesian coordinates.
  77205. * @param position Targeted world position
  77206. * @param scene BABYLON.Scene
  77207. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77208. */
  77209. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77210. /**
  77211. * Move one end of the line to a position in screen absolute space.
  77212. * @param projectedPosition Position in screen absolute space (X, Y)
  77213. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77214. */
  77215. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77216. }
  77217. }
  77218. declare module BABYLON.GUI {
  77219. /**
  77220. * Class used to store a point for a MultiLine object.
  77221. * The point can be pure 2D coordinates, a mesh or a control
  77222. */
  77223. export class MultiLinePoint {
  77224. private _multiLine;
  77225. private _x;
  77226. private _y;
  77227. private _control;
  77228. private _mesh;
  77229. private _controlObserver;
  77230. private _meshObserver;
  77231. /** @hidden */
  77232. _point: BABYLON.Vector2;
  77233. /**
  77234. * Creates a new MultiLinePoint
  77235. * @param multiLine defines the source MultiLine object
  77236. */
  77237. constructor(multiLine: MultiLine);
  77238. /** Gets or sets x coordinate */
  77239. get x(): string | number;
  77240. set x(value: string | number);
  77241. /** Gets or sets y coordinate */
  77242. get y(): string | number;
  77243. set y(value: string | number);
  77244. /** Gets or sets the control associated with this point */
  77245. get control(): BABYLON.Nullable<Control>;
  77246. set control(value: BABYLON.Nullable<Control>);
  77247. /** Gets or sets the mesh associated with this point */
  77248. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77249. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77250. /** Resets links */
  77251. resetLinks(): void;
  77252. /**
  77253. * Gets a translation vector
  77254. * @returns the translation vector
  77255. */
  77256. translate(): BABYLON.Vector2;
  77257. private _translatePoint;
  77258. /** Release associated resources */
  77259. dispose(): void;
  77260. }
  77261. }
  77262. declare module BABYLON.GUI {
  77263. /**
  77264. * Class used to create multi line control
  77265. */
  77266. export class MultiLine extends Control {
  77267. name?: string | undefined;
  77268. private _lineWidth;
  77269. private _dash;
  77270. private _points;
  77271. private _minX;
  77272. private _minY;
  77273. private _maxX;
  77274. private _maxY;
  77275. /**
  77276. * Creates a new MultiLine
  77277. * @param name defines the control name
  77278. */
  77279. constructor(name?: string | undefined);
  77280. /** Gets or sets dash pattern */
  77281. get dash(): Array<number>;
  77282. set dash(value: Array<number>);
  77283. /**
  77284. * Gets point stored at specified index
  77285. * @param index defines the index to look for
  77286. * @returns the requested point if found
  77287. */
  77288. getAt(index: number): MultiLinePoint;
  77289. /** Function called when a point is updated */
  77290. onPointUpdate: () => void;
  77291. /**
  77292. * Adds new points to the point collection
  77293. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77294. * @returns the list of created MultiLinePoint
  77295. */
  77296. add(...items: (AbstractMesh | Control | {
  77297. x: string | number;
  77298. y: string | number;
  77299. })[]): MultiLinePoint[];
  77300. /**
  77301. * Adds a new point to the point collection
  77302. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77303. * @returns the created MultiLinePoint
  77304. */
  77305. push(item?: (AbstractMesh | Control | {
  77306. x: string | number;
  77307. y: string | number;
  77308. })): MultiLinePoint;
  77309. /**
  77310. * Remove a specific value or point from the active point collection
  77311. * @param value defines the value or point to remove
  77312. */
  77313. remove(value: number | MultiLinePoint): void;
  77314. /**
  77315. * Resets this object to initial state (no point)
  77316. */
  77317. reset(): void;
  77318. /**
  77319. * Resets all links
  77320. */
  77321. resetLinks(): void;
  77322. /** Gets or sets line width */
  77323. get lineWidth(): number;
  77324. set lineWidth(value: number);
  77325. set horizontalAlignment(value: number);
  77326. set verticalAlignment(value: number);
  77327. protected _getTypeName(): string;
  77328. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77329. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77330. _measure(): void;
  77331. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77332. dispose(): void;
  77333. }
  77334. }
  77335. declare module BABYLON.GUI {
  77336. /**
  77337. * Class used to create radio button controls
  77338. */
  77339. export class RadioButton extends Control {
  77340. name?: string | undefined;
  77341. private _isChecked;
  77342. private _background;
  77343. private _checkSizeRatio;
  77344. private _thickness;
  77345. /** Gets or sets border thickness */
  77346. get thickness(): number;
  77347. set thickness(value: number);
  77348. /** Gets or sets group name */
  77349. group: string;
  77350. /** BABYLON.Observable raised when isChecked is changed */
  77351. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77352. /** Gets or sets a value indicating the ratio between overall size and check size */
  77353. get checkSizeRatio(): number;
  77354. set checkSizeRatio(value: number);
  77355. /** Gets or sets background color */
  77356. get background(): string;
  77357. set background(value: string);
  77358. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77359. get isChecked(): boolean;
  77360. set isChecked(value: boolean);
  77361. /**
  77362. * Creates a new RadioButton
  77363. * @param name defines the control name
  77364. */
  77365. constructor(name?: string | undefined);
  77366. protected _getTypeName(): string;
  77367. _draw(context: CanvasRenderingContext2D): void;
  77368. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77369. /**
  77370. * Utility function to easily create a radio button with a header
  77371. * @param title defines the label to use for the header
  77372. * @param group defines the group to use for the radio button
  77373. * @param isChecked defines the initial state of the radio button
  77374. * @param onValueChanged defines the callback to call when value changes
  77375. * @returns a StackPanel containing the radio button and a textBlock
  77376. */
  77377. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77378. }
  77379. }
  77380. declare module BABYLON.GUI {
  77381. /**
  77382. * Class used to create slider controls
  77383. */
  77384. export class BaseSlider extends Control {
  77385. name?: string | undefined;
  77386. protected _thumbWidth: ValueAndUnit;
  77387. private _minimum;
  77388. private _maximum;
  77389. private _value;
  77390. private _isVertical;
  77391. protected _barOffset: ValueAndUnit;
  77392. private _isThumbClamped;
  77393. protected _displayThumb: boolean;
  77394. private _step;
  77395. private _lastPointerDownID;
  77396. protected _effectiveBarOffset: number;
  77397. protected _renderLeft: number;
  77398. protected _renderTop: number;
  77399. protected _renderWidth: number;
  77400. protected _renderHeight: number;
  77401. protected _backgroundBoxLength: number;
  77402. protected _backgroundBoxThickness: number;
  77403. protected _effectiveThumbThickness: number;
  77404. /** BABYLON.Observable raised when the sldier value changes */
  77405. onValueChangedObservable: BABYLON.Observable<number>;
  77406. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77407. get displayThumb(): boolean;
  77408. set displayThumb(value: boolean);
  77409. /** Gets or sets a step to apply to values (0 by default) */
  77410. get step(): number;
  77411. set step(value: number);
  77412. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77413. get barOffset(): string | number;
  77414. /** Gets main bar offset in pixels*/
  77415. get barOffsetInPixels(): number;
  77416. set barOffset(value: string | number);
  77417. /** Gets or sets thumb width */
  77418. get thumbWidth(): string | number;
  77419. /** Gets thumb width in pixels */
  77420. get thumbWidthInPixels(): number;
  77421. set thumbWidth(value: string | number);
  77422. /** Gets or sets minimum value */
  77423. get minimum(): number;
  77424. set minimum(value: number);
  77425. /** Gets or sets maximum value */
  77426. get maximum(): number;
  77427. set maximum(value: number);
  77428. /** Gets or sets current value */
  77429. get value(): number;
  77430. set value(value: number);
  77431. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77432. get isVertical(): boolean;
  77433. set isVertical(value: boolean);
  77434. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77435. get isThumbClamped(): boolean;
  77436. set isThumbClamped(value: boolean);
  77437. /**
  77438. * Creates a new BaseSlider
  77439. * @param name defines the control name
  77440. */
  77441. constructor(name?: string | undefined);
  77442. protected _getTypeName(): string;
  77443. protected _getThumbPosition(): number;
  77444. protected _getThumbThickness(type: string): number;
  77445. protected _prepareRenderingData(type: string): void;
  77446. private _pointerIsDown;
  77447. /** @hidden */
  77448. protected _updateValueFromPointer(x: number, y: number): void;
  77449. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77450. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77451. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77452. }
  77453. }
  77454. declare module BABYLON.GUI {
  77455. /**
  77456. * Class used to create slider controls
  77457. */
  77458. export class Slider extends BaseSlider {
  77459. name?: string | undefined;
  77460. private _background;
  77461. private _borderColor;
  77462. private _isThumbCircle;
  77463. protected _displayValueBar: boolean;
  77464. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77465. get displayValueBar(): boolean;
  77466. set displayValueBar(value: boolean);
  77467. /** Gets or sets border color */
  77468. get borderColor(): string;
  77469. set borderColor(value: string);
  77470. /** Gets or sets background color */
  77471. get background(): string;
  77472. set background(value: string);
  77473. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77474. get isThumbCircle(): boolean;
  77475. set isThumbCircle(value: boolean);
  77476. /**
  77477. * Creates a new Slider
  77478. * @param name defines the control name
  77479. */
  77480. constructor(name?: string | undefined);
  77481. protected _getTypeName(): string;
  77482. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77483. }
  77484. }
  77485. declare module BABYLON.GUI {
  77486. /** Class used to create a RadioGroup
  77487. * which contains groups of radio buttons
  77488. */
  77489. export class SelectorGroup {
  77490. /** name of SelectorGroup */
  77491. name: string;
  77492. private _groupPanel;
  77493. private _selectors;
  77494. private _groupHeader;
  77495. /**
  77496. * Creates a new SelectorGroup
  77497. * @param name of group, used as a group heading
  77498. */
  77499. constructor(
  77500. /** name of SelectorGroup */
  77501. name: string);
  77502. /** Gets the groupPanel of the SelectorGroup */
  77503. get groupPanel(): StackPanel;
  77504. /** Gets the selectors array */
  77505. get selectors(): StackPanel[];
  77506. /** Gets and sets the group header */
  77507. get header(): string;
  77508. set header(label: string);
  77509. /** @hidden */
  77510. private _addGroupHeader;
  77511. /** @hidden*/
  77512. _getSelector(selectorNb: number): StackPanel | undefined;
  77513. /** Removes the selector at the given position
  77514. * @param selectorNb the position of the selector within the group
  77515. */
  77516. removeSelector(selectorNb: number): void;
  77517. }
  77518. /** Class used to create a CheckboxGroup
  77519. * which contains groups of checkbox buttons
  77520. */
  77521. export class CheckboxGroup extends SelectorGroup {
  77522. /** Adds a checkbox as a control
  77523. * @param text is the label for the selector
  77524. * @param func is the function called when the Selector is checked
  77525. * @param checked is true when Selector is checked
  77526. */
  77527. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77528. /** @hidden */
  77529. _setSelectorLabel(selectorNb: number, label: string): void;
  77530. /** @hidden */
  77531. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77532. /** @hidden */
  77533. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77534. /** @hidden */
  77535. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77536. }
  77537. /** Class used to create a RadioGroup
  77538. * which contains groups of radio buttons
  77539. */
  77540. export class RadioGroup extends SelectorGroup {
  77541. private _selectNb;
  77542. /** Adds a radio button as a control
  77543. * @param label is the label for the selector
  77544. * @param func is the function called when the Selector is checked
  77545. * @param checked is true when Selector is checked
  77546. */
  77547. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77548. /** @hidden */
  77549. _setSelectorLabel(selectorNb: number, label: string): void;
  77550. /** @hidden */
  77551. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77552. /** @hidden */
  77553. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77554. /** @hidden */
  77555. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77556. }
  77557. /** Class used to create a SliderGroup
  77558. * which contains groups of slider buttons
  77559. */
  77560. export class SliderGroup extends SelectorGroup {
  77561. /**
  77562. * Adds a slider to the SelectorGroup
  77563. * @param label is the label for the SliderBar
  77564. * @param func is the function called when the Slider moves
  77565. * @param unit is a string describing the units used, eg degrees or metres
  77566. * @param min is the minimum value for the Slider
  77567. * @param max is the maximum value for the Slider
  77568. * @param value is the start value for the Slider between min and max
  77569. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77570. */
  77571. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77572. /** @hidden */
  77573. _setSelectorLabel(selectorNb: number, label: string): void;
  77574. /** @hidden */
  77575. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77576. /** @hidden */
  77577. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77578. /** @hidden */
  77579. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77580. }
  77581. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77582. * @see https://doc.babylonjs.com/how_to/selector
  77583. */
  77584. export class SelectionPanel extends Rectangle {
  77585. /** name of SelectionPanel */
  77586. name: string;
  77587. /** an array of SelectionGroups */
  77588. groups: SelectorGroup[];
  77589. private _panel;
  77590. private _buttonColor;
  77591. private _buttonBackground;
  77592. private _headerColor;
  77593. private _barColor;
  77594. private _barHeight;
  77595. private _spacerHeight;
  77596. private _labelColor;
  77597. private _groups;
  77598. private _bars;
  77599. /**
  77600. * Creates a new SelectionPanel
  77601. * @param name of SelectionPanel
  77602. * @param groups is an array of SelectionGroups
  77603. */
  77604. constructor(
  77605. /** name of SelectionPanel */
  77606. name: string,
  77607. /** an array of SelectionGroups */
  77608. groups?: SelectorGroup[]);
  77609. protected _getTypeName(): string;
  77610. /** Gets or sets the headerColor */
  77611. get headerColor(): string;
  77612. set headerColor(color: string);
  77613. private _setHeaderColor;
  77614. /** Gets or sets the button color */
  77615. get buttonColor(): string;
  77616. set buttonColor(color: string);
  77617. private _setbuttonColor;
  77618. /** Gets or sets the label color */
  77619. get labelColor(): string;
  77620. set labelColor(color: string);
  77621. private _setLabelColor;
  77622. /** Gets or sets the button background */
  77623. get buttonBackground(): string;
  77624. set buttonBackground(color: string);
  77625. private _setButtonBackground;
  77626. /** Gets or sets the color of separator bar */
  77627. get barColor(): string;
  77628. set barColor(color: string);
  77629. private _setBarColor;
  77630. /** Gets or sets the height of separator bar */
  77631. get barHeight(): string;
  77632. set barHeight(value: string);
  77633. private _setBarHeight;
  77634. /** Gets or sets the height of spacers*/
  77635. get spacerHeight(): string;
  77636. set spacerHeight(value: string);
  77637. private _setSpacerHeight;
  77638. /** Adds a bar between groups */
  77639. private _addSpacer;
  77640. /** Add a group to the selection panel
  77641. * @param group is the selector group to add
  77642. */
  77643. addGroup(group: SelectorGroup): void;
  77644. /** Remove the group from the given position
  77645. * @param groupNb is the position of the group in the list
  77646. */
  77647. removeGroup(groupNb: number): void;
  77648. /** Change a group header label
  77649. * @param label is the new group header label
  77650. * @param groupNb is the number of the group to relabel
  77651. * */
  77652. setHeaderName(label: string, groupNb: number): void;
  77653. /** Change selector label to the one given
  77654. * @param label is the new selector label
  77655. * @param groupNb is the number of the groupcontaining the selector
  77656. * @param selectorNb is the number of the selector within a group to relabel
  77657. * */
  77658. relabel(label: string, groupNb: number, selectorNb: number): void;
  77659. /** For a given group position remove the selector at the given position
  77660. * @param groupNb is the number of the group to remove the selector from
  77661. * @param selectorNb is the number of the selector within the group
  77662. */
  77663. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77664. /** For a given group position of correct type add a checkbox button
  77665. * @param groupNb is the number of the group to remove the selector from
  77666. * @param label is the label for the selector
  77667. * @param func is the function called when the Selector is checked
  77668. * @param checked is true when Selector is checked
  77669. */
  77670. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77671. /** For a given group position of correct type add a radio button
  77672. * @param groupNb is the number of the group to remove the selector from
  77673. * @param label is the label for the selector
  77674. * @param func is the function called when the Selector is checked
  77675. * @param checked is true when Selector is checked
  77676. */
  77677. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77678. /**
  77679. * For a given slider group add a slider
  77680. * @param groupNb is the number of the group to add the slider to
  77681. * @param label is the label for the Slider
  77682. * @param func is the function called when the Slider moves
  77683. * @param unit is a string describing the units used, eg degrees or metres
  77684. * @param min is the minimum value for the Slider
  77685. * @param max is the maximum value for the Slider
  77686. * @param value is the start value for the Slider between min and max
  77687. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77688. */
  77689. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77690. }
  77691. }
  77692. declare module BABYLON.GUI {
  77693. /**
  77694. * Class used to hold a the container for ScrollViewer
  77695. * @hidden
  77696. */
  77697. export class _ScrollViewerWindow extends Container {
  77698. parentClientWidth: number;
  77699. parentClientHeight: number;
  77700. private _freezeControls;
  77701. private _parentMeasure;
  77702. private _oldLeft;
  77703. private _oldTop;
  77704. get freezeControls(): boolean;
  77705. set freezeControls(value: boolean);
  77706. private _bucketWidth;
  77707. private _bucketHeight;
  77708. private _buckets;
  77709. private _bucketLen;
  77710. get bucketWidth(): number;
  77711. get bucketHeight(): number;
  77712. setBucketSizes(width: number, height: number): void;
  77713. private _useBuckets;
  77714. private _makeBuckets;
  77715. private _dispatchInBuckets;
  77716. private _updateMeasures;
  77717. private _updateChildrenMeasures;
  77718. private _restoreMeasures;
  77719. /**
  77720. * Creates a new ScrollViewerWindow
  77721. * @param name of ScrollViewerWindow
  77722. */
  77723. constructor(name?: string);
  77724. protected _getTypeName(): string;
  77725. /** @hidden */
  77726. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77727. /** @hidden */
  77728. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77729. private _scrollChildren;
  77730. private _scrollChildrenWithBuckets;
  77731. /** @hidden */
  77732. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  77733. protected _postMeasure(): void;
  77734. }
  77735. }
  77736. declare module BABYLON.GUI {
  77737. /**
  77738. * Class used to create slider controls
  77739. */
  77740. export class ScrollBar extends BaseSlider {
  77741. name?: string | undefined;
  77742. private _background;
  77743. private _borderColor;
  77744. private _tempMeasure;
  77745. /** Gets or sets border color */
  77746. get borderColor(): string;
  77747. set borderColor(value: string);
  77748. /** Gets or sets background color */
  77749. get background(): string;
  77750. set background(value: string);
  77751. /**
  77752. * Creates a new Slider
  77753. * @param name defines the control name
  77754. */
  77755. constructor(name?: string | undefined);
  77756. protected _getTypeName(): string;
  77757. protected _getThumbThickness(): number;
  77758. _draw(context: CanvasRenderingContext2D): void;
  77759. private _first;
  77760. private _originX;
  77761. private _originY;
  77762. /** @hidden */
  77763. protected _updateValueFromPointer(x: number, y: number): void;
  77764. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77765. }
  77766. }
  77767. declare module BABYLON.GUI {
  77768. /**
  77769. * Class used to create slider controls
  77770. */
  77771. export class ImageScrollBar extends BaseSlider {
  77772. name?: string | undefined;
  77773. private _backgroundBaseImage;
  77774. private _backgroundImage;
  77775. private _thumbImage;
  77776. private _thumbBaseImage;
  77777. private _thumbLength;
  77778. private _thumbHeight;
  77779. private _barImageHeight;
  77780. private _tempMeasure;
  77781. /** Number of 90° rotation to apply on the images when in vertical mode */
  77782. num90RotationInVerticalMode: number;
  77783. /**
  77784. * Gets or sets the image used to render the background for horizontal bar
  77785. */
  77786. get backgroundImage(): Image;
  77787. set backgroundImage(value: Image);
  77788. /**
  77789. * Gets or sets the image used to render the thumb
  77790. */
  77791. get thumbImage(): Image;
  77792. set thumbImage(value: Image);
  77793. /**
  77794. * Gets or sets the length of the thumb
  77795. */
  77796. get thumbLength(): number;
  77797. set thumbLength(value: number);
  77798. /**
  77799. * Gets or sets the height of the thumb
  77800. */
  77801. get thumbHeight(): number;
  77802. set thumbHeight(value: number);
  77803. /**
  77804. * Gets or sets the height of the bar image
  77805. */
  77806. get barImageHeight(): number;
  77807. set barImageHeight(value: number);
  77808. /**
  77809. * Creates a new ImageScrollBar
  77810. * @param name defines the control name
  77811. */
  77812. constructor(name?: string | undefined);
  77813. protected _getTypeName(): string;
  77814. protected _getThumbThickness(): number;
  77815. _draw(context: CanvasRenderingContext2D): void;
  77816. private _first;
  77817. private _originX;
  77818. private _originY;
  77819. /** @hidden */
  77820. protected _updateValueFromPointer(x: number, y: number): void;
  77821. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77822. }
  77823. }
  77824. declare module BABYLON.GUI {
  77825. /**
  77826. * Class used to hold a viewer window and sliders in a grid
  77827. */
  77828. export class ScrollViewer extends Rectangle {
  77829. private _grid;
  77830. private _horizontalBarSpace;
  77831. private _verticalBarSpace;
  77832. private _dragSpace;
  77833. private _horizontalBar;
  77834. private _verticalBar;
  77835. private _barColor;
  77836. private _barBackground;
  77837. private _barImage;
  77838. private _horizontalBarImage;
  77839. private _verticalBarImage;
  77840. private _barBackgroundImage;
  77841. private _horizontalBarBackgroundImage;
  77842. private _verticalBarBackgroundImage;
  77843. private _barSize;
  77844. private _window;
  77845. private _pointerIsOver;
  77846. private _wheelPrecision;
  77847. private _onWheelObserver;
  77848. private _clientWidth;
  77849. private _clientHeight;
  77850. private _useImageBar;
  77851. private _thumbLength;
  77852. private _thumbHeight;
  77853. private _barImageHeight;
  77854. private _horizontalBarImageHeight;
  77855. private _verticalBarImageHeight;
  77856. private _oldWindowContentsWidth;
  77857. private _oldWindowContentsHeight;
  77858. /**
  77859. * Gets the horizontal scrollbar
  77860. */
  77861. get horizontalBar(): ScrollBar | ImageScrollBar;
  77862. /**
  77863. * Gets the vertical scrollbar
  77864. */
  77865. get verticalBar(): ScrollBar | ImageScrollBar;
  77866. /**
  77867. * Adds a new control to the current container
  77868. * @param control defines the control to add
  77869. * @returns the current container
  77870. */
  77871. addControl(control: BABYLON.Nullable<Control>): Container;
  77872. /**
  77873. * Removes a control from the current container
  77874. * @param control defines the control to remove
  77875. * @returns the current container
  77876. */
  77877. removeControl(control: Control): Container;
  77878. /** Gets the list of children */
  77879. get children(): Control[];
  77880. _flagDescendantsAsMatrixDirty(): void;
  77881. /**
  77882. * Freezes or unfreezes the controls in the window.
  77883. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  77884. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  77885. */
  77886. get freezeControls(): boolean;
  77887. set freezeControls(value: boolean);
  77888. /** Gets the bucket width */
  77889. get bucketWidth(): number;
  77890. /** Gets the bucket height */
  77891. get bucketHeight(): number;
  77892. /**
  77893. * Sets the bucket sizes.
  77894. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  77895. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  77896. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  77897. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  77898. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  77899. * used), that's why it is not enabled by default.
  77900. * @param width width of the bucket
  77901. * @param height height of the bucket
  77902. */
  77903. setBucketSizes(width: number, height: number): void;
  77904. private _forceHorizontalBar;
  77905. private _forceVerticalBar;
  77906. /**
  77907. * Forces the horizontal scroll bar to be displayed
  77908. */
  77909. get forceHorizontalBar(): boolean;
  77910. set forceHorizontalBar(value: boolean);
  77911. /**
  77912. * Forces the vertical scroll bar to be displayed
  77913. */
  77914. get forceVerticalBar(): boolean;
  77915. set forceVerticalBar(value: boolean);
  77916. /**
  77917. * Creates a new ScrollViewer
  77918. * @param name of ScrollViewer
  77919. */
  77920. constructor(name?: string, isImageBased?: boolean);
  77921. /** Reset the scroll viewer window to initial size */
  77922. resetWindow(): void;
  77923. protected _getTypeName(): string;
  77924. private _buildClientSizes;
  77925. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77926. protected _postMeasure(): void;
  77927. /**
  77928. * Gets or sets the mouse wheel precision
  77929. * from 0 to 1 with a default value of 0.05
  77930. * */
  77931. get wheelPrecision(): number;
  77932. set wheelPrecision(value: number);
  77933. /** Gets or sets the scroll bar container background color */
  77934. get scrollBackground(): string;
  77935. set scrollBackground(color: string);
  77936. /** Gets or sets the bar color */
  77937. get barColor(): string;
  77938. set barColor(color: string);
  77939. /** Gets or sets the bar image */
  77940. get thumbImage(): Image;
  77941. set thumbImage(value: Image);
  77942. /** Gets or sets the horizontal bar image */
  77943. get horizontalThumbImage(): Image;
  77944. set horizontalThumbImage(value: Image);
  77945. /** Gets or sets the vertical bar image */
  77946. get verticalThumbImage(): Image;
  77947. set verticalThumbImage(value: Image);
  77948. /** Gets or sets the size of the bar */
  77949. get barSize(): number;
  77950. set barSize(value: number);
  77951. /** Gets or sets the length of the thumb */
  77952. get thumbLength(): number;
  77953. set thumbLength(value: number);
  77954. /** Gets or sets the height of the thumb */
  77955. get thumbHeight(): number;
  77956. set thumbHeight(value: number);
  77957. /** Gets or sets the height of the bar image */
  77958. get barImageHeight(): number;
  77959. set barImageHeight(value: number);
  77960. /** Gets or sets the height of the horizontal bar image */
  77961. get horizontalBarImageHeight(): number;
  77962. set horizontalBarImageHeight(value: number);
  77963. /** Gets or sets the height of the vertical bar image */
  77964. get verticalBarImageHeight(): number;
  77965. set verticalBarImageHeight(value: number);
  77966. /** Gets or sets the bar background */
  77967. get barBackground(): string;
  77968. set barBackground(color: string);
  77969. /** Gets or sets the bar background image */
  77970. get barImage(): Image;
  77971. set barImage(value: Image);
  77972. /** Gets or sets the horizontal bar background image */
  77973. get horizontalBarImage(): Image;
  77974. set horizontalBarImage(value: Image);
  77975. /** Gets or sets the vertical bar background image */
  77976. get verticalBarImage(): Image;
  77977. set verticalBarImage(value: Image);
  77978. private _setWindowPosition;
  77979. /** @hidden */
  77980. private _updateScroller;
  77981. _link(host: AdvancedDynamicTexture): void;
  77982. /** @hidden */
  77983. private _addBar;
  77984. /** @hidden */
  77985. private _attachWheel;
  77986. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77987. /** Releases associated resources */
  77988. dispose(): void;
  77989. }
  77990. }
  77991. declare module BABYLON.GUI {
  77992. /** Class used to render a grid */
  77993. export class DisplayGrid extends Control {
  77994. name?: string | undefined;
  77995. private _cellWidth;
  77996. private _cellHeight;
  77997. private _minorLineTickness;
  77998. private _minorLineColor;
  77999. private _majorLineTickness;
  78000. private _majorLineColor;
  78001. private _majorLineFrequency;
  78002. private _background;
  78003. private _displayMajorLines;
  78004. private _displayMinorLines;
  78005. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78006. get displayMinorLines(): boolean;
  78007. set displayMinorLines(value: boolean);
  78008. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78009. get displayMajorLines(): boolean;
  78010. set displayMajorLines(value: boolean);
  78011. /** Gets or sets background color (Black by default) */
  78012. get background(): string;
  78013. set background(value: string);
  78014. /** Gets or sets the width of each cell (20 by default) */
  78015. get cellWidth(): number;
  78016. set cellWidth(value: number);
  78017. /** Gets or sets the height of each cell (20 by default) */
  78018. get cellHeight(): number;
  78019. set cellHeight(value: number);
  78020. /** Gets or sets the tickness of minor lines (1 by default) */
  78021. get minorLineTickness(): number;
  78022. set minorLineTickness(value: number);
  78023. /** Gets or sets the color of minor lines (DarkGray by default) */
  78024. get minorLineColor(): string;
  78025. set minorLineColor(value: string);
  78026. /** Gets or sets the tickness of major lines (2 by default) */
  78027. get majorLineTickness(): number;
  78028. set majorLineTickness(value: number);
  78029. /** Gets or sets the color of major lines (White by default) */
  78030. get majorLineColor(): string;
  78031. set majorLineColor(value: string);
  78032. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78033. get majorLineFrequency(): number;
  78034. set majorLineFrequency(value: number);
  78035. /**
  78036. * Creates a new GridDisplayRectangle
  78037. * @param name defines the control name
  78038. */
  78039. constructor(name?: string | undefined);
  78040. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78041. protected _getTypeName(): string;
  78042. }
  78043. }
  78044. declare module BABYLON.GUI {
  78045. /**
  78046. * Class used to create slider controls based on images
  78047. */
  78048. export class ImageBasedSlider extends BaseSlider {
  78049. name?: string | undefined;
  78050. private _backgroundImage;
  78051. private _thumbImage;
  78052. private _valueBarImage;
  78053. private _tempMeasure;
  78054. get displayThumb(): boolean;
  78055. set displayThumb(value: boolean);
  78056. /**
  78057. * Gets or sets the image used to render the background
  78058. */
  78059. get backgroundImage(): Image;
  78060. set backgroundImage(value: Image);
  78061. /**
  78062. * Gets or sets the image used to render the value bar
  78063. */
  78064. get valueBarImage(): Image;
  78065. set valueBarImage(value: Image);
  78066. /**
  78067. * Gets or sets the image used to render the thumb
  78068. */
  78069. get thumbImage(): Image;
  78070. set thumbImage(value: Image);
  78071. /**
  78072. * Creates a new ImageBasedSlider
  78073. * @param name defines the control name
  78074. */
  78075. constructor(name?: string | undefined);
  78076. protected _getTypeName(): string;
  78077. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78078. }
  78079. }
  78080. declare module BABYLON.GUI {
  78081. /**
  78082. * Forcing an export so that this code will execute
  78083. * @hidden
  78084. */
  78085. const name = "Statics";
  78086. }
  78087. declare module BABYLON.GUI {
  78088. /**
  78089. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78090. */
  78091. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78092. /**
  78093. * Define the instrumented AdvancedDynamicTexture.
  78094. */
  78095. texture: AdvancedDynamicTexture;
  78096. private _captureRenderTime;
  78097. private _renderTime;
  78098. private _captureLayoutTime;
  78099. private _layoutTime;
  78100. private _onBeginRenderObserver;
  78101. private _onEndRenderObserver;
  78102. private _onBeginLayoutObserver;
  78103. private _onEndLayoutObserver;
  78104. /**
  78105. * Gets the perf counter used to capture render time
  78106. */
  78107. get renderTimeCounter(): BABYLON.PerfCounter;
  78108. /**
  78109. * Gets the perf counter used to capture layout time
  78110. */
  78111. get layoutTimeCounter(): BABYLON.PerfCounter;
  78112. /**
  78113. * Enable or disable the render time capture
  78114. */
  78115. get captureRenderTime(): boolean;
  78116. set captureRenderTime(value: boolean);
  78117. /**
  78118. * Enable or disable the layout time capture
  78119. */
  78120. get captureLayoutTime(): boolean;
  78121. set captureLayoutTime(value: boolean);
  78122. /**
  78123. * Instantiates a new advanced dynamic texture instrumentation.
  78124. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78125. * @param texture Defines the AdvancedDynamicTexture to instrument
  78126. */
  78127. constructor(
  78128. /**
  78129. * Define the instrumented AdvancedDynamicTexture.
  78130. */
  78131. texture: AdvancedDynamicTexture);
  78132. /**
  78133. * Dispose and release associated resources.
  78134. */
  78135. dispose(): void;
  78136. }
  78137. }
  78138. declare module BABYLON.GUI {
  78139. /**
  78140. * Class used to load GUI via XML.
  78141. */
  78142. export class XmlLoader {
  78143. private _nodes;
  78144. private _nodeTypes;
  78145. private _isLoaded;
  78146. private _objectAttributes;
  78147. private _parentClass;
  78148. /**
  78149. * Create a new xml loader
  78150. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78151. */
  78152. constructor(parentClass?: null);
  78153. private _getChainElement;
  78154. private _getClassAttribute;
  78155. private _createGuiElement;
  78156. private _parseGrid;
  78157. private _parseElement;
  78158. private _prepareSourceElement;
  78159. private _parseElementsFromSource;
  78160. private _parseXml;
  78161. /**
  78162. * Gets if the loading has finished.
  78163. * @returns whether the loading has finished or not
  78164. */
  78165. isLoaded(): boolean;
  78166. /**
  78167. * Gets a loaded node / control by id.
  78168. * @param id the Controls id set in the xml
  78169. * @returns element of type Control
  78170. */
  78171. getNodeById(id: string): any;
  78172. /**
  78173. * Gets all loaded nodes / controls
  78174. * @returns Array of controls
  78175. */
  78176. getNodes(): any;
  78177. /**
  78178. * Initiates the xml layout loading
  78179. * @param xmlFile defines the xml layout to load
  78180. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78181. * @param callback defines the callback called on layout load.
  78182. */
  78183. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78184. }
  78185. }
  78186. declare module BABYLON.GUI {
  78187. /**
  78188. * Class used to create containers for controls
  78189. */
  78190. export class Container3D extends Control3D {
  78191. private _blockLayout;
  78192. /**
  78193. * Gets the list of child controls
  78194. */
  78195. protected _children: Control3D[];
  78196. /**
  78197. * Gets the list of child controls
  78198. */
  78199. get children(): Array<Control3D>;
  78200. /**
  78201. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78202. * This is helpful to optimize layout operation when adding multiple children in a row
  78203. */
  78204. get blockLayout(): boolean;
  78205. set blockLayout(value: boolean);
  78206. /**
  78207. * Creates a new container
  78208. * @param name defines the container name
  78209. */
  78210. constructor(name?: string);
  78211. /**
  78212. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78213. * @returns the current container
  78214. */
  78215. updateLayout(): Container3D;
  78216. /**
  78217. * Gets a boolean indicating if the given control is in the children of this control
  78218. * @param control defines the control to check
  78219. * @returns true if the control is in the child list
  78220. */
  78221. containsControl(control: Control3D): boolean;
  78222. /**
  78223. * Adds a control to the children of this control
  78224. * @param control defines the control to add
  78225. * @returns the current container
  78226. */
  78227. addControl(control: Control3D): Container3D;
  78228. /**
  78229. * This function will be called everytime a new control is added
  78230. */
  78231. protected _arrangeChildren(): void;
  78232. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78233. /**
  78234. * Removes a control from the children of this control
  78235. * @param control defines the control to remove
  78236. * @returns the current container
  78237. */
  78238. removeControl(control: Control3D): Container3D;
  78239. protected _getTypeName(): string;
  78240. /**
  78241. * Releases all associated resources
  78242. */
  78243. dispose(): void;
  78244. /** Control rotation will remain unchanged */
  78245. static readonly UNSET_ORIENTATION: number;
  78246. /** Control will rotate to make it look at sphere central axis */
  78247. static readonly FACEORIGIN_ORIENTATION: number;
  78248. /** Control will rotate to make it look back at sphere central axis */
  78249. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78250. /** Control will rotate to look at z axis (0, 0, 1) */
  78251. static readonly FACEFORWARD_ORIENTATION: number;
  78252. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78253. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78254. }
  78255. }
  78256. declare module BABYLON.GUI {
  78257. /**
  78258. * Class used to manage 3D user interface
  78259. * @see https://doc.babylonjs.com/how_to/gui3d
  78260. */
  78261. export class GUI3DManager implements BABYLON.IDisposable {
  78262. private _scene;
  78263. private _sceneDisposeObserver;
  78264. private _utilityLayer;
  78265. private _rootContainer;
  78266. private _pointerObserver;
  78267. private _pointerOutObserver;
  78268. /** @hidden */
  78269. _lastPickedControl: Control3D;
  78270. /** @hidden */
  78271. _lastControlOver: {
  78272. [pointerId: number]: Control3D;
  78273. };
  78274. /** @hidden */
  78275. _lastControlDown: {
  78276. [pointerId: number]: Control3D;
  78277. };
  78278. /**
  78279. * BABYLON.Observable raised when the point picked by the pointer events changed
  78280. */
  78281. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78282. /** @hidden */
  78283. _sharedMaterials: {
  78284. [key: string]: BABYLON.Material;
  78285. };
  78286. /** Gets the hosting scene */
  78287. get scene(): BABYLON.Scene;
  78288. /** Gets associated utility layer */
  78289. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78290. /**
  78291. * Creates a new GUI3DManager
  78292. * @param scene
  78293. */
  78294. constructor(scene?: BABYLON.Scene);
  78295. private _handlePointerOut;
  78296. private _doPicking;
  78297. /**
  78298. * Gets the root container
  78299. */
  78300. get rootContainer(): Container3D;
  78301. /**
  78302. * Gets a boolean indicating if the given control is in the root child list
  78303. * @param control defines the control to check
  78304. * @returns true if the control is in the root child list
  78305. */
  78306. containsControl(control: Control3D): boolean;
  78307. /**
  78308. * Adds a control to the root child list
  78309. * @param control defines the control to add
  78310. * @returns the current manager
  78311. */
  78312. addControl(control: Control3D): GUI3DManager;
  78313. /**
  78314. * Removes a control from the root child list
  78315. * @param control defines the control to remove
  78316. * @returns the current container
  78317. */
  78318. removeControl(control: Control3D): GUI3DManager;
  78319. /**
  78320. * Releases all associated resources
  78321. */
  78322. dispose(): void;
  78323. }
  78324. }
  78325. declare module BABYLON.GUI {
  78326. /**
  78327. * Class used to transport BABYLON.Vector3 information for pointer events
  78328. */
  78329. export class Vector3WithInfo extends BABYLON.Vector3 {
  78330. /** defines the current mouse button index */
  78331. buttonIndex: number;
  78332. /**
  78333. * Creates a new Vector3WithInfo
  78334. * @param source defines the vector3 data to transport
  78335. * @param buttonIndex defines the current mouse button index
  78336. */
  78337. constructor(source: BABYLON.Vector3,
  78338. /** defines the current mouse button index */
  78339. buttonIndex?: number);
  78340. }
  78341. }
  78342. declare module BABYLON.GUI {
  78343. /**
  78344. * Class used as base class for controls
  78345. */
  78346. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78347. /** Defines the control name */
  78348. name?: string | undefined;
  78349. /** @hidden */
  78350. _host: GUI3DManager;
  78351. private _node;
  78352. private _downCount;
  78353. private _enterCount;
  78354. private _downPointerIds;
  78355. private _isVisible;
  78356. /** Gets or sets the control position in world space */
  78357. get position(): BABYLON.Vector3;
  78358. set position(value: BABYLON.Vector3);
  78359. /** Gets or sets the control scaling in world space */
  78360. get scaling(): BABYLON.Vector3;
  78361. set scaling(value: BABYLON.Vector3);
  78362. /** Callback used to start pointer enter animation */
  78363. pointerEnterAnimation: () => void;
  78364. /** Callback used to start pointer out animation */
  78365. pointerOutAnimation: () => void;
  78366. /** Callback used to start pointer down animation */
  78367. pointerDownAnimation: () => void;
  78368. /** Callback used to start pointer up animation */
  78369. pointerUpAnimation: () => void;
  78370. /**
  78371. * An event triggered when the pointer move over the control
  78372. */
  78373. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78374. /**
  78375. * An event triggered when the pointer move out of the control
  78376. */
  78377. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78378. /**
  78379. * An event triggered when the pointer taps the control
  78380. */
  78381. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78382. /**
  78383. * An event triggered when pointer is up
  78384. */
  78385. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78386. /**
  78387. * An event triggered when a control is clicked on (with a mouse)
  78388. */
  78389. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78390. /**
  78391. * An event triggered when pointer enters the control
  78392. */
  78393. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78394. /**
  78395. * Gets or sets the parent container
  78396. */
  78397. parent: BABYLON.Nullable<Container3D>;
  78398. private _behaviors;
  78399. /**
  78400. * Gets the list of attached behaviors
  78401. * @see https://doc.babylonjs.com/features/behaviour
  78402. */
  78403. get behaviors(): BABYLON.Behavior<Control3D>[];
  78404. /**
  78405. * Attach a behavior to the control
  78406. * @see https://doc.babylonjs.com/features/behaviour
  78407. * @param behavior defines the behavior to attach
  78408. * @returns the current control
  78409. */
  78410. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78411. /**
  78412. * Remove an attached behavior
  78413. * @see https://doc.babylonjs.com/features/behaviour
  78414. * @param behavior defines the behavior to attach
  78415. * @returns the current control
  78416. */
  78417. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78418. /**
  78419. * Gets an attached behavior by name
  78420. * @param name defines the name of the behavior to look for
  78421. * @see https://doc.babylonjs.com/features/behaviour
  78422. * @returns null if behavior was not found else the requested behavior
  78423. */
  78424. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78425. /** Gets or sets a boolean indicating if the control is visible */
  78426. get isVisible(): boolean;
  78427. set isVisible(value: boolean);
  78428. /**
  78429. * Creates a new control
  78430. * @param name defines the control name
  78431. */
  78432. constructor(
  78433. /** Defines the control name */
  78434. name?: string | undefined);
  78435. /**
  78436. * Gets a string representing the class name
  78437. */
  78438. get typeName(): string;
  78439. /**
  78440. * Get the current class name of the control.
  78441. * @returns current class name
  78442. */
  78443. getClassName(): string;
  78444. protected _getTypeName(): string;
  78445. /**
  78446. * Gets the transform node used by this control
  78447. */
  78448. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78449. /**
  78450. * Gets the mesh used to render this control
  78451. */
  78452. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78453. /**
  78454. * Link the control as child of the given node
  78455. * @param node defines the node to link to. Use null to unlink the control
  78456. * @returns the current control
  78457. */
  78458. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78459. /** @hidden **/
  78460. _prepareNode(scene: BABYLON.Scene): void;
  78461. /**
  78462. * Node creation.
  78463. * Can be overriden by children
  78464. * @param scene defines the scene where the node must be attached
  78465. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78466. */
  78467. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78468. /**
  78469. * Affect a material to the given mesh
  78470. * @param mesh defines the mesh which will represent the control
  78471. */
  78472. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78473. /** @hidden */
  78474. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78475. /** @hidden */
  78476. _onPointerEnter(target: Control3D): boolean;
  78477. /** @hidden */
  78478. _onPointerOut(target: Control3D): void;
  78479. /** @hidden */
  78480. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78481. /** @hidden */
  78482. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78483. /** @hidden */
  78484. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78485. /** @hidden */
  78486. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78487. /** @hidden */
  78488. _disposeNode(): void;
  78489. /**
  78490. * Releases all associated resources
  78491. */
  78492. dispose(): void;
  78493. }
  78494. }
  78495. declare module BABYLON.GUI {
  78496. /**
  78497. * Class used as a root to all buttons
  78498. */
  78499. export class AbstractButton3D extends Control3D {
  78500. /**
  78501. * Creates a new button
  78502. * @param name defines the control name
  78503. */
  78504. constructor(name?: string);
  78505. protected _getTypeName(): string;
  78506. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78507. }
  78508. }
  78509. declare module BABYLON.GUI {
  78510. /**
  78511. * Class used to create a button in 3D
  78512. */
  78513. export class Button3D extends AbstractButton3D {
  78514. /** @hidden */
  78515. protected _currentMaterial: BABYLON.Material;
  78516. private _facadeTexture;
  78517. private _content;
  78518. private _contentResolution;
  78519. private _contentScaleRatio;
  78520. /**
  78521. * Gets or sets the texture resolution used to render content (512 by default)
  78522. */
  78523. get contentResolution(): BABYLON.int;
  78524. set contentResolution(value: BABYLON.int);
  78525. /**
  78526. * Gets or sets the texture scale ratio used to render content (2 by default)
  78527. */
  78528. get contentScaleRatio(): number;
  78529. set contentScaleRatio(value: number);
  78530. protected _disposeFacadeTexture(): void;
  78531. protected _resetContent(): void;
  78532. /**
  78533. * Creates a new button
  78534. * @param name defines the control name
  78535. */
  78536. constructor(name?: string);
  78537. /**
  78538. * Gets or sets the GUI 2D content used to display the button's facade
  78539. */
  78540. get content(): Control;
  78541. set content(value: Control);
  78542. /**
  78543. * Apply the facade texture (created from the content property).
  78544. * This function can be overloaded by child classes
  78545. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78546. */
  78547. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78548. protected _getTypeName(): string;
  78549. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78550. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78551. /**
  78552. * Releases all associated resources
  78553. */
  78554. dispose(): void;
  78555. }
  78556. }
  78557. declare module BABYLON.GUI {
  78558. /**
  78559. * Abstract class used to create a container panel deployed on the surface of a volume
  78560. */
  78561. export abstract class VolumeBasedPanel extends Container3D {
  78562. private _columns;
  78563. private _rows;
  78564. private _rowThenColum;
  78565. private _orientation;
  78566. protected _cellWidth: number;
  78567. protected _cellHeight: number;
  78568. /**
  78569. * Gets or sets the distance between elements
  78570. */
  78571. margin: number;
  78572. /**
  78573. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78574. * | Value | Type | Description |
  78575. * | ----- | ----------------------------------- | ----------- |
  78576. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78577. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78578. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78579. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78580. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78581. */
  78582. get orientation(): number;
  78583. set orientation(value: number);
  78584. /**
  78585. * Gets or sets the number of columns requested (10 by default).
  78586. * The panel will automatically compute the number of rows based on number of child controls.
  78587. */
  78588. get columns(): BABYLON.int;
  78589. set columns(value: BABYLON.int);
  78590. /**
  78591. * Gets or sets a the number of rows requested.
  78592. * The panel will automatically compute the number of columns based on number of child controls.
  78593. */
  78594. get rows(): BABYLON.int;
  78595. set rows(value: BABYLON.int);
  78596. /**
  78597. * Creates new VolumeBasedPanel
  78598. */
  78599. constructor();
  78600. protected _arrangeChildren(): void;
  78601. /** Child classes must implement this function to provide correct control positioning */
  78602. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78603. /** Child classes can implement this function to provide additional processing */
  78604. protected _finalProcessing(): void;
  78605. }
  78606. }
  78607. declare module BABYLON.GUI {
  78608. /**
  78609. * Class used to create a container panel deployed on the surface of a cylinder
  78610. */
  78611. export class CylinderPanel extends VolumeBasedPanel {
  78612. private _radius;
  78613. /**
  78614. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78615. */
  78616. get radius(): BABYLON.float;
  78617. set radius(value: BABYLON.float);
  78618. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78619. private _cylindricalMapping;
  78620. }
  78621. }
  78622. declare module BABYLON.GUI {
  78623. /** @hidden */
  78624. export var fluentVertexShader: {
  78625. name: string;
  78626. shader: string;
  78627. };
  78628. }
  78629. declare module BABYLON.GUI {
  78630. /** @hidden */
  78631. export var fluentPixelShader: {
  78632. name: string;
  78633. shader: string;
  78634. };
  78635. }
  78636. declare module BABYLON.GUI {
  78637. /** @hidden */
  78638. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78639. INNERGLOW: boolean;
  78640. BORDER: boolean;
  78641. HOVERLIGHT: boolean;
  78642. TEXTURE: boolean;
  78643. constructor();
  78644. }
  78645. /**
  78646. * Class used to render controls with fluent desgin
  78647. */
  78648. export class FluentMaterial extends BABYLON.PushMaterial {
  78649. /**
  78650. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78651. */
  78652. innerGlowColorIntensity: number;
  78653. /**
  78654. * Gets or sets the inner glow color (white by default)
  78655. */
  78656. innerGlowColor: BABYLON.Color3;
  78657. /**
  78658. * Gets or sets alpha value (default is 1.0)
  78659. */
  78660. alpha: number;
  78661. /**
  78662. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78663. */
  78664. albedoColor: BABYLON.Color3;
  78665. /**
  78666. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78667. */
  78668. renderBorders: boolean;
  78669. /**
  78670. * Gets or sets border width (default is 0.5)
  78671. */
  78672. borderWidth: number;
  78673. /**
  78674. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78675. */
  78676. edgeSmoothingValue: number;
  78677. /**
  78678. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78679. */
  78680. borderMinValue: number;
  78681. /**
  78682. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78683. */
  78684. renderHoverLight: boolean;
  78685. /**
  78686. * Gets or sets the radius used to render the hover light (default is 1.0)
  78687. */
  78688. hoverRadius: number;
  78689. /**
  78690. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78691. */
  78692. hoverColor: BABYLON.Color4;
  78693. /**
  78694. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78695. */
  78696. hoverPosition: BABYLON.Vector3;
  78697. private _albedoTexture;
  78698. /** Gets or sets the texture to use for albedo color */
  78699. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78700. /**
  78701. * Creates a new Fluent material
  78702. * @param name defines the name of the material
  78703. * @param scene defines the hosting scene
  78704. */
  78705. constructor(name: string, scene: BABYLON.Scene);
  78706. needAlphaBlending(): boolean;
  78707. needAlphaTesting(): boolean;
  78708. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78709. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78710. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78711. getActiveTextures(): BABYLON.BaseTexture[];
  78712. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78713. dispose(forceDisposeEffect?: boolean): void;
  78714. clone(name: string): FluentMaterial;
  78715. serialize(): any;
  78716. getClassName(): string;
  78717. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  78718. }
  78719. }
  78720. declare module BABYLON.GUI {
  78721. /**
  78722. * Class used to create a holographic button in 3D
  78723. */
  78724. export class HolographicButton extends Button3D {
  78725. private _backPlate;
  78726. private _textPlate;
  78727. private _frontPlate;
  78728. private _text;
  78729. private _imageUrl;
  78730. private _shareMaterials;
  78731. private _frontMaterial;
  78732. private _backMaterial;
  78733. private _plateMaterial;
  78734. private _pickedPointObserver;
  78735. private _tooltipFade;
  78736. private _tooltipTextBlock;
  78737. private _tooltipTexture;
  78738. private _tooltipMesh;
  78739. private _tooltipHoverObserver;
  78740. private _tooltipOutObserver;
  78741. private _disposeTooltip;
  78742. /**
  78743. * Rendering ground id of all the mesh in the button
  78744. */
  78745. set renderingGroupId(id: number);
  78746. get renderingGroupId(): number;
  78747. /**
  78748. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  78749. */
  78750. set tooltipText(text: BABYLON.Nullable<string>);
  78751. get tooltipText(): BABYLON.Nullable<string>;
  78752. /**
  78753. * Gets or sets text for the button
  78754. */
  78755. get text(): string;
  78756. set text(value: string);
  78757. /**
  78758. * Gets or sets the image url for the button
  78759. */
  78760. get imageUrl(): string;
  78761. set imageUrl(value: string);
  78762. /**
  78763. * Gets the back material used by this button
  78764. */
  78765. get backMaterial(): FluentMaterial;
  78766. /**
  78767. * Gets the front material used by this button
  78768. */
  78769. get frontMaterial(): FluentMaterial;
  78770. /**
  78771. * Gets the plate material used by this button
  78772. */
  78773. get plateMaterial(): BABYLON.StandardMaterial;
  78774. /**
  78775. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  78776. */
  78777. get shareMaterials(): boolean;
  78778. /**
  78779. * Creates a new button
  78780. * @param name defines the control name
  78781. */
  78782. constructor(name?: string, shareMaterials?: boolean);
  78783. protected _getTypeName(): string;
  78784. private _rebuildContent;
  78785. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78786. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78787. private _createBackMaterial;
  78788. private _createFrontMaterial;
  78789. private _createPlateMaterial;
  78790. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  78791. /**
  78792. * Releases all associated resources
  78793. */
  78794. dispose(): void;
  78795. }
  78796. }
  78797. declare module BABYLON.GUI {
  78798. /**
  78799. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  78800. */
  78801. export class MeshButton3D extends Button3D {
  78802. /** @hidden */
  78803. protected _currentMesh: BABYLON.Mesh;
  78804. /**
  78805. * Creates a new 3D button based on a mesh
  78806. * @param mesh mesh to become a 3D button
  78807. * @param name defines the control name
  78808. */
  78809. constructor(mesh: BABYLON.Mesh, name?: string);
  78810. protected _getTypeName(): string;
  78811. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78812. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78813. }
  78814. }
  78815. declare module BABYLON.GUI {
  78816. /**
  78817. * Class used to create a container panel deployed on the surface of a plane
  78818. */
  78819. export class PlanePanel extends VolumeBasedPanel {
  78820. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78821. }
  78822. }
  78823. declare module BABYLON.GUI {
  78824. /**
  78825. * Class used to create a container panel where items get randomized planar mapping
  78826. */
  78827. export class ScatterPanel extends VolumeBasedPanel {
  78828. private _iteration;
  78829. /**
  78830. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  78831. */
  78832. get iteration(): BABYLON.float;
  78833. set iteration(value: BABYLON.float);
  78834. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78835. private _scatterMapping;
  78836. protected _finalProcessing(): void;
  78837. }
  78838. }
  78839. declare module BABYLON.GUI {
  78840. /**
  78841. * Class used to create a container panel deployed on the surface of a sphere
  78842. */
  78843. export class SpherePanel extends VolumeBasedPanel {
  78844. private _radius;
  78845. /**
  78846. * Gets or sets the radius of the sphere where to project controls (5 by default)
  78847. */
  78848. get radius(): BABYLON.float;
  78849. set radius(value: BABYLON.float);
  78850. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78851. private _sphericalMapping;
  78852. }
  78853. }
  78854. declare module BABYLON.GUI {
  78855. /**
  78856. * Class used to create a stack panel in 3D on XY plane
  78857. */
  78858. export class StackPanel3D extends Container3D {
  78859. private _isVertical;
  78860. /**
  78861. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  78862. */
  78863. get isVertical(): boolean;
  78864. set isVertical(value: boolean);
  78865. /**
  78866. * Gets or sets the distance between elements
  78867. */
  78868. margin: number;
  78869. /**
  78870. * Creates new StackPanel
  78871. * @param isVertical
  78872. */
  78873. constructor(isVertical?: boolean);
  78874. protected _arrangeChildren(): void;
  78875. }
  78876. }
  78877. declare module BABYLON {
  78878. /**
  78879. * Configuration for glTF validation
  78880. */
  78881. export interface IGLTFValidationConfiguration {
  78882. /**
  78883. * The url of the glTF validator.
  78884. */
  78885. url: string;
  78886. }
  78887. /**
  78888. * glTF validation
  78889. */
  78890. export class GLTFValidation {
  78891. /**
  78892. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  78893. */
  78894. static Configuration: IGLTFValidationConfiguration;
  78895. private static _LoadScriptPromise;
  78896. /**
  78897. * Validate a glTF asset using the glTF-Validator.
  78898. * @param data The JSON of a glTF or the array buffer of a binary glTF
  78899. * @param rootUrl The root url for the glTF
  78900. * @param fileName The file name for the glTF
  78901. * @param getExternalResource The callback to get external resources for the glTF validator
  78902. * @returns A promise that resolves with the glTF validation results once complete
  78903. */
  78904. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  78905. }
  78906. }
  78907. declare module BABYLON {
  78908. /**
  78909. * Mode that determines the coordinate system to use.
  78910. */
  78911. export enum GLTFLoaderCoordinateSystemMode {
  78912. /**
  78913. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  78914. */
  78915. AUTO = 0,
  78916. /**
  78917. * Sets the useRightHandedSystem flag on the scene.
  78918. */
  78919. FORCE_RIGHT_HANDED = 1
  78920. }
  78921. /**
  78922. * Mode that determines what animations will start.
  78923. */
  78924. export enum GLTFLoaderAnimationStartMode {
  78925. /**
  78926. * No animation will start.
  78927. */
  78928. NONE = 0,
  78929. /**
  78930. * The first animation will start.
  78931. */
  78932. FIRST = 1,
  78933. /**
  78934. * All animations will start.
  78935. */
  78936. ALL = 2
  78937. }
  78938. /**
  78939. * Interface that contains the data for the glTF asset.
  78940. */
  78941. export interface IGLTFLoaderData {
  78942. /**
  78943. * The object that represents the glTF JSON.
  78944. */
  78945. json: Object;
  78946. /**
  78947. * The BIN chunk of a binary glTF.
  78948. */
  78949. bin: Nullable<IDataBuffer>;
  78950. }
  78951. /**
  78952. * Interface for extending the loader.
  78953. */
  78954. export interface IGLTFLoaderExtension {
  78955. /**
  78956. * The name of this extension.
  78957. */
  78958. readonly name: string;
  78959. /**
  78960. * Defines whether this extension is enabled.
  78961. */
  78962. enabled: boolean;
  78963. /**
  78964. * Defines the order of this extension.
  78965. * The loader sorts the extensions using these values when loading.
  78966. */
  78967. order?: number;
  78968. }
  78969. /**
  78970. * Loader state.
  78971. */
  78972. export enum GLTFLoaderState {
  78973. /**
  78974. * The asset is loading.
  78975. */
  78976. LOADING = 0,
  78977. /**
  78978. * The asset is ready for rendering.
  78979. */
  78980. READY = 1,
  78981. /**
  78982. * The asset is completely loaded.
  78983. */
  78984. COMPLETE = 2
  78985. }
  78986. /** @hidden */
  78987. export interface IImportMeshAsyncOutput {
  78988. meshes: AbstractMesh[];
  78989. particleSystems: IParticleSystem[];
  78990. skeletons: Skeleton[];
  78991. animationGroups: AnimationGroup[];
  78992. lights: Light[];
  78993. transformNodes: TransformNode[];
  78994. }
  78995. /** @hidden */
  78996. export interface IGLTFLoader extends IDisposable {
  78997. readonly state: Nullable<GLTFLoaderState>;
  78998. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  78999. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79000. }
  79001. /**
  79002. * File loader for loading glTF files into a scene.
  79003. */
  79004. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79005. /** @hidden */
  79006. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79007. /** @hidden */
  79008. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79009. /**
  79010. * Raised when the asset has been parsed
  79011. */
  79012. onParsedObservable: Observable<IGLTFLoaderData>;
  79013. private _onParsedObserver;
  79014. /**
  79015. * Raised when the asset has been parsed
  79016. */
  79017. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79018. /**
  79019. * 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.
  79020. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79021. * Defaults to true.
  79022. * @hidden
  79023. */
  79024. static IncrementalLoading: boolean;
  79025. /**
  79026. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79027. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79028. * @hidden
  79029. */
  79030. static HomogeneousCoordinates: boolean;
  79031. /**
  79032. * The coordinate system mode. Defaults to AUTO.
  79033. */
  79034. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79035. /**
  79036. * The animation start mode. Defaults to FIRST.
  79037. */
  79038. animationStartMode: GLTFLoaderAnimationStartMode;
  79039. /**
  79040. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79041. */
  79042. compileMaterials: boolean;
  79043. /**
  79044. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79045. */
  79046. useClipPlane: boolean;
  79047. /**
  79048. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79049. */
  79050. compileShadowGenerators: boolean;
  79051. /**
  79052. * Defines if the Alpha blended materials are only applied as coverage.
  79053. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79054. * If true, no extra effects are applied to transparent pixels.
  79055. */
  79056. transparencyAsCoverage: boolean;
  79057. /**
  79058. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79059. * Enabling will disable offline support and glTF validator.
  79060. * Defaults to false.
  79061. */
  79062. useRangeRequests: boolean;
  79063. /**
  79064. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79065. */
  79066. createInstances: boolean;
  79067. /**
  79068. * 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.
  79069. */
  79070. alwaysComputeBoundingBox: boolean;
  79071. /**
  79072. * Function called before loading a url referenced by the asset.
  79073. */
  79074. preprocessUrlAsync: (url: string) => Promise<string>;
  79075. /**
  79076. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79077. */
  79078. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79079. private _onMeshLoadedObserver;
  79080. /**
  79081. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79082. */
  79083. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79084. /**
  79085. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79086. */
  79087. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79088. private _onTextureLoadedObserver;
  79089. /**
  79090. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79091. */
  79092. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79093. /**
  79094. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79095. */
  79096. readonly onMaterialLoadedObservable: Observable<Material>;
  79097. private _onMaterialLoadedObserver;
  79098. /**
  79099. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79100. */
  79101. set onMaterialLoaded(callback: (material: Material) => void);
  79102. /**
  79103. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79104. */
  79105. readonly onCameraLoadedObservable: Observable<Camera>;
  79106. private _onCameraLoadedObserver;
  79107. /**
  79108. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79109. */
  79110. set onCameraLoaded(callback: (camera: Camera) => void);
  79111. /**
  79112. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79113. * For assets with LODs, raised when all of the LODs are complete.
  79114. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79115. */
  79116. readonly onCompleteObservable: Observable<void>;
  79117. private _onCompleteObserver;
  79118. /**
  79119. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79120. * For assets with LODs, raised when all of the LODs are complete.
  79121. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79122. */
  79123. set onComplete(callback: () => void);
  79124. /**
  79125. * Observable raised when an error occurs.
  79126. */
  79127. readonly onErrorObservable: Observable<any>;
  79128. private _onErrorObserver;
  79129. /**
  79130. * Callback raised when an error occurs.
  79131. */
  79132. set onError(callback: (reason: any) => void);
  79133. /**
  79134. * Observable raised after the loader is disposed.
  79135. */
  79136. readonly onDisposeObservable: Observable<void>;
  79137. private _onDisposeObserver;
  79138. /**
  79139. * Callback raised after the loader is disposed.
  79140. */
  79141. set onDispose(callback: () => void);
  79142. /**
  79143. * Observable raised after a loader extension is created.
  79144. * Set additional options for a loader extension in this event.
  79145. */
  79146. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79147. private _onExtensionLoadedObserver;
  79148. /**
  79149. * Callback raised after a loader extension is created.
  79150. */
  79151. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79152. /**
  79153. * Defines if the loader logging is enabled.
  79154. */
  79155. get loggingEnabled(): boolean;
  79156. set loggingEnabled(value: boolean);
  79157. /**
  79158. * Defines if the loader should capture performance counters.
  79159. */
  79160. get capturePerformanceCounters(): boolean;
  79161. set capturePerformanceCounters(value: boolean);
  79162. /**
  79163. * Defines if the loader should validate the asset.
  79164. */
  79165. validate: boolean;
  79166. /**
  79167. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79168. */
  79169. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79170. private _onValidatedObserver;
  79171. /**
  79172. * Callback raised after a loader extension is created.
  79173. */
  79174. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79175. private _loader;
  79176. private _progressCallback?;
  79177. private _requests;
  79178. private static magicBase64Encoded;
  79179. /**
  79180. * Name of the loader ("gltf")
  79181. */
  79182. name: string;
  79183. /** @hidden */
  79184. extensions: ISceneLoaderPluginExtensions;
  79185. /**
  79186. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79187. */
  79188. dispose(): void;
  79189. /** @hidden */
  79190. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79191. /** @hidden */
  79192. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79193. /** @hidden */
  79194. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79195. meshes: AbstractMesh[];
  79196. particleSystems: IParticleSystem[];
  79197. skeletons: Skeleton[];
  79198. animationGroups: AnimationGroup[];
  79199. }>;
  79200. /** @hidden */
  79201. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79202. /** @hidden */
  79203. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79204. /** @hidden */
  79205. canDirectLoad(data: string): boolean;
  79206. /** @hidden */
  79207. directLoad(scene: Scene, data: string): Promise<any>;
  79208. /**
  79209. * The callback that allows custom handling of the root url based on the response url.
  79210. * @param rootUrl the original root url
  79211. * @param responseURL the response url if available
  79212. * @returns the new root url
  79213. */
  79214. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79215. /** @hidden */
  79216. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79217. /**
  79218. * The loader state or null if the loader is not active.
  79219. */
  79220. get loaderState(): Nullable<GLTFLoaderState>;
  79221. /**
  79222. * Returns a promise that resolves when the asset is completely loaded.
  79223. * @returns a promise that resolves when the asset is completely loaded.
  79224. */
  79225. whenCompleteAsync(): Promise<void>;
  79226. /** @hidden */
  79227. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79228. /** @hidden */
  79229. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79230. private _onProgress;
  79231. private _validate;
  79232. private _getLoader;
  79233. private _parseJson;
  79234. private _unpackBinaryAsync;
  79235. private _unpackBinaryV1Async;
  79236. private _unpackBinaryV2Async;
  79237. private static _parseVersion;
  79238. private static _compareVersion;
  79239. private static readonly _logSpaces;
  79240. private _logIndentLevel;
  79241. private _loggingEnabled;
  79242. /** @hidden */
  79243. _log: (message: string) => void;
  79244. /** @hidden */
  79245. _logOpen(message: string): void;
  79246. /** @hidden */
  79247. _logClose(): void;
  79248. private _logEnabled;
  79249. private _logDisabled;
  79250. private _capturePerformanceCounters;
  79251. /** @hidden */
  79252. _startPerformanceCounter: (counterName: string) => void;
  79253. /** @hidden */
  79254. _endPerformanceCounter: (counterName: string) => void;
  79255. private _startPerformanceCounterEnabled;
  79256. private _startPerformanceCounterDisabled;
  79257. private _endPerformanceCounterEnabled;
  79258. private _endPerformanceCounterDisabled;
  79259. }
  79260. }
  79261. declare module BABYLON.GLTF1 {
  79262. /**
  79263. * Enums
  79264. * @hidden
  79265. */
  79266. export enum EComponentType {
  79267. BYTE = 5120,
  79268. UNSIGNED_BYTE = 5121,
  79269. SHORT = 5122,
  79270. UNSIGNED_SHORT = 5123,
  79271. FLOAT = 5126
  79272. }
  79273. /** @hidden */
  79274. export enum EShaderType {
  79275. FRAGMENT = 35632,
  79276. VERTEX = 35633
  79277. }
  79278. /** @hidden */
  79279. export enum EParameterType {
  79280. BYTE = 5120,
  79281. UNSIGNED_BYTE = 5121,
  79282. SHORT = 5122,
  79283. UNSIGNED_SHORT = 5123,
  79284. INT = 5124,
  79285. UNSIGNED_INT = 5125,
  79286. FLOAT = 5126,
  79287. FLOAT_VEC2 = 35664,
  79288. FLOAT_VEC3 = 35665,
  79289. FLOAT_VEC4 = 35666,
  79290. INT_VEC2 = 35667,
  79291. INT_VEC3 = 35668,
  79292. INT_VEC4 = 35669,
  79293. BOOL = 35670,
  79294. BOOL_VEC2 = 35671,
  79295. BOOL_VEC3 = 35672,
  79296. BOOL_VEC4 = 35673,
  79297. FLOAT_MAT2 = 35674,
  79298. FLOAT_MAT3 = 35675,
  79299. FLOAT_MAT4 = 35676,
  79300. SAMPLER_2D = 35678
  79301. }
  79302. /** @hidden */
  79303. export enum ETextureWrapMode {
  79304. CLAMP_TO_EDGE = 33071,
  79305. MIRRORED_REPEAT = 33648,
  79306. REPEAT = 10497
  79307. }
  79308. /** @hidden */
  79309. export enum ETextureFilterType {
  79310. NEAREST = 9728,
  79311. LINEAR = 9728,
  79312. NEAREST_MIPMAP_NEAREST = 9984,
  79313. LINEAR_MIPMAP_NEAREST = 9985,
  79314. NEAREST_MIPMAP_LINEAR = 9986,
  79315. LINEAR_MIPMAP_LINEAR = 9987
  79316. }
  79317. /** @hidden */
  79318. export enum ETextureFormat {
  79319. ALPHA = 6406,
  79320. RGB = 6407,
  79321. RGBA = 6408,
  79322. LUMINANCE = 6409,
  79323. LUMINANCE_ALPHA = 6410
  79324. }
  79325. /** @hidden */
  79326. export enum ECullingType {
  79327. FRONT = 1028,
  79328. BACK = 1029,
  79329. FRONT_AND_BACK = 1032
  79330. }
  79331. /** @hidden */
  79332. export enum EBlendingFunction {
  79333. ZERO = 0,
  79334. ONE = 1,
  79335. SRC_COLOR = 768,
  79336. ONE_MINUS_SRC_COLOR = 769,
  79337. DST_COLOR = 774,
  79338. ONE_MINUS_DST_COLOR = 775,
  79339. SRC_ALPHA = 770,
  79340. ONE_MINUS_SRC_ALPHA = 771,
  79341. DST_ALPHA = 772,
  79342. ONE_MINUS_DST_ALPHA = 773,
  79343. CONSTANT_COLOR = 32769,
  79344. ONE_MINUS_CONSTANT_COLOR = 32770,
  79345. CONSTANT_ALPHA = 32771,
  79346. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79347. SRC_ALPHA_SATURATE = 776
  79348. }
  79349. /** @hidden */
  79350. export interface IGLTFProperty {
  79351. extensions?: {
  79352. [key: string]: any;
  79353. };
  79354. extras?: Object;
  79355. }
  79356. /** @hidden */
  79357. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79358. name?: string;
  79359. }
  79360. /** @hidden */
  79361. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79362. bufferView: string;
  79363. byteOffset: number;
  79364. byteStride: number;
  79365. count: number;
  79366. type: string;
  79367. componentType: EComponentType;
  79368. max?: number[];
  79369. min?: number[];
  79370. name?: string;
  79371. }
  79372. /** @hidden */
  79373. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79374. buffer: string;
  79375. byteOffset: number;
  79376. byteLength: number;
  79377. byteStride: number;
  79378. target?: number;
  79379. }
  79380. /** @hidden */
  79381. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79382. uri: string;
  79383. byteLength?: number;
  79384. type?: string;
  79385. }
  79386. /** @hidden */
  79387. export interface IGLTFShader extends IGLTFChildRootProperty {
  79388. uri: string;
  79389. type: EShaderType;
  79390. }
  79391. /** @hidden */
  79392. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79393. attributes: string[];
  79394. fragmentShader: string;
  79395. vertexShader: string;
  79396. }
  79397. /** @hidden */
  79398. export interface IGLTFTechniqueParameter {
  79399. type: number;
  79400. count?: number;
  79401. semantic?: string;
  79402. node?: string;
  79403. value?: number | boolean | string | Array<any>;
  79404. source?: string;
  79405. babylonValue?: any;
  79406. }
  79407. /** @hidden */
  79408. export interface IGLTFTechniqueCommonProfile {
  79409. lightingModel: string;
  79410. texcoordBindings: Object;
  79411. parameters?: Array<any>;
  79412. }
  79413. /** @hidden */
  79414. export interface IGLTFTechniqueStatesFunctions {
  79415. blendColor?: number[];
  79416. blendEquationSeparate?: number[];
  79417. blendFuncSeparate?: number[];
  79418. colorMask: boolean[];
  79419. cullFace: number[];
  79420. }
  79421. /** @hidden */
  79422. export interface IGLTFTechniqueStates {
  79423. enable: number[];
  79424. functions: IGLTFTechniqueStatesFunctions;
  79425. }
  79426. /** @hidden */
  79427. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79428. parameters: {
  79429. [key: string]: IGLTFTechniqueParameter;
  79430. };
  79431. program: string;
  79432. attributes: {
  79433. [key: string]: string;
  79434. };
  79435. uniforms: {
  79436. [key: string]: string;
  79437. };
  79438. states: IGLTFTechniqueStates;
  79439. }
  79440. /** @hidden */
  79441. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79442. technique?: string;
  79443. values: string[];
  79444. }
  79445. /** @hidden */
  79446. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79447. attributes: {
  79448. [key: string]: string;
  79449. };
  79450. indices: string;
  79451. material: string;
  79452. mode?: number;
  79453. }
  79454. /** @hidden */
  79455. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79456. primitives: IGLTFMeshPrimitive[];
  79457. }
  79458. /** @hidden */
  79459. export interface IGLTFImage extends IGLTFChildRootProperty {
  79460. uri: string;
  79461. }
  79462. /** @hidden */
  79463. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79464. magFilter?: number;
  79465. minFilter?: number;
  79466. wrapS?: number;
  79467. wrapT?: number;
  79468. }
  79469. /** @hidden */
  79470. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79471. sampler: string;
  79472. source: string;
  79473. format?: ETextureFormat;
  79474. internalFormat?: ETextureFormat;
  79475. target?: number;
  79476. type?: number;
  79477. babylonTexture?: Texture;
  79478. }
  79479. /** @hidden */
  79480. export interface IGLTFAmbienLight {
  79481. color?: number[];
  79482. }
  79483. /** @hidden */
  79484. export interface IGLTFDirectionalLight {
  79485. color?: number[];
  79486. }
  79487. /** @hidden */
  79488. export interface IGLTFPointLight {
  79489. color?: number[];
  79490. constantAttenuation?: number;
  79491. linearAttenuation?: number;
  79492. quadraticAttenuation?: number;
  79493. }
  79494. /** @hidden */
  79495. export interface IGLTFSpotLight {
  79496. color?: number[];
  79497. constantAttenuation?: number;
  79498. fallOfAngle?: number;
  79499. fallOffExponent?: number;
  79500. linearAttenuation?: number;
  79501. quadraticAttenuation?: number;
  79502. }
  79503. /** @hidden */
  79504. export interface IGLTFLight extends IGLTFChildRootProperty {
  79505. type: string;
  79506. }
  79507. /** @hidden */
  79508. export interface IGLTFCameraOrthographic {
  79509. xmag: number;
  79510. ymag: number;
  79511. zfar: number;
  79512. znear: number;
  79513. }
  79514. /** @hidden */
  79515. export interface IGLTFCameraPerspective {
  79516. aspectRatio: number;
  79517. yfov: number;
  79518. zfar: number;
  79519. znear: number;
  79520. }
  79521. /** @hidden */
  79522. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79523. type: string;
  79524. }
  79525. /** @hidden */
  79526. export interface IGLTFAnimationChannelTarget {
  79527. id: string;
  79528. path: string;
  79529. }
  79530. /** @hidden */
  79531. export interface IGLTFAnimationChannel {
  79532. sampler: string;
  79533. target: IGLTFAnimationChannelTarget;
  79534. }
  79535. /** @hidden */
  79536. export interface IGLTFAnimationSampler {
  79537. input: string;
  79538. output: string;
  79539. interpolation?: string;
  79540. }
  79541. /** @hidden */
  79542. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79543. channels?: IGLTFAnimationChannel[];
  79544. parameters?: {
  79545. [key: string]: string;
  79546. };
  79547. samplers?: {
  79548. [key: string]: IGLTFAnimationSampler;
  79549. };
  79550. }
  79551. /** @hidden */
  79552. export interface IGLTFNodeInstanceSkin {
  79553. skeletons: string[];
  79554. skin: string;
  79555. meshes: string[];
  79556. }
  79557. /** @hidden */
  79558. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79559. bindShapeMatrix: number[];
  79560. inverseBindMatrices: string;
  79561. jointNames: string[];
  79562. babylonSkeleton?: Skeleton;
  79563. }
  79564. /** @hidden */
  79565. export interface IGLTFNode extends IGLTFChildRootProperty {
  79566. camera?: string;
  79567. children: string[];
  79568. skin?: string;
  79569. jointName?: string;
  79570. light?: string;
  79571. matrix: number[];
  79572. mesh?: string;
  79573. meshes?: string[];
  79574. rotation?: number[];
  79575. scale?: number[];
  79576. translation?: number[];
  79577. babylonNode?: Node;
  79578. }
  79579. /** @hidden */
  79580. export interface IGLTFScene extends IGLTFChildRootProperty {
  79581. nodes: string[];
  79582. }
  79583. /** @hidden */
  79584. export interface IGLTFRuntime {
  79585. extensions: {
  79586. [key: string]: any;
  79587. };
  79588. accessors: {
  79589. [key: string]: IGLTFAccessor;
  79590. };
  79591. buffers: {
  79592. [key: string]: IGLTFBuffer;
  79593. };
  79594. bufferViews: {
  79595. [key: string]: IGLTFBufferView;
  79596. };
  79597. meshes: {
  79598. [key: string]: IGLTFMesh;
  79599. };
  79600. lights: {
  79601. [key: string]: IGLTFLight;
  79602. };
  79603. cameras: {
  79604. [key: string]: IGLTFCamera;
  79605. };
  79606. nodes: {
  79607. [key: string]: IGLTFNode;
  79608. };
  79609. images: {
  79610. [key: string]: IGLTFImage;
  79611. };
  79612. textures: {
  79613. [key: string]: IGLTFTexture;
  79614. };
  79615. shaders: {
  79616. [key: string]: IGLTFShader;
  79617. };
  79618. programs: {
  79619. [key: string]: IGLTFProgram;
  79620. };
  79621. samplers: {
  79622. [key: string]: IGLTFSampler;
  79623. };
  79624. techniques: {
  79625. [key: string]: IGLTFTechnique;
  79626. };
  79627. materials: {
  79628. [key: string]: IGLTFMaterial;
  79629. };
  79630. animations: {
  79631. [key: string]: IGLTFAnimation;
  79632. };
  79633. skins: {
  79634. [key: string]: IGLTFSkins;
  79635. };
  79636. currentScene?: Object;
  79637. scenes: {
  79638. [key: string]: IGLTFScene;
  79639. };
  79640. extensionsUsed: string[];
  79641. extensionsRequired?: string[];
  79642. buffersCount: number;
  79643. shaderscount: number;
  79644. scene: Scene;
  79645. rootUrl: string;
  79646. loadedBufferCount: number;
  79647. loadedBufferViews: {
  79648. [name: string]: ArrayBufferView;
  79649. };
  79650. loadedShaderCount: number;
  79651. importOnlyMeshes: boolean;
  79652. importMeshesNames?: string[];
  79653. dummyNodes: Node[];
  79654. forAssetContainer: boolean;
  79655. }
  79656. /** @hidden */
  79657. export interface INodeToRoot {
  79658. bone: Bone;
  79659. node: IGLTFNode;
  79660. id: string;
  79661. }
  79662. /** @hidden */
  79663. export interface IJointNode {
  79664. node: IGLTFNode;
  79665. id: string;
  79666. }
  79667. }
  79668. declare module BABYLON.GLTF1 {
  79669. /**
  79670. * Utils functions for GLTF
  79671. * @hidden
  79672. */
  79673. export class GLTFUtils {
  79674. /**
  79675. * Sets the given "parameter" matrix
  79676. * @param scene: the Scene object
  79677. * @param source: the source node where to pick the matrix
  79678. * @param parameter: the GLTF technique parameter
  79679. * @param uniformName: the name of the shader's uniform
  79680. * @param shaderMaterial: the shader material
  79681. */
  79682. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79683. /**
  79684. * Sets the given "parameter" matrix
  79685. * @param shaderMaterial: the shader material
  79686. * @param uniform: the name of the shader's uniform
  79687. * @param value: the value of the uniform
  79688. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79689. */
  79690. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79691. /**
  79692. * Returns the wrap mode of the texture
  79693. * @param mode: the mode value
  79694. */
  79695. static GetWrapMode(mode: number): number;
  79696. /**
  79697. * Returns the byte stride giving an accessor
  79698. * @param accessor: the GLTF accessor objet
  79699. */
  79700. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79701. /**
  79702. * Returns the texture filter mode giving a mode value
  79703. * @param mode: the filter mode value
  79704. */
  79705. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79706. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  79707. /**
  79708. * Returns a buffer from its accessor
  79709. * @param gltfRuntime: the GLTF runtime
  79710. * @param accessor: the GLTF accessor
  79711. */
  79712. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  79713. /**
  79714. * Decodes a buffer view into a string
  79715. * @param view: the buffer view
  79716. */
  79717. static DecodeBufferToText(view: ArrayBufferView): string;
  79718. /**
  79719. * Returns the default material of gltf. Related to
  79720. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  79721. * @param scene: the Babylon.js scene
  79722. */
  79723. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  79724. private static _DefaultMaterial;
  79725. }
  79726. }
  79727. declare module BABYLON.GLTF1 {
  79728. /**
  79729. * Implementation of the base glTF spec
  79730. * @hidden
  79731. */
  79732. export class GLTFLoaderBase {
  79733. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  79734. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79735. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  79736. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79737. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  79738. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79739. }
  79740. /**
  79741. * glTF V1 Loader
  79742. * @hidden
  79743. */
  79744. export class GLTFLoader implements IGLTFLoader {
  79745. static Extensions: {
  79746. [name: string]: GLTFLoaderExtension;
  79747. };
  79748. static RegisterExtension(extension: GLTFLoaderExtension): void;
  79749. state: Nullable<GLTFLoaderState>;
  79750. dispose(): void;
  79751. private _importMeshAsync;
  79752. /**
  79753. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  79754. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  79755. * @param scene the scene the meshes should be added to
  79756. * @param forAssetContainer defines if the entities must be stored in the scene
  79757. * @param data gltf data containing information of the meshes in a loaded file
  79758. * @param rootUrl root url to load from
  79759. * @param onProgress event that fires when loading progress has occured
  79760. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  79761. */
  79762. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  79763. private _loadAsync;
  79764. /**
  79765. * Imports all objects from a loaded gltf file and adds them to the scene
  79766. * @param scene the scene the objects should be added to
  79767. * @param data gltf data containing information of the meshes in a loaded file
  79768. * @param rootUrl root url to load from
  79769. * @param onProgress event that fires when loading progress has occured
  79770. * @returns a promise which completes when objects have been loaded to the scene
  79771. */
  79772. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  79773. private _loadShadersAsync;
  79774. private _loadBuffersAsync;
  79775. private _createNodes;
  79776. }
  79777. /** @hidden */
  79778. export abstract class GLTFLoaderExtension {
  79779. private _name;
  79780. constructor(name: string);
  79781. get name(): string;
  79782. /**
  79783. * Defines an override for loading the runtime
  79784. * Return true to stop further extensions from loading the runtime
  79785. */
  79786. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  79787. /**
  79788. * Defines an onverride for creating gltf runtime
  79789. * Return true to stop further extensions from creating the runtime
  79790. */
  79791. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  79792. /**
  79793. * Defines an override for loading buffers
  79794. * Return true to stop further extensions from loading this buffer
  79795. */
  79796. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  79797. /**
  79798. * Defines an override for loading texture buffers
  79799. * Return true to stop further extensions from loading this texture data
  79800. */
  79801. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79802. /**
  79803. * Defines an override for creating textures
  79804. * Return true to stop further extensions from loading this texture
  79805. */
  79806. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  79807. /**
  79808. * Defines an override for loading shader strings
  79809. * Return true to stop further extensions from loading this shader data
  79810. */
  79811. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79812. /**
  79813. * Defines an override for loading materials
  79814. * Return true to stop further extensions from loading this material
  79815. */
  79816. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79817. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  79818. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  79819. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  79820. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  79821. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  79822. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  79823. private static LoadTextureBufferAsync;
  79824. private static CreateTextureAsync;
  79825. private static ApplyExtensions;
  79826. }
  79827. }
  79828. declare module BABYLON.GLTF1 {
  79829. /** @hidden */
  79830. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  79831. private _bin;
  79832. constructor();
  79833. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  79834. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79835. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  79836. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  79837. }
  79838. }
  79839. declare module BABYLON.GLTF1 {
  79840. /** @hidden */
  79841. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  79842. constructor();
  79843. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  79844. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  79845. private _loadTexture;
  79846. }
  79847. }
  79848. declare module BABYLON.GLTF2.Loader {
  79849. /**
  79850. * Loader interface with an index field.
  79851. */
  79852. export interface IArrayItem {
  79853. /**
  79854. * The index of this item in the array.
  79855. */
  79856. index: number;
  79857. }
  79858. /**
  79859. * Loader interface with additional members.
  79860. */
  79861. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  79862. /** @hidden */
  79863. _data?: Promise<ArrayBufferView>;
  79864. /** @hidden */
  79865. _babylonVertexBuffer?: Promise<VertexBuffer>;
  79866. }
  79867. /**
  79868. * Loader interface with additional members.
  79869. */
  79870. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  79871. }
  79872. /** @hidden */
  79873. export interface _IAnimationSamplerData {
  79874. input: Float32Array;
  79875. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  79876. output: Float32Array;
  79877. }
  79878. /**
  79879. * Loader interface with additional members.
  79880. */
  79881. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  79882. /** @hidden */
  79883. _data?: Promise<_IAnimationSamplerData>;
  79884. }
  79885. /**
  79886. * Loader interface with additional members.
  79887. */
  79888. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  79889. channels: IAnimationChannel[];
  79890. samplers: IAnimationSampler[];
  79891. /** @hidden */
  79892. _babylonAnimationGroup?: AnimationGroup;
  79893. }
  79894. /**
  79895. * Loader interface with additional members.
  79896. */
  79897. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  79898. /** @hidden */
  79899. _data?: Promise<ArrayBufferView>;
  79900. }
  79901. /**
  79902. * Loader interface with additional members.
  79903. */
  79904. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  79905. /** @hidden */
  79906. _data?: Promise<ArrayBufferView>;
  79907. /** @hidden */
  79908. _babylonBuffer?: Promise<Buffer>;
  79909. }
  79910. /**
  79911. * Loader interface with additional members.
  79912. */
  79913. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  79914. }
  79915. /**
  79916. * Loader interface with additional members.
  79917. */
  79918. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  79919. /** @hidden */
  79920. _data?: Promise<ArrayBufferView>;
  79921. }
  79922. /**
  79923. * Loader interface with additional members.
  79924. */
  79925. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  79926. }
  79927. /**
  79928. * Loader interface with additional members.
  79929. */
  79930. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  79931. }
  79932. /**
  79933. * Loader interface with additional members.
  79934. */
  79935. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  79936. baseColorTexture?: ITextureInfo;
  79937. metallicRoughnessTexture?: ITextureInfo;
  79938. }
  79939. /**
  79940. * Loader interface with additional members.
  79941. */
  79942. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  79943. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79944. normalTexture?: IMaterialNormalTextureInfo;
  79945. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79946. emissiveTexture?: ITextureInfo;
  79947. /** @hidden */
  79948. _data?: {
  79949. [babylonDrawMode: number]: {
  79950. babylonMaterial: Material;
  79951. babylonMeshes: AbstractMesh[];
  79952. promise: Promise<void>;
  79953. };
  79954. };
  79955. }
  79956. /**
  79957. * Loader interface with additional members.
  79958. */
  79959. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  79960. primitives: IMeshPrimitive[];
  79961. }
  79962. /**
  79963. * Loader interface with additional members.
  79964. */
  79965. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  79966. /** @hidden */
  79967. _instanceData?: {
  79968. babylonSourceMesh: Mesh;
  79969. promise: Promise<any>;
  79970. };
  79971. }
  79972. /**
  79973. * Loader interface with additional members.
  79974. */
  79975. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  79976. /**
  79977. * The parent glTF node.
  79978. */
  79979. parent?: INode;
  79980. /** @hidden */
  79981. _babylonTransformNode?: TransformNode;
  79982. /** @hidden */
  79983. _primitiveBabylonMeshes?: AbstractMesh[];
  79984. /** @hidden */
  79985. _babylonBones?: Bone[];
  79986. /** @hidden */
  79987. _numMorphTargets?: number;
  79988. }
  79989. /** @hidden */
  79990. export interface _ISamplerData {
  79991. noMipMaps: boolean;
  79992. samplingMode: number;
  79993. wrapU: number;
  79994. wrapV: number;
  79995. }
  79996. /**
  79997. * Loader interface with additional members.
  79998. */
  79999. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80000. /** @hidden */
  80001. _data?: _ISamplerData;
  80002. }
  80003. /**
  80004. * Loader interface with additional members.
  80005. */
  80006. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80007. }
  80008. /**
  80009. * Loader interface with additional members.
  80010. */
  80011. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80012. /** @hidden */
  80013. _data?: {
  80014. babylonSkeleton: Skeleton;
  80015. promise: Promise<void>;
  80016. };
  80017. }
  80018. /**
  80019. * Loader interface with additional members.
  80020. */
  80021. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80022. }
  80023. /**
  80024. * Loader interface with additional members.
  80025. */
  80026. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80027. }
  80028. /**
  80029. * Loader interface with additional members.
  80030. */
  80031. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80032. accessors?: IAccessor[];
  80033. animations?: IAnimation[];
  80034. buffers?: IBuffer[];
  80035. bufferViews?: IBufferView[];
  80036. cameras?: ICamera[];
  80037. images?: IImage[];
  80038. materials?: IMaterial[];
  80039. meshes?: IMesh[];
  80040. nodes?: INode[];
  80041. samplers?: ISampler[];
  80042. scenes?: IScene[];
  80043. skins?: ISkin[];
  80044. textures?: ITexture[];
  80045. }
  80046. }
  80047. declare module BABYLON.GLTF2 {
  80048. /**
  80049. * Interface for a glTF loader extension.
  80050. */
  80051. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80052. /**
  80053. * Called after the loader state changes to LOADING.
  80054. */
  80055. onLoading?(): void;
  80056. /**
  80057. * Called after the loader state changes to READY.
  80058. */
  80059. onReady?(): void;
  80060. /**
  80061. * Define this method to modify the default behavior when loading scenes.
  80062. * @param context The context when loading the asset
  80063. * @param scene The glTF scene property
  80064. * @returns A promise that resolves when the load is complete or null if not handled
  80065. */
  80066. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80067. /**
  80068. * Define this method to modify the default behavior when loading nodes.
  80069. * @param context The context when loading the asset
  80070. * @param node The glTF node property
  80071. * @param assign A function called synchronously after parsing the glTF properties
  80072. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80073. */
  80074. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80075. /**
  80076. * Define this method to modify the default behavior when loading cameras.
  80077. * @param context The context when loading the asset
  80078. * @param camera The glTF camera property
  80079. * @param assign A function called synchronously after parsing the glTF properties
  80080. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80081. */
  80082. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80083. /**
  80084. * @hidden
  80085. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80086. * @param context The context when loading the asset
  80087. * @param primitive The glTF mesh primitive property
  80088. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80089. */
  80090. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80091. /**
  80092. * @hidden
  80093. * Define this method to modify the default behavior when loading data for mesh primitives.
  80094. * @param context The context when loading the asset
  80095. * @param name The mesh name when loading the asset
  80096. * @param node The glTF node when loading the asset
  80097. * @param mesh The glTF mesh when loading the asset
  80098. * @param primitive The glTF mesh primitive property
  80099. * @param assign A function called synchronously after parsing the glTF properties
  80100. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80101. */
  80102. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80103. /**
  80104. * @hidden
  80105. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80106. * @param context The context when loading the asset
  80107. * @param material The glTF material property
  80108. * @param assign A function called synchronously after parsing the glTF properties
  80109. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80110. */
  80111. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80112. /**
  80113. * Define this method to modify the default behavior when creating materials.
  80114. * @param context The context when loading the asset
  80115. * @param material The glTF material property
  80116. * @param babylonDrawMode The draw mode for the Babylon material
  80117. * @returns The Babylon material or null if not handled
  80118. */
  80119. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80120. /**
  80121. * Define this method to modify the default behavior when loading material properties.
  80122. * @param context The context when loading the asset
  80123. * @param material The glTF material property
  80124. * @param babylonMaterial The Babylon material
  80125. * @returns A promise that resolves when the load is complete or null if not handled
  80126. */
  80127. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80128. /**
  80129. * Define this method to modify the default behavior when loading texture infos.
  80130. * @param context The context when loading the asset
  80131. * @param textureInfo The glTF texture info property
  80132. * @param assign A function called synchronously after parsing the glTF properties
  80133. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80134. */
  80135. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80136. /**
  80137. * @hidden
  80138. * Define this method to modify the default behavior when loading textures.
  80139. * @param context The context when loading the asset
  80140. * @param texture The glTF texture property
  80141. * @param assign A function called synchronously after parsing the glTF properties
  80142. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80143. */
  80144. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80145. /**
  80146. * Define this method to modify the default behavior when loading animations.
  80147. * @param context The context when loading the asset
  80148. * @param animation The glTF animation property
  80149. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80150. */
  80151. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80152. /**
  80153. * @hidden
  80154. * Define this method to modify the default behavior when loading skins.
  80155. * @param context The context when loading the asset
  80156. * @param node The glTF node property
  80157. * @param skin The glTF skin property
  80158. * @returns A promise that resolves when the load is complete or null if not handled
  80159. */
  80160. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80161. /**
  80162. * @hidden
  80163. * Define this method to modify the default behavior when loading uris.
  80164. * @param context The context when loading the asset
  80165. * @param property The glTF property associated with the uri
  80166. * @param uri The uri to load
  80167. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80168. */
  80169. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80170. /**
  80171. * Define this method to modify the default behavior when loading buffer views.
  80172. * @param context The context when loading the asset
  80173. * @param bufferView The glTF buffer view property
  80174. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80175. */
  80176. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80177. /**
  80178. * Define this method to modify the default behavior when loading buffers.
  80179. * @param context The context when loading the asset
  80180. * @param buffer The glTF buffer property
  80181. * @param byteOffset The byte offset to load
  80182. * @param byteLength The byte length to load
  80183. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80184. */
  80185. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80186. }
  80187. }
  80188. declare module BABYLON.GLTF2 {
  80189. /**
  80190. * Helper class for working with arrays when loading the glTF asset
  80191. */
  80192. export class ArrayItem {
  80193. /**
  80194. * Gets an item from the given array.
  80195. * @param context The context when loading the asset
  80196. * @param array The array to get the item from
  80197. * @param index The index to the array
  80198. * @returns The array item
  80199. */
  80200. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80201. /**
  80202. * Assign an `index` field to each item of the given array.
  80203. * @param array The array of items
  80204. */
  80205. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80206. }
  80207. /**
  80208. * The glTF 2.0 loader
  80209. */
  80210. export class GLTFLoader implements IGLTFLoader {
  80211. /** @hidden */
  80212. _completePromises: Promise<any>[];
  80213. /** @hidden */
  80214. _forAssetContainer: boolean;
  80215. /** Storage */
  80216. _babylonLights: Light[];
  80217. /** @hidden */
  80218. _disableInstancedMesh: number;
  80219. private _disposed;
  80220. private _parent;
  80221. private _state;
  80222. private _extensions;
  80223. private _rootUrl;
  80224. private _fileName;
  80225. private _uniqueRootUrl;
  80226. private _gltf;
  80227. private _bin;
  80228. private _babylonScene;
  80229. private _rootBabylonMesh;
  80230. private _defaultBabylonMaterialData;
  80231. private static _RegisteredExtensions;
  80232. /**
  80233. * The default glTF sampler.
  80234. */
  80235. static readonly DefaultSampler: ISampler;
  80236. /**
  80237. * Registers a loader extension.
  80238. * @param name The name of the loader extension.
  80239. * @param factory The factory function that creates the loader extension.
  80240. */
  80241. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80242. /**
  80243. * Unregisters a loader extension.
  80244. * @param name The name of the loader extension.
  80245. * @returns A boolean indicating whether the extension has been unregistered
  80246. */
  80247. static UnregisterExtension(name: string): boolean;
  80248. /**
  80249. * The loader state.
  80250. */
  80251. get state(): Nullable<GLTFLoaderState>;
  80252. /**
  80253. * The object that represents the glTF JSON.
  80254. */
  80255. get gltf(): IGLTF;
  80256. /**
  80257. * The BIN chunk of a binary glTF.
  80258. */
  80259. get bin(): Nullable<IDataBuffer>;
  80260. /**
  80261. * The parent file loader.
  80262. */
  80263. get parent(): GLTFFileLoader;
  80264. /**
  80265. * The Babylon scene when loading the asset.
  80266. */
  80267. get babylonScene(): Scene;
  80268. /**
  80269. * The root Babylon mesh when loading the asset.
  80270. */
  80271. get rootBabylonMesh(): Mesh;
  80272. /** @hidden */
  80273. constructor(parent: GLTFFileLoader);
  80274. /** @hidden */
  80275. dispose(): void;
  80276. /** @hidden */
  80277. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80278. /** @hidden */
  80279. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80280. private _loadAsync;
  80281. private _loadData;
  80282. private _setupData;
  80283. private _loadExtensions;
  80284. private _checkExtensions;
  80285. private _setState;
  80286. private _createRootNode;
  80287. /**
  80288. * Loads a glTF scene.
  80289. * @param context The context when loading the asset
  80290. * @param scene The glTF scene property
  80291. * @returns A promise that resolves when the load is complete
  80292. */
  80293. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80294. private _forEachPrimitive;
  80295. private _getMeshes;
  80296. private _getTransformNodes;
  80297. private _getSkeletons;
  80298. private _getAnimationGroups;
  80299. private _startAnimations;
  80300. /**
  80301. * Loads a glTF node.
  80302. * @param context The context when loading the asset
  80303. * @param node The glTF node property
  80304. * @param assign A function called synchronously after parsing the glTF properties
  80305. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80306. */
  80307. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80308. private _loadMeshAsync;
  80309. /**
  80310. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80311. * @param context The context when loading the asset
  80312. * @param name The mesh name when loading the asset
  80313. * @param node The glTF node when loading the asset
  80314. * @param mesh The glTF mesh when loading the asset
  80315. * @param primitive The glTF mesh primitive property
  80316. * @param assign A function called synchronously after parsing the glTF properties
  80317. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80318. */
  80319. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80320. private _loadVertexDataAsync;
  80321. private _createMorphTargets;
  80322. private _loadMorphTargetsAsync;
  80323. private _loadMorphTargetVertexDataAsync;
  80324. private static _LoadTransform;
  80325. private _loadSkinAsync;
  80326. private _loadBones;
  80327. private _loadBone;
  80328. private _loadSkinInverseBindMatricesDataAsync;
  80329. private _updateBoneMatrices;
  80330. private _getNodeMatrix;
  80331. /**
  80332. * Loads a glTF camera.
  80333. * @param context The context when loading the asset
  80334. * @param camera The glTF camera property
  80335. * @param assign A function called synchronously after parsing the glTF properties
  80336. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80337. */
  80338. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80339. private _loadAnimationsAsync;
  80340. /**
  80341. * Loads a glTF animation.
  80342. * @param context The context when loading the asset
  80343. * @param animation The glTF animation property
  80344. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80345. */
  80346. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80347. /**
  80348. * @hidden Loads a glTF animation channel.
  80349. * @param context The context when loading the asset
  80350. * @param animationContext The context of the animation when loading the asset
  80351. * @param animation The glTF animation property
  80352. * @param channel The glTF animation channel property
  80353. * @param babylonAnimationGroup The babylon animation group property
  80354. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80355. * @returns A void promise when the channel load is complete
  80356. */
  80357. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80358. private _loadAnimationSamplerAsync;
  80359. private _loadBufferAsync;
  80360. /**
  80361. * Loads a glTF buffer view.
  80362. * @param context The context when loading the asset
  80363. * @param bufferView The glTF buffer view property
  80364. * @returns A promise that resolves with the loaded data when the load is complete
  80365. */
  80366. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80367. private _loadAccessorAsync;
  80368. /** @hidden */
  80369. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80370. private _loadIndicesAccessorAsync;
  80371. private _loadVertexBufferViewAsync;
  80372. private _loadVertexAccessorAsync;
  80373. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80374. /** @hidden */
  80375. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80376. private _createDefaultMaterial;
  80377. /**
  80378. * Creates a Babylon material from a glTF material.
  80379. * @param context The context when loading the asset
  80380. * @param material The glTF material property
  80381. * @param babylonDrawMode The draw mode for the Babylon material
  80382. * @returns The Babylon material
  80383. */
  80384. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80385. /**
  80386. * Loads properties from a glTF material into a Babylon material.
  80387. * @param context The context when loading the asset
  80388. * @param material The glTF material property
  80389. * @param babylonMaterial The Babylon material
  80390. * @returns A promise that resolves when the load is complete
  80391. */
  80392. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80393. /**
  80394. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80395. * @param context The context when loading the asset
  80396. * @param material The glTF material property
  80397. * @param babylonMaterial The Babylon material
  80398. * @returns A promise that resolves when the load is complete
  80399. */
  80400. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80401. /**
  80402. * Loads the alpha properties from a glTF material into a Babylon material.
  80403. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80404. * @param context The context when loading the asset
  80405. * @param material The glTF material property
  80406. * @param babylonMaterial The Babylon material
  80407. */
  80408. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80409. /**
  80410. * Loads a glTF texture info.
  80411. * @param context The context when loading the asset
  80412. * @param textureInfo The glTF texture info property
  80413. * @param assign A function called synchronously after parsing the glTF properties
  80414. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80415. */
  80416. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80417. /** @hidden */
  80418. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80419. /** @hidden */
  80420. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80421. private _loadSampler;
  80422. /**
  80423. * Loads a glTF image.
  80424. * @param context The context when loading the asset
  80425. * @param image The glTF image property
  80426. * @returns A promise that resolves with the loaded data when the load is complete
  80427. */
  80428. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80429. /**
  80430. * Loads a glTF uri.
  80431. * @param context The context when loading the asset
  80432. * @param property The glTF property associated with the uri
  80433. * @param uri The base64 or relative uri
  80434. * @returns A promise that resolves with the loaded data when the load is complete
  80435. */
  80436. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80437. /**
  80438. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80439. * @param babylonObject the Babylon object with metadata
  80440. * @param pointer the JSON pointer
  80441. */
  80442. static AddPointerMetadata(babylonObject: {
  80443. metadata: any;
  80444. }, pointer: string): void;
  80445. private static _GetTextureWrapMode;
  80446. private static _GetTextureSamplingMode;
  80447. private static _GetTypedArrayConstructor;
  80448. private static _GetTypedArray;
  80449. private static _GetNumComponents;
  80450. private static _ValidateUri;
  80451. /** @hidden */
  80452. static _GetDrawMode(context: string, mode: number | undefined): number;
  80453. private _compileMaterialsAsync;
  80454. private _compileShadowGeneratorsAsync;
  80455. private _forEachExtensions;
  80456. private _applyExtensions;
  80457. private _extensionsOnLoading;
  80458. private _extensionsOnReady;
  80459. private _extensionsLoadSceneAsync;
  80460. private _extensionsLoadNodeAsync;
  80461. private _extensionsLoadCameraAsync;
  80462. private _extensionsLoadVertexDataAsync;
  80463. private _extensionsLoadMeshPrimitiveAsync;
  80464. private _extensionsLoadMaterialAsync;
  80465. private _extensionsCreateMaterial;
  80466. private _extensionsLoadMaterialPropertiesAsync;
  80467. private _extensionsLoadTextureInfoAsync;
  80468. private _extensionsLoadTextureAsync;
  80469. private _extensionsLoadAnimationAsync;
  80470. private _extensionsLoadSkinAsync;
  80471. private _extensionsLoadUriAsync;
  80472. private _extensionsLoadBufferViewAsync;
  80473. private _extensionsLoadBufferAsync;
  80474. /**
  80475. * Helper method called by a loader extension to load an glTF extension.
  80476. * @param context The context when loading the asset
  80477. * @param property The glTF property to load the extension from
  80478. * @param extensionName The name of the extension to load
  80479. * @param actionAsync The action to run
  80480. * @returns The promise returned by actionAsync or null if the extension does not exist
  80481. */
  80482. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80483. /**
  80484. * Helper method called by a loader extension to load a glTF extra.
  80485. * @param context The context when loading the asset
  80486. * @param property The glTF property to load the extra from
  80487. * @param extensionName The name of the extension to load
  80488. * @param actionAsync The action to run
  80489. * @returns The promise returned by actionAsync or null if the extra does not exist
  80490. */
  80491. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80492. /**
  80493. * Checks for presence of an extension.
  80494. * @param name The name of the extension to check
  80495. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80496. */
  80497. isExtensionUsed(name: string): boolean;
  80498. /**
  80499. * Increments the indentation level and logs a message.
  80500. * @param message The message to log
  80501. */
  80502. logOpen(message: string): void;
  80503. /**
  80504. * Decrements the indentation level.
  80505. */
  80506. logClose(): void;
  80507. /**
  80508. * Logs a message
  80509. * @param message The message to log
  80510. */
  80511. log(message: string): void;
  80512. /**
  80513. * Starts a performance counter.
  80514. * @param counterName The name of the performance counter
  80515. */
  80516. startPerformanceCounter(counterName: string): void;
  80517. /**
  80518. * Ends a performance counter.
  80519. * @param counterName The name of the performance counter
  80520. */
  80521. endPerformanceCounter(counterName: string): void;
  80522. }
  80523. }
  80524. declare module BABYLON.GLTF2.Loader.Extensions {
  80525. /** @hidden */
  80526. interface IEXTLightsImageBased_LightImageBased {
  80527. _babylonTexture?: BaseTexture;
  80528. _loaded?: Promise<void>;
  80529. }
  80530. /**
  80531. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80532. */
  80533. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80534. /**
  80535. * The name of this extension.
  80536. */
  80537. readonly name: string;
  80538. /**
  80539. * Defines whether this extension is enabled.
  80540. */
  80541. enabled: boolean;
  80542. private _loader;
  80543. private _lights?;
  80544. /** @hidden */
  80545. constructor(loader: GLTFLoader);
  80546. /** @hidden */
  80547. dispose(): void;
  80548. /** @hidden */
  80549. onLoading(): void;
  80550. /** @hidden */
  80551. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80552. private _loadLightAsync;
  80553. }
  80554. }
  80555. declare module BABYLON.GLTF2.Loader.Extensions {
  80556. /**
  80557. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80558. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80559. * !!! Experimental Extension Subject to Changes !!!
  80560. */
  80561. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80562. /**
  80563. * The name of this extension.
  80564. */
  80565. readonly name: string;
  80566. /**
  80567. * Defines whether this extension is enabled.
  80568. */
  80569. enabled: boolean;
  80570. private _loader;
  80571. /** @hidden */
  80572. constructor(loader: GLTFLoader);
  80573. /** @hidden */
  80574. dispose(): void;
  80575. /** @hidden */
  80576. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80577. }
  80578. }
  80579. declare module BABYLON.GLTF2.Loader.Extensions {
  80580. /**
  80581. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80582. */
  80583. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80584. /**
  80585. * The name of this extension.
  80586. */
  80587. readonly name: string;
  80588. /**
  80589. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80590. */
  80591. dracoCompression?: DracoCompression;
  80592. /**
  80593. * Defines whether this extension is enabled.
  80594. */
  80595. enabled: boolean;
  80596. private _loader;
  80597. /** @hidden */
  80598. constructor(loader: GLTFLoader);
  80599. /** @hidden */
  80600. dispose(): void;
  80601. /** @hidden */
  80602. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80603. }
  80604. }
  80605. declare module BABYLON.GLTF2.Loader.Extensions {
  80606. /**
  80607. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80608. */
  80609. export class KHR_lights implements IGLTFLoaderExtension {
  80610. /**
  80611. * The name of this extension.
  80612. */
  80613. readonly name: string;
  80614. /**
  80615. * Defines whether this extension is enabled.
  80616. */
  80617. enabled: boolean;
  80618. private _loader;
  80619. private _lights?;
  80620. /** @hidden */
  80621. constructor(loader: GLTFLoader);
  80622. /** @hidden */
  80623. dispose(): void;
  80624. /** @hidden */
  80625. onLoading(): void;
  80626. /** @hidden */
  80627. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80628. }
  80629. }
  80630. declare module BABYLON.GLTF2.Loader.Extensions {
  80631. /**
  80632. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80633. */
  80634. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80635. /**
  80636. * The name of this extension.
  80637. */
  80638. readonly name: string;
  80639. /**
  80640. * Defines whether this extension is enabled.
  80641. */
  80642. enabled: boolean;
  80643. /**
  80644. * Defines a number that determines the order the extensions are applied.
  80645. */
  80646. order: number;
  80647. private _loader;
  80648. /** @hidden */
  80649. constructor(loader: GLTFLoader);
  80650. /** @hidden */
  80651. dispose(): void;
  80652. /** @hidden */
  80653. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80654. private _loadSpecularGlossinessPropertiesAsync;
  80655. }
  80656. }
  80657. declare module BABYLON.GLTF2.Loader.Extensions {
  80658. /**
  80659. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80660. */
  80661. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80662. /**
  80663. * The name of this extension.
  80664. */
  80665. readonly name: string;
  80666. /**
  80667. * Defines whether this extension is enabled.
  80668. */
  80669. enabled: boolean;
  80670. /**
  80671. * Defines a number that determines the order the extensions are applied.
  80672. */
  80673. order: number;
  80674. private _loader;
  80675. /** @hidden */
  80676. constructor(loader: GLTFLoader);
  80677. /** @hidden */
  80678. dispose(): void;
  80679. /** @hidden */
  80680. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80681. private _loadUnlitPropertiesAsync;
  80682. }
  80683. }
  80684. declare module BABYLON.GLTF2.Loader.Extensions {
  80685. /**
  80686. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80687. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80688. * !!! Experimental Extension Subject to Changes !!!
  80689. */
  80690. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80691. /**
  80692. * The name of this extension.
  80693. */
  80694. readonly name: string;
  80695. /**
  80696. * Defines whether this extension is enabled.
  80697. */
  80698. enabled: boolean;
  80699. /**
  80700. * Defines a number that determines the order the extensions are applied.
  80701. */
  80702. order: number;
  80703. private _loader;
  80704. /** @hidden */
  80705. constructor(loader: GLTFLoader);
  80706. /** @hidden */
  80707. dispose(): void;
  80708. /** @hidden */
  80709. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80710. private _loadClearCoatPropertiesAsync;
  80711. }
  80712. }
  80713. declare module BABYLON.GLTF2.Loader.Extensions {
  80714. /**
  80715. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  80716. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  80717. * !!! Experimental Extension Subject to Changes !!!
  80718. */
  80719. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  80720. /**
  80721. * The name of this extension.
  80722. */
  80723. readonly name: string;
  80724. /**
  80725. * Defines whether this extension is enabled.
  80726. */
  80727. enabled: boolean;
  80728. /**
  80729. * Defines a number that determines the order the extensions are applied.
  80730. */
  80731. order: number;
  80732. private _loader;
  80733. /** @hidden */
  80734. constructor(loader: GLTFLoader);
  80735. /** @hidden */
  80736. dispose(): void;
  80737. /** @hidden */
  80738. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80739. private _loadSheenPropertiesAsync;
  80740. }
  80741. }
  80742. declare module BABYLON.GLTF2.Loader.Extensions {
  80743. /**
  80744. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  80745. * !!! Experimental Extension Subject to Changes !!!
  80746. */
  80747. export class KHR_materials_specular implements IGLTFLoaderExtension {
  80748. /**
  80749. * The name of this extension.
  80750. */
  80751. readonly name: string;
  80752. /**
  80753. * Defines whether this extension is enabled.
  80754. */
  80755. enabled: boolean;
  80756. /**
  80757. * Defines a number that determines the order the extensions are applied.
  80758. */
  80759. order: number;
  80760. private _loader;
  80761. /** @hidden */
  80762. constructor(loader: GLTFLoader);
  80763. /** @hidden */
  80764. dispose(): void;
  80765. /** @hidden */
  80766. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80767. private _loadSpecularPropertiesAsync;
  80768. }
  80769. }
  80770. declare module BABYLON.GLTF2.Loader.Extensions {
  80771. /**
  80772. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  80773. * !!! Experimental Extension Subject to Changes !!!
  80774. */
  80775. export class KHR_materials_ior implements IGLTFLoaderExtension {
  80776. /**
  80777. * Default ior Value from the spec.
  80778. */
  80779. private static readonly _DEFAULT_IOR;
  80780. /**
  80781. * The name of this extension.
  80782. */
  80783. readonly name: string;
  80784. /**
  80785. * Defines whether this extension is enabled.
  80786. */
  80787. enabled: boolean;
  80788. /**
  80789. * Defines a number that determines the order the extensions are applied.
  80790. */
  80791. order: number;
  80792. private _loader;
  80793. /** @hidden */
  80794. constructor(loader: GLTFLoader);
  80795. /** @hidden */
  80796. dispose(): void;
  80797. /** @hidden */
  80798. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80799. private _loadIorPropertiesAsync;
  80800. }
  80801. }
  80802. declare module BABYLON.GLTF2.Loader.Extensions {
  80803. /**
  80804. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  80805. * !!! Experimental Extension Subject to Changes !!!
  80806. */
  80807. export class KHR_materials_variants implements IGLTFLoaderExtension {
  80808. /**
  80809. * The name of this extension.
  80810. */
  80811. readonly name: string;
  80812. /**
  80813. * Defines whether this extension is enabled.
  80814. */
  80815. enabled: boolean;
  80816. private _loader;
  80817. /** @hidden */
  80818. constructor(loader: GLTFLoader);
  80819. /** @hidden */
  80820. dispose(): void;
  80821. /**
  80822. * Gets the list of available variant tag names for this asset.
  80823. * @param rootMesh The glTF root mesh
  80824. * @returns the list of all the variant names for this model
  80825. */
  80826. static GetAvailableVariants(rootMesh: Mesh): string[];
  80827. /**
  80828. * Gets the list of available variant tag names for this asset.
  80829. * @param rootMesh The glTF root mesh
  80830. * @returns the list of all the variant names for this model
  80831. */
  80832. getAvailableVariants(rootMesh: Mesh): string[];
  80833. /**
  80834. * Select a variant given a variant tag name or a list of variant tag names.
  80835. * @param rootMesh The glTF root mesh
  80836. * @param variantName The variant name(s) to select.
  80837. */
  80838. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80839. /**
  80840. * Select a variant given a variant tag name or a list of variant tag names.
  80841. * @param rootMesh The glTF root mesh
  80842. * @param variantName The variant name(s) to select.
  80843. */
  80844. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  80845. /**
  80846. * Reset back to the original before selecting a variant.
  80847. * @param rootMesh The glTF root mesh
  80848. */
  80849. static Reset(rootMesh: Mesh): void;
  80850. /**
  80851. * Reset back to the original before selecting a variant.
  80852. * @param rootMesh The glTF root mesh
  80853. */
  80854. reset(rootMesh: Mesh): void;
  80855. /**
  80856. * Gets the last selected variant tag name(s) or null if original.
  80857. * @param rootMesh The glTF root mesh
  80858. * @returns The selected variant tag name(s).
  80859. */
  80860. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  80861. /**
  80862. * Gets the last selected variant tag name(s) or null if original.
  80863. * @param rootMesh The glTF root mesh
  80864. * @returns The selected variant tag name(s).
  80865. */
  80866. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  80867. private static _GetExtensionMetadata;
  80868. /** @hidden */
  80869. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80870. }
  80871. }
  80872. declare module BABYLON.GLTF2.Loader.Extensions {
  80873. /**
  80874. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  80875. * !!! Experimental Extension Subject to Changes !!!
  80876. */
  80877. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  80878. /**
  80879. * The name of this extension.
  80880. */
  80881. readonly name: string;
  80882. /**
  80883. * Defines whether this extension is enabled.
  80884. */
  80885. enabled: boolean;
  80886. /**
  80887. * Defines a number that determines the order the extensions are applied.
  80888. */
  80889. order: number;
  80890. private _loader;
  80891. /** @hidden */
  80892. constructor(loader: GLTFLoader);
  80893. /** @hidden */
  80894. dispose(): void;
  80895. /** @hidden */
  80896. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80897. private _loadTransparentPropertiesAsync;
  80898. }
  80899. }
  80900. declare module BABYLON.GLTF2.Loader.Extensions {
  80901. /**
  80902. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  80903. */
  80904. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  80905. /**
  80906. * The name of this extension.
  80907. */
  80908. readonly name: string;
  80909. /**
  80910. * Defines whether this extension is enabled.
  80911. */
  80912. enabled: boolean;
  80913. /** @hidden */
  80914. constructor(loader: GLTFLoader);
  80915. /** @hidden */
  80916. dispose(): void;
  80917. }
  80918. }
  80919. declare module BABYLON.GLTF2.Loader.Extensions {
  80920. /**
  80921. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  80922. * !!! Experimental Extension Subject to Changes !!!
  80923. */
  80924. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  80925. /** The name of this extension. */
  80926. readonly name: string;
  80927. /** Defines whether this extension is enabled. */
  80928. enabled: boolean;
  80929. private _loader;
  80930. /** @hidden */
  80931. constructor(loader: GLTFLoader);
  80932. /** @hidden */
  80933. dispose(): void;
  80934. /** @hidden */
  80935. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80936. }
  80937. }
  80938. declare module BABYLON.GLTF2.Loader.Extensions {
  80939. /**
  80940. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  80941. */
  80942. export class KHR_texture_transform implements IGLTFLoaderExtension {
  80943. /**
  80944. * The name of this extension.
  80945. */
  80946. readonly name: string;
  80947. /**
  80948. * Defines whether this extension is enabled.
  80949. */
  80950. enabled: boolean;
  80951. private _loader;
  80952. /** @hidden */
  80953. constructor(loader: GLTFLoader);
  80954. /** @hidden */
  80955. dispose(): void;
  80956. /** @hidden */
  80957. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80958. }
  80959. }
  80960. declare module BABYLON.GLTF2.Loader.Extensions {
  80961. /**
  80962. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  80963. * !!! Experimental Extension Subject to Changes !!!
  80964. */
  80965. export class KHR_xmp implements IGLTFLoaderExtension {
  80966. /**
  80967. * The name of this extension.
  80968. */
  80969. readonly name: string;
  80970. /**
  80971. * Defines whether this extension is enabled.
  80972. */
  80973. enabled: boolean;
  80974. /**
  80975. * Defines a number that determines the order the extensions are applied.
  80976. */
  80977. order: number;
  80978. private _loader;
  80979. /** @hidden */
  80980. constructor(loader: GLTFLoader);
  80981. /** @hidden */
  80982. dispose(): void;
  80983. /**
  80984. * Called after the loader state changes to LOADING.
  80985. */
  80986. onLoading(): void;
  80987. }
  80988. }
  80989. declare module BABYLON.GLTF2.Loader.Extensions {
  80990. /**
  80991. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  80992. */
  80993. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  80994. /**
  80995. * The name of this extension.
  80996. */
  80997. readonly name: string;
  80998. /**
  80999. * Defines whether this extension is enabled.
  81000. */
  81001. enabled: boolean;
  81002. private _loader;
  81003. private _clips;
  81004. private _emitters;
  81005. /** @hidden */
  81006. constructor(loader: GLTFLoader);
  81007. /** @hidden */
  81008. dispose(): void;
  81009. /** @hidden */
  81010. onLoading(): void;
  81011. /** @hidden */
  81012. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81013. /** @hidden */
  81014. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81015. /** @hidden */
  81016. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81017. private _loadClipAsync;
  81018. private _loadEmitterAsync;
  81019. private _getEventAction;
  81020. private _loadAnimationEventAsync;
  81021. }
  81022. }
  81023. declare module BABYLON.GLTF2.Loader.Extensions {
  81024. /**
  81025. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81026. */
  81027. export class MSFT_lod implements IGLTFLoaderExtension {
  81028. /**
  81029. * The name of this extension.
  81030. */
  81031. readonly name: string;
  81032. /**
  81033. * Defines whether this extension is enabled.
  81034. */
  81035. enabled: boolean;
  81036. /**
  81037. * Defines a number that determines the order the extensions are applied.
  81038. */
  81039. order: number;
  81040. /**
  81041. * Maximum number of LODs to load, starting from the lowest LOD.
  81042. */
  81043. maxLODsToLoad: number;
  81044. /**
  81045. * Observable raised when all node LODs of one level are loaded.
  81046. * The event data is the index of the loaded LOD starting from zero.
  81047. * Dispose the loader to cancel the loading of the next level of LODs.
  81048. */
  81049. onNodeLODsLoadedObservable: Observable<number>;
  81050. /**
  81051. * Observable raised when all material LODs of one level are loaded.
  81052. * The event data is the index of the loaded LOD starting from zero.
  81053. * Dispose the loader to cancel the loading of the next level of LODs.
  81054. */
  81055. onMaterialLODsLoadedObservable: Observable<number>;
  81056. private _loader;
  81057. private _bufferLODs;
  81058. private _nodeIndexLOD;
  81059. private _nodeSignalLODs;
  81060. private _nodePromiseLODs;
  81061. private _nodeBufferLODs;
  81062. private _materialIndexLOD;
  81063. private _materialSignalLODs;
  81064. private _materialPromiseLODs;
  81065. private _materialBufferLODs;
  81066. /** @hidden */
  81067. constructor(loader: GLTFLoader);
  81068. /** @hidden */
  81069. dispose(): void;
  81070. /** @hidden */
  81071. onReady(): void;
  81072. /** @hidden */
  81073. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81074. /** @hidden */
  81075. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81076. /** @hidden */
  81077. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81078. /** @hidden */
  81079. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81080. /** @hidden */
  81081. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81082. private _loadBufferLOD;
  81083. /**
  81084. * Gets an array of LOD properties from lowest to highest.
  81085. */
  81086. private _getLODs;
  81087. private _disposeTransformNode;
  81088. private _disposeMaterials;
  81089. }
  81090. }
  81091. declare module BABYLON.GLTF2.Loader.Extensions {
  81092. /** @hidden */
  81093. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81094. readonly name: string;
  81095. enabled: boolean;
  81096. private _loader;
  81097. constructor(loader: GLTFLoader);
  81098. dispose(): void;
  81099. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81100. }
  81101. }
  81102. declare module BABYLON.GLTF2.Loader.Extensions {
  81103. /** @hidden */
  81104. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81105. readonly name: string;
  81106. enabled: boolean;
  81107. private _loader;
  81108. constructor(loader: GLTFLoader);
  81109. dispose(): void;
  81110. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81111. }
  81112. }
  81113. declare module BABYLON.GLTF2.Loader.Extensions {
  81114. /**
  81115. * Store glTF extras (if present) in BJS objects' metadata
  81116. */
  81117. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81118. /**
  81119. * The name of this extension.
  81120. */
  81121. readonly name: string;
  81122. /**
  81123. * Defines whether this extension is enabled.
  81124. */
  81125. enabled: boolean;
  81126. private _loader;
  81127. private _assignExtras;
  81128. /** @hidden */
  81129. constructor(loader: GLTFLoader);
  81130. /** @hidden */
  81131. dispose(): void;
  81132. /** @hidden */
  81133. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81134. /** @hidden */
  81135. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81136. /** @hidden */
  81137. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81138. }
  81139. }
  81140. declare module BABYLON {
  81141. /**
  81142. * Class reading and parsing the MTL file bundled with the obj file.
  81143. */
  81144. export class MTLFileLoader {
  81145. /**
  81146. * Invert Y-Axis of referenced textures on load
  81147. */
  81148. static INVERT_TEXTURE_Y: boolean;
  81149. /**
  81150. * All material loaded from the mtl will be set here
  81151. */
  81152. materials: StandardMaterial[];
  81153. /**
  81154. * This function will read the mtl file and create each material described inside
  81155. * This function could be improve by adding :
  81156. * -some component missing (Ni, Tf...)
  81157. * -including the specific options available
  81158. *
  81159. * @param scene defines the scene the material will be created in
  81160. * @param data defines the mtl data to parse
  81161. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81162. * @param forAssetContainer defines if the material should be registered in the scene
  81163. */
  81164. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81165. /**
  81166. * Gets the texture for the material.
  81167. *
  81168. * If the material is imported from input file,
  81169. * We sanitize the url to ensure it takes the textre from aside the material.
  81170. *
  81171. * @param rootUrl The root url to load from
  81172. * @param value The value stored in the mtl
  81173. * @return The Texture
  81174. */
  81175. private static _getTexture;
  81176. }
  81177. }
  81178. declare module BABYLON {
  81179. /**
  81180. * Options for loading OBJ/MTL files
  81181. */
  81182. type MeshLoadOptions = {
  81183. /**
  81184. * Defines if UVs are optimized by default during load.
  81185. */
  81186. OptimizeWithUV: boolean;
  81187. /**
  81188. * Defines custom scaling of UV coordinates of loaded meshes.
  81189. */
  81190. UVScaling: Vector2;
  81191. /**
  81192. * Invert model on y-axis (does a model scaling inversion)
  81193. */
  81194. InvertY: boolean;
  81195. /**
  81196. * Invert Y-Axis of referenced textures on load
  81197. */
  81198. InvertTextureY: boolean;
  81199. /**
  81200. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81201. */
  81202. ImportVertexColors: boolean;
  81203. /**
  81204. * Compute the normals for the model, even if normals are present in the file.
  81205. */
  81206. ComputeNormals: boolean;
  81207. /**
  81208. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81209. */
  81210. SkipMaterials: boolean;
  81211. /**
  81212. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81213. */
  81214. MaterialLoadingFailsSilently: boolean;
  81215. };
  81216. /**
  81217. * OBJ file type loader.
  81218. * This is a babylon scene loader plugin.
  81219. */
  81220. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81221. /**
  81222. * Defines if UVs are optimized by default during load.
  81223. */
  81224. static OPTIMIZE_WITH_UV: boolean;
  81225. /**
  81226. * Invert model on y-axis (does a model scaling inversion)
  81227. */
  81228. static INVERT_Y: boolean;
  81229. /**
  81230. * Invert Y-Axis of referenced textures on load
  81231. */
  81232. static get INVERT_TEXTURE_Y(): boolean;
  81233. static set INVERT_TEXTURE_Y(value: boolean);
  81234. /**
  81235. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81236. */
  81237. static IMPORT_VERTEX_COLORS: boolean;
  81238. /**
  81239. * Compute the normals for the model, even if normals are present in the file.
  81240. */
  81241. static COMPUTE_NORMALS: boolean;
  81242. /**
  81243. * Defines custom scaling of UV coordinates of loaded meshes.
  81244. */
  81245. static UV_SCALING: Vector2;
  81246. /**
  81247. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81248. */
  81249. static SKIP_MATERIALS: boolean;
  81250. /**
  81251. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81252. *
  81253. * Defaults to true for backwards compatibility.
  81254. */
  81255. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81256. /**
  81257. * Defines the name of the plugin.
  81258. */
  81259. name: string;
  81260. /**
  81261. * Defines the extension the plugin is able to load.
  81262. */
  81263. extensions: string;
  81264. /** @hidden */
  81265. obj: RegExp;
  81266. /** @hidden */
  81267. group: RegExp;
  81268. /** @hidden */
  81269. mtllib: RegExp;
  81270. /** @hidden */
  81271. usemtl: RegExp;
  81272. /** @hidden */
  81273. smooth: RegExp;
  81274. /** @hidden */
  81275. vertexPattern: RegExp;
  81276. /** @hidden */
  81277. normalPattern: RegExp;
  81278. /** @hidden */
  81279. uvPattern: RegExp;
  81280. /** @hidden */
  81281. facePattern1: RegExp;
  81282. /** @hidden */
  81283. facePattern2: RegExp;
  81284. /** @hidden */
  81285. facePattern3: RegExp;
  81286. /** @hidden */
  81287. facePattern4: RegExp;
  81288. /** @hidden */
  81289. facePattern5: RegExp;
  81290. private _forAssetContainer;
  81291. private _meshLoadOptions;
  81292. /**
  81293. * Creates loader for .OBJ files
  81294. *
  81295. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81296. */
  81297. constructor(meshLoadOptions?: MeshLoadOptions);
  81298. private static get currentMeshLoadOptions();
  81299. /**
  81300. * Calls synchronously the MTL file attached to this obj.
  81301. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81302. * Without this function materials are not displayed in the first frame (but displayed after).
  81303. * In consequence it is impossible to get material information in your HTML file
  81304. *
  81305. * @param url The URL of the MTL file
  81306. * @param rootUrl
  81307. * @param onSuccess Callback function to be called when the MTL file is loaded
  81308. * @private
  81309. */
  81310. private _loadMTL;
  81311. /**
  81312. * Instantiates a OBJ file loader plugin.
  81313. * @returns the created plugin
  81314. */
  81315. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81316. /**
  81317. * If the data string can be loaded directly.
  81318. *
  81319. * @param data string containing the file data
  81320. * @returns if the data can be loaded directly
  81321. */
  81322. canDirectLoad(data: string): boolean;
  81323. /**
  81324. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81325. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81326. * @param scene the scene the meshes should be added to
  81327. * @param data the OBJ data to load
  81328. * @param rootUrl root url to load from
  81329. * @param onProgress event that fires when loading progress has occured
  81330. * @param fileName Defines the name of the file to load
  81331. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81332. */
  81333. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81334. meshes: AbstractMesh[];
  81335. particleSystems: IParticleSystem[];
  81336. skeletons: Skeleton[];
  81337. animationGroups: AnimationGroup[];
  81338. }>;
  81339. /**
  81340. * Imports all objects from the loaded OBJ data and adds them to the scene
  81341. * @param scene the scene the objects should be added to
  81342. * @param data the OBJ data to load
  81343. * @param rootUrl root url to load from
  81344. * @param onProgress event that fires when loading progress has occured
  81345. * @param fileName Defines the name of the file to load
  81346. * @returns a promise which completes when objects have been loaded to the scene
  81347. */
  81348. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81349. /**
  81350. * Load into an asset container.
  81351. * @param scene The scene to load into
  81352. * @param data The data to import
  81353. * @param rootUrl The root url for scene and resources
  81354. * @param onProgress The callback when the load progresses
  81355. * @param fileName Defines the name of the file to load
  81356. * @returns The loaded asset container
  81357. */
  81358. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81359. /**
  81360. * Read the OBJ file and create an Array of meshes.
  81361. * Each mesh contains all information given by the OBJ and the MTL file.
  81362. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81363. *
  81364. * @param meshesNames
  81365. * @param scene Scene The scene where are displayed the data
  81366. * @param data String The content of the obj file
  81367. * @param rootUrl String The path to the folder
  81368. * @returns Array<AbstractMesh>
  81369. * @private
  81370. */
  81371. private _parseSolid;
  81372. }
  81373. }
  81374. declare module BABYLON {
  81375. /**
  81376. * STL file type loader.
  81377. * This is a babylon scene loader plugin.
  81378. */
  81379. export class STLFileLoader implements ISceneLoaderPlugin {
  81380. /** @hidden */
  81381. solidPattern: RegExp;
  81382. /** @hidden */
  81383. facetsPattern: RegExp;
  81384. /** @hidden */
  81385. normalPattern: RegExp;
  81386. /** @hidden */
  81387. vertexPattern: RegExp;
  81388. /**
  81389. * Defines the name of the plugin.
  81390. */
  81391. name: string;
  81392. /**
  81393. * Defines the extensions the stl loader is able to load.
  81394. * force data to come in as an ArrayBuffer
  81395. * we'll convert to string if it looks like it's an ASCII .stl
  81396. */
  81397. extensions: ISceneLoaderPluginExtensions;
  81398. /**
  81399. * Import meshes into a scene.
  81400. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81401. * @param scene The scene to import into
  81402. * @param data The data to import
  81403. * @param rootUrl The root url for scene and resources
  81404. * @param meshes The meshes array to import into
  81405. * @param particleSystems The particle systems array to import into
  81406. * @param skeletons The skeletons array to import into
  81407. * @param onError The callback when import fails
  81408. * @returns True if successful or false otherwise
  81409. */
  81410. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81411. /**
  81412. * Load into a scene.
  81413. * @param scene The scene to load into
  81414. * @param data The data to import
  81415. * @param rootUrl The root url for scene and resources
  81416. * @param onError The callback when import fails
  81417. * @returns true if successful or false otherwise
  81418. */
  81419. load(scene: Scene, data: any, rootUrl: string): boolean;
  81420. /**
  81421. * Load into an asset container.
  81422. * @param scene The scene to load into
  81423. * @param data The data to import
  81424. * @param rootUrl The root url for scene and resources
  81425. * @param onError The callback when import fails
  81426. * @returns The loaded asset container
  81427. */
  81428. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81429. private _isBinary;
  81430. private _parseBinary;
  81431. private _parseASCII;
  81432. }
  81433. }
  81434. declare module BABYLON {
  81435. /**
  81436. * Class for generating OBJ data from a Babylon scene.
  81437. */
  81438. export class OBJExport {
  81439. /**
  81440. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81441. * @param mesh defines the list of meshes to serialize
  81442. * @param materials defines if materials should be exported
  81443. * @param matlibname defines the name of the associated mtl file
  81444. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81445. * @returns the OBJ content
  81446. */
  81447. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81448. /**
  81449. * Exports the material(s) of a mesh in .MTL file format (text)
  81450. * @param mesh defines the mesh to extract the material from
  81451. * @returns the mtl content
  81452. */
  81453. static MTL(mesh: Mesh): string;
  81454. }
  81455. }
  81456. declare module BABYLON {
  81457. /** @hidden */
  81458. export var __IGLTFExporterExtension: number;
  81459. /**
  81460. * Interface for extending the exporter
  81461. * @hidden
  81462. */
  81463. export interface IGLTFExporterExtension {
  81464. /**
  81465. * The name of this extension
  81466. */
  81467. readonly name: string;
  81468. /**
  81469. * Defines whether this extension is enabled
  81470. */
  81471. enabled: boolean;
  81472. /**
  81473. * Defines whether this extension is required
  81474. */
  81475. required: boolean;
  81476. }
  81477. }
  81478. declare module BABYLON.GLTF2.Exporter {
  81479. /** @hidden */
  81480. export var __IGLTFExporterExtensionV2: number;
  81481. /**
  81482. * Interface for a glTF exporter extension
  81483. * @hidden
  81484. */
  81485. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81486. /**
  81487. * Define this method to modify the default behavior before exporting a texture
  81488. * @param context The context when loading the asset
  81489. * @param babylonTexture The Babylon.js texture
  81490. * @param mimeType The mime-type of the generated image
  81491. * @returns A promise that resolves with the exported texture
  81492. */
  81493. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81494. /**
  81495. * Define this method to get notified when a texture info is created
  81496. * @param context The context when loading the asset
  81497. * @param textureInfo The glTF texture info
  81498. * @param babylonTexture The Babylon.js texture
  81499. */
  81500. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81501. /**
  81502. * Define this method to modify the default behavior when exporting texture info
  81503. * @param context The context when loading the asset
  81504. * @param meshPrimitive glTF mesh primitive
  81505. * @param babylonSubMesh Babylon submesh
  81506. * @param binaryWriter glTF serializer binary writer instance
  81507. * @returns nullable IMeshPrimitive promise
  81508. */
  81509. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81510. /**
  81511. * Define this method to modify the default behavior when exporting a node
  81512. * @param context The context when exporting the node
  81513. * @param node glTF node
  81514. * @param babylonNode BabylonJS node
  81515. * @returns nullable INode promise
  81516. */
  81517. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81518. [key: number]: number;
  81519. }): Promise<Nullable<INode>>;
  81520. /**
  81521. * Define this method to modify the default behavior when exporting a material
  81522. * @param material glTF material
  81523. * @param babylonMaterial BabylonJS material
  81524. * @returns nullable IMaterial promise
  81525. */
  81526. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81527. /**
  81528. * Define this method to return additional textures to export from a material
  81529. * @param material glTF material
  81530. * @param babylonMaterial BabylonJS material
  81531. * @returns List of textures
  81532. */
  81533. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81534. /** Gets a boolean indicating that this extension was used */
  81535. wasUsed: boolean;
  81536. /** Gets a boolean indicating that this extension is required for the file to work */
  81537. required: boolean;
  81538. /**
  81539. * Called after the exporter state changes to EXPORTING
  81540. */
  81541. onExporting?(): void;
  81542. }
  81543. }
  81544. declare module BABYLON.GLTF2.Exporter {
  81545. /**
  81546. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81547. * @hidden
  81548. */
  81549. export class _GLTFMaterialExporter {
  81550. /**
  81551. * Represents the dielectric specular values for R, G and B
  81552. */
  81553. private static readonly _DielectricSpecular;
  81554. /**
  81555. * Allows the maximum specular power to be defined for material calculations
  81556. */
  81557. private static readonly _MaxSpecularPower;
  81558. /**
  81559. * Mapping to store textures
  81560. */
  81561. private _textureMap;
  81562. /**
  81563. * Numeric tolerance value
  81564. */
  81565. private static readonly _Epsilon;
  81566. /**
  81567. * Reference to the glTF Exporter
  81568. */
  81569. private _exporter;
  81570. constructor(exporter: _Exporter);
  81571. /**
  81572. * Specifies if two colors are approximately equal in value
  81573. * @param color1 first color to compare to
  81574. * @param color2 second color to compare to
  81575. * @param epsilon threshold value
  81576. */
  81577. private static FuzzyEquals;
  81578. /**
  81579. * Gets the materials from a Babylon scene and converts them to glTF materials
  81580. * @param scene babylonjs scene
  81581. * @param mimeType texture mime type
  81582. * @param images array of images
  81583. * @param textures array of textures
  81584. * @param materials array of materials
  81585. * @param imageData mapping of texture names to base64 textures
  81586. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81587. */
  81588. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81589. /**
  81590. * Makes a copy of the glTF material without the texture parameters
  81591. * @param originalMaterial original glTF material
  81592. * @returns glTF material without texture parameters
  81593. */
  81594. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81595. /**
  81596. * Specifies if the material has any texture parameters present
  81597. * @param material glTF Material
  81598. * @returns boolean specifying if texture parameters are present
  81599. */
  81600. _hasTexturesPresent(material: IMaterial): boolean;
  81601. /**
  81602. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81603. * @param babylonStandardMaterial
  81604. * @returns glTF Metallic Roughness Material representation
  81605. */
  81606. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81607. /**
  81608. * Computes the metallic factor
  81609. * @param diffuse diffused value
  81610. * @param specular specular value
  81611. * @param oneMinusSpecularStrength one minus the specular strength
  81612. * @returns metallic value
  81613. */
  81614. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81615. /**
  81616. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81617. * @param glTFMaterial glTF material
  81618. * @param babylonMaterial Babylon material
  81619. */
  81620. private static _SetAlphaMode;
  81621. /**
  81622. * Converts a Babylon Standard Material to a glTF Material
  81623. * @param babylonStandardMaterial BJS Standard Material
  81624. * @param mimeType mime type to use for the textures
  81625. * @param images array of glTF image interfaces
  81626. * @param textures array of glTF texture interfaces
  81627. * @param materials array of glTF material interfaces
  81628. * @param imageData map of image file name to data
  81629. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81630. */
  81631. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81632. private _finishMaterial;
  81633. /**
  81634. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81635. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81636. * @param mimeType mime type to use for the textures
  81637. * @param images array of glTF image interfaces
  81638. * @param textures array of glTF texture interfaces
  81639. * @param materials array of glTF material interfaces
  81640. * @param imageData map of image file name to data
  81641. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81642. */
  81643. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81644. /**
  81645. * Converts an image typed array buffer to a base64 image
  81646. * @param buffer typed array buffer
  81647. * @param width width of the image
  81648. * @param height height of the image
  81649. * @param mimeType mimetype of the image
  81650. * @returns base64 image string
  81651. */
  81652. private _createBase64FromCanvasAsync;
  81653. /**
  81654. * Generates a white texture based on the specified width and height
  81655. * @param width width of the texture in pixels
  81656. * @param height height of the texture in pixels
  81657. * @param scene babylonjs scene
  81658. * @returns white texture
  81659. */
  81660. private _createWhiteTexture;
  81661. /**
  81662. * 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
  81663. * @param texture1 first texture to resize
  81664. * @param texture2 second texture to resize
  81665. * @param scene babylonjs scene
  81666. * @returns resized textures or null
  81667. */
  81668. private _resizeTexturesToSameDimensions;
  81669. /**
  81670. * Converts an array of pixels to a Float32Array
  81671. * Throws an error if the pixel format is not supported
  81672. * @param pixels - array buffer containing pixel values
  81673. * @returns Float32 of pixels
  81674. */
  81675. private _convertPixelArrayToFloat32;
  81676. /**
  81677. * Convert Specular Glossiness Textures to Metallic Roughness
  81678. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81679. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81680. * @param diffuseTexture texture used to store diffuse information
  81681. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81682. * @param factors specular glossiness material factors
  81683. * @param mimeType the mime type to use for the texture
  81684. * @returns pbr metallic roughness interface or null
  81685. */
  81686. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81687. /**
  81688. * Converts specular glossiness material properties to metallic roughness
  81689. * @param specularGlossiness interface with specular glossiness material properties
  81690. * @returns interface with metallic roughness material properties
  81691. */
  81692. private _convertSpecularGlossinessToMetallicRoughness;
  81693. /**
  81694. * Calculates the surface reflectance, independent of lighting conditions
  81695. * @param color Color source to calculate brightness from
  81696. * @returns number representing the perceived brightness, or zero if color is undefined
  81697. */
  81698. private _getPerceivedBrightness;
  81699. /**
  81700. * Returns the maximum color component value
  81701. * @param color
  81702. * @returns maximum color component value, or zero if color is null or undefined
  81703. */
  81704. private _getMaxComponent;
  81705. /**
  81706. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  81707. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81708. * @param mimeType mime type to use for the textures
  81709. * @param images array of glTF image interfaces
  81710. * @param textures array of glTF texture interfaces
  81711. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81712. * @param imageData map of image file name to data
  81713. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81714. * @returns glTF PBR Metallic Roughness factors
  81715. */
  81716. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  81717. private _getGLTFTextureSampler;
  81718. private _getGLTFTextureWrapMode;
  81719. private _getGLTFTextureWrapModesSampler;
  81720. /**
  81721. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  81722. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81723. * @param mimeType mime type to use for the textures
  81724. * @param images array of glTF image interfaces
  81725. * @param textures array of glTF texture interfaces
  81726. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  81727. * @param imageData map of image file name to data
  81728. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81729. * @returns glTF PBR Metallic Roughness factors
  81730. */
  81731. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  81732. /**
  81733. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81734. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  81735. * @param mimeType mime type to use for the textures
  81736. * @param images array of glTF image interfaces
  81737. * @param textures array of glTF texture interfaces
  81738. * @param materials array of glTF material interfaces
  81739. * @param imageData map of image file name to data
  81740. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81741. */
  81742. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81743. private setMetallicRoughnessPbrMaterial;
  81744. private getPixelsFromTexture;
  81745. /**
  81746. * Extracts a texture from a Babylon texture into file data and glTF data
  81747. * @param babylonTexture Babylon texture to extract
  81748. * @param mimeType Mime Type of the babylonTexture
  81749. * @return glTF texture info, or null if the texture format is not supported
  81750. */
  81751. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81752. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  81753. /**
  81754. * Builds a texture from base64 string
  81755. * @param base64Texture base64 texture string
  81756. * @param baseTextureName Name to use for the texture
  81757. * @param mimeType image mime type for the texture
  81758. * @param images array of images
  81759. * @param textures array of textures
  81760. * @param imageData map of image data
  81761. * @returns glTF texture info, or null if the texture format is not supported
  81762. */
  81763. private _getTextureInfoFromBase64;
  81764. }
  81765. }
  81766. declare module BABYLON {
  81767. /**
  81768. * Class for holding and downloading glTF file data
  81769. */
  81770. export class GLTFData {
  81771. /**
  81772. * Object which contains the file name as the key and its data as the value
  81773. */
  81774. glTFFiles: {
  81775. [fileName: string]: string | Blob;
  81776. };
  81777. /**
  81778. * Initializes the glTF file object
  81779. */
  81780. constructor();
  81781. /**
  81782. * Downloads the glTF data as files based on their names and data
  81783. */
  81784. downloadFiles(): void;
  81785. }
  81786. }
  81787. declare module BABYLON {
  81788. /**
  81789. * Holds a collection of exporter options and parameters
  81790. */
  81791. export interface IExportOptions {
  81792. /**
  81793. * Function which indicates whether a babylon node should be exported or not
  81794. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  81795. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  81796. */
  81797. shouldExportNode?(node: Node): boolean;
  81798. /**
  81799. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  81800. * @param metadata source metadata to read from
  81801. * @returns the data to store to glTF node extras
  81802. */
  81803. metadataSelector?(metadata: any): any;
  81804. /**
  81805. * The sample rate to bake animation curves
  81806. */
  81807. animationSampleRate?: number;
  81808. /**
  81809. * Begin serialization without waiting for the scene to be ready
  81810. */
  81811. exportWithoutWaitingForScene?: boolean;
  81812. /**
  81813. * Indicates if coordinate system swapping root nodes should be included in export
  81814. */
  81815. includeCoordinateSystemConversionNodes?: boolean;
  81816. }
  81817. /**
  81818. * Class for generating glTF data from a Babylon scene.
  81819. */
  81820. export class GLTF2Export {
  81821. /**
  81822. * Exports the geometry of the scene to .gltf file format asynchronously
  81823. * @param scene Babylon scene with scene hierarchy information
  81824. * @param filePrefix File prefix to use when generating the glTF file
  81825. * @param options Exporter options
  81826. * @returns Returns an object with a .gltf file and associates texture names
  81827. * as keys and their data and paths as values
  81828. */
  81829. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81830. private static _PreExportAsync;
  81831. private static _PostExportAsync;
  81832. /**
  81833. * Exports the geometry of the scene to .glb file format asychronously
  81834. * @param scene Babylon scene with scene hierarchy information
  81835. * @param filePrefix File prefix to use when generating glb file
  81836. * @param options Exporter options
  81837. * @returns Returns an object with a .glb filename as key and data as value
  81838. */
  81839. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  81840. }
  81841. }
  81842. declare module BABYLON.GLTF2.Exporter {
  81843. /**
  81844. * @hidden
  81845. */
  81846. export class _GLTFUtilities {
  81847. /**
  81848. * Creates a buffer view based on the supplied arguments
  81849. * @param bufferIndex index value of the specified buffer
  81850. * @param byteOffset byte offset value
  81851. * @param byteLength byte length of the bufferView
  81852. * @param byteStride byte distance between conequential elements
  81853. * @param name name of the buffer view
  81854. * @returns bufferView for glTF
  81855. */
  81856. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  81857. /**
  81858. * Creates an accessor based on the supplied arguments
  81859. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  81860. * @param name The name of the accessor
  81861. * @param type The type of the accessor
  81862. * @param componentType The datatype of components in the attribute
  81863. * @param count The number of attributes referenced by this accessor
  81864. * @param byteOffset The offset relative to the start of the bufferView in bytes
  81865. * @param min Minimum value of each component in this attribute
  81866. * @param max Maximum value of each component in this attribute
  81867. * @returns accessor for glTF
  81868. */
  81869. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  81870. /**
  81871. * Calculates the minimum and maximum values of an array of position floats
  81872. * @param positions Positions array of a mesh
  81873. * @param vertexStart Starting vertex offset to calculate min and max values
  81874. * @param vertexCount Number of vertices to check for min and max values
  81875. * @returns min number array and max number array
  81876. */
  81877. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  81878. min: number[];
  81879. max: number[];
  81880. };
  81881. /**
  81882. * Converts a new right-handed Vector3
  81883. * @param vector vector3 array
  81884. * @returns right-handed Vector3
  81885. */
  81886. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  81887. /**
  81888. * Converts a Vector3 to right-handed
  81889. * @param vector Vector3 to convert to right-handed
  81890. */
  81891. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  81892. /**
  81893. * Converts a three element number array to right-handed
  81894. * @param vector number array to convert to right-handed
  81895. */
  81896. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  81897. /**
  81898. * Converts a new right-handed Vector3
  81899. * @param vector vector3 array
  81900. * @returns right-handed Vector3
  81901. */
  81902. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  81903. /**
  81904. * Converts a Vector3 to right-handed
  81905. * @param vector Vector3 to convert to right-handed
  81906. */
  81907. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  81908. /**
  81909. * Converts a three element number array to right-handed
  81910. * @param vector number array to convert to right-handed
  81911. */
  81912. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  81913. /**
  81914. * Converts a Vector4 to right-handed
  81915. * @param vector Vector4 to convert to right-handed
  81916. */
  81917. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  81918. /**
  81919. * Converts a Vector4 to right-handed
  81920. * @param vector Vector4 to convert to right-handed
  81921. */
  81922. static _GetRightHandedArray4FromRef(vector: number[]): void;
  81923. /**
  81924. * Converts a Quaternion to right-handed
  81925. * @param quaternion Source quaternion to convert to right-handed
  81926. */
  81927. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  81928. /**
  81929. * Converts a Quaternion to right-handed
  81930. * @param quaternion Source quaternion to convert to right-handed
  81931. */
  81932. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  81933. static _NormalizeTangentFromRef(tangent: Vector4): void;
  81934. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  81935. }
  81936. }
  81937. declare module BABYLON.GLTF2.Exporter {
  81938. /**
  81939. * Converts Babylon Scene into glTF 2.0.
  81940. * @hidden
  81941. */
  81942. export class _Exporter {
  81943. /**
  81944. * Stores the glTF to export
  81945. */
  81946. _glTF: IGLTF;
  81947. /**
  81948. * Stores all generated buffer views, which represents views into the main glTF buffer data
  81949. */
  81950. _bufferViews: IBufferView[];
  81951. /**
  81952. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  81953. */
  81954. _accessors: IAccessor[];
  81955. /**
  81956. * Stores all the generated nodes, which contains transform and/or mesh information per node
  81957. */
  81958. _nodes: INode[];
  81959. /**
  81960. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  81961. */
  81962. private _scenes;
  81963. /**
  81964. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  81965. */
  81966. private _meshes;
  81967. /**
  81968. * Stores all the generated material information, which represents the appearance of each primitive
  81969. */
  81970. _materials: IMaterial[];
  81971. _materialMap: {
  81972. [materialID: number]: number;
  81973. };
  81974. /**
  81975. * Stores all the generated texture information, which is referenced by glTF materials
  81976. */
  81977. _textures: ITexture[];
  81978. /**
  81979. * Stores all the generated image information, which is referenced by glTF textures
  81980. */
  81981. _images: IImage[];
  81982. /**
  81983. * Stores all the texture samplers
  81984. */
  81985. _samplers: ISampler[];
  81986. /**
  81987. * Stores all the generated glTF skins
  81988. */
  81989. _skins: ISkin[];
  81990. /**
  81991. * Stores all the generated animation samplers, which is referenced by glTF animations
  81992. */
  81993. /**
  81994. * Stores the animations for glTF models
  81995. */
  81996. private _animations;
  81997. /**
  81998. * Stores the total amount of bytes stored in the glTF buffer
  81999. */
  82000. private _totalByteLength;
  82001. /**
  82002. * Stores a reference to the Babylon scene containing the source geometry and material information
  82003. */
  82004. _babylonScene: Scene;
  82005. /**
  82006. * Stores a map of the image data, where the key is the file name and the value
  82007. * is the image data
  82008. */
  82009. _imageData: {
  82010. [fileName: string]: {
  82011. data: Uint8Array;
  82012. mimeType: ImageMimeType;
  82013. };
  82014. };
  82015. /**
  82016. * Stores a map of the unique id of a node to its index in the node array
  82017. */
  82018. _nodeMap: {
  82019. [key: number]: number;
  82020. };
  82021. /**
  82022. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82023. */
  82024. _convertToRightHandedSystem: boolean;
  82025. /**
  82026. * Specifies if a Babylon node should be converted to right-handed on export
  82027. */
  82028. _convertToRightHandedSystemMap: {
  82029. [nodeId: number]: boolean;
  82030. };
  82031. _includeCoordinateSystemConversionNodes: boolean;
  82032. /**
  82033. * Baked animation sample rate
  82034. */
  82035. private _animationSampleRate;
  82036. private _options;
  82037. private _localEngine;
  82038. _glTFMaterialExporter: _GLTFMaterialExporter;
  82039. private _extensions;
  82040. private static _ExtensionNames;
  82041. private static _ExtensionFactories;
  82042. private _applyExtension;
  82043. private _applyExtensions;
  82044. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82045. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82046. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82047. [key: number]: number;
  82048. }): Promise<Nullable<INode>>;
  82049. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82050. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82051. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82052. private _forEachExtensions;
  82053. private _extensionsOnExporting;
  82054. /**
  82055. * Load glTF serializer extensions
  82056. */
  82057. private _loadExtensions;
  82058. /**
  82059. * Creates a glTF Exporter instance, which can accept optional exporter options
  82060. * @param babylonScene Babylon scene object
  82061. * @param options Options to modify the behavior of the exporter
  82062. */
  82063. constructor(babylonScene: Scene, options?: IExportOptions);
  82064. dispose(): void;
  82065. /**
  82066. * Registers a glTF exporter extension
  82067. * @param name Name of the extension to export
  82068. * @param factory The factory function that creates the exporter extension
  82069. */
  82070. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82071. /**
  82072. * Un-registers an exporter extension
  82073. * @param name The name fo the exporter extension
  82074. * @returns A boolean indicating whether the extension has been un-registered
  82075. */
  82076. static UnregisterExtension(name: string): boolean;
  82077. /**
  82078. * Lazy load a local engine
  82079. */
  82080. _getLocalEngine(): Engine;
  82081. private reorderIndicesBasedOnPrimitiveMode;
  82082. /**
  82083. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82084. * clock-wise during export to glTF
  82085. * @param submesh BabylonJS submesh
  82086. * @param primitiveMode Primitive mode of the mesh
  82087. * @param sideOrientation the winding order of the submesh
  82088. * @param vertexBufferKind The type of vertex attribute
  82089. * @param meshAttributeArray The vertex attribute data
  82090. * @param byteOffset The offset to the binary data
  82091. * @param binaryWriter The binary data for the glTF file
  82092. * @param convertToRightHandedSystem Converts the values to right-handed
  82093. */
  82094. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82095. /**
  82096. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82097. * clock-wise during export to glTF
  82098. * @param submesh BabylonJS submesh
  82099. * @param primitiveMode Primitive mode of the mesh
  82100. * @param sideOrientation the winding order of the submesh
  82101. * @param vertexBufferKind The type of vertex attribute
  82102. * @param meshAttributeArray The vertex attribute data
  82103. * @param byteOffset The offset to the binary data
  82104. * @param binaryWriter The binary data for the glTF file
  82105. * @param convertToRightHandedSystem Converts the values to right-handed
  82106. */
  82107. private reorderTriangleFillMode;
  82108. /**
  82109. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82110. * clock-wise during export to glTF
  82111. * @param submesh BabylonJS submesh
  82112. * @param primitiveMode Primitive mode of the mesh
  82113. * @param sideOrientation the winding order of the submesh
  82114. * @param vertexBufferKind The type of vertex attribute
  82115. * @param meshAttributeArray The vertex attribute data
  82116. * @param byteOffset The offset to the binary data
  82117. * @param binaryWriter The binary data for the glTF file
  82118. * @param convertToRightHandedSystem Converts the values to right-handed
  82119. */
  82120. private reorderTriangleStripDrawMode;
  82121. /**
  82122. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82123. * clock-wise during export to glTF
  82124. * @param submesh BabylonJS submesh
  82125. * @param primitiveMode Primitive mode of the mesh
  82126. * @param sideOrientation the winding order of the submesh
  82127. * @param vertexBufferKind The type of vertex attribute
  82128. * @param meshAttributeArray The vertex attribute data
  82129. * @param byteOffset The offset to the binary data
  82130. * @param binaryWriter The binary data for the glTF file
  82131. * @param convertToRightHandedSystem Converts the values to right-handed
  82132. */
  82133. private reorderTriangleFanMode;
  82134. /**
  82135. * Writes the vertex attribute data to binary
  82136. * @param vertices The vertices to write to the binary writer
  82137. * @param byteOffset The offset into the binary writer to overwrite binary data
  82138. * @param vertexAttributeKind The vertex attribute type
  82139. * @param meshAttributeArray The vertex attribute data
  82140. * @param binaryWriter The writer containing the binary data
  82141. * @param convertToRightHandedSystem Converts the values to right-handed
  82142. */
  82143. private writeVertexAttributeData;
  82144. /**
  82145. * Writes mesh attribute data to a data buffer
  82146. * Returns the bytelength of the data
  82147. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82148. * @param meshAttributeArray Array containing the attribute data
  82149. * @param byteStride Specifies the space between data
  82150. * @param binaryWriter The buffer to write the binary data to
  82151. * @param convertToRightHandedSystem Converts the values to right-handed
  82152. */
  82153. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  82154. /**
  82155. * Generates glTF json data
  82156. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82157. * @param glTFPrefix Text to use when prefixing a glTF file
  82158. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82159. * @returns json data as string
  82160. */
  82161. private generateJSON;
  82162. /**
  82163. * Generates data for .gltf and .bin files based on the glTF prefix string
  82164. * @param glTFPrefix Text to use when prefixing a glTF file
  82165. * @param dispose Dispose the exporter
  82166. * @returns GLTFData with glTF file data
  82167. */
  82168. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82169. /**
  82170. * Creates a binary buffer for glTF
  82171. * @returns array buffer for binary data
  82172. */
  82173. private _generateBinaryAsync;
  82174. /**
  82175. * Pads the number to a multiple of 4
  82176. * @param num number to pad
  82177. * @returns padded number
  82178. */
  82179. private _getPadding;
  82180. /**
  82181. * @hidden
  82182. */
  82183. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82184. /**
  82185. * Sets the TRS for each node
  82186. * @param node glTF Node for storing the transformation data
  82187. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82188. * @param convertToRightHandedSystem Converts the values to right-handed
  82189. */
  82190. private setNodeTransformation;
  82191. private getVertexBufferFromMesh;
  82192. /**
  82193. * Creates a bufferview based on the vertices type for the Babylon mesh
  82194. * @param kind Indicates the type of vertices data
  82195. * @param componentType Indicates the numerical type used to store the data
  82196. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82197. * @param binaryWriter The buffer to write the bufferview data to
  82198. * @param convertToRightHandedSystem Converts the values to right-handed
  82199. */
  82200. private createBufferViewKind;
  82201. /**
  82202. * The primitive mode of the Babylon mesh
  82203. * @param babylonMesh The BabylonJS mesh
  82204. */
  82205. private getMeshPrimitiveMode;
  82206. /**
  82207. * Sets the primitive mode of the glTF mesh primitive
  82208. * @param meshPrimitive glTF mesh primitive
  82209. * @param primitiveMode The primitive mode
  82210. */
  82211. private setPrimitiveMode;
  82212. /**
  82213. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82214. * @param meshPrimitive glTF mesh primitive
  82215. * @param attributeKind vertex attribute
  82216. * @returns boolean specifying if uv coordinates are present
  82217. */
  82218. private setAttributeKind;
  82219. /**
  82220. * Sets data for the primitive attributes of each submesh
  82221. * @param mesh glTF Mesh object to store the primitive attribute information
  82222. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82223. * @param binaryWriter Buffer to write the attribute data to
  82224. * @param convertToRightHandedSystem Converts the values to right-handed
  82225. */
  82226. private setPrimitiveAttributesAsync;
  82227. /**
  82228. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82229. * @param node The node to check
  82230. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82231. */
  82232. private isBabylonCoordinateSystemConvertingNode;
  82233. /**
  82234. * Creates a glTF scene based on the array of meshes
  82235. * Returns the the total byte offset
  82236. * @param babylonScene Babylon scene to get the mesh data from
  82237. * @param binaryWriter Buffer to write binary data to
  82238. */
  82239. private createSceneAsync;
  82240. /**
  82241. * Creates a mapping of Node unique id to node index and handles animations
  82242. * @param babylonScene Babylon Scene
  82243. * @param nodes Babylon transform nodes
  82244. * @param binaryWriter Buffer to write binary data to
  82245. * @returns Node mapping of unique id to index
  82246. */
  82247. private createNodeMapAndAnimationsAsync;
  82248. /**
  82249. * Creates a glTF node from a Babylon mesh
  82250. * @param babylonMesh Source Babylon mesh
  82251. * @param binaryWriter Buffer for storing geometry data
  82252. * @param convertToRightHandedSystem Converts the values to right-handed
  82253. * @param nodeMap Node mapping of unique id to glTF node index
  82254. * @returns glTF node
  82255. */
  82256. private createNodeAsync;
  82257. /**
  82258. * Creates a glTF skin from a Babylon skeleton
  82259. * @param babylonScene Babylon Scene
  82260. * @param nodes Babylon transform nodes
  82261. * @param binaryWriter Buffer to write binary data to
  82262. * @returns Node mapping of unique id to index
  82263. */
  82264. private createSkinsAsync;
  82265. }
  82266. /**
  82267. * @hidden
  82268. *
  82269. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82270. */
  82271. export class _BinaryWriter {
  82272. /**
  82273. * Array buffer which stores all binary data
  82274. */
  82275. private _arrayBuffer;
  82276. /**
  82277. * View of the array buffer
  82278. */
  82279. private _dataView;
  82280. /**
  82281. * byte offset of data in array buffer
  82282. */
  82283. private _byteOffset;
  82284. /**
  82285. * Initialize binary writer with an initial byte length
  82286. * @param byteLength Initial byte length of the array buffer
  82287. */
  82288. constructor(byteLength: number);
  82289. /**
  82290. * Resize the array buffer to the specified byte length
  82291. * @param byteLength
  82292. */
  82293. private resizeBuffer;
  82294. /**
  82295. * Get an array buffer with the length of the byte offset
  82296. * @returns ArrayBuffer resized to the byte offset
  82297. */
  82298. getArrayBuffer(): ArrayBuffer;
  82299. /**
  82300. * Get the byte offset of the array buffer
  82301. * @returns byte offset
  82302. */
  82303. getByteOffset(): number;
  82304. /**
  82305. * Stores an UInt8 in the array buffer
  82306. * @param entry
  82307. * @param byteOffset If defined, specifies where to set the value as an offset.
  82308. */
  82309. setUInt8(entry: number, byteOffset?: number): void;
  82310. /**
  82311. * Stores an UInt16 in the array buffer
  82312. * @param entry
  82313. * @param byteOffset If defined, specifies where to set the value as an offset.
  82314. */
  82315. setUInt16(entry: number, byteOffset?: number): void;
  82316. /**
  82317. * Gets an UInt32 in the array buffer
  82318. * @param entry
  82319. * @param byteOffset If defined, specifies where to set the value as an offset.
  82320. */
  82321. getUInt32(byteOffset: number): number;
  82322. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82323. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82324. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82325. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82326. /**
  82327. * Stores a Float32 in the array buffer
  82328. * @param entry
  82329. */
  82330. setFloat32(entry: number, byteOffset?: number): void;
  82331. /**
  82332. * Stores an UInt32 in the array buffer
  82333. * @param entry
  82334. * @param byteOffset If defined, specifies where to set the value as an offset.
  82335. */
  82336. setUInt32(entry: number, byteOffset?: number): void;
  82337. }
  82338. }
  82339. declare module BABYLON.GLTF2.Exporter {
  82340. /**
  82341. * @hidden
  82342. * Interface to store animation data.
  82343. */
  82344. export interface _IAnimationData {
  82345. /**
  82346. * Keyframe data.
  82347. */
  82348. inputs: number[];
  82349. /**
  82350. * Value data.
  82351. */
  82352. outputs: number[][];
  82353. /**
  82354. * Animation interpolation data.
  82355. */
  82356. samplerInterpolation: AnimationSamplerInterpolation;
  82357. /**
  82358. * Minimum keyframe value.
  82359. */
  82360. inputsMin: number;
  82361. /**
  82362. * Maximum keyframe value.
  82363. */
  82364. inputsMax: number;
  82365. }
  82366. /**
  82367. * @hidden
  82368. */
  82369. export interface _IAnimationInfo {
  82370. /**
  82371. * The target channel for the animation
  82372. */
  82373. animationChannelTargetPath: AnimationChannelTargetPath;
  82374. /**
  82375. * The glTF accessor type for the data.
  82376. */
  82377. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82378. /**
  82379. * Specifies if quaternions should be used.
  82380. */
  82381. useQuaternion: boolean;
  82382. }
  82383. /**
  82384. * @hidden
  82385. * Utility class for generating glTF animation data from BabylonJS.
  82386. */
  82387. export class _GLTFAnimation {
  82388. /**
  82389. * @ignore
  82390. *
  82391. * Creates glTF channel animation from BabylonJS animation.
  82392. * @param babylonTransformNode - BabylonJS mesh.
  82393. * @param animation - animation.
  82394. * @param animationChannelTargetPath - The target animation channel.
  82395. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82396. * @param useQuaternion - Specifies if quaternions are used.
  82397. * @returns nullable IAnimationData
  82398. */
  82399. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82400. private static _DeduceAnimationInfo;
  82401. /**
  82402. * @ignore
  82403. * Create node animations from the transform node animations
  82404. * @param babylonNode
  82405. * @param runtimeGLTFAnimation
  82406. * @param idleGLTFAnimations
  82407. * @param nodeMap
  82408. * @param nodes
  82409. * @param binaryWriter
  82410. * @param bufferViews
  82411. * @param accessors
  82412. * @param convertToRightHandedSystem
  82413. * @param animationSampleRate
  82414. */
  82415. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82416. [key: number]: number;
  82417. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82418. /**
  82419. * @ignore
  82420. * Create node animations from the animation groups
  82421. * @param babylonScene
  82422. * @param glTFAnimations
  82423. * @param nodeMap
  82424. * @param nodes
  82425. * @param binaryWriter
  82426. * @param bufferViews
  82427. * @param accessors
  82428. * @param convertToRightHandedSystemMap
  82429. * @param animationSampleRate
  82430. */
  82431. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82432. [key: number]: number;
  82433. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82434. [nodeId: number]: boolean;
  82435. }, animationSampleRate: number): void;
  82436. private static AddAnimation;
  82437. /**
  82438. * Create a baked animation
  82439. * @param babylonTransformNode BabylonJS mesh
  82440. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82441. * @param animationChannelTargetPath animation target channel
  82442. * @param minFrame minimum animation frame
  82443. * @param maxFrame maximum animation frame
  82444. * @param fps frames per second of the animation
  82445. * @param inputs input key frames of the animation
  82446. * @param outputs output key frame data of the animation
  82447. * @param convertToRightHandedSystem converts the values to right-handed
  82448. * @param useQuaternion specifies if quaternions should be used
  82449. */
  82450. private static _CreateBakedAnimation;
  82451. private static _ConvertFactorToVector3OrQuaternion;
  82452. private static _SetInterpolatedValue;
  82453. /**
  82454. * Creates linear animation from the animation key frames
  82455. * @param babylonTransformNode BabylonJS mesh
  82456. * @param animation BabylonJS animation
  82457. * @param animationChannelTargetPath The target animation channel
  82458. * @param frameDelta The difference between the last and first frame of the animation
  82459. * @param inputs Array to store the key frame times
  82460. * @param outputs Array to store the key frame data
  82461. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82462. * @param useQuaternion Specifies if quaternions are used in the animation
  82463. */
  82464. private static _CreateLinearOrStepAnimation;
  82465. /**
  82466. * Creates cubic spline animation from the animation key frames
  82467. * @param babylonTransformNode BabylonJS mesh
  82468. * @param animation BabylonJS animation
  82469. * @param animationChannelTargetPath The target animation channel
  82470. * @param frameDelta The difference between the last and first frame of the animation
  82471. * @param inputs Array to store the key frame times
  82472. * @param outputs Array to store the key frame data
  82473. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82474. * @param useQuaternion Specifies if quaternions are used in the animation
  82475. */
  82476. private static _CreateCubicSplineAnimation;
  82477. private static _GetBasePositionRotationOrScale;
  82478. /**
  82479. * Adds a key frame value
  82480. * @param keyFrame
  82481. * @param animation
  82482. * @param outputs
  82483. * @param animationChannelTargetPath
  82484. * @param basePositionRotationOrScale
  82485. * @param convertToRightHandedSystem
  82486. * @param useQuaternion
  82487. */
  82488. private static _AddKeyframeValue;
  82489. /**
  82490. * Determine the interpolation based on the key frames
  82491. * @param keyFrames
  82492. * @param animationChannelTargetPath
  82493. * @param useQuaternion
  82494. */
  82495. private static _DeduceInterpolation;
  82496. /**
  82497. * Adds an input tangent or output tangent to the output data
  82498. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82499. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82500. * @param outputs The animation data by keyframe
  82501. * @param animationChannelTargetPath The target animation channel
  82502. * @param interpolation The interpolation type
  82503. * @param keyFrame The key frame with the animation data
  82504. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82505. * @param useQuaternion Specifies if quaternions are used
  82506. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82507. */
  82508. private static AddSplineTangent;
  82509. /**
  82510. * Get the minimum and maximum key frames' frame values
  82511. * @param keyFrames animation key frames
  82512. * @returns the minimum and maximum key frame value
  82513. */
  82514. private static calculateMinMaxKeyFrames;
  82515. }
  82516. }
  82517. declare module BABYLON.GLTF2.Exporter {
  82518. /** @hidden */
  82519. export var textureTransformPixelShader: {
  82520. name: string;
  82521. shader: string;
  82522. };
  82523. }
  82524. declare module BABYLON.GLTF2.Exporter.Extensions {
  82525. /**
  82526. * @hidden
  82527. */
  82528. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82529. private _recordedTextures;
  82530. /** Name of this extension */
  82531. readonly name: string;
  82532. /** Defines whether this extension is enabled */
  82533. enabled: boolean;
  82534. /** Defines whether this extension is required */
  82535. required: boolean;
  82536. /** Reference to the glTF exporter */
  82537. private _wasUsed;
  82538. constructor(exporter: _Exporter);
  82539. dispose(): void;
  82540. /** @hidden */
  82541. get wasUsed(): boolean;
  82542. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82543. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82544. /**
  82545. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82546. * @param babylonTexture
  82547. * @param offset
  82548. * @param rotation
  82549. * @param scale
  82550. * @param scene
  82551. */
  82552. private _textureTransformTextureAsync;
  82553. }
  82554. }
  82555. declare module BABYLON.GLTF2.Exporter.Extensions {
  82556. /**
  82557. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82558. */
  82559. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82560. /** The name of this extension. */
  82561. readonly name: string;
  82562. /** Defines whether this extension is enabled. */
  82563. enabled: boolean;
  82564. /** Defines whether this extension is required */
  82565. required: boolean;
  82566. /** Reference to the glTF exporter */
  82567. private _exporter;
  82568. private _lights;
  82569. /** @hidden */
  82570. constructor(exporter: _Exporter);
  82571. /** @hidden */
  82572. dispose(): void;
  82573. /** @hidden */
  82574. get wasUsed(): boolean;
  82575. /** @hidden */
  82576. onExporting(): void;
  82577. /**
  82578. * Define this method to modify the default behavior when exporting a node
  82579. * @param context The context when exporting the node
  82580. * @param node glTF node
  82581. * @param babylonNode BabylonJS node
  82582. * @param nodeMap Node mapping of unique id to glTF node index
  82583. * @returns nullable INode promise
  82584. */
  82585. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82586. [key: number]: number;
  82587. }): Promise<Nullable<INode>>;
  82588. }
  82589. }
  82590. declare module BABYLON.GLTF2.Exporter.Extensions {
  82591. /**
  82592. * @hidden
  82593. */
  82594. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82595. /** Name of this extension */
  82596. readonly name: string;
  82597. /** Defines whether this extension is enabled */
  82598. enabled: boolean;
  82599. /** Defines whether this extension is required */
  82600. required: boolean;
  82601. /** Reference to the glTF exporter */
  82602. private _textureInfos;
  82603. private _exportedTextures;
  82604. private _wasUsed;
  82605. constructor(exporter: _Exporter);
  82606. dispose(): void;
  82607. /** @hidden */
  82608. get wasUsed(): boolean;
  82609. private _getTextureIndex;
  82610. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82611. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82612. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82613. }
  82614. }
  82615. declare module BABYLON.GLTF2.Exporter.Extensions {
  82616. /**
  82617. * @hidden
  82618. */
  82619. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  82620. /** Name of this extension */
  82621. readonly name: string;
  82622. /** Defines whether this extension is enabled */
  82623. enabled: boolean;
  82624. /** Defines whether this extension is required */
  82625. required: boolean;
  82626. private _wasUsed;
  82627. constructor(exporter: _Exporter);
  82628. /** @hidden */
  82629. get wasUsed(): boolean;
  82630. dispose(): void;
  82631. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82632. }
  82633. }
  82634. declare module BABYLON {
  82635. /**
  82636. * Class for generating STL data from a Babylon scene.
  82637. */
  82638. export class STLExport {
  82639. /**
  82640. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82641. * @param meshes list defines the mesh to serialize
  82642. * @param download triggers the automatic download of the file.
  82643. * @param fileName changes the downloads fileName.
  82644. * @param binary changes the STL to a binary type.
  82645. * @param isLittleEndian toggle for binary type exporter.
  82646. * @returns the STL as UTF8 string
  82647. */
  82648. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82649. }
  82650. }
  82651. declare module "babylonjs-gltf2interface" {
  82652. export = BABYLON.GLTF2;
  82653. }
  82654. /**
  82655. * Module for glTF 2.0 Interface
  82656. */
  82657. declare module BABYLON.GLTF2 {
  82658. /**
  82659. * The datatype of the components in the attribute
  82660. */
  82661. const enum AccessorComponentType {
  82662. /**
  82663. * Byte
  82664. */
  82665. BYTE = 5120,
  82666. /**
  82667. * Unsigned Byte
  82668. */
  82669. UNSIGNED_BYTE = 5121,
  82670. /**
  82671. * Short
  82672. */
  82673. SHORT = 5122,
  82674. /**
  82675. * Unsigned Short
  82676. */
  82677. UNSIGNED_SHORT = 5123,
  82678. /**
  82679. * Unsigned Int
  82680. */
  82681. UNSIGNED_INT = 5125,
  82682. /**
  82683. * Float
  82684. */
  82685. FLOAT = 5126,
  82686. }
  82687. /**
  82688. * Specifies if the attirbute is a scalar, vector, or matrix
  82689. */
  82690. const enum AccessorType {
  82691. /**
  82692. * Scalar
  82693. */
  82694. SCALAR = "SCALAR",
  82695. /**
  82696. * Vector2
  82697. */
  82698. VEC2 = "VEC2",
  82699. /**
  82700. * Vector3
  82701. */
  82702. VEC3 = "VEC3",
  82703. /**
  82704. * Vector4
  82705. */
  82706. VEC4 = "VEC4",
  82707. /**
  82708. * Matrix2x2
  82709. */
  82710. MAT2 = "MAT2",
  82711. /**
  82712. * Matrix3x3
  82713. */
  82714. MAT3 = "MAT3",
  82715. /**
  82716. * Matrix4x4
  82717. */
  82718. MAT4 = "MAT4",
  82719. }
  82720. /**
  82721. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  82722. */
  82723. const enum AnimationChannelTargetPath {
  82724. /**
  82725. * Translation
  82726. */
  82727. TRANSLATION = "translation",
  82728. /**
  82729. * Rotation
  82730. */
  82731. ROTATION = "rotation",
  82732. /**
  82733. * Scale
  82734. */
  82735. SCALE = "scale",
  82736. /**
  82737. * Weights
  82738. */
  82739. WEIGHTS = "weights",
  82740. }
  82741. /**
  82742. * Interpolation algorithm
  82743. */
  82744. const enum AnimationSamplerInterpolation {
  82745. /**
  82746. * The animated values are linearly interpolated between keyframes
  82747. */
  82748. LINEAR = "LINEAR",
  82749. /**
  82750. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  82751. */
  82752. STEP = "STEP",
  82753. /**
  82754. * The animation's interpolation is computed using a cubic spline with specified tangents
  82755. */
  82756. CUBICSPLINE = "CUBICSPLINE",
  82757. }
  82758. /**
  82759. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  82760. */
  82761. const enum CameraType {
  82762. /**
  82763. * A perspective camera containing properties to create a perspective projection matrix
  82764. */
  82765. PERSPECTIVE = "perspective",
  82766. /**
  82767. * An orthographic camera containing properties to create an orthographic projection matrix
  82768. */
  82769. ORTHOGRAPHIC = "orthographic",
  82770. }
  82771. /**
  82772. * The mime-type of the image
  82773. */
  82774. const enum ImageMimeType {
  82775. /**
  82776. * JPEG Mime-type
  82777. */
  82778. JPEG = "image/jpeg",
  82779. /**
  82780. * PNG Mime-type
  82781. */
  82782. PNG = "image/png",
  82783. }
  82784. /**
  82785. * The alpha rendering mode of the material
  82786. */
  82787. const enum MaterialAlphaMode {
  82788. /**
  82789. * The alpha value is ignored and the rendered output is fully opaque
  82790. */
  82791. OPAQUE = "OPAQUE",
  82792. /**
  82793. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  82794. */
  82795. MASK = "MASK",
  82796. /**
  82797. * 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)
  82798. */
  82799. BLEND = "BLEND",
  82800. }
  82801. /**
  82802. * The type of the primitives to render
  82803. */
  82804. const enum MeshPrimitiveMode {
  82805. /**
  82806. * Points
  82807. */
  82808. POINTS = 0,
  82809. /**
  82810. * Lines
  82811. */
  82812. LINES = 1,
  82813. /**
  82814. * Line Loop
  82815. */
  82816. LINE_LOOP = 2,
  82817. /**
  82818. * Line Strip
  82819. */
  82820. LINE_STRIP = 3,
  82821. /**
  82822. * Triangles
  82823. */
  82824. TRIANGLES = 4,
  82825. /**
  82826. * Triangle Strip
  82827. */
  82828. TRIANGLE_STRIP = 5,
  82829. /**
  82830. * Triangle Fan
  82831. */
  82832. TRIANGLE_FAN = 6,
  82833. }
  82834. /**
  82835. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  82836. */
  82837. const enum TextureMagFilter {
  82838. /**
  82839. * Nearest
  82840. */
  82841. NEAREST = 9728,
  82842. /**
  82843. * Linear
  82844. */
  82845. LINEAR = 9729,
  82846. }
  82847. /**
  82848. * Minification filter. All valid values correspond to WebGL enums
  82849. */
  82850. const enum TextureMinFilter {
  82851. /**
  82852. * Nearest
  82853. */
  82854. NEAREST = 9728,
  82855. /**
  82856. * Linear
  82857. */
  82858. LINEAR = 9729,
  82859. /**
  82860. * Nearest Mip-Map Nearest
  82861. */
  82862. NEAREST_MIPMAP_NEAREST = 9984,
  82863. /**
  82864. * Linear Mipmap Nearest
  82865. */
  82866. LINEAR_MIPMAP_NEAREST = 9985,
  82867. /**
  82868. * Nearest Mipmap Linear
  82869. */
  82870. NEAREST_MIPMAP_LINEAR = 9986,
  82871. /**
  82872. * Linear Mipmap Linear
  82873. */
  82874. LINEAR_MIPMAP_LINEAR = 9987,
  82875. }
  82876. /**
  82877. * S (U) wrapping mode. All valid values correspond to WebGL enums
  82878. */
  82879. const enum TextureWrapMode {
  82880. /**
  82881. * Clamp to Edge
  82882. */
  82883. CLAMP_TO_EDGE = 33071,
  82884. /**
  82885. * Mirrored Repeat
  82886. */
  82887. MIRRORED_REPEAT = 33648,
  82888. /**
  82889. * Repeat
  82890. */
  82891. REPEAT = 10497,
  82892. }
  82893. /**
  82894. * glTF Property
  82895. */
  82896. interface IProperty {
  82897. /**
  82898. * Dictionary object with extension-specific objects
  82899. */
  82900. extensions?: {
  82901. [key: string]: any;
  82902. };
  82903. /**
  82904. * Application-Specific data
  82905. */
  82906. extras?: any;
  82907. }
  82908. /**
  82909. * glTF Child of Root Property
  82910. */
  82911. interface IChildRootProperty extends IProperty {
  82912. /**
  82913. * The user-defined name of this object
  82914. */
  82915. name?: string;
  82916. }
  82917. /**
  82918. * Indices of those attributes that deviate from their initialization value
  82919. */
  82920. interface IAccessorSparseIndices extends IProperty {
  82921. /**
  82922. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82923. */
  82924. bufferView: number;
  82925. /**
  82926. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82927. */
  82928. byteOffset?: number;
  82929. /**
  82930. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  82931. */
  82932. componentType: AccessorComponentType;
  82933. }
  82934. /**
  82935. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  82936. */
  82937. interface IAccessorSparseValues extends IProperty {
  82938. /**
  82939. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  82940. */
  82941. bufferView: number;
  82942. /**
  82943. * The offset relative to the start of the bufferView in bytes. Must be aligned
  82944. */
  82945. byteOffset?: number;
  82946. }
  82947. /**
  82948. * Sparse storage of attributes that deviate from their initialization value
  82949. */
  82950. interface IAccessorSparse extends IProperty {
  82951. /**
  82952. * The number of attributes encoded in this sparse accessor
  82953. */
  82954. count: number;
  82955. /**
  82956. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  82957. */
  82958. indices: IAccessorSparseIndices;
  82959. /**
  82960. * 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
  82961. */
  82962. values: IAccessorSparseValues;
  82963. }
  82964. /**
  82965. * 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
  82966. */
  82967. interface IAccessor extends IChildRootProperty {
  82968. /**
  82969. * The index of the bufferview
  82970. */
  82971. bufferView?: number;
  82972. /**
  82973. * The offset relative to the start of the bufferView in bytes
  82974. */
  82975. byteOffset?: number;
  82976. /**
  82977. * The datatype of components in the attribute
  82978. */
  82979. componentType: AccessorComponentType;
  82980. /**
  82981. * Specifies whether integer data values should be normalized
  82982. */
  82983. normalized?: boolean;
  82984. /**
  82985. * The number of attributes referenced by this accessor
  82986. */
  82987. count: number;
  82988. /**
  82989. * Specifies if the attribute is a scalar, vector, or matrix
  82990. */
  82991. type: AccessorType;
  82992. /**
  82993. * Maximum value of each component in this attribute
  82994. */
  82995. max?: number[];
  82996. /**
  82997. * Minimum value of each component in this attribute
  82998. */
  82999. min?: number[];
  83000. /**
  83001. * Sparse storage of attributes that deviate from their initialization value
  83002. */
  83003. sparse?: IAccessorSparse;
  83004. }
  83005. /**
  83006. * Targets an animation's sampler at a node's property
  83007. */
  83008. interface IAnimationChannel extends IProperty {
  83009. /**
  83010. * The index of a sampler in this animation used to compute the value for the target
  83011. */
  83012. sampler: number;
  83013. /**
  83014. * The index of the node and TRS property to target
  83015. */
  83016. target: IAnimationChannelTarget;
  83017. }
  83018. /**
  83019. * The index of the node and TRS property that an animation channel targets
  83020. */
  83021. interface IAnimationChannelTarget extends IProperty {
  83022. /**
  83023. * The index of the node to target
  83024. */
  83025. node: number;
  83026. /**
  83027. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83028. */
  83029. path: AnimationChannelTargetPath;
  83030. }
  83031. /**
  83032. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83033. */
  83034. interface IAnimationSampler extends IProperty {
  83035. /**
  83036. * The index of an accessor containing keyframe input values, e.g., time
  83037. */
  83038. input: number;
  83039. /**
  83040. * Interpolation algorithm
  83041. */
  83042. interpolation?: AnimationSamplerInterpolation;
  83043. /**
  83044. * The index of an accessor, containing keyframe output values
  83045. */
  83046. output: number;
  83047. }
  83048. /**
  83049. * A keyframe animation
  83050. */
  83051. interface IAnimation extends IChildRootProperty {
  83052. /**
  83053. * An array of channels, each of which targets an animation's sampler at a node's property
  83054. */
  83055. channels: IAnimationChannel[];
  83056. /**
  83057. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83058. */
  83059. samplers: IAnimationSampler[];
  83060. }
  83061. /**
  83062. * Metadata about the glTF asset
  83063. */
  83064. interface IAsset extends IChildRootProperty {
  83065. /**
  83066. * A copyright message suitable for display to credit the content creator
  83067. */
  83068. copyright?: string;
  83069. /**
  83070. * Tool that generated this glTF model. Useful for debugging
  83071. */
  83072. generator?: string;
  83073. /**
  83074. * The glTF version that this asset targets
  83075. */
  83076. version: string;
  83077. /**
  83078. * The minimum glTF version that this asset targets
  83079. */
  83080. minVersion?: string;
  83081. }
  83082. /**
  83083. * A buffer points to binary geometry, animation, or skins
  83084. */
  83085. interface IBuffer extends IChildRootProperty {
  83086. /**
  83087. * 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
  83088. */
  83089. uri?: string;
  83090. /**
  83091. * The length of the buffer in bytes
  83092. */
  83093. byteLength: number;
  83094. }
  83095. /**
  83096. * A view into a buffer generally representing a subset of the buffer
  83097. */
  83098. interface IBufferView extends IChildRootProperty {
  83099. /**
  83100. * The index of the buffer
  83101. */
  83102. buffer: number;
  83103. /**
  83104. * The offset into the buffer in bytes
  83105. */
  83106. byteOffset?: number;
  83107. /**
  83108. * The lenth of the bufferView in bytes
  83109. */
  83110. byteLength: number;
  83111. /**
  83112. * The stride, in bytes
  83113. */
  83114. byteStride?: number;
  83115. }
  83116. /**
  83117. * An orthographic camera containing properties to create an orthographic projection matrix
  83118. */
  83119. interface ICameraOrthographic extends IProperty {
  83120. /**
  83121. * The floating-point horizontal magnification of the view. Must not be zero
  83122. */
  83123. xmag: number;
  83124. /**
  83125. * The floating-point vertical magnification of the view. Must not be zero
  83126. */
  83127. ymag: number;
  83128. /**
  83129. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83130. */
  83131. zfar: number;
  83132. /**
  83133. * The floating-point distance to the near clipping plane
  83134. */
  83135. znear: number;
  83136. }
  83137. /**
  83138. * A perspective camera containing properties to create a perspective projection matrix
  83139. */
  83140. interface ICameraPerspective extends IProperty {
  83141. /**
  83142. * The floating-point aspect ratio of the field of view
  83143. */
  83144. aspectRatio?: number;
  83145. /**
  83146. * The floating-point vertical field of view in radians
  83147. */
  83148. yfov: number;
  83149. /**
  83150. * The floating-point distance to the far clipping plane
  83151. */
  83152. zfar?: number;
  83153. /**
  83154. * The floating-point distance to the near clipping plane
  83155. */
  83156. znear: number;
  83157. }
  83158. /**
  83159. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83160. */
  83161. interface ICamera extends IChildRootProperty {
  83162. /**
  83163. * An orthographic camera containing properties to create an orthographic projection matrix
  83164. */
  83165. orthographic?: ICameraOrthographic;
  83166. /**
  83167. * A perspective camera containing properties to create a perspective projection matrix
  83168. */
  83169. perspective?: ICameraPerspective;
  83170. /**
  83171. * Specifies if the camera uses a perspective or orthographic projection
  83172. */
  83173. type: CameraType;
  83174. }
  83175. /**
  83176. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83177. */
  83178. interface IImage extends IChildRootProperty {
  83179. /**
  83180. * 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
  83181. */
  83182. uri?: string;
  83183. /**
  83184. * The image's MIME type
  83185. */
  83186. mimeType?: ImageMimeType;
  83187. /**
  83188. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83189. */
  83190. bufferView?: number;
  83191. }
  83192. /**
  83193. * Material Normal Texture Info
  83194. */
  83195. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83196. /**
  83197. * The scalar multiplier applied to each normal vector of the normal texture
  83198. */
  83199. scale?: number;
  83200. }
  83201. /**
  83202. * Material Occlusion Texture Info
  83203. */
  83204. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83205. /**
  83206. * A scalar multiplier controlling the amount of occlusion applied
  83207. */
  83208. strength?: number;
  83209. }
  83210. /**
  83211. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83212. */
  83213. interface IMaterialPbrMetallicRoughness {
  83214. /**
  83215. * The material's base color factor
  83216. */
  83217. baseColorFactor?: number[];
  83218. /**
  83219. * The base color texture
  83220. */
  83221. baseColorTexture?: ITextureInfo;
  83222. /**
  83223. * The metalness of the material
  83224. */
  83225. metallicFactor?: number;
  83226. /**
  83227. * The roughness of the material
  83228. */
  83229. roughnessFactor?: number;
  83230. /**
  83231. * The metallic-roughness texture
  83232. */
  83233. metallicRoughnessTexture?: ITextureInfo;
  83234. }
  83235. /**
  83236. * The material appearance of a primitive
  83237. */
  83238. interface IMaterial extends IChildRootProperty {
  83239. /**
  83240. * 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
  83241. */
  83242. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83243. /**
  83244. * The normal map texture
  83245. */
  83246. normalTexture?: IMaterialNormalTextureInfo;
  83247. /**
  83248. * The occlusion map texture
  83249. */
  83250. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83251. /**
  83252. * The emissive map texture
  83253. */
  83254. emissiveTexture?: ITextureInfo;
  83255. /**
  83256. * 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
  83257. */
  83258. emissiveFactor?: number[];
  83259. /**
  83260. * The alpha rendering mode of the material
  83261. */
  83262. alphaMode?: MaterialAlphaMode;
  83263. /**
  83264. * The alpha cutoff value of the material
  83265. */
  83266. alphaCutoff?: number;
  83267. /**
  83268. * Specifies whether the material is double sided
  83269. */
  83270. doubleSided?: boolean;
  83271. }
  83272. /**
  83273. * Geometry to be rendered with the given material
  83274. */
  83275. interface IMeshPrimitive extends IProperty {
  83276. /**
  83277. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83278. */
  83279. attributes: {
  83280. [name: string]: number;
  83281. };
  83282. /**
  83283. * The index of the accessor that contains the indices
  83284. */
  83285. indices?: number;
  83286. /**
  83287. * The index of the material to apply to this primitive when rendering
  83288. */
  83289. material?: number;
  83290. /**
  83291. * The type of primitives to render. All valid values correspond to WebGL enums
  83292. */
  83293. mode?: MeshPrimitiveMode;
  83294. /**
  83295. * 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
  83296. */
  83297. targets?: {
  83298. [name: string]: number;
  83299. }[];
  83300. }
  83301. /**
  83302. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83303. */
  83304. interface IMesh extends IChildRootProperty {
  83305. /**
  83306. * An array of primitives, each defining geometry to be rendered with a material
  83307. */
  83308. primitives: IMeshPrimitive[];
  83309. /**
  83310. * Array of weights to be applied to the Morph Targets
  83311. */
  83312. weights?: number[];
  83313. }
  83314. /**
  83315. * A node in the node hierarchy
  83316. */
  83317. interface INode extends IChildRootProperty {
  83318. /**
  83319. * The index of the camera referenced by this node
  83320. */
  83321. camera?: number;
  83322. /**
  83323. * The indices of this node's children
  83324. */
  83325. children?: number[];
  83326. /**
  83327. * The index of the skin referenced by this node
  83328. */
  83329. skin?: number;
  83330. /**
  83331. * A floating-point 4x4 transformation matrix stored in column-major order
  83332. */
  83333. matrix?: number[];
  83334. /**
  83335. * The index of the mesh in this node
  83336. */
  83337. mesh?: number;
  83338. /**
  83339. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83340. */
  83341. rotation?: number[];
  83342. /**
  83343. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83344. */
  83345. scale?: number[];
  83346. /**
  83347. * The node's translation along the x, y, and z axes
  83348. */
  83349. translation?: number[];
  83350. /**
  83351. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83352. */
  83353. weights?: number[];
  83354. }
  83355. /**
  83356. * Texture sampler properties for filtering and wrapping modes
  83357. */
  83358. interface ISampler extends IChildRootProperty {
  83359. /**
  83360. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83361. */
  83362. magFilter?: TextureMagFilter;
  83363. /**
  83364. * Minification filter. All valid values correspond to WebGL enums
  83365. */
  83366. minFilter?: TextureMinFilter;
  83367. /**
  83368. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83369. */
  83370. wrapS?: TextureWrapMode;
  83371. /**
  83372. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83373. */
  83374. wrapT?: TextureWrapMode;
  83375. }
  83376. /**
  83377. * The root nodes of a scene
  83378. */
  83379. interface IScene extends IChildRootProperty {
  83380. /**
  83381. * The indices of each root node
  83382. */
  83383. nodes: number[];
  83384. }
  83385. /**
  83386. * Joints and matrices defining a skin
  83387. */
  83388. interface ISkin extends IChildRootProperty {
  83389. /**
  83390. * 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
  83391. */
  83392. inverseBindMatrices?: number;
  83393. /**
  83394. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83395. */
  83396. skeleton?: number;
  83397. /**
  83398. * 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)
  83399. */
  83400. joints: number[];
  83401. }
  83402. /**
  83403. * A texture and its sampler
  83404. */
  83405. interface ITexture extends IChildRootProperty {
  83406. /**
  83407. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83408. */
  83409. sampler?: number;
  83410. /**
  83411. * The index of the image used by this texture
  83412. */
  83413. source: number;
  83414. }
  83415. /**
  83416. * Reference to a texture
  83417. */
  83418. interface ITextureInfo extends IProperty {
  83419. /**
  83420. * The index of the texture
  83421. */
  83422. index: number;
  83423. /**
  83424. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83425. */
  83426. texCoord?: number;
  83427. }
  83428. /**
  83429. * The root object for a glTF asset
  83430. */
  83431. interface IGLTF extends IProperty {
  83432. /**
  83433. * An array of accessors. An accessor is a typed view into a bufferView
  83434. */
  83435. accessors?: IAccessor[];
  83436. /**
  83437. * An array of keyframe animations
  83438. */
  83439. animations?: IAnimation[];
  83440. /**
  83441. * Metadata about the glTF asset
  83442. */
  83443. asset: IAsset;
  83444. /**
  83445. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83446. */
  83447. buffers?: IBuffer[];
  83448. /**
  83449. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83450. */
  83451. bufferViews?: IBufferView[];
  83452. /**
  83453. * An array of cameras
  83454. */
  83455. cameras?: ICamera[];
  83456. /**
  83457. * Names of glTF extensions used somewhere in this asset
  83458. */
  83459. extensionsUsed?: string[];
  83460. /**
  83461. * Names of glTF extensions required to properly load this asset
  83462. */
  83463. extensionsRequired?: string[];
  83464. /**
  83465. * An array of images. An image defines data used to create a texture
  83466. */
  83467. images?: IImage[];
  83468. /**
  83469. * An array of materials. A material defines the appearance of a primitive
  83470. */
  83471. materials?: IMaterial[];
  83472. /**
  83473. * An array of meshes. A mesh is a set of primitives to be rendered
  83474. */
  83475. meshes?: IMesh[];
  83476. /**
  83477. * An array of nodes
  83478. */
  83479. nodes?: INode[];
  83480. /**
  83481. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83482. */
  83483. samplers?: ISampler[];
  83484. /**
  83485. * The index of the default scene
  83486. */
  83487. scene?: number;
  83488. /**
  83489. * An array of scenes
  83490. */
  83491. scenes?: IScene[];
  83492. /**
  83493. * An array of skins. A skin is defined by joints and matrices
  83494. */
  83495. skins?: ISkin[];
  83496. /**
  83497. * An array of textures
  83498. */
  83499. textures?: ITexture[];
  83500. }
  83501. /**
  83502. * The glTF validation results
  83503. * @ignore
  83504. */
  83505. interface IGLTFValidationResults {
  83506. info: {
  83507. generator: string;
  83508. hasAnimations: boolean;
  83509. hasDefaultScene: boolean;
  83510. hasMaterials: boolean;
  83511. hasMorphTargets: boolean;
  83512. hasSkins: boolean;
  83513. hasTextures: boolean;
  83514. maxAttributesUsed: number;
  83515. primitivesCount: number
  83516. };
  83517. issues: {
  83518. messages: Array<string>;
  83519. numErrors: number;
  83520. numHints: number;
  83521. numInfos: number;
  83522. numWarnings: number;
  83523. truncated: boolean
  83524. };
  83525. mimeType: string;
  83526. uri: string;
  83527. validatedAt: string;
  83528. validatorVersion: string;
  83529. }
  83530. /**
  83531. * The glTF validation options
  83532. */
  83533. interface IGLTFValidationOptions {
  83534. /** Uri to use */
  83535. uri?: string;
  83536. /** Function used to load external resources */
  83537. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83538. /** Boolean indicating that we need to validate accessor data */
  83539. validateAccessorData?: boolean;
  83540. /** max number of issues allowed */
  83541. maxIssues?: number;
  83542. /** Ignored issues */
  83543. ignoredIssues?: Array<string>;
  83544. /** Value to override severy settings */
  83545. severityOverrides?: Object;
  83546. }
  83547. /**
  83548. * The glTF validator object
  83549. * @ignore
  83550. */
  83551. interface IGLTFValidator {
  83552. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83553. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83554. }
  83555. /**
  83556. * Interfaces from the EXT_lights_image_based extension
  83557. */
  83558. /** @hidden */
  83559. interface IEXTLightsImageBased_LightReferenceImageBased {
  83560. light: number;
  83561. }
  83562. /** @hidden */
  83563. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  83564. intensity: number;
  83565. rotation: number[];
  83566. specularImageSize: number;
  83567. specularImages: number[][];
  83568. irradianceCoefficients: number[][];
  83569. }
  83570. /** @hidden */
  83571. interface IEXTLightsImageBased {
  83572. lights: IEXTLightsImageBased_LightImageBased[];
  83573. }
  83574. /**
  83575. * Interfaces from the EXT_mesh_gpu_instancing extension
  83576. * !!! Experimental Extension Subject to Changes !!!
  83577. */
  83578. /** @hidden */
  83579. interface IEXTMeshGpuInstancing {
  83580. mesh?: number;
  83581. attributes: { [name: string]: number };
  83582. }
  83583. /**
  83584. * Interfaces from the KHR_draco_mesh_compression extension
  83585. */
  83586. /** @hidden */
  83587. interface IKHRDracoMeshCompression {
  83588. bufferView: number;
  83589. attributes: { [name: string]: number };
  83590. }
  83591. /**
  83592. * Interfaces from the KHR_lights_punctual extension
  83593. */
  83594. /** @hidden */
  83595. const enum IKHRLightsPunctual_LightType {
  83596. DIRECTIONAL = "directional",
  83597. POINT = "point",
  83598. SPOT = "spot"
  83599. }
  83600. /** @hidden */
  83601. interface IKHRLightsPunctual_LightReference {
  83602. light: number;
  83603. }
  83604. /** @hidden */
  83605. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  83606. type: IKHRLightsPunctual_LightType;
  83607. color?: number[];
  83608. intensity?: number;
  83609. range?: number;
  83610. spot?: {
  83611. innerConeAngle?: number;
  83612. outerConeAngle?: number;
  83613. };
  83614. }
  83615. /** @hidden */
  83616. interface IKHRLightsPunctual {
  83617. lights: IKHRLightsPunctual_Light[];
  83618. }
  83619. /**
  83620. * Interfaces from the KHR_materials_clearcoat extension
  83621. * !!! Experimental Extension Subject to Changes !!!
  83622. */
  83623. /** @hidden */
  83624. interface IKHRMaterialsClearcoat {
  83625. clearcoatFactor: number;
  83626. clearcoatTexture: ITextureInfo;
  83627. clearcoatRoughnessFactor: number;
  83628. clearcoatRoughnessTexture: ITextureInfo;
  83629. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  83630. }
  83631. /**
  83632. * Interfaces from the KHR_materials_ior extension
  83633. * !!! Experimental Extension Subject to Changes !!!
  83634. */
  83635. /** @hidden */
  83636. interface IKHRMaterialsIor {
  83637. ior: number;
  83638. }
  83639. /**
  83640. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  83641. */
  83642. /** @hidden */
  83643. interface IKHRMaterialsPbrSpecularGlossiness {
  83644. diffuseFactor: number[];
  83645. diffuseTexture: ITextureInfo;
  83646. specularFactor: number[];
  83647. glossinessFactor: number;
  83648. specularGlossinessTexture: ITextureInfo;
  83649. }
  83650. /**
  83651. * Interfaces from the KHR_materials_sheen extension
  83652. * !!! Experimental Extension Subject to Changes !!!
  83653. */
  83654. /** @hidden */
  83655. interface IKHRMaterialsSheen {
  83656. sheenColorFactor?: number[];
  83657. sheenTexture?: ITextureInfo;
  83658. sheenRoughnessFactor?: number;
  83659. }
  83660. /**
  83661. * Interfaces from the KHR_materials_specular extension
  83662. * !!! Experimental Extension Subject to Changes !!!
  83663. */
  83664. /** @hidden */
  83665. interface IKHRMaterialsSpecular {
  83666. specularFactor: number;
  83667. specularColorFactor: number[];
  83668. specularTexture: ITextureInfo;
  83669. }
  83670. /**
  83671. * Interfaces from the KHR_materials_transmission extension
  83672. * !!! Experimental Extension Subject to Changes !!!
  83673. */
  83674. /** @hidden */
  83675. interface IKHRMaterialsTransmission {
  83676. transmissionFactor?: number;
  83677. transmissionTexture?: ITextureInfo;
  83678. }
  83679. /**
  83680. * Interfaces from the KHR_materials_variants extension
  83681. * !!! Experimental Extension Subject to Changes !!!
  83682. */
  83683. /** @hidden */
  83684. interface IKHRMaterialVariants_Mapping {
  83685. tags: string[];
  83686. material: number;
  83687. }
  83688. /** @hidden */
  83689. interface IKHRMaterialVariants {
  83690. mapping: IKHRMaterialVariants_Mapping[];
  83691. }
  83692. /**
  83693. * Interfaces from the KHR_texture_basisu extension
  83694. * !!! Experimental Extension Subject to Changes !!!
  83695. */
  83696. /** @hidden */
  83697. interface IKHRTextureBasisU {
  83698. source: number;
  83699. }
  83700. /**
  83701. * Interfaces from the KHR_texture_transform extension
  83702. */
  83703. /** @hidden */
  83704. interface IKHRTextureTransform {
  83705. offset?: number[];
  83706. rotation?: number;
  83707. scale?: number[];
  83708. texCoord?: number;
  83709. }
  83710. /**
  83711. * Interfaces from the KHR_xmp extension
  83712. * !!! Experimental Extension Subject to Changes !!!
  83713. */
  83714. /** @hidden */
  83715. interface IKHRXmp_Data {
  83716. [key: string]: unknown;
  83717. }
  83718. /** @hidden */
  83719. interface IKHRXmp_Gltf {
  83720. packets: IKHRXmp_Data[];
  83721. }
  83722. /** @hidden */
  83723. interface IKHRXmp_Node {
  83724. packet: number;
  83725. }
  83726. /**
  83727. * Interfaces from the MSFT_audio_emitter extension
  83728. */
  83729. /** @hidden */
  83730. interface IMSFTAudioEmitter_ClipReference {
  83731. clip: number;
  83732. weight?: number;
  83733. }
  83734. /** @hidden */
  83735. interface IMSFTAudioEmitter_EmittersReference {
  83736. emitters: number[];
  83737. }
  83738. /** @hidden */
  83739. const enum IMSFTAudioEmitter_DistanceModel {
  83740. linear = "linear",
  83741. inverse = "inverse",
  83742. exponential = "exponential",
  83743. }
  83744. /** @hidden */
  83745. interface IMSFTAudioEmitter_Emitter {
  83746. name?: string;
  83747. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  83748. refDistance?: number;
  83749. maxDistance?: number;
  83750. rolloffFactor?: number;
  83751. innerAngle?: number;
  83752. outerAngle?: number;
  83753. loop?: boolean;
  83754. volume?: number;
  83755. clips: IMSFTAudioEmitter_ClipReference[];
  83756. }
  83757. /** @hidden */
  83758. const enum IMSFTAudioEmitter_AudioMimeType {
  83759. WAV = "audio/wav",
  83760. }
  83761. /** @hidden */
  83762. interface IMSFTAudioEmitter_Clip extends IProperty {
  83763. uri?: string;
  83764. bufferView?: number;
  83765. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  83766. }
  83767. /** @hidden */
  83768. const enum IMSFTAudioEmitter_AnimationEventAction {
  83769. play = "play",
  83770. pause = "pause",
  83771. stop = "stop",
  83772. }
  83773. /** @hidden */
  83774. interface IMSFTAudioEmitter_AnimationEvent {
  83775. action: IMSFTAudioEmitter_AnimationEventAction;
  83776. emitter: number;
  83777. time: number;
  83778. startOffset?: number;
  83779. }
  83780. /**
  83781. * Interfaces from the MSFT_lod extension
  83782. */
  83783. /** @hidden */
  83784. interface IMSFTLOD {
  83785. ids: number[];
  83786. }
  83787. }
  83788. declare module BABYLON {
  83789. /** @hidden */
  83790. export var cellPixelShader: {
  83791. name: string;
  83792. shader: string;
  83793. };
  83794. }
  83795. declare module BABYLON {
  83796. /** @hidden */
  83797. export var cellVertexShader: {
  83798. name: string;
  83799. shader: string;
  83800. };
  83801. }
  83802. declare module BABYLON {
  83803. export class CellMaterial extends BABYLON.PushMaterial {
  83804. private _diffuseTexture;
  83805. diffuseTexture: BABYLON.BaseTexture;
  83806. diffuseColor: BABYLON.Color3;
  83807. _computeHighLevel: boolean;
  83808. computeHighLevel: boolean;
  83809. private _disableLighting;
  83810. disableLighting: boolean;
  83811. private _maxSimultaneousLights;
  83812. maxSimultaneousLights: number;
  83813. constructor(name: string, scene: BABYLON.Scene);
  83814. needAlphaBlending(): boolean;
  83815. needAlphaTesting(): boolean;
  83816. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83817. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83818. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83819. getAnimatables(): BABYLON.IAnimatable[];
  83820. getActiveTextures(): BABYLON.BaseTexture[];
  83821. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83822. dispose(forceDisposeEffect?: boolean): void;
  83823. getClassName(): string;
  83824. clone(name: string): CellMaterial;
  83825. serialize(): any;
  83826. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  83827. }
  83828. }
  83829. declare module BABYLON {
  83830. export class CustomShaderStructure {
  83831. FragmentStore: string;
  83832. VertexStore: string;
  83833. constructor();
  83834. }
  83835. export class ShaderSpecialParts {
  83836. constructor();
  83837. Fragment_Begin: string;
  83838. Fragment_Definitions: string;
  83839. Fragment_MainBegin: string;
  83840. Fragment_Custom_Diffuse: string;
  83841. Fragment_Before_Lights: string;
  83842. Fragment_Before_Fog: string;
  83843. Fragment_Custom_Alpha: string;
  83844. Fragment_Before_FragColor: string;
  83845. Vertex_Begin: string;
  83846. Vertex_Definitions: string;
  83847. Vertex_MainBegin: string;
  83848. Vertex_Before_PositionUpdated: string;
  83849. Vertex_Before_NormalUpdated: string;
  83850. Vertex_After_WorldPosComputed: string;
  83851. Vertex_MainEnd: string;
  83852. }
  83853. export class CustomMaterial extends BABYLON.StandardMaterial {
  83854. static ShaderIndexer: number;
  83855. CustomParts: ShaderSpecialParts;
  83856. _isCreatedShader: boolean;
  83857. _createdShaderName: string;
  83858. _customUniform: string[];
  83859. _newUniforms: string[];
  83860. _newUniformInstances: {
  83861. [name: string]: any;
  83862. };
  83863. _newSamplerInstances: {
  83864. [name: string]: BABYLON.Texture;
  83865. };
  83866. _customAttributes: string[];
  83867. FragmentShader: string;
  83868. VertexShader: string;
  83869. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83870. ReviewUniform(name: string, arr: string[]): string[];
  83871. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83872. constructor(name: string, scene: BABYLON.Scene);
  83873. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  83874. AddAttribute(name: string): CustomMaterial;
  83875. Fragment_Begin(shaderPart: string): CustomMaterial;
  83876. Fragment_Definitions(shaderPart: string): CustomMaterial;
  83877. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  83878. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  83879. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  83880. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  83881. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  83882. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  83883. Vertex_Begin(shaderPart: string): CustomMaterial;
  83884. Vertex_Definitions(shaderPart: string): CustomMaterial;
  83885. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  83886. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  83887. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  83888. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  83889. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  83890. }
  83891. }
  83892. declare module BABYLON {
  83893. export class ShaderAlebdoParts {
  83894. constructor();
  83895. Fragment_Begin: string;
  83896. Fragment_Definitions: string;
  83897. Fragment_MainBegin: string;
  83898. Fragment_Custom_Albedo: string;
  83899. Fragment_Before_Lights: string;
  83900. Fragment_Custom_MetallicRoughness: string;
  83901. Fragment_Custom_MicroSurface: string;
  83902. Fragment_Before_Fog: string;
  83903. Fragment_Custom_Alpha: string;
  83904. Fragment_Before_FragColor: string;
  83905. Vertex_Begin: string;
  83906. Vertex_Definitions: string;
  83907. Vertex_MainBegin: string;
  83908. Vertex_Before_PositionUpdated: string;
  83909. Vertex_Before_NormalUpdated: string;
  83910. Vertex_After_WorldPosComputed: string;
  83911. Vertex_MainEnd: string;
  83912. }
  83913. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  83914. static ShaderIndexer: number;
  83915. CustomParts: ShaderAlebdoParts;
  83916. _isCreatedShader: boolean;
  83917. _createdShaderName: string;
  83918. _customUniform: string[];
  83919. _newUniforms: string[];
  83920. _newUniformInstances: {
  83921. [name: string]: any;
  83922. };
  83923. _newSamplerInstances: {
  83924. [name: string]: BABYLON.Texture;
  83925. };
  83926. _customAttributes: string[];
  83927. FragmentShader: string;
  83928. VertexShader: string;
  83929. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  83930. ReviewUniform(name: string, arr: string[]): string[];
  83931. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  83932. constructor(name: string, scene: BABYLON.Scene);
  83933. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  83934. AddAttribute(name: string): PBRCustomMaterial;
  83935. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  83936. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  83937. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  83938. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  83939. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  83940. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  83941. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  83942. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  83943. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  83944. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  83945. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  83946. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  83947. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  83948. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  83949. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  83950. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  83951. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  83952. }
  83953. }
  83954. declare module BABYLON {
  83955. /** @hidden */
  83956. export var firePixelShader: {
  83957. name: string;
  83958. shader: string;
  83959. };
  83960. }
  83961. declare module BABYLON {
  83962. /** @hidden */
  83963. export var fireVertexShader: {
  83964. name: string;
  83965. shader: string;
  83966. };
  83967. }
  83968. declare module BABYLON {
  83969. export class FireMaterial extends BABYLON.PushMaterial {
  83970. private _diffuseTexture;
  83971. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83972. private _distortionTexture;
  83973. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83974. private _opacityTexture;
  83975. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  83976. diffuseColor: BABYLON.Color3;
  83977. speed: number;
  83978. private _scaledDiffuse;
  83979. private _lastTime;
  83980. constructor(name: string, scene: BABYLON.Scene);
  83981. needAlphaBlending(): boolean;
  83982. needAlphaTesting(): boolean;
  83983. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  83984. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  83985. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  83986. getAnimatables(): BABYLON.IAnimatable[];
  83987. getActiveTextures(): BABYLON.BaseTexture[];
  83988. hasTexture(texture: BABYLON.BaseTexture): boolean;
  83989. getClassName(): string;
  83990. dispose(forceDisposeEffect?: boolean): void;
  83991. clone(name: string): FireMaterial;
  83992. serialize(): any;
  83993. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  83994. }
  83995. }
  83996. declare module BABYLON {
  83997. /** @hidden */
  83998. export var furPixelShader: {
  83999. name: string;
  84000. shader: string;
  84001. };
  84002. }
  84003. declare module BABYLON {
  84004. /** @hidden */
  84005. export var furVertexShader: {
  84006. name: string;
  84007. shader: string;
  84008. };
  84009. }
  84010. declare module BABYLON {
  84011. export class FurMaterial extends BABYLON.PushMaterial {
  84012. private _diffuseTexture;
  84013. diffuseTexture: BABYLON.BaseTexture;
  84014. private _heightTexture;
  84015. heightTexture: BABYLON.BaseTexture;
  84016. diffuseColor: BABYLON.Color3;
  84017. furLength: number;
  84018. furAngle: number;
  84019. furColor: BABYLON.Color3;
  84020. furOffset: number;
  84021. furSpacing: number;
  84022. furGravity: BABYLON.Vector3;
  84023. furSpeed: number;
  84024. furDensity: number;
  84025. furOcclusion: number;
  84026. furTexture: BABYLON.DynamicTexture;
  84027. private _disableLighting;
  84028. disableLighting: boolean;
  84029. private _maxSimultaneousLights;
  84030. maxSimultaneousLights: number;
  84031. highLevelFur: boolean;
  84032. _meshes: BABYLON.AbstractMesh[];
  84033. private _furTime;
  84034. constructor(name: string, scene: BABYLON.Scene);
  84035. get furTime(): number;
  84036. set furTime(furTime: number);
  84037. needAlphaBlending(): boolean;
  84038. needAlphaTesting(): boolean;
  84039. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84040. updateFur(): void;
  84041. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84042. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84043. getAnimatables(): BABYLON.IAnimatable[];
  84044. getActiveTextures(): BABYLON.BaseTexture[];
  84045. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84046. dispose(forceDisposeEffect?: boolean): void;
  84047. clone(name: string): FurMaterial;
  84048. serialize(): any;
  84049. getClassName(): string;
  84050. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84051. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84052. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84053. }
  84054. }
  84055. declare module BABYLON {
  84056. /** @hidden */
  84057. export var gradientPixelShader: {
  84058. name: string;
  84059. shader: string;
  84060. };
  84061. }
  84062. declare module BABYLON {
  84063. /** @hidden */
  84064. export var gradientVertexShader: {
  84065. name: string;
  84066. shader: string;
  84067. };
  84068. }
  84069. declare module BABYLON {
  84070. export class GradientMaterial extends BABYLON.PushMaterial {
  84071. private _maxSimultaneousLights;
  84072. maxSimultaneousLights: number;
  84073. topColor: BABYLON.Color3;
  84074. topColorAlpha: number;
  84075. bottomColor: BABYLON.Color3;
  84076. bottomColorAlpha: number;
  84077. offset: number;
  84078. scale: number;
  84079. smoothness: number;
  84080. private _disableLighting;
  84081. disableLighting: boolean;
  84082. constructor(name: string, scene: BABYLON.Scene);
  84083. needAlphaBlending(): boolean;
  84084. needAlphaTesting(): boolean;
  84085. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84086. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84087. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84088. getAnimatables(): BABYLON.IAnimatable[];
  84089. dispose(forceDisposeEffect?: boolean): void;
  84090. clone(name: string): GradientMaterial;
  84091. serialize(): any;
  84092. getClassName(): string;
  84093. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84094. }
  84095. }
  84096. declare module BABYLON {
  84097. /** @hidden */
  84098. export var gridPixelShader: {
  84099. name: string;
  84100. shader: string;
  84101. };
  84102. }
  84103. declare module BABYLON {
  84104. /** @hidden */
  84105. export var gridVertexShader: {
  84106. name: string;
  84107. shader: string;
  84108. };
  84109. }
  84110. declare module BABYLON {
  84111. /**
  84112. * The grid materials allows you to wrap any shape with a grid.
  84113. * Colors are customizable.
  84114. */
  84115. export class GridMaterial extends BABYLON.PushMaterial {
  84116. /**
  84117. * Main color of the grid (e.g. between lines)
  84118. */
  84119. mainColor: BABYLON.Color3;
  84120. /**
  84121. * Color of the grid lines.
  84122. */
  84123. lineColor: BABYLON.Color3;
  84124. /**
  84125. * The scale of the grid compared to unit.
  84126. */
  84127. gridRatio: number;
  84128. /**
  84129. * Allows setting an offset for the grid lines.
  84130. */
  84131. gridOffset: BABYLON.Vector3;
  84132. /**
  84133. * The frequency of thicker lines.
  84134. */
  84135. majorUnitFrequency: number;
  84136. /**
  84137. * The visibility of minor units in the grid.
  84138. */
  84139. minorUnitVisibility: number;
  84140. /**
  84141. * The grid opacity outside of the lines.
  84142. */
  84143. opacity: number;
  84144. /**
  84145. * Determine RBG output is premultiplied by alpha value.
  84146. */
  84147. preMultiplyAlpha: boolean;
  84148. private _opacityTexture;
  84149. opacityTexture: BABYLON.BaseTexture;
  84150. private _gridControl;
  84151. /**
  84152. * constructor
  84153. * @param name The name given to the material in order to identify it afterwards.
  84154. * @param scene The scene the material is used in.
  84155. */
  84156. constructor(name: string, scene: BABYLON.Scene);
  84157. /**
  84158. * Returns wehter or not the grid requires alpha blending.
  84159. */
  84160. needAlphaBlending(): boolean;
  84161. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84162. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84163. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84164. /**
  84165. * Dispose the material and its associated resources.
  84166. * @param forceDisposeEffect will also dispose the used effect when true
  84167. */
  84168. dispose(forceDisposeEffect?: boolean): void;
  84169. clone(name: string): GridMaterial;
  84170. serialize(): any;
  84171. getClassName(): string;
  84172. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84173. }
  84174. }
  84175. declare module BABYLON {
  84176. /** @hidden */
  84177. export var lavaPixelShader: {
  84178. name: string;
  84179. shader: string;
  84180. };
  84181. }
  84182. declare module BABYLON {
  84183. /** @hidden */
  84184. export var lavaVertexShader: {
  84185. name: string;
  84186. shader: string;
  84187. };
  84188. }
  84189. declare module BABYLON {
  84190. export class LavaMaterial extends BABYLON.PushMaterial {
  84191. private _diffuseTexture;
  84192. diffuseTexture: BABYLON.BaseTexture;
  84193. noiseTexture: BABYLON.BaseTexture;
  84194. fogColor: BABYLON.Color3;
  84195. speed: number;
  84196. movingSpeed: number;
  84197. lowFrequencySpeed: number;
  84198. fogDensity: number;
  84199. private _lastTime;
  84200. diffuseColor: BABYLON.Color3;
  84201. private _disableLighting;
  84202. disableLighting: boolean;
  84203. private _unlit;
  84204. unlit: boolean;
  84205. private _maxSimultaneousLights;
  84206. maxSimultaneousLights: number;
  84207. private _scaledDiffuse;
  84208. constructor(name: string, scene: BABYLON.Scene);
  84209. needAlphaBlending(): boolean;
  84210. needAlphaTesting(): boolean;
  84211. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84212. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84213. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84214. getAnimatables(): BABYLON.IAnimatable[];
  84215. getActiveTextures(): BABYLON.BaseTexture[];
  84216. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84217. dispose(forceDisposeEffect?: boolean): void;
  84218. clone(name: string): LavaMaterial;
  84219. serialize(): any;
  84220. getClassName(): string;
  84221. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84222. }
  84223. }
  84224. declare module BABYLON {
  84225. /** @hidden */
  84226. export var mixPixelShader: {
  84227. name: string;
  84228. shader: string;
  84229. };
  84230. }
  84231. declare module BABYLON {
  84232. /** @hidden */
  84233. export var mixVertexShader: {
  84234. name: string;
  84235. shader: string;
  84236. };
  84237. }
  84238. declare module BABYLON {
  84239. export class MixMaterial extends BABYLON.PushMaterial {
  84240. /**
  84241. * Mix textures
  84242. */
  84243. private _mixTexture1;
  84244. mixTexture1: BABYLON.BaseTexture;
  84245. private _mixTexture2;
  84246. mixTexture2: BABYLON.BaseTexture;
  84247. /**
  84248. * Diffuse textures
  84249. */
  84250. private _diffuseTexture1;
  84251. diffuseTexture1: BABYLON.Texture;
  84252. private _diffuseTexture2;
  84253. diffuseTexture2: BABYLON.Texture;
  84254. private _diffuseTexture3;
  84255. diffuseTexture3: BABYLON.Texture;
  84256. private _diffuseTexture4;
  84257. diffuseTexture4: BABYLON.Texture;
  84258. private _diffuseTexture5;
  84259. diffuseTexture5: BABYLON.Texture;
  84260. private _diffuseTexture6;
  84261. diffuseTexture6: BABYLON.Texture;
  84262. private _diffuseTexture7;
  84263. diffuseTexture7: BABYLON.Texture;
  84264. private _diffuseTexture8;
  84265. diffuseTexture8: BABYLON.Texture;
  84266. /**
  84267. * Uniforms
  84268. */
  84269. diffuseColor: BABYLON.Color3;
  84270. specularColor: BABYLON.Color3;
  84271. specularPower: number;
  84272. private _disableLighting;
  84273. disableLighting: boolean;
  84274. private _maxSimultaneousLights;
  84275. maxSimultaneousLights: number;
  84276. constructor(name: string, scene: BABYLON.Scene);
  84277. needAlphaBlending(): boolean;
  84278. needAlphaTesting(): boolean;
  84279. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84280. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84281. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84282. getAnimatables(): BABYLON.IAnimatable[];
  84283. getActiveTextures(): BABYLON.BaseTexture[];
  84284. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84285. dispose(forceDisposeEffect?: boolean): void;
  84286. clone(name: string): MixMaterial;
  84287. serialize(): any;
  84288. getClassName(): string;
  84289. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84290. }
  84291. }
  84292. declare module BABYLON {
  84293. /** @hidden */
  84294. export var normalPixelShader: {
  84295. name: string;
  84296. shader: string;
  84297. };
  84298. }
  84299. declare module BABYLON {
  84300. /** @hidden */
  84301. export var normalVertexShader: {
  84302. name: string;
  84303. shader: string;
  84304. };
  84305. }
  84306. declare module BABYLON {
  84307. export class NormalMaterial extends BABYLON.PushMaterial {
  84308. private _diffuseTexture;
  84309. diffuseTexture: BABYLON.BaseTexture;
  84310. diffuseColor: BABYLON.Color3;
  84311. private _disableLighting;
  84312. disableLighting: boolean;
  84313. private _maxSimultaneousLights;
  84314. maxSimultaneousLights: number;
  84315. constructor(name: string, scene: BABYLON.Scene);
  84316. needAlphaBlending(): boolean;
  84317. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84318. needAlphaTesting(): boolean;
  84319. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84320. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84321. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84322. getAnimatables(): BABYLON.IAnimatable[];
  84323. getActiveTextures(): BABYLON.BaseTexture[];
  84324. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84325. dispose(forceDisposeEffect?: boolean): void;
  84326. clone(name: string): NormalMaterial;
  84327. serialize(): any;
  84328. getClassName(): string;
  84329. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84330. }
  84331. }
  84332. declare module BABYLON {
  84333. /** @hidden */
  84334. export var shadowOnlyPixelShader: {
  84335. name: string;
  84336. shader: string;
  84337. };
  84338. }
  84339. declare module BABYLON {
  84340. /** @hidden */
  84341. export var shadowOnlyVertexShader: {
  84342. name: string;
  84343. shader: string;
  84344. };
  84345. }
  84346. declare module BABYLON {
  84347. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84348. private _activeLight;
  84349. private _needAlphaBlending;
  84350. constructor(name: string, scene: BABYLON.Scene);
  84351. shadowColor: BABYLON.Color3;
  84352. needAlphaBlending(): boolean;
  84353. needAlphaTesting(): boolean;
  84354. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84355. get activeLight(): BABYLON.IShadowLight;
  84356. set activeLight(light: BABYLON.IShadowLight);
  84357. private _getFirstShadowLightForMesh;
  84358. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84359. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84360. clone(name: string): ShadowOnlyMaterial;
  84361. serialize(): any;
  84362. getClassName(): string;
  84363. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84364. }
  84365. }
  84366. declare module BABYLON {
  84367. /** @hidden */
  84368. export var simplePixelShader: {
  84369. name: string;
  84370. shader: string;
  84371. };
  84372. }
  84373. declare module BABYLON {
  84374. /** @hidden */
  84375. export var simpleVertexShader: {
  84376. name: string;
  84377. shader: string;
  84378. };
  84379. }
  84380. declare module BABYLON {
  84381. export class SimpleMaterial extends BABYLON.PushMaterial {
  84382. private _diffuseTexture;
  84383. diffuseTexture: BABYLON.BaseTexture;
  84384. diffuseColor: BABYLON.Color3;
  84385. private _disableLighting;
  84386. disableLighting: boolean;
  84387. private _maxSimultaneousLights;
  84388. maxSimultaneousLights: number;
  84389. constructor(name: string, scene: BABYLON.Scene);
  84390. needAlphaBlending(): boolean;
  84391. needAlphaTesting(): boolean;
  84392. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84393. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84394. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84395. getAnimatables(): BABYLON.IAnimatable[];
  84396. getActiveTextures(): BABYLON.BaseTexture[];
  84397. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84398. dispose(forceDisposeEffect?: boolean): void;
  84399. clone(name: string): SimpleMaterial;
  84400. serialize(): any;
  84401. getClassName(): string;
  84402. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84403. }
  84404. }
  84405. declare module BABYLON {
  84406. /** @hidden */
  84407. export var skyPixelShader: {
  84408. name: string;
  84409. shader: string;
  84410. };
  84411. }
  84412. declare module BABYLON {
  84413. /** @hidden */
  84414. export var skyVertexShader: {
  84415. name: string;
  84416. shader: string;
  84417. };
  84418. }
  84419. declare module BABYLON {
  84420. /**
  84421. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84422. * @see https://doc.babylonjs.com/extensions/sky
  84423. */
  84424. export class SkyMaterial extends BABYLON.PushMaterial {
  84425. /**
  84426. * Defines the overall luminance of sky in interval ]0, 1[.
  84427. */
  84428. luminance: number;
  84429. /**
  84430. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84431. */
  84432. turbidity: number;
  84433. /**
  84434. * Defines the sky appearance (light intensity).
  84435. */
  84436. rayleigh: number;
  84437. /**
  84438. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84439. */
  84440. mieCoefficient: number;
  84441. /**
  84442. * Defines the amount of haze particles following the Mie scattering theory.
  84443. */
  84444. mieDirectionalG: number;
  84445. /**
  84446. * Defines the distance of the sun according to the active scene camera.
  84447. */
  84448. distance: number;
  84449. /**
  84450. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84451. * "inclined".
  84452. */
  84453. inclination: number;
  84454. /**
  84455. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84456. * an object direction and a reference direction.
  84457. */
  84458. azimuth: number;
  84459. /**
  84460. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84461. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84462. */
  84463. sunPosition: BABYLON.Vector3;
  84464. /**
  84465. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84466. * .sunPosition property.
  84467. */
  84468. useSunPosition: boolean;
  84469. /**
  84470. * Defines an offset vector used to get a horizon offset.
  84471. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84472. */
  84473. cameraOffset: BABYLON.Vector3;
  84474. private _cameraPosition;
  84475. /**
  84476. * Instantiates a new sky material.
  84477. * This material allows to create dynamic and texture free
  84478. * effects for skyboxes by taking care of the atmosphere state.
  84479. * @see https://doc.babylonjs.com/extensions/sky
  84480. * @param name Define the name of the material in the scene
  84481. * @param scene Define the scene the material belong to
  84482. */
  84483. constructor(name: string, scene: BABYLON.Scene);
  84484. /**
  84485. * Specifies if the material will require alpha blending
  84486. * @returns a boolean specifying if alpha blending is needed
  84487. */
  84488. needAlphaBlending(): boolean;
  84489. /**
  84490. * Specifies if this material should be rendered in alpha test mode
  84491. * @returns false as the sky material doesn't need alpha testing.
  84492. */
  84493. needAlphaTesting(): boolean;
  84494. /**
  84495. * Get the texture used for alpha test purpose.
  84496. * @returns null as the sky material has no texture.
  84497. */
  84498. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84499. /**
  84500. * Get if the submesh is ready to be used and all its information available.
  84501. * Child classes can use it to update shaders
  84502. * @param mesh defines the mesh to check
  84503. * @param subMesh defines which submesh to check
  84504. * @param useInstances specifies that instances should be used
  84505. * @returns a boolean indicating that the submesh is ready or not
  84506. */
  84507. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84508. /**
  84509. * Binds the submesh to this material by preparing the effect and shader to draw
  84510. * @param world defines the world transformation matrix
  84511. * @param mesh defines the mesh containing the submesh
  84512. * @param subMesh defines the submesh to bind the material to
  84513. */
  84514. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84515. /**
  84516. * Get the list of animatables in the material.
  84517. * @returns the list of animatables object used in the material
  84518. */
  84519. getAnimatables(): BABYLON.IAnimatable[];
  84520. /**
  84521. * Disposes the material
  84522. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84523. */
  84524. dispose(forceDisposeEffect?: boolean): void;
  84525. /**
  84526. * Makes a duplicate of the material, and gives it a new name
  84527. * @param name defines the new name for the duplicated material
  84528. * @returns the cloned material
  84529. */
  84530. clone(name: string): SkyMaterial;
  84531. /**
  84532. * Serializes this material in a JSON representation
  84533. * @returns the serialized material object
  84534. */
  84535. serialize(): any;
  84536. /**
  84537. * Gets the current class name of the material e.g. "SkyMaterial"
  84538. * Mainly use in serialization.
  84539. * @returns the class name
  84540. */
  84541. getClassName(): string;
  84542. /**
  84543. * Creates a sky material from parsed material data
  84544. * @param source defines the JSON representation of the material
  84545. * @param scene defines the hosting scene
  84546. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84547. * @returns a new sky material
  84548. */
  84549. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84550. }
  84551. }
  84552. declare module BABYLON {
  84553. /** @hidden */
  84554. export var terrainPixelShader: {
  84555. name: string;
  84556. shader: string;
  84557. };
  84558. }
  84559. declare module BABYLON {
  84560. /** @hidden */
  84561. export var terrainVertexShader: {
  84562. name: string;
  84563. shader: string;
  84564. };
  84565. }
  84566. declare module BABYLON {
  84567. export class TerrainMaterial extends BABYLON.PushMaterial {
  84568. private _mixTexture;
  84569. mixTexture: BABYLON.BaseTexture;
  84570. private _diffuseTexture1;
  84571. diffuseTexture1: BABYLON.Texture;
  84572. private _diffuseTexture2;
  84573. diffuseTexture2: BABYLON.Texture;
  84574. private _diffuseTexture3;
  84575. diffuseTexture3: BABYLON.Texture;
  84576. private _bumpTexture1;
  84577. bumpTexture1: BABYLON.Texture;
  84578. private _bumpTexture2;
  84579. bumpTexture2: BABYLON.Texture;
  84580. private _bumpTexture3;
  84581. bumpTexture3: BABYLON.Texture;
  84582. diffuseColor: BABYLON.Color3;
  84583. specularColor: BABYLON.Color3;
  84584. specularPower: number;
  84585. private _disableLighting;
  84586. disableLighting: boolean;
  84587. private _maxSimultaneousLights;
  84588. maxSimultaneousLights: number;
  84589. constructor(name: string, scene: BABYLON.Scene);
  84590. needAlphaBlending(): boolean;
  84591. needAlphaTesting(): boolean;
  84592. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84593. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84594. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84595. getAnimatables(): BABYLON.IAnimatable[];
  84596. getActiveTextures(): BABYLON.BaseTexture[];
  84597. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84598. dispose(forceDisposeEffect?: boolean): void;
  84599. clone(name: string): TerrainMaterial;
  84600. serialize(): any;
  84601. getClassName(): string;
  84602. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84603. }
  84604. }
  84605. declare module BABYLON {
  84606. /** @hidden */
  84607. export var triplanarPixelShader: {
  84608. name: string;
  84609. shader: string;
  84610. };
  84611. }
  84612. declare module BABYLON {
  84613. /** @hidden */
  84614. export var triplanarVertexShader: {
  84615. name: string;
  84616. shader: string;
  84617. };
  84618. }
  84619. declare module BABYLON {
  84620. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84621. mixTexture: BABYLON.BaseTexture;
  84622. private _diffuseTextureX;
  84623. diffuseTextureX: BABYLON.BaseTexture;
  84624. private _diffuseTextureY;
  84625. diffuseTextureY: BABYLON.BaseTexture;
  84626. private _diffuseTextureZ;
  84627. diffuseTextureZ: BABYLON.BaseTexture;
  84628. private _normalTextureX;
  84629. normalTextureX: BABYLON.BaseTexture;
  84630. private _normalTextureY;
  84631. normalTextureY: BABYLON.BaseTexture;
  84632. private _normalTextureZ;
  84633. normalTextureZ: BABYLON.BaseTexture;
  84634. tileSize: number;
  84635. diffuseColor: BABYLON.Color3;
  84636. specularColor: BABYLON.Color3;
  84637. specularPower: number;
  84638. private _disableLighting;
  84639. disableLighting: boolean;
  84640. private _maxSimultaneousLights;
  84641. maxSimultaneousLights: number;
  84642. constructor(name: string, scene: BABYLON.Scene);
  84643. needAlphaBlending(): boolean;
  84644. needAlphaTesting(): boolean;
  84645. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84646. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84647. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84648. getAnimatables(): BABYLON.IAnimatable[];
  84649. getActiveTextures(): BABYLON.BaseTexture[];
  84650. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84651. dispose(forceDisposeEffect?: boolean): void;
  84652. clone(name: string): TriPlanarMaterial;
  84653. serialize(): any;
  84654. getClassName(): string;
  84655. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84656. }
  84657. }
  84658. declare module BABYLON {
  84659. /** @hidden */
  84660. export var waterPixelShader: {
  84661. name: string;
  84662. shader: string;
  84663. };
  84664. }
  84665. declare module BABYLON {
  84666. /** @hidden */
  84667. export var waterVertexShader: {
  84668. name: string;
  84669. shader: string;
  84670. };
  84671. }
  84672. declare module BABYLON {
  84673. export class WaterMaterial extends BABYLON.PushMaterial {
  84674. renderTargetSize: BABYLON.Vector2;
  84675. private _bumpTexture;
  84676. bumpTexture: BABYLON.BaseTexture;
  84677. diffuseColor: BABYLON.Color3;
  84678. specularColor: BABYLON.Color3;
  84679. specularPower: number;
  84680. private _disableLighting;
  84681. disableLighting: boolean;
  84682. private _maxSimultaneousLights;
  84683. maxSimultaneousLights: number;
  84684. /**
  84685. * @param {number}: Represents the wind force
  84686. */
  84687. windForce: number;
  84688. /**
  84689. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84690. */
  84691. windDirection: BABYLON.Vector2;
  84692. /**
  84693. * @param {number}: Wave height, represents the height of the waves
  84694. */
  84695. waveHeight: number;
  84696. /**
  84697. * @param {number}: Bump height, represents the bump height related to the bump map
  84698. */
  84699. bumpHeight: number;
  84700. /**
  84701. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84702. */
  84703. private _bumpSuperimpose;
  84704. bumpSuperimpose: boolean;
  84705. /**
  84706. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  84707. */
  84708. private _fresnelSeparate;
  84709. fresnelSeparate: boolean;
  84710. /**
  84711. * @param {boolean}: bump Waves modify the reflection.
  84712. */
  84713. private _bumpAffectsReflection;
  84714. bumpAffectsReflection: boolean;
  84715. /**
  84716. * @param {number}: The water color blended with the refraction (near)
  84717. */
  84718. waterColor: BABYLON.Color3;
  84719. /**
  84720. * @param {number}: The blend factor related to the water color
  84721. */
  84722. colorBlendFactor: number;
  84723. /**
  84724. * @param {number}: The water color blended with the reflection (far)
  84725. */
  84726. waterColor2: BABYLON.Color3;
  84727. /**
  84728. * @param {number}: The blend factor related to the water color (reflection, far)
  84729. */
  84730. colorBlendFactor2: number;
  84731. /**
  84732. * @param {number}: Represents the maximum length of a wave
  84733. */
  84734. waveLength: number;
  84735. /**
  84736. * @param {number}: Defines the waves speed
  84737. */
  84738. waveSpeed: number;
  84739. /**
  84740. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  84741. * will avoid calculating useless pixels in the pixel shader of the water material.
  84742. */
  84743. disableClipPlane: boolean;
  84744. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  84745. private _mesh;
  84746. private _refractionRTT;
  84747. private _reflectionRTT;
  84748. private _reflectionTransform;
  84749. private _lastTime;
  84750. private _lastDeltaTime;
  84751. private _useLogarithmicDepth;
  84752. private _waitingRenderList;
  84753. private _imageProcessingConfiguration;
  84754. private _imageProcessingObserver;
  84755. /**
  84756. * Gets a boolean indicating that current material needs to register RTT
  84757. */
  84758. get hasRenderTargetTextures(): boolean;
  84759. /**
  84760. * Constructor
  84761. */
  84762. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  84763. get useLogarithmicDepth(): boolean;
  84764. set useLogarithmicDepth(value: boolean);
  84765. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84766. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  84767. addToRenderList(node: any): void;
  84768. enableRenderTargets(enable: boolean): void;
  84769. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  84770. get renderTargetsEnabled(): boolean;
  84771. needAlphaBlending(): boolean;
  84772. needAlphaTesting(): boolean;
  84773. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84774. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84775. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84776. private _createRenderTargets;
  84777. getAnimatables(): BABYLON.IAnimatable[];
  84778. getActiveTextures(): BABYLON.BaseTexture[];
  84779. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84780. dispose(forceDisposeEffect?: boolean): void;
  84781. clone(name: string): WaterMaterial;
  84782. serialize(): any;
  84783. getClassName(): string;
  84784. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  84785. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  84786. }
  84787. }
  84788. declare module BABYLON {
  84789. /** @hidden */
  84790. export var asciiartPixelShader: {
  84791. name: string;
  84792. shader: string;
  84793. };
  84794. }
  84795. declare module BABYLON {
  84796. /**
  84797. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  84798. *
  84799. * It basically takes care rendering the font front the given font size to a texture.
  84800. * This is used later on in the postprocess.
  84801. */
  84802. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  84803. private _font;
  84804. private _text;
  84805. private _charSize;
  84806. /**
  84807. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84808. */
  84809. get charSize(): number;
  84810. /**
  84811. * Create a new instance of the Ascii Art FontTexture class
  84812. * @param name the name of the texture
  84813. * @param font the font to use, use the W3C CSS notation
  84814. * @param text the caracter set to use in the rendering.
  84815. * @param scene the scene that owns the texture
  84816. */
  84817. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84818. /**
  84819. * Gets the max char width of a font.
  84820. * @param font the font to use, use the W3C CSS notation
  84821. * @return the max char width
  84822. */
  84823. private getFontWidth;
  84824. /**
  84825. * Gets the max char height of a font.
  84826. * @param font the font to use, use the W3C CSS notation
  84827. * @return the max char height
  84828. */
  84829. private getFontHeight;
  84830. /**
  84831. * Clones the current AsciiArtTexture.
  84832. * @return the clone of the texture.
  84833. */
  84834. clone(): AsciiArtFontTexture;
  84835. /**
  84836. * Parses a json object representing the texture and returns an instance of it.
  84837. * @param source the source JSON representation
  84838. * @param scene the scene to create the texture for
  84839. * @return the parsed texture
  84840. */
  84841. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  84842. }
  84843. /**
  84844. * Option available in the Ascii Art Post Process.
  84845. */
  84846. export interface IAsciiArtPostProcessOptions {
  84847. /**
  84848. * The font to use following the w3c font definition.
  84849. */
  84850. font?: string;
  84851. /**
  84852. * The character set to use in the postprocess.
  84853. */
  84854. characterSet?: string;
  84855. /**
  84856. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84857. * This number is defined between 0 and 1;
  84858. */
  84859. mixToTile?: number;
  84860. /**
  84861. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84862. * This number is defined between 0 and 1;
  84863. */
  84864. mixToNormal?: number;
  84865. }
  84866. /**
  84867. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  84868. *
  84869. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84870. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  84871. */
  84872. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  84873. /**
  84874. * The font texture used to render the char in the post process.
  84875. */
  84876. private _asciiArtFontTexture;
  84877. /**
  84878. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  84879. * This number is defined between 0 and 1;
  84880. */
  84881. mixToTile: number;
  84882. /**
  84883. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  84884. * This number is defined between 0 and 1;
  84885. */
  84886. mixToNormal: number;
  84887. /**
  84888. * Instantiates a new Ascii Art Post Process.
  84889. * @param name the name to give to the postprocess
  84890. * @camera the camera to apply the post process to.
  84891. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  84892. */
  84893. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  84894. }
  84895. }
  84896. declare module BABYLON {
  84897. /** @hidden */
  84898. export var digitalrainPixelShader: {
  84899. name: string;
  84900. shader: string;
  84901. };
  84902. }
  84903. declare module BABYLON {
  84904. /**
  84905. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  84906. *
  84907. * It basically takes care rendering the font front the given font size to a texture.
  84908. * This is used later on in the postprocess.
  84909. */
  84910. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  84911. private _font;
  84912. private _text;
  84913. private _charSize;
  84914. /**
  84915. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  84916. */
  84917. get charSize(): number;
  84918. /**
  84919. * Create a new instance of the Digital Rain FontTexture class
  84920. * @param name the name of the texture
  84921. * @param font the font to use, use the W3C CSS notation
  84922. * @param text the caracter set to use in the rendering.
  84923. * @param scene the scene that owns the texture
  84924. */
  84925. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  84926. /**
  84927. * Gets the max char width of a font.
  84928. * @param font the font to use, use the W3C CSS notation
  84929. * @return the max char width
  84930. */
  84931. private getFontWidth;
  84932. /**
  84933. * Gets the max char height of a font.
  84934. * @param font the font to use, use the W3C CSS notation
  84935. * @return the max char height
  84936. */
  84937. private getFontHeight;
  84938. /**
  84939. * Clones the current DigitalRainFontTexture.
  84940. * @return the clone of the texture.
  84941. */
  84942. clone(): DigitalRainFontTexture;
  84943. /**
  84944. * Parses a json object representing the texture and returns an instance of it.
  84945. * @param source the source JSON representation
  84946. * @param scene the scene to create the texture for
  84947. * @return the parsed texture
  84948. */
  84949. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  84950. }
  84951. /**
  84952. * Option available in the Digital Rain Post Process.
  84953. */
  84954. export interface IDigitalRainPostProcessOptions {
  84955. /**
  84956. * The font to use following the w3c font definition.
  84957. */
  84958. font?: string;
  84959. /**
  84960. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84961. * This number is defined between 0 and 1;
  84962. */
  84963. mixToTile?: number;
  84964. /**
  84965. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84966. * This number is defined between 0 and 1;
  84967. */
  84968. mixToNormal?: number;
  84969. }
  84970. /**
  84971. * DigitalRainPostProcess helps rendering everithing in digital rain.
  84972. *
  84973. * Simmply add it to your scene and let the nerd that lives in you have fun.
  84974. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  84975. */
  84976. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  84977. /**
  84978. * The font texture used to render the char in the post process.
  84979. */
  84980. private _digitalRainFontTexture;
  84981. /**
  84982. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  84983. * This number is defined between 0 and 1;
  84984. */
  84985. mixToTile: number;
  84986. /**
  84987. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  84988. * This number is defined between 0 and 1;
  84989. */
  84990. mixToNormal: number;
  84991. /**
  84992. * Instantiates a new Digital Rain Post Process.
  84993. * @param name the name to give to the postprocess
  84994. * @camera the camera to apply the post process to.
  84995. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  84996. */
  84997. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  84998. }
  84999. }
  85000. declare module BABYLON {
  85001. /** @hidden */
  85002. export var brickProceduralTexturePixelShader: {
  85003. name: string;
  85004. shader: string;
  85005. };
  85006. }
  85007. declare module BABYLON {
  85008. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85009. private _numberOfBricksHeight;
  85010. private _numberOfBricksWidth;
  85011. private _jointColor;
  85012. private _brickColor;
  85013. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85014. updateShaderUniforms(): void;
  85015. get numberOfBricksHeight(): number;
  85016. set numberOfBricksHeight(value: number);
  85017. get numberOfBricksWidth(): number;
  85018. set numberOfBricksWidth(value: number);
  85019. get jointColor(): BABYLON.Color3;
  85020. set jointColor(value: BABYLON.Color3);
  85021. get brickColor(): BABYLON.Color3;
  85022. set brickColor(value: BABYLON.Color3);
  85023. /**
  85024. * Serializes this brick procedural texture
  85025. * @returns a serialized brick procedural texture object
  85026. */
  85027. serialize(): any;
  85028. /**
  85029. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85030. * @param parsedTexture defines parsed texture data
  85031. * @param scene defines the current scene
  85032. * @param rootUrl defines the root URL containing brick procedural texture information
  85033. * @returns a parsed Brick Procedural BABYLON.Texture
  85034. */
  85035. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85036. }
  85037. }
  85038. declare module BABYLON {
  85039. /** @hidden */
  85040. export var cloudProceduralTexturePixelShader: {
  85041. name: string;
  85042. shader: string;
  85043. };
  85044. }
  85045. declare module BABYLON {
  85046. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85047. private _skyColor;
  85048. private _cloudColor;
  85049. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85050. updateShaderUniforms(): void;
  85051. get skyColor(): BABYLON.Color4;
  85052. set skyColor(value: BABYLON.Color4);
  85053. get cloudColor(): BABYLON.Color4;
  85054. set cloudColor(value: BABYLON.Color4);
  85055. /**
  85056. * Serializes this cloud procedural texture
  85057. * @returns a serialized cloud procedural texture object
  85058. */
  85059. serialize(): any;
  85060. /**
  85061. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85062. * @param parsedTexture defines parsed texture data
  85063. * @param scene defines the current scene
  85064. * @param rootUrl defines the root URL containing cloud procedural texture information
  85065. * @returns a parsed Cloud Procedural BABYLON.Texture
  85066. */
  85067. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85068. }
  85069. }
  85070. declare module BABYLON {
  85071. /** @hidden */
  85072. export var fireProceduralTexturePixelShader: {
  85073. name: string;
  85074. shader: string;
  85075. };
  85076. }
  85077. declare module BABYLON {
  85078. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85079. private _time;
  85080. private _speed;
  85081. private _autoGenerateTime;
  85082. private _fireColors;
  85083. private _alphaThreshold;
  85084. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85085. updateShaderUniforms(): void;
  85086. render(useCameraPostProcess?: boolean): void;
  85087. static get PurpleFireColors(): BABYLON.Color3[];
  85088. static get GreenFireColors(): BABYLON.Color3[];
  85089. static get RedFireColors(): BABYLON.Color3[];
  85090. static get BlueFireColors(): BABYLON.Color3[];
  85091. get autoGenerateTime(): boolean;
  85092. set autoGenerateTime(value: boolean);
  85093. get fireColors(): BABYLON.Color3[];
  85094. set fireColors(value: BABYLON.Color3[]);
  85095. get time(): number;
  85096. set time(value: number);
  85097. get speed(): BABYLON.Vector2;
  85098. set speed(value: BABYLON.Vector2);
  85099. get alphaThreshold(): number;
  85100. set alphaThreshold(value: number);
  85101. /**
  85102. * Serializes this fire procedural texture
  85103. * @returns a serialized fire procedural texture object
  85104. */
  85105. serialize(): any;
  85106. /**
  85107. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85108. * @param parsedTexture defines parsed texture data
  85109. * @param scene defines the current scene
  85110. * @param rootUrl defines the root URL containing fire procedural texture information
  85111. * @returns a parsed Fire Procedural BABYLON.Texture
  85112. */
  85113. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85114. }
  85115. }
  85116. declare module BABYLON {
  85117. /** @hidden */
  85118. export var grassProceduralTexturePixelShader: {
  85119. name: string;
  85120. shader: string;
  85121. };
  85122. }
  85123. declare module BABYLON {
  85124. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85125. private _grassColors;
  85126. private _groundColor;
  85127. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85128. updateShaderUniforms(): void;
  85129. get grassColors(): BABYLON.Color3[];
  85130. set grassColors(value: BABYLON.Color3[]);
  85131. get groundColor(): BABYLON.Color3;
  85132. set groundColor(value: BABYLON.Color3);
  85133. /**
  85134. * Serializes this grass procedural texture
  85135. * @returns a serialized grass procedural texture object
  85136. */
  85137. serialize(): any;
  85138. /**
  85139. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85140. * @param parsedTexture defines parsed texture data
  85141. * @param scene defines the current scene
  85142. * @param rootUrl defines the root URL containing grass procedural texture information
  85143. * @returns a parsed Grass Procedural BABYLON.Texture
  85144. */
  85145. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85146. }
  85147. }
  85148. declare module BABYLON {
  85149. /** @hidden */
  85150. export var marbleProceduralTexturePixelShader: {
  85151. name: string;
  85152. shader: string;
  85153. };
  85154. }
  85155. declare module BABYLON {
  85156. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85157. private _numberOfTilesHeight;
  85158. private _numberOfTilesWidth;
  85159. private _amplitude;
  85160. private _jointColor;
  85161. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85162. updateShaderUniforms(): void;
  85163. get numberOfTilesHeight(): number;
  85164. set numberOfTilesHeight(value: number);
  85165. get amplitude(): number;
  85166. set amplitude(value: number);
  85167. get numberOfTilesWidth(): number;
  85168. set numberOfTilesWidth(value: number);
  85169. get jointColor(): BABYLON.Color3;
  85170. set jointColor(value: BABYLON.Color3);
  85171. /**
  85172. * Serializes this marble procedural texture
  85173. * @returns a serialized marble procedural texture object
  85174. */
  85175. serialize(): any;
  85176. /**
  85177. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85178. * @param parsedTexture defines parsed texture data
  85179. * @param scene defines the current scene
  85180. * @param rootUrl defines the root URL containing marble procedural texture information
  85181. * @returns a parsed Marble Procedural BABYLON.Texture
  85182. */
  85183. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85184. }
  85185. }
  85186. declare module BABYLON {
  85187. /** @hidden */
  85188. export var normalMapProceduralTexturePixelShader: {
  85189. name: string;
  85190. shader: string;
  85191. };
  85192. }
  85193. declare module BABYLON {
  85194. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85195. private _baseTexture;
  85196. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85197. updateShaderUniforms(): void;
  85198. render(useCameraPostProcess?: boolean): void;
  85199. resize(size: any, generateMipMaps: any): void;
  85200. get baseTexture(): BABYLON.Texture;
  85201. set baseTexture(texture: BABYLON.Texture);
  85202. /**
  85203. * Serializes this normal map procedural texture
  85204. * @returns a serialized normal map procedural texture object
  85205. */
  85206. serialize(): any;
  85207. /**
  85208. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85209. * @param parsedTexture defines parsed texture data
  85210. * @param scene defines the current scene
  85211. * @param rootUrl defines the root URL containing normal map procedural texture information
  85212. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85213. */
  85214. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85215. }
  85216. }
  85217. declare module BABYLON {
  85218. /** @hidden */
  85219. export var perlinNoiseProceduralTexturePixelShader: {
  85220. name: string;
  85221. shader: string;
  85222. };
  85223. }
  85224. declare module BABYLON {
  85225. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85226. time: number;
  85227. timeScale: number;
  85228. translationSpeed: number;
  85229. private _currentTranslation;
  85230. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85231. updateShaderUniforms(): void;
  85232. render(useCameraPostProcess?: boolean): void;
  85233. resize(size: any, generateMipMaps: any): void;
  85234. /**
  85235. * Serializes this perlin noise procedural texture
  85236. * @returns a serialized perlin noise procedural texture object
  85237. */
  85238. serialize(): any;
  85239. /**
  85240. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85241. * @param parsedTexture defines parsed texture data
  85242. * @param scene defines the current scene
  85243. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85244. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85245. */
  85246. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85247. }
  85248. }
  85249. declare module BABYLON {
  85250. /** @hidden */
  85251. export var roadProceduralTexturePixelShader: {
  85252. name: string;
  85253. shader: string;
  85254. };
  85255. }
  85256. declare module BABYLON {
  85257. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85258. private _roadColor;
  85259. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85260. updateShaderUniforms(): void;
  85261. get roadColor(): BABYLON.Color3;
  85262. set roadColor(value: BABYLON.Color3);
  85263. /**
  85264. * Serializes this road procedural texture
  85265. * @returns a serialized road procedural texture object
  85266. */
  85267. serialize(): any;
  85268. /**
  85269. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85270. * @param parsedTexture defines parsed texture data
  85271. * @param scene defines the current scene
  85272. * @param rootUrl defines the root URL containing road procedural texture information
  85273. * @returns a parsed Road Procedural BABYLON.Texture
  85274. */
  85275. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85276. }
  85277. }
  85278. declare module BABYLON {
  85279. /** @hidden */
  85280. export var starfieldProceduralTexturePixelShader: {
  85281. name: string;
  85282. shader: string;
  85283. };
  85284. }
  85285. declare module BABYLON {
  85286. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85287. private _time;
  85288. private _alpha;
  85289. private _beta;
  85290. private _zoom;
  85291. private _formuparam;
  85292. private _stepsize;
  85293. private _tile;
  85294. private _brightness;
  85295. private _darkmatter;
  85296. private _distfading;
  85297. private _saturation;
  85298. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85299. updateShaderUniforms(): void;
  85300. get time(): number;
  85301. set time(value: number);
  85302. get alpha(): number;
  85303. set alpha(value: number);
  85304. get beta(): number;
  85305. set beta(value: number);
  85306. get formuparam(): number;
  85307. set formuparam(value: number);
  85308. get stepsize(): number;
  85309. set stepsize(value: number);
  85310. get zoom(): number;
  85311. set zoom(value: number);
  85312. get tile(): number;
  85313. set tile(value: number);
  85314. get brightness(): number;
  85315. set brightness(value: number);
  85316. get darkmatter(): number;
  85317. set darkmatter(value: number);
  85318. get distfading(): number;
  85319. set distfading(value: number);
  85320. get saturation(): number;
  85321. set saturation(value: number);
  85322. /**
  85323. * Serializes this starfield procedural texture
  85324. * @returns a serialized starfield procedural texture object
  85325. */
  85326. serialize(): any;
  85327. /**
  85328. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85329. * @param parsedTexture defines parsed texture data
  85330. * @param scene defines the current scene
  85331. * @param rootUrl defines the root URL containing startfield procedural texture information
  85332. * @returns a parsed Starfield Procedural BABYLON.Texture
  85333. */
  85334. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85335. }
  85336. }
  85337. declare module BABYLON {
  85338. /** @hidden */
  85339. export var woodProceduralTexturePixelShader: {
  85340. name: string;
  85341. shader: string;
  85342. };
  85343. }
  85344. declare module BABYLON {
  85345. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85346. private _ampScale;
  85347. private _woodColor;
  85348. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85349. updateShaderUniforms(): void;
  85350. get ampScale(): number;
  85351. set ampScale(value: number);
  85352. get woodColor(): BABYLON.Color3;
  85353. set woodColor(value: BABYLON.Color3);
  85354. /**
  85355. * Serializes this wood procedural texture
  85356. * @returns a serialized wood procedural texture object
  85357. */
  85358. serialize(): any;
  85359. /**
  85360. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85361. * @param parsedTexture defines parsed texture data
  85362. * @param scene defines the current scene
  85363. * @param rootUrl defines the root URL containing wood procedural texture information
  85364. * @returns a parsed Wood Procedural BABYLON.Texture
  85365. */
  85366. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85367. }
  85368. }